diff options
-rw-r--r-- | pkg/mixer/mixer.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/pkg/mixer/mixer.go b/pkg/mixer/mixer.go index fb575d6..ee25207 100644 --- a/pkg/mixer/mixer.go +++ b/pkg/mixer/mixer.go @@ -38,7 +38,7 @@ type Mixer struct { DevOut *midi.Device } -// TODO: make this confgurabel +// TODO: make this confgurable const ( CC_MUTE = byte(0xB1) CC_FADER = byte(0xB0) @@ -79,6 +79,20 @@ func NewMixer(c Config) (*Mixer, error) { return m, nil } +func (m *Mixer) handleMidiPacket(p midi.Packet) { + switch p.Data[0] { + case CC_FADER: + log.Printf("mixer: fader movement on channel 0x%02X, level is now: 0x%02X", p.Data[1], p.Data[2]) + case CC_MUTE: + newState := "unmuted" + if p.Data[2] > 0 { + newState = "muted" + } + log.Printf("mixer: channel 0x%02X is now %s", p.Data[1], newState) + } + // TODO: send new state to subscribers +} + func (m *Mixer) Init() error { ch, err := m.DevIn.Packets() if err != nil { @@ -87,9 +101,7 @@ func (m *Mixer) Init() error { go func() { for { - p := <-ch - log.Printf("mixer: got packet: '%v'", p) - // TODO: send to subscribers + m.handleMidiPacket(<-ch) } }() return nil |