Updated everything for dependencies. All sub packages are now part of the project. This was a massive update, hopefully won't have to be reverted.

This commit is contained in:
Storm Dragon
2025-01-16 17:03:01 -05:00
parent a5c0e7a71c
commit 2e337db3c5
78 changed files with 4774 additions and 82 deletions

View File

@@ -0,0 +1,67 @@
// Copyright © Go Opus Authors (see AUTHORS file)
//
// License for use of this code is detailed in the LICENSE file
package opus
import (
"math"
)
// utility functions for unit tests
func addSineFloat32(buf []float32, sampleRate int, freq float64) {
factor := 2 * math.Pi * freq / float64(sampleRate)
for i := range buf {
buf[i] += float32(math.Sin(float64(i) * factor))
}
}
func addSine(buf []int16, sampleRate int, freq float64) {
factor := 2 * math.Pi * freq / float64(sampleRate)
for i := range buf {
buf[i] += int16(math.Sin(float64(i)*factor) * (math.MaxInt16 - 1))
}
}
func maxDiff(a []int16, b []int16) int32 {
if len(a) != len(b) {
return math.MaxInt16
}
var max int32 = 0
for i := range a {
d := int32(a[i]) - int32(b[i])
if d < 0 {
d = -d
}
if d > max {
max = d
}
}
return max
}
func interleave(a []int16, b []int16) []int16 {
if len(a) != len(b) {
panic("interleave: buffers must have equal length")
}
result := make([]int16, 2*len(a))
for i := range a {
result[2*i] = a[i]
result[2*i+1] = b[i]
}
return result
}
func split(interleaved []int16) ([]int16, []int16) {
if len(interleaved)%2 != 0 {
panic("split: interleaved buffer must have even number of samples")
}
left := make([]int16, len(interleaved)/2)
right := make([]int16, len(interleaved)/2)
for i := range left {
left[i] = interleaved[2*i]
right[i] = interleaved[2*i+1]
}
return left, right
}