1 // VoRS -- Vo(IP) Really Simple
2 // Copyright (C) 2024 Sergey Matveev <stargrave@stargrave.org>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, version 3 of the License.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Affero General Public License for more details.
13 // You should have received a copy of the GNU Affero General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 "go.stargrave.org/opus/v2"
22 vors "go.stargrave.org/vors/v3/internal"
25 func newOpusEnc() *opus.Encoder {
26 enc, err := opus.NewEncoder(vors.Rate, 1, opus.AppVoIP)
30 err = enc.SetComplexity(10)
34 err = enc.SetDTX(true)
38 err = enc.SetBitrate(vors.Bitrate)
45 func pcmConv(buf []byte, pcm []int16) {
46 for i := 0; i < len(pcm); i++ {
47 buf[i*2+0] = byte((uint16(pcm[i]) & 0x00FF) >> 0)
48 buf[i*2+1] = byte((uint16(pcm[i]) & 0xFF00) >> 8)