mirror of
https://github.com/vsariola/sointu.git
synced 2026-02-12 11:13:03 -05:00
refactor(tracker): use strings to identify MIDI ports
This commit is contained in:
parent
651ceb3cbb
commit
173648fbdb
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/vsariola/sointu"
|
||||
)
|
||||
@ -126,19 +127,14 @@ type (
|
||||
Dialog int
|
||||
|
||||
MIDIContext interface {
|
||||
InputDevices(yield func(MIDIDevice) bool)
|
||||
InputDevices(yield func(string) bool)
|
||||
Open(name string) error
|
||||
Close()
|
||||
HasDeviceOpen() bool
|
||||
TryToOpenBy(name string, first bool)
|
||||
IsOpen() bool
|
||||
}
|
||||
|
||||
NullMIDIContext struct{}
|
||||
|
||||
MIDIDevice interface {
|
||||
String() string
|
||||
Open() error
|
||||
}
|
||||
|
||||
InstrumentTab int
|
||||
)
|
||||
|
||||
@ -221,6 +217,15 @@ func NewModel(broker *Broker, synthers []sointu.Synther, midiContext MIDIContext
|
||||
return m
|
||||
}
|
||||
|
||||
func FindMIDIDeviceByPrefix(c MIDIContext, prefix string) (input string, ok bool) {
|
||||
for input := range c.InputDevices {
|
||||
if strings.HasPrefix(input, prefix) {
|
||||
return input, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (m *Model) change(kind string, t ChangeType, severity ChangeSeverity) func() {
|
||||
if m.changeLevel == 0 {
|
||||
m.changeType = NoChange
|
||||
@ -434,10 +439,10 @@ func (d *modelData) Copy() modelData {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (m NullMIDIContext) InputDevices(yield func(MIDIDevice) bool) {}
|
||||
func (m NullMIDIContext) Close() {}
|
||||
func (m NullMIDIContext) HasDeviceOpen() bool { return false }
|
||||
func (m NullMIDIContext) TryToOpenBy(name string, first bool) {}
|
||||
func (m NullMIDIContext) InputDevices(yield func(string) bool) {}
|
||||
func (m NullMIDIContext) Open(name string) error { return nil }
|
||||
func (m NullMIDIContext) Close() {}
|
||||
func (m NullMIDIContext) IsOpen() bool { return false }
|
||||
|
||||
func (m *Model) resetSong() {
|
||||
m.d.Song = defaultSong.Copy()
|
||||
|
||||
Reference in New Issue
Block a user