Repository navigation
Conversation
|
I have a few questions:
|
Yamaha's sequencer shows these 3 messages always in an Event like this: CC0=0, CC32=0, Program 0 this guy has a tutorial and explains how he packs Bank change and program Change together: This article is talking about "Continuous controller commands" and talks about good programs automating this process. this shows that it's somewhat common practice to put them together. You can test it out here: https://signalmidi.app/edit
You'll see: It has automatically added a Bank Change 0 at Tick 0.
the reason we have to handle CC0 is because only this case gets coded back in manually: CC32 just passes by and gets ignored by
In RobustToolbox/Robust.Client/Audio/Midi/MidiRenderer.cs Lines 606 to 616 in 0ca6ad8 the bank changes arrive to all channels but it isn't intended for percussion ones. RobustToolbox/Robust.Client/Audio/Midi/MidiRenderer.cs Lines 91 to 105 in 0ca6ad8 so someone thought about that already but wasn't considering the file sending bank changes. |
|
i heard that other engines use the Edit: |
Fix Drum Channel switching Banks
About the PR
Prevents the percussion channel in
MidiRenderer.csfrom switching banks. The engine already covered bank changes by the instrument in theMidiBanksetter. This fix handles bank changes sent by the MIDI file itself.Why / Balance
The bug affects the Super Synthesizer and DAW (all instruments that have
allowProgramChange).The MIDI file changes its percussion channel to bank 0, resulting in drum notes played as a melodic instrument and therefore causing this file to be unenjoyable.
For example in a song the drums sit on bank 128 playing instrument 25, which is the TR-808 kit.
The drum channel reads change bank in the file (CC0=0).
Instead of ignoring it like done in the
MidiBanksetter it changes to bank 0 and plays instrument 25 there which is Steel guitar. And suddenly the rest of the song sounds messed up.This issue seems very common among musicians. It appears to be one of the reasons people share so many MIDIs on SS14 Discord. This bug creates an unnecessary need for files without bank changes.
Technical details
In
InitializeFluidsynth()ofMidiManager.csRobustToolbox is setting["synth.midi-bank-select"].StringValue = "gm";. This setting ignores CC0 and CC32 (both are bank changes. See FluidSynth documentation https://www.fluidsynth.org/wiki/settings/synth/?h=midi-bank-selecc#settings_synth_midi-bank-select for more information)SendMidiEvent()then handles each MIDI event given. The caseRobustMidiCommand.ControlChangemanually adds switching banks again in the else section with
_synth.BankSelect().It also includes the case CC0 on
PercussionChannelresulting in a switched bank inside it.The fix adds an additional early break by checking if the event is a bank change and happening on
PercussionChannel.It is handling the
PercussionChannelthe same way as in theMidiBanksetter, by ignoring the percussion channel manually.Someone could argue to just bypass bank changes to FluidSynth since
gmignores this anyway but this could lead to the bug returning if anybody decides to use something other thangm.Test plan
I included
trap.midandworking.midin the zip file provided.(see Media)
working.midis a counter case where no changes happen.trap.midis causing the bug on purpose.This bug can be consistently reproduced by:
C9 18)Before fix:
trap.midwill be playing drums like intended until the MIDI program change sets in. You will be able to notice its drums getting messed up, starting at its position.working.midwill work as intended.After fix:
Drums play as intended. No bank changes will happen on
PercussionChannel.trap.midandworking.midsound the same.Tested if:
trap.midandworking.midsound the same.allowPercussionlike the Piano playtrap.midandworking.midcompletely silent.Media
Test files: Testfiles.zip
SS14.drumFix.mp4
Breaking changes
MIDI files that intend to play melodic instruments instead of drums on the percussion channel will no longer be able to. This is intended, as it is the MIDI standard and the solution already chosen in the
MidiBanksetter.Changelog
🆑