Change the sointu.h api to return -1, 0 or n>0 depending if buffer is full and/or row ended.

test_render_samples_api.c was added to test the api. bridge.go was modified to reflect that there is no need to check for row manually; su_render_samples already returns the information if a row has ended.
This commit is contained in:
Veikko Sariola
2020-10-24 13:00:08 +03:00
parent c9e8000c5f
commit 6e85ff674a
7 changed files with 158 additions and 38 deletions

View File

@ -2,6 +2,7 @@ package bridge
import "fmt"
import "unsafe"
import "math"
// #cgo CFLAGS: -I"${SRCDIR}/../include"
// #cgo LDFLAGS: "${SRCDIR}/../build/src/libsointu.a"
@ -83,16 +84,12 @@ func (s *SynthState) Release(voice int) {
fmt.Printf("Returning from Release...\n")
}
func (s *SynthState) RowEnd() bool {
return s.RowTick == s.RowLen
}
func (s *SynthState) ResetRow() bool {
return s.RowTick == 0
}
func NewSynthState() *SynthState {
s := new(SynthState)
s.RandSeed = 1
// The default behaviour will be to have rows/beats disabled i.e.
// fill the whole buffer every call. This is a lot better default
// behaviour than leaving this 0 (Render would never render anything)
s.SamplesPerRow = math.MaxInt32
return s
}