733188ab17
bitdepth package takes F32LE -> S16LE and handles upsampling from 16Khz -> 48Khz
17 lines
386 B
Go
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")
|
|
}
|
|
}
|