// Check if a note matchs the note options. bool NoteFilter(MidiNoteControl note) { var device = (Minis.MidiDevice)note.device; if (_channel != Channel.All && (int)_channel != device.channel) { return(false); } var number = note.noteNumber; switch (_source) { case Source.NoteNumbers: foreach (var n in _noteNumbers) { if (n == number) { return(true); } } return(false); case Source.NoteRange: return(_lowestNote <= number && number <= _highestNote); default: // Source.AllNotes: return(true); } }
// Note off callback for MIDI device void OnMidiNoteOff(MidiNoteControl note) { if (NoteFilter(note)) { OnNoteOff(note.noteNumber); } }
// Note on callback for MIDI device void OnMidiNoteOn(MidiNoteControl note, float velocity) { if (NoteFilter(note)) { OnNoteOn(note.noteNumber, velocity); } }
// Note off callback for MIDI device void OnMidiNoteOff(MidiNoteControl note) { if (NoteFilter(note)) { OnNoteOff(); } }
void OnPerformed(InputAction.CallbackContext ctx) { MidiNoteControl controller = ctx.control as MidiNoteControl; precisionManager.PadHit(controller.noteNumber); //color changing var cubeRenderer = cube.GetComponent <Renderer>(); System.Random ran = new System.Random(); //int r = (int)(255 * controller.velocity / (ran.NextDouble() * 8)); //int g = (int)(255 * controller.velocity / (ran.NextDouble() * 8)); //int b = (int)(255 * controller.velocity / (ran.NextDouble() * 8)); int r = (int)(255 * 2.5 / (ran.NextDouble() * 8)); int g = (int)(255 * 2 / (ran.NextDouble() * 8)); int b = (int)(255 * 2 / (ran.NextDouble() * 8)); cubeRenderer.material.SetColor("_Color", new Color(r / 255f, g / 255f, b / 255f)); }
void OnPerformed(InputAction.CallbackContext ctx) { MidiNoteControl controller = ctx.control as MidiNoteControl; recordManager.PadHit(controller.noteNumber); }