#pragma once #include #include "MidiEvent.h" #include "SqCommand.h" class MidiEditorContext; class MidiEvent; class MidiNoteEvent; class MidiSong; class MidiSequencer; class MidiSelectionModel; class ReplaceDataCommand; using ReplaceDataCommandPtr = std::shared_ptr; class ReplaceDataCommand : public SqCommand { public: virtual void execute() override; virtual void undo() override; // TODO: rvalue ReplaceDataCommand( std::shared_ptr song, std::shared_ptr, std::shared_ptr, int trackNumber, const std::vector& inRemove, const std::vector& inAdd); /** * static factories for replace commands */ static ReplaceDataCommandPtr makeDeleteCommand(std::shared_ptr seq); static ReplaceDataCommandPtr makeInsertNoteCommand(std::shared_ptr seq, std::shared_ptr); static ReplaceDataCommandPtr makeChangePitchCommand(std::shared_ptr seq, int semitones); static ReplaceDataCommandPtr makeChangeStartTimeCommand(std::shared_ptr seq, float delta); static ReplaceDataCommandPtr makeChangeDurationCommand(std::shared_ptr seq, float delta); private: std::shared_ptr song; int trackNumber; std::shared_ptr selection; std::vector removeData; std::vector addData; static void extendTrackToMinDuration( std::shared_ptr seq, float neededLength, std::vector& toAdd, std::vector& toDelete); // base for change pitch, start time, duration enum class Ops {Pitch, Start, Duration }; using Xform = std::function; static ReplaceDataCommandPtr makeChangeNoteCommand( Ops, std::shared_ptr seq, Xform xform, bool canChangeLength); };