public NoteData(float x, float y, float z, GeneralMidiPercussion percInt) { X = x; Y = y; Z = z; PercissionInst = percInt; }
void PlotData(float x, float y, float z) { this.chart1.BeginInvoke((MethodInvoker) delegate { chart1.Series["accX"].Points.AddY(x); chart1.Series["accY"].Points.AddY(y); chart1.Series["accZ"].Points.AddY(z); if (chart1.Series["accX"].Points.Count > 200) { chart1.Series["accX"].Points.RemoveAt(0); chart1.Series["accY"].Points.RemoveAt(0); chart1.Series["accZ"].Points.RemoveAt(0); } curX = x; curY = y; curZ = z; if (z > 15 && !playLock) { GeneralMidiPercussion percussion = (GeneralMidiPercussion)Enum.Parse(typeof(GeneralMidiPercussion), comboBox2.SelectedItem.ToString(), true); MidiPlayer.Play(new NoteOn(0, percussion, 127)); playLock = true; } if (z < 15 && playLock) { playLock = false; } }); }
/// <summary> /// Gets an instance of the <see cref="NoteOffEvent"/> corresponding to the specified /// General MIDI Level 1 percussion. /// </summary> /// <param name="percussion"><see cref="GeneralMidiPercussion"/> to get an event for.</param> /// <param name="velocity">Velocity of the <see cref="NoteOffEvent"/>.</param> /// <param name="channel">Channel an event should be created for.</param> /// <returns>An instance of the <see cref="NoteOffEvent"/> corresponding to the specified /// <paramref name="percussion"/>.</returns> /// <exception cref="InvalidEnumArgumentException"><paramref name="percussion"/> specified an invalid value.</exception> public static NoteOffEvent GetNoteOffEvent(this GeneralMidiPercussion percussion, SevenBitNumber velocity, FourBitNumber channel) { ThrowIfArgument.IsInvalidEnumValue(nameof(percussion), percussion); return(new NoteOffEvent(percussion.AsSevenBitNumber(), velocity) { Channel = channel }); }
private void button2_Click(object sender, EventArgs e) { GeneralMidiPercussion percussion = (GeneralMidiPercussion)Enum.Parse(typeof(GeneralMidiPercussion), comboBox2.SelectedItem.ToString(), true); notes.Add(new NoteData(curX, curY, curZ, percussion)); BindingSource bs = new BindingSource(); bs.DataSource = notes; dataGridView1.DataSource = bs; }
public PercussionNoteSegment( int track, MidiEventWithTime <OnNoteVoiceMidiEvent> onNoteEvent, MidiEventWithTime <OffNoteVoiceMidiEvent> offNoteEvent, int startSample, int durationSamples, GeneralMidiPercussion instrument) : base(track, onNoteEvent, offNoteEvent, startSample, durationSamples) { PercussionInstrument = instrument; PercussionType = PercussionHelper.GetPercussionType(instrument); }
// Groupings pulled from Abundant Music > Song Settings > Domains // To simplify synthesis, all instruments in a group will use the same signal generator. /// <summary> /// Generalizes a General MIDI percussion instrument to a PercussionType. /// </summary> /// <param name="instrument"></param> /// <returns></returns> public static PercussionType GetPercussionType(GeneralMidiPercussion instrument) { switch (instrument) { // Bass drums case GeneralMidiPercussion.HighFloorTom: case GeneralMidiPercussion.LowFloorTom: case GeneralMidiPercussion.LowBongo: case GeneralMidiPercussion.LowConga: case GeneralMidiPercussion.LowTimbale: case GeneralMidiPercussion.BassDrum1: case GeneralMidiPercussion.BassDrum: return(PercussionType.Bass); // Snare drums case GeneralMidiPercussion.AcousticSnare: case GeneralMidiPercussion.HandClap: case GeneralMidiPercussion.HighTom: case GeneralMidiPercussion.HiMidTom: case GeneralMidiPercussion.LowMidTom: case GeneralMidiPercussion.LowTom: case GeneralMidiPercussion.OpenHiConga: case GeneralMidiPercussion.ElectricSnare: return(PercussionType.Snare); // Crash drums case GeneralMidiPercussion.ChineseCymbal: case GeneralMidiPercussion.SplashCymbal: case GeneralMidiPercussion.CrashCymbal1: case GeneralMidiPercussion.CrashCymbal2: return(PercussionType.Crash); // Ride drums case GeneralMidiPercussion.Maracas: case GeneralMidiPercussion.OpenTriangle: case GeneralMidiPercussion.MuteTriangle: case GeneralMidiPercussion.Claves: case GeneralMidiPercussion.RideBell: case GeneralMidiPercussion.SideStick: case GeneralMidiPercussion.RideCymbal: case GeneralMidiPercussion.RideCymbal2: case GeneralMidiPercussion.PedalHiHat: case GeneralMidiPercussion.ClosedHiHat: case GeneralMidiPercussion.OpenHiHat: // Defaulting to a ride drum probably isn't good, but it will sound ok in lots of situations. default: return(PercussionType.Ride); } }
/// <summary>Create a complete note (both on and off messages).</summary> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="percussion">The percussion instrument to sound.</param> /// <param name="velocity">The velocity of the note (0x0 to 0x7F).</param> /// <param name="duration">The duration of the note.</param> /// <remarks>Channel 10 (internally 0x9) is assumed.</remarks> public static MidiEventCollection Complete( long deltaTime, GeneralMidiPercussion percussion, byte velocity, long duration) { return Complete(deltaTime, (byte)SpecialChannels.Percussion, GetNoteValue(percussion), velocity, duration); }
/// <summary>Gets the note value for the specific percussion.</summary> /// <param name="percussion">The percussion for which we need the note value.</param> /// <returns>The numeric value of the specified percussion.</returns> public static byte GetNoteValue(GeneralMidiPercussion percussion) { // The GeneralMidiPercussion enumeration already has the correct note values // built into it, so just cast the value to a byte and return it. return((byte)percussion); }
/// <summary>Initialize the NoteOn MIDI event message.</summary> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="percussion">The percussion instrument to sound.</param> /// <param name="velocity">The velocity of the note (0x0 to 0x7F).</param> /// <remarks>Channel 10 (internally 0x9) is assumed.</remarks> public OnNoteVoiceMidiEvent(long deltaTime, GeneralMidiPercussion percussion, byte velocity) : this(deltaTime, (byte)SpecialChannel.Percussion, GetNoteValue(percussion), velocity) { }
/// <summary> /// Converts <see cref="GeneralMidiPercussion" /> to the corresponding value of the /// <see cref="SevenBitNumber" /> type. /// </summary> /// <param name="percussion"><see cref="GeneralMidiPercussion" /> to convert to <see cref="SevenBitNumber" />.</param> /// <returns><see cref="SevenBitNumber" /> representing the <paramref name="percussion" />.</returns> /// <exception cref="InvalidEnumArgumentException"><paramref name="percussion" /> specified an invalid value.</exception> public static SevenBitNumber AsSevenBitNumber(this GeneralMidiPercussion percussion) { ThrowIfArgument.IsInvalidEnumValue(nameof(percussion), percussion); return((SevenBitNumber)(byte)percussion); }
public NoteOff(long deltaTime, GeneralMidiPercussion percussion, byte velocity) : this(deltaTime, 9, MidiEvent.GetNoteValue(percussion), velocity) { }
/// <summary>Gets the note value for the specific percussion.</summary> /// <param name="percussion">The percussion for which we need the note value.</param> /// <returns>The numeric value of the specified percussion.</returns> public static byte GetNoteValue(GeneralMidiPercussion percussion) { // The GeneralMidiPercussion enumeration already has the correct note values // built into it, so just cast the value to a byte and return it. return (byte)percussion; }
/// <summary>Create a complete note (both on and off messages).</summary> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="percussion">The percussion instrument to sound.</param> /// <param name="velocity">The velocity of the note (0x0 to 0x7F).</param> /// <param name="duration">The duration of the note.</param> /// <remarks>Channel 10 (internally 0x9) is assumed.</remarks> public static MidiEvent[] Complete( long deltaTime, GeneralMidiPercussion percussion, byte velocity, long duration) { return(Complete(deltaTime, (byte)SpecialChannel.Percussion, GetNoteValue(percussion), velocity, duration)); }
private void button3_Click(object sender, EventArgs e) { GeneralMidiPercussion percussion = (GeneralMidiPercussion)Enum.Parse(typeof(GeneralMidiPercussion), comboBox2.SelectedItem.ToString(), true); MidiPlayer.Play(new NoteOn(0, percussion, 64)); }
/// <summary>Initialize the NoteOn MIDI event message.</summary> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="percussion">The percussion instrument to sound.</param> /// <param name="velocity">The velocity of the note (0x0 to 0x7F).</param> /// <remarks>Channel 10 (internally 0x9) is assumed.</remarks> public NoteOn(long deltaTime, GeneralMidiPercussion percussion, byte velocity) : this(deltaTime, (byte)SpecialChannels.Percussion, GetNoteValue(percussion), velocity) { }
/// <summary>Initialize the NoteOff MIDI event message.</summary> /// <param name="owner">The track that owns this event.</param> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="percussion">The percussion instrument to sound.</param> /// <param name="velocity">The velocity of the note (0x0 to 0x7F).</param> /// <remarks>Channel 10 (internally 0x9) is assumed.</remarks> public OffNoteVoiceMidiEvent(MidiTrack owner, long deltaTime, GeneralMidiPercussion percussion, byte velocity) : this(owner, deltaTime, (byte)SpecialChannel.Percussion, GetNoteValue(percussion), velocity) { }
public static byte GetNoteValue(GeneralMidiPercussion percussion) { return (byte) percussion; }
/// <summary>Initialize the Aftertouch MIDI event message.</summary> /// <param name="owner">The track that owns this event.</param> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="percussion">The percussion instrument to modify.</param> /// <param name="pressure">The pressure of the note (0x0 to 0x7F).</param> /// <remarks>Channel 10 (internally 0x9) is assumed.</remarks> public AftertouchNoteVoiceMidiEvent(MidiTrack owner, long deltaTime, GeneralMidiPercussion percussion, byte pressure) : this(owner, deltaTime, (byte)SpecialChannel.Percussion, GetNoteValue(percussion), pressure) { }
/// <summary>Initialize the Aftertouch MIDI event message.</summary> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="percussion">The percussion instrument to modify.</param> /// <param name="pressure">The pressure of the note (0x0 to 0x7F).</param> /// <remarks>Channel 10 (internally 0x9) is assumed.</remarks> public Aftertouch(long deltaTime, GeneralMidiPercussion percussion, byte pressure) : this(deltaTime, (byte)SpecialChannels.Percussion, GetNoteValue(percussion), pressure) { }
public Aftertouch(long deltaTime, GeneralMidiPercussion percussion, byte pressure) : this(deltaTime, 9, MidiEvent.GetNoteValue(percussion), pressure) { }