mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-25 18:00:37 -04:00
refactor(tracker): ask for midiContext in the model constructor
This commit is contained in:
parent
f427eca1f4
commit
2809526de6
@ -53,9 +53,8 @@ func main() {
|
||||
if configDir, err := os.UserConfigDir(); err == nil {
|
||||
recoveryFile = filepath.Join(configDir, "Sointu", "sointu-track-recovery")
|
||||
}
|
||||
model, player := tracker.NewModelPlayer(cmd.MainSynther, recoveryFile)
|
||||
midiContext := gomidi.NewContext()
|
||||
model.MIDI = midiContext
|
||||
model, player := tracker.NewModelPlayer(cmd.MainSynther, midiContext, recoveryFile)
|
||||
defer model.MIDI.Close()
|
||||
if a := flag.Args(); len(a) > 0 {
|
||||
f, err := os.Open(a[0])
|
||||
|
@ -27,11 +27,11 @@ type (
|
||||
NullMIDIContext struct{}
|
||||
)
|
||||
|
||||
func (m *NullMIDIContext) ListInputDevices() func(yield func(tracker.MIDIDevice) bool) {
|
||||
func (m NullMIDIContext) ListInputDevices() func(yield func(tracker.MIDIDevice) bool) {
|
||||
return func(yield func(tracker.MIDIDevice) bool) {}
|
||||
}
|
||||
|
||||
func (m *NullMIDIContext) Close() {}
|
||||
func (m NullMIDIContext) Close() {}
|
||||
|
||||
func (c *VSTIProcessContext) NextEvent() (event tracker.MIDINoteEvent, ok bool) {
|
||||
for c.eventIndex < len(c.events) {
|
||||
@ -72,8 +72,7 @@ func init() {
|
||||
rand.Read(randBytes)
|
||||
recoveryFile = filepath.Join(configDir, "sointu", "sointu-vsti-recovery-"+hex.EncodeToString(randBytes))
|
||||
}
|
||||
model, player := tracker.NewModelPlayer(cmd.MainSynther, recoveryFile)
|
||||
model.MIDI = &NullMIDIContext{}
|
||||
model, player := tracker.NewModelPlayer(cmd.MainSynther, NullMIDIContext{}, recoveryFile)
|
||||
|
||||
t := gioui.NewTracker(model)
|
||||
tracker.Bool{BoolData: (*tracker.InstrEnlarged)(model)}.Set(true)
|
||||
|
@ -175,9 +175,10 @@ func (m *Model) Dialog() Dialog { return m.dialog }
|
||||
func (m *Model) Quitted() bool { return m.quitted }
|
||||
|
||||
// NewModelPlayer creates a new model and a player that communicates with it
|
||||
func NewModelPlayer(synther sointu.Synther, recoveryFilePath string) (*Model, *Player) {
|
||||
func NewModelPlayer(synther sointu.Synther, midiContext MIDIContext, recoveryFilePath string) (*Model, *Player) {
|
||||
m := new(Model)
|
||||
m.synther = synther
|
||||
m.MIDI = midiContext
|
||||
modelMessages := make(chan interface{}, 1024)
|
||||
playerMessages := make(chan PlayerMsg, 1024)
|
||||
m.modelMessages = modelMessages
|
||||
|
Loading…
Reference in New Issue
Block a user