opus-go/internal/bitdepth/bitdepth_test.go
Sean DuBois 733188ab17 Implement bitdepth conversion and upsampling
bitdepth package takes F32LE -> S16LE and handles upsampling
from 16Khz -> 48Khz
2022-09-30 21:56:49 -06:00

17 lines
386 B
Go

package bitdepth
import (
"bytes"
"testing"
)
func TestConvertFloat32LittleEndianToSigned16LittleEndian(t *testing.T) {
in := []float32{0.3, 0, .55, .72, -.05}
out := make([]byte, len(in)*2)
ConvertFloat32LittleEndianToSigned16LittleEndian(in, out, 1)
if !bytes.Equal([]byte{0x66, 0x26, 0x00, 0x00, 0x65, 0x46, 0x28, 0x5c, 0x99, 0xf9}, out) {
t.Fatal("buffer mismatch")
}
}