feat: add mute and solo toggles for instruments

Closes #168
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-10-16 00:44:14 +03:00
parent 7b213bd8b0
commit 063b2c29c5
9 changed files with 106 additions and 9 deletions

View File

@ -331,6 +331,15 @@ func (p *Player) compileOrUpdateSynth() {
return
}
}
voice := 0
for _, instr := range p.song.Patch {
if instr.Mute {
for j := 0; j < instr.NumVoices; j++ {
p.synth.Release(voice + j)
}
}
voice += instr.NumVoices
}
}
// all sends from player are always non-blocking, to ensure that the player thread cannot end up in a dead-lock
@ -387,11 +396,13 @@ func (p *Player) trigger(voiceStart, voiceEnd int, note byte, ID int) {
age = p.voices[i].samplesSinceEvent
}
}
instrIndex, err := p.song.Patch.InstrumentForVoice(oldestVoice)
if err != nil || p.song.Patch[instrIndex].Mute {
return
}
p.voices[oldestVoice] = voice{noteID: ID, sustain: true, samplesSinceEvent: 0}
p.voiceLevels[oldestVoice] = 1.0
if p.synth != nil {
p.synth.Trigger(oldestVoice, note)
}
p.synth.Trigger(oldestVoice, note)
}
func (p *Player) release(ID int) {