diff options
author | Christian Pointner <equinox@spreadspace.org> | 2019-02-09 22:53:05 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2019-02-09 22:53:05 +0100 |
commit | 25c92807a81770d3a4757d170eb15785e144fe5e (patch) | |
tree | 0acd5821c143834f35b4511ac090cebfa45b99e8 /pkg | |
parent | mixer: add packet receiver (diff) |
parsing midi packet works now
Diffstat (limited to 'pkg')
-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 |