mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-14 02:54:37 -04:00
feat(tracker): add support for a MIDI controller to the standalone tracker
Closes #132.
This commit is contained in:
committed by
5684185+vsariola@users.noreply.github.com
parent
9779beee99
commit
577265b250
@ -15,19 +15,9 @@ import (
|
||||
"github.com/vsariola/sointu/oto"
|
||||
"github.com/vsariola/sointu/tracker"
|
||||
"github.com/vsariola/sointu/tracker/gioui"
|
||||
"github.com/vsariola/sointu/tracker/gomidi"
|
||||
)
|
||||
|
||||
type NullContext struct {
|
||||
}
|
||||
|
||||
func (NullContext) NextEvent() (event tracker.MIDINoteEvent, ok bool) {
|
||||
return tracker.MIDINoteEvent{}, false
|
||||
}
|
||||
|
||||
func (NullContext) BPM() (bpm float64, ok bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
type PlayerAudioSource struct {
|
||||
*tracker.Player
|
||||
playerProcessContext tracker.PlayerProcessContext
|
||||
@ -64,6 +54,8 @@ func main() {
|
||||
recoveryFile = filepath.Join(configDir, "Sointu", "sointu-track-recovery")
|
||||
}
|
||||
model, player := tracker.NewModelPlayer(cmd.MainSynther, recoveryFile)
|
||||
model.MIDI = gomidi.CreateContext()
|
||||
defer model.MIDI.DestroyContext()
|
||||
if a := flag.Args(); len(a) > 0 {
|
||||
f, err := os.Open(a[0])
|
||||
if err == nil {
|
||||
@ -72,7 +64,7 @@ func main() {
|
||||
f.Close()
|
||||
}
|
||||
tracker := gioui.NewTracker(model)
|
||||
audioCloser := audioContext.Play(&PlayerAudioSource{player, NullContext{}})
|
||||
audioCloser := audioContext.Play(&PlayerAudioSource{player, model.MIDI})
|
||||
go func() {
|
||||
tracker.Main()
|
||||
audioCloser.Close()
|
||||
|
Reference in New Issue
Block a user