public override void AddMidiEvents(ref SSEQMidiResult Result) { MidiEvent midiEvent = MidiEvent.FromRawMessage(MidiMessage.ChangeControl(84, (int)this.Portamento, Result.TrackID + 1).RawData); midiEvent.AbsoluteTime = (long)Result.CurrentTime; Result.MidiTrack.Add(midiEvent); }
public override void AddMidiEvents(ref SSEQMidiResult Result) { MidiEvent midiEvent = MidiEvent.FromRawMessage(MidiMessage.ChangeControl(78, 64 + (int)this.ModulationDelay / 2, Result.TrackID + 1).RawData); midiEvent.AbsoluteTime = (long)Result.CurrentTime; Result.MidiTrack.Add(midiEvent); }
/// <summary> /// Process input midi event. /// </summary> void MidiIn_MessageReceived(object?sender, MidiInMessageEventArgs e) { // Decode the message. We only care about a few. MidiEvent me = MidiEvent.FromRawMessage(e.RawMessage); MidiEventArgs?mevt = null; switch (me) { case NoteOnEvent evt: mevt = new MidiEventArgs() { Channel = evt.Channel, Note = evt.NoteNumber, Velocity = evt.Velocity }; break; case NoteEvent evt: mevt = new MidiEventArgs() { Channel = evt.Channel, Note = evt.NoteNumber, Velocity = 0 }; break; case ControlChangeEvent evt: mevt = new MidiEventArgs() { Channel = evt.Channel, ControllerId = (int)evt.Controller, ControllerValue = evt.ControllerValue }; break; case PitchWheelChangeEvent evt: mevt = new MidiEventArgs() { Channel = evt.Channel, ControllerId = MidiEventArgs.PITCH_CONTROL, ControllerValue = evt.Pitch }; break; } if (mevt is not null) { // Pass it up for handling. InputEvent?.Invoke(this, mevt); } // else ignore?? }
public override void AddMidiEvents(ref SSEQMidiResult Result) { MidiEvent midiEvent1 = MidiEvent.FromRawMessage(MidiMessage.ChangeControl(101, 0, Result.TrackID + 1).RawData); midiEvent1.AbsoluteTime = (long)Result.CurrentTime; Result.MidiTrack.Add(midiEvent1); MidiEvent midiEvent2 = MidiEvent.FromRawMessage(MidiMessage.ChangeControl(100, 0, Result.TrackID + 1).RawData); midiEvent2.AbsoluteTime = (long)Result.CurrentTime; Result.MidiTrack.Add(midiEvent2); MidiEvent midiEvent3 = MidiEvent.FromRawMessage(MidiMessage.ChangeControl(6, (int)this.PitchRange, Result.TrackID + 1).RawData); midiEvent3.AbsoluteTime = (long)Result.CurrentTime; Result.MidiTrack.Add(midiEvent3); }
public override void AddMidiEvents(ref SSEQMidiResult Result) { int patchNumber = this.RealProgram % 128; int num = this.RealProgram / 128 & 15; MidiEvent midiEvent1 = MidiEvent.FromRawMessage(MidiMessage.ChangeControl(0, this.RealProgram / 128 / 128 & 15, Result.TrackID + 1).RawData); midiEvent1.AbsoluteTime = (long)Result.CurrentTime; Result.MidiTrack.Add(midiEvent1); MidiEvent midiEvent2 = MidiEvent.FromRawMessage(MidiMessage.ChangeControl(32, num, Result.TrackID + 1).RawData); midiEvent2.AbsoluteTime = (long)Result.CurrentTime; Result.MidiTrack.Add(midiEvent2); Result.MidiTrack.Add((MidiEvent) new PatchChangeEvent((long)Result.CurrentTime, Result.TrackID + 1, patchNumber)); if (patchNumber != (int)sbyte.MaxValue) { return; } Result.TrackID = 9; foreach (MidiEvent midiEvent3 in (IEnumerable <MidiEvent>)Result.MidiTrack) { midiEvent3.Channel = 10; } }
/// <summary> /// Process input midi event. /// </summary> void NpMidiIn_MessageReceived(object sender, MidiInMessageEventArgs e) { // Decode the message. We only care about a few. MidiEvent me = MidiEvent.FromRawMessage(e.RawMessage); NpMidiEventArgs mevt = null; switch (me.CommandCode) { case MidiCommandCode.NoteOn: { NoteOnEvent evt = me as NoteOnEvent; mevt = new NpMidiEventArgs() { channel = evt.Channel, note = evt.NoteNumber, velocity = evt.Velocity }; } break; case MidiCommandCode.NoteOff: { NoteEvent evt = me as NoteEvent; mevt = new NpMidiEventArgs() { channel = evt.Channel, note = evt.NoteNumber, velocity = 0 }; } break; case MidiCommandCode.ControlChange: { ControlChangeEvent evt = me as ControlChangeEvent; mevt = new NpMidiEventArgs() { channel = evt.Channel, controllerId = (int)evt.Controller, controllerValue = evt.ControllerValue }; } break; case MidiCommandCode.PitchWheelChange: { PitchWheelChangeEvent evt = me as PitchWheelChangeEvent; mevt = new NpMidiEventArgs() { channel = evt.Channel, controllerId = NpMidiEventArgs.PITCH_CONTROL, controllerValue = evt.Pitch }; } break; } if (mevt != null) { // Pass it up for handling. InputEvent?.Invoke(this, mevt); } // else ignore?? }
/// <summary> /// Process input midi event. Note that NoteOn with 0 velocity are converted to NoteOff. /// </summary> void MidiIn_MessageReceived(object?sender, MidiInMessageEventArgs e) { // Decode the message. We only care about a few. MidiEvent me = MidiEvent.FromRawMessage(e.RawMessage); Step? step = null; switch (me) { case NoteOnEvent evt: { if (evt.Velocity == 0) { step = new StepNoteOff() { Device = this, ChannelNumber = evt.Channel, NoteNumber = MathUtils.Constrain(evt.NoteNumber, 0, Definitions.MAX_MIDI), Velocity = 0.0 }; } else { step = new StepNoteOn() { Device = this, ChannelNumber = evt.Channel, NoteNumber = evt.NoteNumber, Velocity = evt.Velocity / Definitions.MAX_MIDI, VelocityToPlay = evt.Velocity / Definitions.MAX_MIDI, Duration = new Time(0) }; } } break; case NoteEvent evt: { step = new StepNoteOff() { Device = this, ChannelNumber = evt.Channel, NoteNumber = MathUtils.Constrain(evt.NoteNumber, 0, Definitions.MAX_MIDI), Velocity = evt.Velocity / Definitions.MAX_MIDI }; } break; case ControlChangeEvent evt: { step = new StepControllerChange() { Device = this, ChannelNumber = evt.Channel, ControllerId = (ControllerDef)evt.Controller, Value = evt.ControllerValue }; } break; case PitchWheelChangeEvent evt: { step = new StepControllerChange() { Device = this, ChannelNumber = evt.Channel, ControllerId = ControllerDef.PitchControl, Value = MathUtils.Constrain(evt.Pitch, 0, MidiUtils.MAX_PITCH), }; } break; } if (step is not null) { // Pass it up for handling. DeviceInputEventArgs args = new() { Step = step }; DeviceInputEvent?.Invoke(this, args); if (UserSettings.TheSettings.MonitorInput) { _logger.Trace($"{TraceCat.RCV} MidiIn:{step}"); } } } /// <summary> /// Process error midi event - Parameter 1 is invalid. /// </summary> void MidiIn_ErrorReceived(object?sender, MidiInMessageEventArgs e) { _logger.Error($"Message:0x{e.RawMessage:X8}"); } #endregion }