Closed Yorgg closed 5 years ago
I just realized I can do a cast: (I'm new to c#)
if (e.EventType == Melanchall.DryWetMidi.Smf.MidiEventType.NoteOn)
{
var note = e as NoteOnEvent;
Debug.Log(note.Velocity);
Debug.Log($"{note.GetNoteName()}{note.GetNoteOctave()}");
}
I have one question remaining: how to get the sustain pedal data?
Hi,
According to MIDI standard, sustain pedal on/off is a control change event. So you can use this code:
var controlChangeEvent = e as ControlChangeEvent;
if (controlChangeEvent != null && ControlUtilities.GetControlName(controlChangeEvent) == ControlName.DamperPedal)
{
var controlValue = controlChangeEvent.ControlValue;
var sustainOn = controlValue < 64;
}
Values from 0 to 63 correspond to sustain is turned on.
Great thanks.
I am listening to the
InputDevice
and want to get the noteName and velocity fromNoteOn
,NoteOff
events, and also the sustain pedal event (on piano).I know the
EventType
, but don't know what to do next:thank you