- changed title to MidiPlayer not playing certain notes when loading a drum track
MidiPlayer not playing certain notes when loading a drum track
The kick, snare, and certain other sounds would not play when loading a midi file with a drum track.
Reproduction
- Insert a MidiPlayer node
- Add a drum MIDI file as the midi file (tested on files from this site)
- Play the MIDI
Possible Solution
Upon checking the source code, I’ve found that the culprit are these lines in MidiPlayer.gd’s _process_track_event_note_on
method:
# Line 705
var polyphony_count:int = 0
for instrument in instruments:
if instrument.vel_range_min <= key_number and key_number <= instrument.vel_range_max:
polyphony_count += 1
for instrument in instruments:
if instrument.vel_range_min <= key_number and key_number <= instrument.vel_range_max:
var note_player:AudioStreamPlayerADSR = self._get_idle_player( )
I’m not sure how the velocity range is being set, but for the kick, snare, and other tracks they end up being 101 for some reason, making the second if condition fail and the note not playing.
I’m not aware of how the entire system works, but I think key_number
shouldn’t probably be checked against vel_range_min
and vel_range_max
, which I assume refer to the velocity and not the number. I’ve changed key_number
in the conditions to velocity
and the sound plays fine now, but I’m not sure if there would be issues elsewhere.
Comments (5)
-
reporter -
repo owner Thanks for report.
I will fix it.
-
repo owner I fixed at
d186bfa
-
reporter Thanks! Really great addon btw, I’ve been using it for a rhythm game and it’s very flexible.
-
reporter - changed status to resolved
Issue's fixed now
- Log in to comment