public void SetNoteOn(Note note, int octave, int velocity = 0xF) { if (patternView.position.dataColumn != 0) { return; } if (patternView.recording) { byte noteData = EncodeNoteInfo(( int )note, octave); history.AddHistroyAtSelection(); patternView.SetDataAtSelection(noteData); if (note != Note.NoteOff) { patternView.SetDataAtSelection(( byte )currentInstrument, 1); } if (velocity != 0xF) { patternView.SetDataAtSelection((byte)velocity, 2); } if (!playback.isPlaying) { patternView.MoveVertical(patternAdd); } } if (playback.isPlaying) { return; } for (int i = 0; i < m_Instruments.Length; i++) { if (m_Instruments [i].note == Note.None || m_Instruments [i].note == Note.NoteOff) { m_Instruments [i] = instruments.presets [currentInstrument]; m_Instruments [i].note = note; m_Instruments [i].octave = octave; m_Instruments [i].relativeVolume = velocity; break; } } }
// Update is called once per frame void Update() { if (ExclusiveFocus.hasFocus) { return; } if (!playback.isPlaying) { if (Input.GetKeyDown(KeyCode.Home)) { patternView.SetSelection(0); } if (Input.GetKeyDown(KeyCode.End)) { patternView.SetSelection(songData.patternLength - 1); } if (Input.GetKeyDown(KeyCode.DownArrow)) { DoShortcut(KeyCode.DownArrow, () => { patternView.MoveVertical(1); }); } if (Input.GetKeyDown(KeyCode.UpArrow)) { DoShortcut(KeyCode.UpArrow, () => { patternView.MoveVertical(-1); }); } } if (Input.GetKeyDown(KeyCode.LeftArrow)) { DoShortcut(KeyCode.LeftArrow, () => { patternView.MoveHorizontal(-1); }); } if (Input.GetKeyDown(KeyCode.RightArrow)) { DoShortcut(KeyCode.RightArrow, () => { patternView.MoveHorizontal(1); }); } if (ModifierDown()) { if (Input.GetKeyDown(KeyCode.C)) { CopySelection(); } if (Input.GetKeyDown(KeyCode.V)) { PasteSelection(); } if (Input.GetKeyDown(KeyCode.X)) { CopySelection(); DeleteSelection(); } if (Input.GetKeyDown(KeyCode.Z)) { history.Undo(); } if (Input.GetKeyDown(KeyCode.F1)) { Transpose(-1); } if (Input.GetKeyDown(KeyCode.F2)) { Transpose(1); } if (Input.GetKeyDown(KeyCode.F3)) { Transpose(-12); } if (Input.GetKeyDown(KeyCode.F4)) { Transpose(12); } if (Input.GetKeyDown(KeyCode.A)) { SelectAll( ); } if (Input.GetKeyDown(KeyCode.S)) { fileManagement.SaveFile(false); } } if (patternView.recording) { if (Input.GetKeyDown(KeyCode.Delete)) { DoShortcut(KeyCode.Delete, DeleteSelection); } if (Input.GetKeyDown(KeyCode.Backspace)) { DoShortcut(KeyCode.Backspace, Erase); } if (Input.GetKeyDown(KeyCode.Insert)) { DoShortcut(KeyCode.Insert, Insert); } } if (!ModifierDown()) { for (int i = (int)KeyCode.F1; i <= (int)KeyCode.F8; i++) { if (Input.GetKeyDown((KeyCode)i)) { controls.octave.value = i - (int)KeyCode.F1 + 1; } } } }