You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7KB

  1. #pragma once
  2. #include "MidiEditorContext.h"
  3. #include <memory>
  4. class MidiEditorContext;
  5. class MidiSelectionModel;
  6. class MidiSequencer;
  7. class MidiSong;
  8. class MidiTrack;
  9. class MidiEditor
  10. {
  11. public:
  12. MidiEditor(std::shared_ptr<MidiSequencer>);
  13. MidiEditor(const MidiEditor&) = delete;
  14. ~MidiEditor();
  15. /************** functions that move the cursor position ***********/
  16. void selectNextNote();
  17. void selectPrevNote();
  18. /**
  19. * If ticks is false, will move by "units" (like 1/16 note)
  20. * amount is a multiplier, and may be negative
  21. */
  22. void advanceCursor(bool ticks, int amount);
  23. /*********** functions that edit/change the notes **************/
  24. void changeCursorPitch(int semitones);
  25. void changePitch(int semitones);
  26. void changeStartTime(bool ticks, int amount);
  27. void changeDuration(bool ticks, int amount);
  28. void insertNote();
  29. void deleteNote();
  30. /************* ***************/
  31. // Editing start time / duration / pitch
  32. void setNoteEditorAttribute(MidiEditorContext::NoteAttribute);
  33. void assertCursorInSelection();
  34. private:
  35. /**
  36. * The sequencer we will act on.
  37. * use wek ptr to break ref circle
  38. */
  39. std::weak_ptr<MidiSequencer> m_seq;
  40. std::shared_ptr< MidiSequencer> seq()
  41. {
  42. // This assumes of course that m_seq still exists
  43. auto ret = m_seq.lock();
  44. assert(ret);
  45. return ret;
  46. }
  47. std::shared_ptr<MidiTrack> getTrack();
  48. // move the cursor, if necessary.
  49. void updateCursor();
  50. // select any note that is under the cursor
  51. void updateSelectionForCursor();
  52. void extendTrackToMinDuration(float time);
  53. };
  54. using MidiEditorPtr = std::shared_ptr<MidiEditor>;