AddNote.hpp
1 #pragma once
2 #include <Process/TimeValue.hpp>
3 
4 #include <Midi/Commands/CommandFactory.hpp>
5 #include <Midi/MidiNote.hpp>
6 
7 #include <score/model/path/Path.hpp>
8 
9 #include <score_plugin_midi_export.h>
10 namespace Midi
11 {
12 class ProcessModel;
13 
14 class AddNote final : public score::Command
15 {
16  SCORE_COMMAND_DECL(Midi::CommandFactoryName(), AddNote, "Add a note")
17 public:
18  AddNote(const ProcessModel& model, const NoteData& note);
19 
20  void undo(const score::DocumentContext& ctx) const override;
21  void redo(const score::DocumentContext& ctx) const override;
22 
23 protected:
24  void serializeImpl(DataStreamInput& s) const override;
25  void deserializeImpl(DataStreamOutput& s) override;
26 
27 private:
28  Path<ProcessModel> m_model;
29  Id<Note> m_id;
30  NoteData m_note;
31 };
32 
33 class AddNotes final : public score::Command
34 {
35  SCORE_COMMAND_DECL(Midi::CommandFactoryName(), AddNotes, "Add multiple notes")
36 public:
37  AddNotes(const ProcessModel& model, const std::vector<NoteData>& notes);
38 
39  void undo(const score::DocumentContext& ctx) const override;
40  void redo(const score::DocumentContext& ctx) const override;
41 
42 protected:
43  void serializeImpl(DataStreamInput& s) const override;
44  void deserializeImpl(DataStreamOutput& s) override;
45 
46 private:
47  Path<ProcessModel> m_model;
48  std::vector<Id<Note>> m_ids;
49  std::vector<NoteData> m_notes;
50 };
51 
52 class SCORE_PLUGIN_MIDI_EXPORT ReplaceNotes final : public score::Command
53 {
54  SCORE_COMMAND_DECL(Midi::CommandFactoryName(), ReplaceNotes, "Set notes")
55 public:
57  const ProcessModel& model, const std::vector<NoteData>& note, int min, int max,
58  TimeVal dur);
59 
60  void undo(const score::DocumentContext& ctx) const override;
61  void redo(const score::DocumentContext& ctx) const override;
62 
63 protected:
64  void serializeImpl(DataStreamInput& s) const override;
65  void deserializeImpl(DataStreamOutput& s) override;
66 
67 private:
68  Path<ProcessModel> m_model;
69  std::vector<std::pair<Id<Note>, NoteData>> m_old, m_new;
70  int m_oldmin{}, m_oldmax{}, m_newmin{}, m_newmax{};
71  TimeVal m_olddur{}, m_newdur{};
72 };
73 }
Definition: AddNote.hpp:15
Definition: AddNote.hpp:34
Definition: MidiProcess.hpp:15
Definition: AddNote.hpp:53
The id_base_t class.
Definition: Identifier.hpp:57
The Command class.
Definition: Command.hpp:34
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: MidiNote.hpp:11
Definition: TimeValue.hpp:21
Definition: DocumentContext.hpp:18