mirror of
https://github.com/vsariola/sointu.git
synced 2026-02-16 05:03:18 -05:00
fix(cmd/sointu-vsti): query sample rate through host.GetTimeInfo
Closes #222
This commit is contained in:
parent
f2f76c0e18
commit
b8d9ca09f1
@ -37,6 +37,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
roughly to -12 dBFS true peak. ([#211][i211])
|
||||
|
||||
### Fixed
|
||||
- VSTi queries the host sample rate more robustly. Cubase previously reported
|
||||
the sample rate as 0 Hz, leading to persistent error message about the sample
|
||||
rate not being 44100 Hz. ([#222][i222])
|
||||
- Occasional NaNs in the Trisaw oscillator when the color was 0 in the Go VM.
|
||||
- The tracker thought that "sync" unit pops the value from stack, even if the VM
|
||||
did not, resulting it claiming errors in patches that worked once compiled.
|
||||
@ -427,3 +430,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
[i211]: https://github.com/vsariola/sointu/issues/211
|
||||
[i215]: https://github.com/vsariola/sointu/issues/215
|
||||
[i221]: https://github.com/vsariola/sointu/issues/221
|
||||
[i222]: https://github.com/vsariola/sointu/issues/222
|
||||
|
||||
@ -34,6 +34,14 @@ func (c *VSTIProcessContext) BPM() (bpm float64, ok bool) {
|
||||
return timeInfo.Tempo, true
|
||||
}
|
||||
|
||||
func (c *VSTIProcessContext) SampleRate() (samplerate float64, ok bool) {
|
||||
timeInfo := c.host.GetTimeInfo(0)
|
||||
if timeInfo == nil || timeInfo.SampleRate == 0 {
|
||||
return 0, false
|
||||
}
|
||||
return timeInfo.SampleRate, true
|
||||
}
|
||||
|
||||
func init() {
|
||||
var (
|
||||
version = int32(100)
|
||||
@ -60,6 +68,7 @@ func init() {
|
||||
context := &VSTIProcessContext{host: h}
|
||||
buf := make(sointu.AudioBuffer, 1024)
|
||||
var totalFrames int64 = 0
|
||||
start := time.Now()
|
||||
return vst2.Plugin{
|
||||
UniqueID: [4]byte{'S', 'n', 't', 'u'},
|
||||
Version: version,
|
||||
@ -70,8 +79,11 @@ func init() {
|
||||
Category: vst2.PluginCategorySynth,
|
||||
Flags: vst2.PluginIsSynth,
|
||||
ProcessFloatFunc: func(in, out vst2.FloatBuffer) {
|
||||
if s := h.GetSampleRate(); math.Abs(float64(h.GetSampleRate()-44100.0)) > 1e-6 {
|
||||
player.SendAlert("WrongSampleRate", fmt.Sprintf("VSTi host sample rate is %.0f Hz; sointu supports 44100 Hz only", s), tracker.Error)
|
||||
if time.Since(start) > 2*time.Second { // limit the rate we query the samplerate from the host and send alerts
|
||||
if s, ok := context.SampleRate(); ok && math.Abs(float64(s-44100.0)) > 1e-6 {
|
||||
player.SendAlert("WrongSampleRate", fmt.Sprintf("VSTi host sample rate is %.0f Hz; Sointu supports 44100 Hz only", s), tracker.Error)
|
||||
}
|
||||
start = time.Now()
|
||||
}
|
||||
left := out.Channel(0)
|
||||
right := out.Channel(1)
|
||||
|
||||
Reference in New Issue
Block a user