Skip to content

Commit

Permalink
add silence method to midi package
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviergodart committed Apr 10, 2023
1 parent f4aedd3 commit c1d175a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions midi/midi.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Midi interface {
Devices() gomidi.OutPorts
NoteOn(device int, channel uint8, note uint8, velocity uint8)
NoteOff(device int, channel uint8, note uint8)
Silence(device int, channel uint8)
ControlChange(device int, channel, controller, value uint8)
ProgramChange(device int, channel uint8, value uint8)
Pitchbend(device int, channel uint8, value int16)
Expand Down Expand Up @@ -120,6 +121,13 @@ func (m *midi) NoteOff(device int, channel uint8, note uint8) {
m.outputs[device] <- gomidi.NoteOff(channel, note)
}

// Silence sends a note off message for every running note on every channel.
func (m *midi) Silence(device int, channel uint8) {
for _, msg := range gomidi.SilenceChannel(int8(channel)) {
m.outputs[device] <- msg
}
}

// ControlChange sends a Control Change messages to the given device.
func (m *midi) ControlChange(device int, channel, controller, value uint8) {
m.outputs[device] <- gomidi.ControlChange(channel, controller, value)
Expand Down
1 change: 1 addition & 0 deletions sequencer/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,5 @@ func (t *track) clear() {
for _, step := range t.steps {
step.reset()
}
t.midi.Silence(t.device, t.channel)
}

0 comments on commit c1d175a

Please sign in to comment.