Correct AddFloat/AddShort
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2022-03-08 11:51:26 +01:00
parent ffc70c6395
commit 3299585e6a
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
2 changed files with 4 additions and 4 deletions

View file

@ -141,7 +141,7 @@ func (s *State) GetLoudnessShortTerm() (out float64, err error) {
}
func (s *State) AddFloat(src []float32) error {
ret := C.ebur128_add_frames_float(s.p, (*C.float)(&src[0]), C.size_t(len(src)))
ret := C.ebur128_add_frames_float(s.p, (*C.float)(&src[0]), C.size_t(len(src)/s.channels))
if ret != C.EBUR128_SUCCESS {
return fmt.Errorf("error adding frames: %d", ret)
}
@ -149,7 +149,7 @@ func (s *State) AddFloat(src []float32) error {
}
func (s *State) AddShort(src []int16) error {
ret := C.ebur128_add_frames_short(s.p, (*C.short)(&src[0]), C.size_t(len(src)))
ret := C.ebur128_add_frames_short(s.p, (*C.short)(&src[0]), C.size_t(len(src)/s.channels))
if ret != C.EBUR128_SUCCESS {
return fmt.Errorf("error adding frames: %d", ret)
}

View file

@ -67,7 +67,7 @@ func TestFloat(t *testing.T) {
}
result := fmt.Sprintf("%f dB, %f", loudness, maxPeak)
expected := "-14.927264 dB, 0.666256"
expected := "-15.060377 dB, 0.666256"
if result != expected {
t.Errorf("expected %s, got %s", expected, result)
}
@ -131,7 +131,7 @@ func TestShort(t *testing.T) {
}
result := fmt.Sprintf("%f dB, %f", loudness, maxPeak)
expected := "-14.927263 dB, 0.666260"
expected := "-15.060377 dB, 0.666260"
if result != expected {
t.Errorf("expected %s, got %s", expected, result)
}