feat(tracker): compile with midi support only when CGO is available

Also add the midi context to the VSTI, so VSTI can use MIDI if they
wish so.
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2025-06-20 19:38:06 +03:00
parent 3881b8eb22
commit 602b3b05cc
7 changed files with 42 additions and 21 deletions

View File

@ -24,16 +24,8 @@ type (
eventIndex int
host vst2.Host
}
NullMIDIContext struct{}
)
func (m NullMIDIContext) InputDevices(yield func(tracker.MIDIDevice) bool) {}
func (m NullMIDIContext) Close() {}
func (m NullMIDIContext) HasDeviceOpen() bool { return false }
func (c *VSTIProcessContext) BPM() (bpm float64, ok bool) {
timeInfo := c.host.GetTimeInfo(vst2.TempoValid)
if timeInfo == nil || timeInfo.Flags&vst2.TempoValid == 0 || timeInfo.Tempo == 0 {
@ -54,7 +46,7 @@ func init() {
recoveryFile = filepath.Join(configDir, "sointu", "sointu-vsti-recovery-"+hex.EncodeToString(randBytes))
}
broker := tracker.NewBroker()
model := tracker.NewModel(broker, cmd.MainSynther, NullMIDIContext{}, recoveryFile)
model := tracker.NewModel(broker, cmd.MainSynther, cmd.NewMidiContext(broker), recoveryFile)
player := tracker.NewPlayer(broker, cmd.MainSynther)
detector := tracker.NewDetector(broker)
go detector.Run()