public void SendAll() { if (!ClearToTransmit()) { return; } MidiChannel.PitchBendFactor(_pitchbend_factor); SendPitchBend(); MidiChannel.Volume((byte)_vol_eff); MidiChannel.Sustain(Pedal); MidiChannel.ModulationWheel(_modwheel); SendPanPosition(_pan_eff + 0x40); if (Instrument.IsValid) { Instrument.Send(MidiChannel); } // We need to send the effect level after setting up the instrument // otherwise the reverb setting for MT-32 will be overwritten. SendEffectLevel((byte)_effect_level); MidiChannel.ChorusLevel(_chorus); MidiChannel.Priority((byte)PriorityEffective); }
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); } }