internal void NoteOn(byte note, byte velocity) { if (!On) { return; } MidiChannel mc = MidiChannel; // DEBUG if (_unassignedInstrument && !Percussion) { _unassignedInstrument = false; if (!Instrument.IsValid) { Debug.WriteLine("[{0}] No instrument specified", Channel); return; } } if (mc != null && Instrument.IsValid) { mc.NoteOn(note, velocity); } else if (Percussion) { mc = Player.MidiDriver.GetPercussionChannel(); if (mc == null) { return; } // FIXME: The following is evil, EVIL!!! Either prev_vol_eff is // actually meant to be a member of the Part class (i.e. each // instance of Part keeps a separate copy of it); or it really // is supposed to be shared by all Part instances -- but then it // should be implemented as a class static var. As it is, using // a function level static var in most cases is arcane and evil. prev_vol_eff = 128; if (_vol_eff != prev_vol_eff) { mc.Volume((byte)_vol_eff); prev_vol_eff = (byte)_vol_eff; } if ((note < 35) && (!Player._se.IsNativeMT32)) { note = Instrument._gmRhythmMap[note]; } mc.NoteOn(note, velocity); } }