ScaleNotes.hpp
1 #pragma once
2 #include <Midi/Commands/CommandFactory.hpp>
3 #include <Midi/MidiNote.hpp>
4 
5 #include <score/command/AggregateCommand.hpp>
6 #include <score/model/path/Path.hpp>
7 
8 namespace Midi
9 {
10 class ProcessModel;
11 
12 class ScaleNotes final : public score::Command
13 {
14  SCORE_COMMAND_DECL(Midi::CommandFactoryName(), ScaleNotes, "Scale notes")
15 public:
16  ScaleNotes(
17  const ProcessModel& model, const std::vector<Id<Note>>& to_move, double delta);
18 
19  void undo(const score::DocumentContext& ctx) const override;
20  void redo(const score::DocumentContext& ctx) const override;
21 
22 protected:
23  void serializeImpl(DataStreamInput& s) const override;
24  void deserializeImpl(DataStreamOutput& s) override;
25 
26 private:
27  Path<ProcessModel> m_model;
28  std::vector<Id<Note>> m_toScale;
29  double m_delta{};
30 };
31 
32 // sclaes the whole process
33 class RescaleMidi final : public score::Command
34 {
35  SCORE_COMMAND_DECL(Midi::CommandFactoryName(), RescaleMidi, "Rescale midi")
36 public:
37  RescaleMidi(const ProcessModel& model, double delta);
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<std::pair<Id<Note>, NoteData>> m_old;
49  double m_delta{};
50 };
52 {
53  SCORE_COMMAND_DECL(Midi::CommandFactoryName(), RescaleAllMidi, "Rescale all midi")
54 public:
55 };
56 }
Definition: MidiProcess.hpp:15
Definition: ScaleNotes.hpp:52
Definition: ScaleNotes.hpp:34
Definition: ScaleNotes.hpp:13
The id_base_t class.
Definition: Identifier.hpp:57
Allows for grouping of multiple commands in a single one.
Definition: AggregateCommand.hpp:15
The Command class.
Definition: Command.hpp:34
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: MidiNote.hpp:11
Definition: DocumentContext.hpp:18