mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-14 11:04:23 -04:00
fix(sointu): fix sync data getting output from play & test it
This commit is contained in:
4
synth.go
4
synth.go
@ -39,9 +39,9 @@ func Play(synth Synth, song Song) ([]float32, []float32, error) {
|
||||
}
|
||||
initialCapacity := song.Score.LengthInRows() * song.SamplesPerRow() * 2
|
||||
buffer := make([]float32, 0, initialCapacity)
|
||||
syncBuffer := make([]float32, 0, initialCapacity)
|
||||
rowbuffer := make([]float32, song.SamplesPerRow()*2)
|
||||
numSyncs := song.Patch.NumSyncs()
|
||||
syncBuffer := make([]float32, 0, (song.Score.LengthInRows()*song.SamplesPerRow()+255)/256*(1+numSyncs))
|
||||
syncRowBuffer := make([]float32, ((song.SamplesPerRow()+255)/256)*(1+numSyncs))
|
||||
for row := 0; row < song.Score.LengthInRows(); row++ {
|
||||
patternRow := row % song.Score.RowsPerPattern
|
||||
@ -87,7 +87,7 @@ func Play(synth Synth, song Song) ([]float32, []float32, error) {
|
||||
}
|
||||
rowtime += time
|
||||
buffer = append(buffer, rowbuffer[:samples*2]...)
|
||||
syncBuffer = append(syncBuffer, syncRowBuffer[:syncs]...)
|
||||
syncBuffer = append(syncBuffer, syncRowBuffer[:syncs*(1+numSyncs)]...)
|
||||
if tries > 100 {
|
||||
return nil, nil, fmt.Errorf("Song speed modulation likely so slow that row never advances; error at pattern %v, row %v", pattern, patternRow)
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ func TestAllRegressionTests(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Compiling patch failed: %v", err)
|
||||
}
|
||||
buffer, _, err := sointu.Play(synth, song)
|
||||
buffer, syncBuffer, err := sointu.Play(synth, song)
|
||||
buffer = buffer[:song.Score.LengthInRows()*song.SamplesPerRow()*2] // extend to the nominal length always.
|
||||
if err != nil {
|
||||
t.Fatalf("Play failed: %v", err)
|
||||
@ -72,6 +72,9 @@ func TestAllRegressionTests(t *testing.T) {
|
||||
}
|
||||
}
|
||||
compareToRawFloat32(t, buffer, testname+".raw")
|
||||
if strings.Contains(testname, "sync") {
|
||||
compareToRawFloat32(t, syncBuffer, testname+"_syncbuf.raw")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user