mirror of
https://github.com/vsariola/sointu.git
synced 2026-02-24 17:14:00 -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])
|
roughly to -12 dBFS true peak. ([#211][i211])
|
||||||
|
|
||||||
### Fixed
|
### 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.
|
- 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
|
- 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.
|
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
|
[i211]: https://github.com/vsariola/sointu/issues/211
|
||||||
[i215]: https://github.com/vsariola/sointu/issues/215
|
[i215]: https://github.com/vsariola/sointu/issues/215
|
||||||
[i221]: https://github.com/vsariola/sointu/issues/221
|
[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
|
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() {
|
func init() {
|
||||||
var (
|
var (
|
||||||
version = int32(100)
|
version = int32(100)
|
||||||
@ -60,6 +68,7 @@ func init() {
|
|||||||
context := &VSTIProcessContext{host: h}
|
context := &VSTIProcessContext{host: h}
|
||||||
buf := make(sointu.AudioBuffer, 1024)
|
buf := make(sointu.AudioBuffer, 1024)
|
||||||
var totalFrames int64 = 0
|
var totalFrames int64 = 0
|
||||||
|
start := time.Now()
|
||||||
return vst2.Plugin{
|
return vst2.Plugin{
|
||||||
UniqueID: [4]byte{'S', 'n', 't', 'u'},
|
UniqueID: [4]byte{'S', 'n', 't', 'u'},
|
||||||
Version: version,
|
Version: version,
|
||||||
@ -70,8 +79,11 @@ func init() {
|
|||||||
Category: vst2.PluginCategorySynth,
|
Category: vst2.PluginCategorySynth,
|
||||||
Flags: vst2.PluginIsSynth,
|
Flags: vst2.PluginIsSynth,
|
||||||
ProcessFloatFunc: func(in, out vst2.FloatBuffer) {
|
ProcessFloatFunc: func(in, out vst2.FloatBuffer) {
|
||||||
if s := h.GetSampleRate(); math.Abs(float64(h.GetSampleRate()-44100.0)) > 1e-6 {
|
if time.Since(start) > 2*time.Second { // limit the rate we query the samplerate from the host and send alerts
|
||||||
player.SendAlert("WrongSampleRate", fmt.Sprintf("VSTi host sample rate is %.0f Hz; sointu supports 44100 Hz only", s), tracker.Error)
|
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)
|
left := out.Channel(0)
|
||||||
right := out.Channel(1)
|
right := out.Channel(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user