Revert test function inline, added special case for two channels on shared.go
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2022-10-03 15:25:40 +02:00
parent 2222e280fc
commit 92541a6f4e
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
2 changed files with 19 additions and 17 deletions

View file

@ -114,22 +114,20 @@ func TestAlbumReplayGain(t *testing.T) {
t.Error(err)
return
}
func() {
defer fp.Close()
decoders, err := guess.GetDecoders(fp, fullPath)
if err != nil {
t.Error(err)
return
}
source, err := guess.Open(fp, decoders)
if err != nil {
t.Error(err)
return
}
sources = append(sources, source)
}()
defer fp.Close()
decoders, err := guess.GetDecoders(fp, fullPath)
if err != nil {
t.Error(err)
return
}
source, err := guess.Open(fp, decoders)
if err != nil {
t.Error(err)
return
}
sources = append(sources, source)
}
}

View file

@ -30,7 +30,9 @@ func MultipleChannelsToMonoFloat32(buffer []float32, channels int) (buf []float3
// MultipleChannelsToStereoFloat32 bring any number of channels to stereo, using downmix formulas when necessary
func MultipleChannelsToStereoFloat32(buffer []float32, channels int) (buf []float32) {
buf = make([]float32, (len(buffer)/channels)*2)
if channels != 2 {
buf = make([]float32, (len(buffer)/channels)*2)
}
var samples int
surroundMix := 1 / float32(math.Sqrt(2))
@ -107,7 +109,9 @@ func MultipleChannelsToMonoInt32(buffer []int32, channels int) (buf []int32) {
// MultipleChannelsToStereoInt32 bring any number of channels to stereo, using downmix formulas when necessary
func MultipleChannelsToStereoInt32(buffer []int32, channels int) (buf []int32) {
buf = make([]int32, (len(buffer)/channels)*2)
if channels != 2 {
buf = make([]int32, (len(buffer)/channels)*2)
}
var samples int
surroundMix := 1 / float32(math.Sqrt(2))
@ -120,7 +124,7 @@ func MultipleChannelsToStereoInt32(buffer []int32, channels int) (buf []int32) {
}
break
case 2: //copy
return slices.Clone(buffer)
buf = slices.Clone(buffer)
break
case 3: //2.1, FL, FR, LFE
for i := 0; i < len(buffer); i += 3 {