Change the Go API to have two versions: Render(buffer []float32), which always fill the whole buffer, and RenderTime(buffer []float32,int maxtime), which ends either when the buffer is full, or modulated time is reached.

This commit is contained in:
Veikko Sariola
2020-10-27 17:26:08 +02:00
parent 7a9ac3489b
commit 5f4b85b0a4
3 changed files with 49 additions and 30 deletions

View File

@ -30,22 +30,15 @@ func TestBridge(t *testing.T) {
}},
})
s.Trigger(0, 64)
s.SamplesPerRow = SAMPLES_PER_ROW * 8 // this song is two blocks of 8 rows, release before second block start
buffer := make([]float32, 2*su_max_samples)
n, rowend, err := s.Render(buffer)
if n < su_max_samples/2 {
t.Fatalf("render should have filled half of the buffer on first call, %v samples rendered, %v expected", n, su_max_samples/2)
}
if rowend != true {
t.Fatalf("Row end should have been hit (rowend should have been true) on the first call to Render")
err := s.Render(buffer[:len(buffer)/2])
if err != nil {
t.Fatalf("first render gave an error")
}
s.Release(0)
n, rowend, err = s.Render(buffer[(n * 2):])
if n < su_max_samples/2 {
t.Fatalf("render should have filled second half of the buffer on the second call, %v samples rendered, %v expected", n, su_max_samples/2)
}
if rowend != true {
t.Fatalf("Row end should have been hit (rowend should have been true) on the second call to Render")
err = s.Render(buffer[len(buffer)/2:])
if err != nil {
t.Fatalf("first render gave an error")
}
_, filename, _, _ := runtime.Caller(0)
expectedb, err := ioutil.ReadFile(path.Join(path.Dir(filename), "..", "tests", "expected_output", "test_render_samples.raw"))