private void HostOnMidiMessageReceived(object sender, MidiEventArgs e) { if (e.Status != 12) // program change { return; } // Find all tracks that have the string 'ChXX-PCYYY' in it's name. // where XX is for the midi channel and YYY for the program change // Whenever a MIDI program change is received, all tracks on that channel are muted, except the one where YYY matches the program change received var tracks = Tracks.Select(t => { var m = Regex.Match(t.Name, "Ch(?<mc>[0-9]{2})-PC(?<mpc>[0-9]{3})"); var channel = m.Success ? int.Parse(m.Groups["mc"].Value) : -1; var programChange = m.Success ? int.Parse(m.Groups["mpc"].Value) : -1; return(new { Track = t, Channel = channel, PC = programChange }); }) .Where(i => i.Channel == e.Channel + 1) .ToArray(); foreach (var trk in tracks) { MuteTrack(trk.Track, trk.PC != e.Data1); } }
public void OnMidiEventReceived(MidiEventArgs e) // receiving all types of midi msgs { Logger.Log(e); lpd.Midi.BasePath = (string)e.AdditionalData; // working profile path, to find midi file if (e.RawState is ChannelMessageEventArgs) { if (e.Pressed) { //lpd.Midi.PlayMidiFile(@"midires\gameover.mid"); lpd.SetColumnColor(e.Note % 10, e.Velocity); // param channel can be omitted if 0 lpd.SetRowColor(e.Note / 10, e.Velocity); // lpd.SetColor(e.Note + 11, e.Velocity); // lpd.SetColor(e.Note + 9, e.Velocity); // default channel 0 // lpd.SetColor(e.Note - 11, e.Velocity); // lpd.SetColor(e.Note - 9, e.Velocity); } else { // lpd.UnsetColor(e.Note+11); // lpd.UnsetColor(e.Note+9); // lpd.UnsetColor(e.Note-11); // lpd.UnsetColor(e.Note-9); lpd.UnsetColumnColor(e.Note % 10); lpd.UnsetRowColor(e.Note / 10); } } }
private void DeviceOnMessageReceived(IMidiMessage message) { if (!(message is ChannelMessage cm)) { return; } var status = ((int)cm.Command) >> 4; var ar = new MidiEventArgs(cm.MidiChannel, status, cm.Data1, cm.Data2); WriteDebug($"Got MIDI : {ar}"); MidiMessageReceived?.Invoke(this, ar); }
public void OnMidiEventReceived(MidiEventArgs e) // receiving all types of midi msgs { Logger.Log(e); lpd.BasePath = (string)e.AdditionalData; if (e.RawState is ChannelMessageEventArgs) { if (e.Pressed) { lpd.SetColor(e.Channel, e.Note, e.Velocity); lpd.PlayMidiFile(@"midires\gameover.mid"); } else { lpd.UnsetColor(e.Channel, e.Note); } } }
public void OnMidiEventReceived(MidiEventArgs e) { if (e.DeviceID == 0) // nanoKontrol { lpd.UnsetColumnColor(e.Note - 35); lpd.SetColor((int)(e.Velocity / 12.7) * 10 + (e.Note - 35), (int)(e.Velocity / 12.7) * 10); } if (e.DeviceID == 2) // Launchpad { if (e.Pressed) { lpd.SetColor(e.Note, e.Velocity); } else { lpd.UnsetColor(e.Note); } } }
public void OnMidiEventReceived(MidiEventArgs e) { if (e.Name.StartsWith("nanoKontrol")) // nanoKontrol { lpd.UnsetColumnColor(e.Note - 35); lpd.SetColor((int)(e.Velocity / 12.7) * 10 + (e.Note - 35), (int)(e.Velocity / 12.7) * 10); } if (e.Name.StartsWith("MIDIIN")) // Launchpad { int x = e.Note % 10, y = e.Note / 10; if (e.Pressed) { UpdateMouseOnLaunchpad(x, y); lpd.SetColor(x + y * 10, 45); Mouse.Move(240 * x, 135 * (9 - y)); } else { lpd.SetColor(x + y * 10, 35); } } }