mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
fix: check that MIDI triggered instrument is within patch limits (#98)
This commit is contained in:
parent
33221b5203
commit
a0bcac3904
@ -328,6 +328,9 @@ func (p *Player) trySend(message interface{}) {
|
|||||||
func (p *Player) triggerInstrument(instrument int, note byte) {
|
func (p *Player) triggerInstrument(instrument int, note byte) {
|
||||||
ID := idForInstrumentNote(instrument, note)
|
ID := idForInstrumentNote(instrument, note)
|
||||||
p.release(ID)
|
p.release(ID)
|
||||||
|
if p.patch == nil || instrument < 0 || instrument >= len(p.patch) {
|
||||||
|
return
|
||||||
|
}
|
||||||
voiceStart := p.patch.FirstVoiceForInstrument(instrument)
|
voiceStart := p.patch.FirstVoiceForInstrument(instrument)
|
||||||
voiceEnd := voiceStart + p.patch[instrument].NumVoices
|
voiceEnd := voiceStart + p.patch[instrument].NumVoices
|
||||||
p.trigger(voiceStart, voiceEnd, note, ID)
|
p.trigger(voiceStart, voiceEnd, note, ID)
|
||||||
|
Loading…
Reference in New Issue
Block a user