mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
fix(sointu-vsti): warn about sample rate only after plugin init
This commit is contained in:
parent
ce673578fd
commit
8fd2df19a1
@ -10,6 +10,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
the command line tools.
|
the command line tools.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Warn about plugin sample rate being different from 44100 only after
|
||||||
|
ProcessFloatFunc has been called, so that host has time to set the sample rate
|
||||||
|
after initialization.
|
||||||
- Crashes with sample-based oscillators in the 32-bit library, as the pointer to
|
- Crashes with sample-based oscillators in the 32-bit library, as the pointer to
|
||||||
sample-table (edi) got accidentally overwritten by detune
|
sample-table (edi) got accidentally overwritten by detune
|
||||||
- Sample-based oscillators could hard crash if a x87 stack overflow happened
|
- Sample-based oscillators could hard crash if a x87 stack overflow happened
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/vsariola/sointu"
|
"github.com/vsariola/sointu"
|
||||||
"github.com/vsariola/sointu/cmd"
|
"github.com/vsariola/sointu/cmd"
|
||||||
@ -66,13 +65,6 @@ func init() {
|
|||||||
model, player := tracker.NewModelPlayer(cmd.MainSynther, recoveryFile)
|
model, player := tracker.NewModelPlayer(cmd.MainSynther, recoveryFile)
|
||||||
t := gioui.NewTracker(model)
|
t := gioui.NewTracker(model)
|
||||||
tracker.Bool{BoolData: (*tracker.InstrEnlarged)(model)}.Set(true)
|
tracker.Bool{BoolData: (*tracker.InstrEnlarged)(model)}.Set(true)
|
||||||
if s := h.GetSampleRate(); math.Abs(float64(h.GetSampleRate()-44100.0)) > 1e-6 {
|
|
||||||
model.Alerts().AddAlert(tracker.Alert{
|
|
||||||
Message: fmt.Sprintf("VSTi host sample rate is %.0f Hz; sointu supports 44100 Hz only", s),
|
|
||||||
Priority: tracker.Error,
|
|
||||||
Duration: 10 * time.Second,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
go t.Main()
|
go t.Main()
|
||||||
context := VSTIProcessContext{host: h}
|
context := VSTIProcessContext{host: h}
|
||||||
buf := make(sointu.AudioBuffer, 1024)
|
buf := make(sointu.AudioBuffer, 1024)
|
||||||
@ -86,6 +78,9 @@ 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 {
|
||||||
|
player.SendAlert("WrongSampleRate", fmt.Sprintf("VSTi host sample rate is %.0f Hz; sointu supports 44100 Hz only", s), tracker.Error)
|
||||||
|
}
|
||||||
left := out.Channel(0)
|
left := out.Channel(0)
|
||||||
right := out.Channel(1)
|
right := out.Channel(1)
|
||||||
if len(buf) < out.Frames {
|
if len(buf) < out.Frames {
|
||||||
|
@ -171,12 +171,12 @@ func (p *Player) Process(buffer sointu.AudioBuffer, context PlayerProcessContext
|
|||||||
err2 := p.peakVolumeMeter.Update(oldBuffer)
|
err2 := p.peakVolumeMeter.Update(oldBuffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.synth = nil
|
p.synth = nil
|
||||||
p.sendAlert("PlayerVolume", err.Error(), Warning)
|
p.SendAlert("PlayerVolume", err.Error(), Warning)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
p.synth = nil
|
p.synth = nil
|
||||||
p.sendAlert("PlayerVolume", err2.Error(), Warning)
|
p.SendAlert("PlayerVolume", err2.Error(), Warning)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.send(nil)
|
p.send(nil)
|
||||||
@ -185,7 +185,7 @@ func (p *Player) Process(buffer sointu.AudioBuffer, context PlayerProcessContext
|
|||||||
}
|
}
|
||||||
// we were not able to fill the buffer with NUM_RENDER_TRIES attempts, destroy synth and throw an error
|
// we were not able to fill the buffer with NUM_RENDER_TRIES attempts, destroy synth and throw an error
|
||||||
p.synth = nil
|
p.synth = nil
|
||||||
p.sendAlert("PlayerCrash", fmt.Sprintf("synth did not fill the audio buffer even with %d render calls", numRenderTries), Error)
|
p.SendAlert("PlayerCrash", fmt.Sprintf("synth did not fill the audio buffer even with %d render calls", numRenderTries), Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) advanceRow() {
|
func (p *Player) advanceRow() {
|
||||||
@ -302,7 +302,7 @@ loop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) sendAlert(name, message string, priority AlertPriority) {
|
func (p *Player) SendAlert(name, message string, priority AlertPriority) {
|
||||||
p.send(Alert{
|
p.send(Alert{
|
||||||
Name: name,
|
Name: name,
|
||||||
Priority: priority,
|
Priority: priority,
|
||||||
@ -319,7 +319,7 @@ func (p *Player) compileOrUpdateSynth() {
|
|||||||
err := p.synth.Update(p.song.Patch, p.song.BPM)
|
err := p.synth.Update(p.song.Patch, p.song.BPM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.synth = nil
|
p.synth = nil
|
||||||
p.sendAlert("PlayerCrash", fmt.Sprintf("synth.Update: %v", err), Error)
|
p.SendAlert("PlayerCrash", fmt.Sprintf("synth.Update: %v", err), Error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -327,7 +327,7 @@ func (p *Player) compileOrUpdateSynth() {
|
|||||||
p.synth, err = p.synther.Synth(p.song.Patch, p.song.BPM)
|
p.synth, err = p.synther.Synth(p.song.Patch, p.song.BPM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.synth = nil
|
p.synth = nil
|
||||||
p.sendAlert("PlayerCrash", fmt.Sprintf("synther.Synth: %v", err), Error)
|
p.SendAlert("PlayerCrash", fmt.Sprintf("synther.Synth: %v", err), Error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user