summaryrefslogtreecommitdiffstats
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/edit/AddDotCommand.cpp98
-rw-r--r--src/commands/edit/AddDotCommand.h68
-rw-r--r--src/commands/edit/AddMarkerCommand.cpp67
-rw-r--r--src/commands/edit/AddMarkerCommand.h71
-rw-r--r--src/commands/edit/ChangeVelocityCommand.cpp68
-rw-r--r--src/commands/edit/ChangeVelocityCommand.h68
-rw-r--r--src/commands/edit/ClearTriggersCommand.cpp53
-rw-r--r--src/commands/edit/ClearTriggersCommand.h66
-rw-r--r--src/commands/edit/CollapseNotesCommand.cpp79
-rw-r--r--src/commands/edit/CollapseNotesCommand.h65
-rw-r--r--src/commands/edit/CopyCommand.cpp120
-rw-r--r--src/commands/edit/CopyCommand.h82
-rw-r--r--src/commands/edit/CutAndCloseCommand.cpp163
-rw-r--r--src/commands/edit/CutAndCloseCommand.h82
-rw-r--r--src/commands/edit/CutCommand.cpp59
-rw-r--r--src/commands/edit/CutCommand.h62
-rw-r--r--src/commands/edit/EraseCommand.cpp86
-rw-r--r--src/commands/edit/EraseCommand.h66
-rw-r--r--src/commands/edit/EventEditCommand.cpp64
-rw-r--r--src/commands/edit/EventEditCommand.h69
-rw-r--r--src/commands/edit/EventInsertionCommand.cpp58
-rw-r--r--src/commands/edit/EventInsertionCommand.h62
-rw-r--r--src/commands/edit/EventQuantizeCommand.cpp273
-rw-r--r--src/commands/edit/EventQuantizeCommand.h98
-rw-r--r--src/commands/edit/EventUnquantizeCommand.cpp106
-rw-r--r--src/commands/edit/EventUnquantizeCommand.h73
-rw-r--r--src/commands/edit/InsertTriggerNoteCommand.cpp132
-rw-r--r--src/commands/edit/InsertTriggerNoteCommand.h78
-rw-r--r--src/commands/edit/InvertCommand.cpp85
-rw-r--r--src/commands/edit/InvertCommand.h67
-rw-r--r--src/commands/edit/ModifyMarkerCommand.cpp95
-rw-r--r--src/commands/edit/ModifyMarkerCommand.h78
-rw-r--r--src/commands/edit/MoveAcrossSegmentsCommand.cpp76
-rw-r--r--src/commands/edit/MoveAcrossSegmentsCommand.h63
-rw-r--r--src/commands/edit/MoveCommand.cpp159
-rw-r--r--src/commands/edit/MoveCommand.h69
-rw-r--r--src/commands/edit/PasteEventsCommand.cpp321
-rw-r--r--src/commands/edit/PasteEventsCommand.h112
-rw-r--r--src/commands/edit/PasteSegmentsCommand.cpp153
-rw-r--r--src/commands/edit/PasteSegmentsCommand.h79
-rw-r--r--src/commands/edit/RemoveMarkerCommand.cpp83
-rw-r--r--src/commands/edit/RemoveMarkerCommand.h75
-rw-r--r--src/commands/edit/RescaleCommand.cpp138
-rw-r--r--src/commands/edit/RescaleCommand.h71
-rw-r--r--src/commands/edit/RetrogradeCommand.cpp121
-rw-r--r--src/commands/edit/RetrogradeCommand.h67
-rw-r--r--src/commands/edit/RetrogradeInvertCommand.cpp163
-rw-r--r--src/commands/edit/RetrogradeInvertCommand.h67
-rw-r--r--src/commands/edit/SelectionPropertyCommand.cpp128
-rw-r--r--src/commands/edit/SelectionPropertyCommand.h82
-rw-r--r--src/commands/edit/SetLyricsCommand.cpp192
-rw-r--r--src/commands/edit/SetLyricsCommand.h66
-rw-r--r--src/commands/edit/SetNoteTypeCommand.cpp87
-rw-r--r--src/commands/edit/SetNoteTypeCommand.h72
-rw-r--r--src/commands/edit/SetTriggerCommand.cpp74
-rw-r--r--src/commands/edit/SetTriggerCommand.h83
-rw-r--r--src/commands/edit/TransposeCommand.cpp83
-rw-r--r--src/commands/edit/TransposeCommand.h83
-rw-r--r--src/commands/matrix/MatrixEraseCommand.cpp70
-rw-r--r--src/commands/matrix/MatrixEraseCommand.h62
-rw-r--r--src/commands/matrix/MatrixInsertionCommand.cpp74
-rw-r--r--src/commands/matrix/MatrixInsertionCommand.h64
-rw-r--r--src/commands/matrix/MatrixModifyCommand.cpp81
-rw-r--r--src/commands/matrix/MatrixModifyCommand.h63
-rw-r--r--src/commands/matrix/MatrixPercussionInsertionCommand.cpp192
-rw-r--r--src/commands/matrix/MatrixPercussionInsertionCommand.h73
-rw-r--r--src/commands/notation/AddFingeringMarkCommand.cpp119
-rw-r--r--src/commands/notation/AddFingeringMarkCommand.h64
-rw-r--r--src/commands/notation/AddIndicationCommand.cpp171
-rw-r--r--src/commands/notation/AddIndicationCommand.h76
-rw-r--r--src/commands/notation/AddMarkCommand.cpp112
-rw-r--r--src/commands/notation/AddMarkCommand.h63
-rw-r--r--src/commands/notation/AddSlashesCommand.cpp53
-rw-r--r--src/commands/notation/AddSlashesCommand.h60
-rw-r--r--src/commands/notation/AddTextMarkCommand.cpp58
-rw-r--r--src/commands/notation/AddTextMarkCommand.h65
-rw-r--r--src/commands/notation/AutoBeamCommand.cpp48
-rw-r--r--src/commands/notation/AutoBeamCommand.h62
-rw-r--r--src/commands/notation/BeamCommand.cpp58
-rw-r--r--src/commands/notation/BeamCommand.h60
-rw-r--r--src/commands/notation/BreakCommand.cpp54
-rw-r--r--src/commands/notation/BreakCommand.h60
-rw-r--r--src/commands/notation/ChangeSlurPositionCommand.cpp58
-rw-r--r--src/commands/notation/ChangeSlurPositionCommand.h66
-rw-r--r--src/commands/notation/ChangeStemsCommand.cpp53
-rw-r--r--src/commands/notation/ChangeStemsCommand.h66
-rw-r--r--src/commands/notation/ChangeStyleCommand.cpp66
-rw-r--r--src/commands/notation/ChangeStyleCommand.h70
-rw-r--r--src/commands/notation/ChangeTiePositionCommand.cpp54
-rw-r--r--src/commands/notation/ChangeTiePositionCommand.h62
-rw-r--r--src/commands/notation/ClefInsertionCommand.cpp137
-rw-r--r--src/commands/notation/ClefInsertionCommand.h72
-rw-r--r--src/commands/notation/CollapseRestsCommand.cpp54
-rw-r--r--src/commands/notation/CollapseRestsCommand.h63
-rw-r--r--src/commands/notation/DeCounterpointCommand.cpp57
-rw-r--r--src/commands/notation/DeCounterpointCommand.h68
-rw-r--r--src/commands/notation/EraseEventCommand.cpp105
-rw-r--r--src/commands/notation/EraseEventCommand.h71
-rw-r--r--src/commands/notation/FixNotationQuantizeCommand.cpp87
-rw-r--r--src/commands/notation/FixNotationQuantizeCommand.h61
-rw-r--r--src/commands/notation/GraceCommand.cpp115
-rw-r--r--src/commands/notation/GraceCommand.h60
-rw-r--r--src/commands/notation/GuitarChordInsertionCommand.cpp59
-rw-r--r--src/commands/notation/GuitarChordInsertionCommand.h61
-rw-r--r--src/commands/notation/IncrementDisplacementsCommand.cpp57
-rw-r--r--src/commands/notation/IncrementDisplacementsCommand.h66
-rw-r--r--src/commands/notation/InterpretCommand.cpp602
-rw-r--r--src/commands/notation/InterpretCommand.h100
-rw-r--r--src/commands/notation/KeyInsertionCommand.cpp264
-rw-r--r--src/commands/notation/KeyInsertionCommand.h91
-rw-r--r--src/commands/notation/MakeAccidentalsCautionaryCommand.cpp68
-rw-r--r--src/commands/notation/MakeAccidentalsCautionaryCommand.h63
-rw-r--r--src/commands/notation/MakeChordCommand.cpp75
-rw-r--r--src/commands/notation/MakeChordCommand.h66
-rw-r--r--src/commands/notation/MakeNotesViableCommand.cpp57
-rw-r--r--src/commands/notation/MakeNotesViableCommand.h67
-rw-r--r--src/commands/notation/MakeRegionViableCommand.cpp48
-rw-r--r--src/commands/notation/MakeRegionViableCommand.h62
-rw-r--r--src/commands/notation/MultiKeyInsertionCommand.cpp80
-rw-r--r--src/commands/notation/MultiKeyInsertionCommand.h73
-rw-r--r--src/commands/notation/NormalizeRestsCommand.cpp52
-rw-r--r--src/commands/notation/NormalizeRestsCommand.h64
-rw-r--r--src/commands/notation/NoteInsertionCommand.cpp296
-rw-r--r--src/commands/notation/NoteInsertionCommand.h98
-rw-r--r--src/commands/notation/RemoveFingeringMarksCommand.cpp54
-rw-r--r--src/commands/notation/RemoveFingeringMarksCommand.h61
-rw-r--r--src/commands/notation/RemoveMarksCommand.cpp58
-rw-r--r--src/commands/notation/RemoveMarksCommand.h61
-rw-r--r--src/commands/notation/RemoveNotationQuantizeCommand.cpp69
-rw-r--r--src/commands/notation/RemoveNotationQuantizeCommand.h61
-rw-r--r--src/commands/notation/ResetDisplacementsCommand.cpp52
-rw-r--r--src/commands/notation/ResetDisplacementsCommand.h61
-rw-r--r--src/commands/notation/RespellCommand.cpp141
-rw-r--r--src/commands/notation/RespellCommand.h72
-rw-r--r--src/commands/notation/RestInsertionCommand.cpp65
-rw-r--r--src/commands/notation/RestInsertionCommand.h58
-rw-r--r--src/commands/notation/RestoreSlursCommand.cpp58
-rw-r--r--src/commands/notation/RestoreSlursCommand.h62
-rw-r--r--src/commands/notation/RestoreStemsCommand.cpp52
-rw-r--r--src/commands/notation/RestoreStemsCommand.h62
-rw-r--r--src/commands/notation/RestoreTiesCommand.cpp51
-rw-r--r--src/commands/notation/RestoreTiesCommand.h62
-rw-r--r--src/commands/notation/SetVisibilityCommand.cpp57
-rw-r--r--src/commands/notation/SetVisibilityCommand.h63
-rw-r--r--src/commands/notation/SustainInsertionCommand.cpp66
-rw-r--r--src/commands/notation/SustainInsertionCommand.h76
-rw-r--r--src/commands/notation/TextChangeCommand.cpp62
-rw-r--r--src/commands/notation/TextChangeCommand.h63
-rw-r--r--src/commands/notation/TextInsertionCommand.cpp63
-rw-r--r--src/commands/notation/TextInsertionCommand.h63
-rw-r--r--src/commands/notation/TieNotesCommand.cpp72
-rw-r--r--src/commands/notation/TieNotesCommand.h62
-rw-r--r--src/commands/notation/TupletCommand.cpp91
-rw-r--r--src/commands/notation/TupletCommand.h71
-rw-r--r--src/commands/notation/UnGraceCommand.cpp42
-rw-r--r--src/commands/notation/UnGraceCommand.h58
-rw-r--r--src/commands/notation/UnTupletCommand.cpp54
-rw-r--r--src/commands/notation/UnTupletCommand.h62
-rw-r--r--src/commands/notation/UntieNotesCommand.cpp52
-rw-r--r--src/commands/notation/UntieNotesCommand.h62
-rw-r--r--src/commands/segment/AddTempoChangeCommand.cpp66
-rw-r--r--src/commands/segment/AddTempoChangeCommand.h76
-rw-r--r--src/commands/segment/AddTimeSignatureAndNormalizeCommand.cpp78
-rw-r--r--src/commands/segment/AddTimeSignatureAndNormalizeCommand.h53
-rw-r--r--src/commands/segment/AddTimeSignatureCommand.cpp78
-rw-r--r--src/commands/segment/AddTimeSignatureCommand.h71
-rw-r--r--src/commands/segment/AddTracksCommand.cpp137
-rw-r--r--src/commands/segment/AddTracksCommand.h77
-rw-r--r--src/commands/segment/AddTriggerSegmentCommand.cpp90
-rw-r--r--src/commands/segment/AddTriggerSegmentCommand.h72
-rw-r--r--src/commands/segment/AudioSegmentAutoSplitCommand.cpp191
-rw-r--r--src/commands/segment/AudioSegmentAutoSplitCommand.h71
-rw-r--r--src/commands/segment/AudioSegmentDistributeCommand.cpp156
-rw-r--r--src/commands/segment/AudioSegmentDistributeCommand.h86
-rw-r--r--src/commands/segment/AudioSegmentInsertCommand.cpp136
-rw-r--r--src/commands/segment/AudioSegmentInsertCommand.h77
-rw-r--r--src/commands/segment/AudioSegmentRescaleCommand.cpp210
-rw-r--r--src/commands/segment/AudioSegmentRescaleCommand.h81
-rw-r--r--src/commands/segment/AudioSegmentResizeFromStartCommand.cpp87
-rw-r--r--src/commands/segment/AudioSegmentResizeFromStartCommand.h66
-rw-r--r--src/commands/segment/AudioSegmentSplitCommand.cpp155
-rw-r--r--src/commands/segment/AudioSegmentSplitCommand.h65
-rw-r--r--src/commands/segment/ChangeCompositionLengthCommand.cpp64
-rw-r--r--src/commands/segment/ChangeCompositionLengthCommand.h70
-rw-r--r--src/commands/segment/CreateTempoMapFromSegmentCommand.cpp166
-rw-r--r--src/commands/segment/CreateTempoMapFromSegmentCommand.h69
-rw-r--r--src/commands/segment/CutRangeCommand.cpp47
-rw-r--r--src/commands/segment/CutRangeCommand.h53
-rw-r--r--src/commands/segment/DeleteRangeCommand.cpp127
-rw-r--r--src/commands/segment/DeleteRangeCommand.h84
-rw-r--r--src/commands/segment/DeleteTracksCommand.cpp161
-rw-r--r--src/commands/segment/DeleteTracksCommand.h68
-rw-r--r--src/commands/segment/DeleteTriggerSegmentCommand.cpp78
-rw-r--r--src/commands/segment/DeleteTriggerSegmentCommand.h66
-rw-r--r--src/commands/segment/EraseSegmentsStartingInRangeCommand.cpp99
-rw-r--r--src/commands/segment/EraseSegmentsStartingInRangeCommand.h67
-rw-r--r--src/commands/segment/InsertRangeCommand.cpp63
-rw-r--r--src/commands/segment/InsertRangeCommand.h47
-rw-r--r--src/commands/segment/ModifyDefaultTempoCommand.cpp48
-rw-r--r--src/commands/segment/ModifyDefaultTempoCommand.h66
-rw-r--r--src/commands/segment/MoveTracksCommand.cpp76
-rw-r--r--src/commands/segment/MoveTracksCommand.h66
-rw-r--r--src/commands/segment/OpenOrCloseRangeCommand.cpp181
-rw-r--r--src/commands/segment/OpenOrCloseRangeCommand.h84
-rw-r--r--src/commands/segment/PasteConductorDataCommand.cpp128
-rw-r--r--src/commands/segment/PasteConductorDataCommand.h67
-rw-r--r--src/commands/segment/PasteRangeCommand.cpp97
-rw-r--r--src/commands/segment/PasteRangeCommand.h52
-rw-r--r--src/commands/segment/PasteToTriggerSegmentCommand.cpp129
-rw-r--r--src/commands/segment/PasteToTriggerSegmentCommand.h73
-rw-r--r--src/commands/segment/RemoveTempoChangeCommand.cpp59
-rw-r--r--src/commands/segment/RemoveTempoChangeCommand.h75
-rw-r--r--src/commands/segment/RemoveTimeSignatureCommand.cpp60
-rw-r--r--src/commands/segment/RemoveTimeSignatureCommand.h74
-rw-r--r--src/commands/segment/RenameTrackCommand.cpp75
-rw-r--r--src/commands/segment/RenameTrackCommand.h67
-rw-r--r--src/commands/segment/SegmentAutoSplitCommand.cpp205
-rw-r--r--src/commands/segment/SegmentAutoSplitCommand.h66
-rw-r--r--src/commands/segment/SegmentChangePlayableRangeCommand.cpp77
-rw-r--r--src/commands/segment/SegmentChangePlayableRangeCommand.h67
-rw-r--r--src/commands/segment/SegmentChangeQuantizationCommand.cpp115
-rw-r--r--src/commands/segment/SegmentChangeQuantizationCommand.h73
-rw-r--r--src/commands/segment/SegmentChangeTransposeCommand.cpp72
-rw-r--r--src/commands/segment/SegmentChangeTransposeCommand.h65
-rw-r--r--src/commands/segment/SegmentColourCommand.cpp65
-rw-r--r--src/commands/segment/SegmentColourCommand.h66
-rw-r--r--src/commands/segment/SegmentColourMapCommand.cpp64
-rw-r--r--src/commands/segment/SegmentColourMapCommand.h71
-rw-r--r--src/commands/segment/SegmentCommand.cpp42
-rw-r--r--src/commands/segment/SegmentCommand.h59
-rw-r--r--src/commands/segment/SegmentCommandRepeat.cpp59
-rw-r--r--src/commands/segment/SegmentCommandRepeat.h81
-rw-r--r--src/commands/segment/SegmentEraseCommand.cpp108
-rw-r--r--src/commands/segment/SegmentEraseCommand.h70
-rw-r--r--src/commands/segment/SegmentInsertCommand.cpp124
-rw-r--r--src/commands/segment/SegmentInsertCommand.h76
-rw-r--r--src/commands/segment/SegmentJoinCommand.cpp175
-rw-r--r--src/commands/segment/SegmentJoinCommand.h65
-rw-r--r--src/commands/segment/SegmentLabelCommand.cpp73
-rw-r--r--src/commands/segment/SegmentLabelCommand.h67
-rw-r--r--src/commands/segment/SegmentQuickCopyCommand.cpp71
-rw-r--r--src/commands/segment/SegmentQuickCopyCommand.h68
-rw-r--r--src/commands/segment/SegmentReconfigureCommand.cpp114
-rw-r--r--src/commands/segment/SegmentReconfigureCommand.h81
-rw-r--r--src/commands/segment/SegmentRecordCommand.cpp67
-rw-r--r--src/commands/segment/SegmentRecordCommand.h67
-rw-r--r--src/commands/segment/SegmentRepeatToCopyCommand.cpp106
-rw-r--r--src/commands/segment/SegmentRepeatToCopyCommand.h62
-rw-r--r--src/commands/segment/SegmentRescaleCommand.cpp148
-rw-r--r--src/commands/segment/SegmentRescaleCommand.h76
-rw-r--r--src/commands/segment/SegmentResizeFromStartCommand.cpp85
-rw-r--r--src/commands/segment/SegmentResizeFromStartCommand.h69
-rw-r--r--src/commands/segment/SegmentSingleRepeatToCopyCommand.cpp73
-rw-r--r--src/commands/segment/SegmentSingleRepeatToCopyCommand.h65
-rw-r--r--src/commands/segment/SegmentSplitByPitchCommand.cpp280
-rw-r--r--src/commands/segment/SegmentSplitByPitchCommand.h83
-rw-r--r--src/commands/segment/SegmentSplitByRecordingSrcCommand.cpp153
-rw-r--r--src/commands/segment/SegmentSplitByRecordingSrcCommand.h70
-rw-r--r--src/commands/segment/SegmentSplitCommand.cpp185
-rw-r--r--src/commands/segment/SegmentSplitCommand.h65
-rw-r--r--src/commands/segment/SegmentSyncClefCommand.cpp67
-rw-r--r--src/commands/segment/SegmentSyncClefCommand.h55
-rw-r--r--src/commands/segment/SegmentSyncCommand.cpp103
-rw-r--r--src/commands/segment/SegmentSyncCommand.h66
-rw-r--r--src/commands/segment/SegmentTransposeCommand.cpp123
-rw-r--r--src/commands/segment/SegmentTransposeCommand.h64
-rw-r--r--src/commands/segment/SetTriggerSegmentBasePitchCommand.cpp74
-rw-r--r--src/commands/segment/SetTriggerSegmentBasePitchCommand.h63
-rw-r--r--src/commands/segment/SetTriggerSegmentBaseVelocityCommand.cpp74
-rw-r--r--src/commands/segment/SetTriggerSegmentBaseVelocityCommand.h63
-rw-r--r--src/commands/segment/SetTriggerSegmentDefaultRetuneCommand.cpp75
-rw-r--r--src/commands/segment/SetTriggerSegmentDefaultRetuneCommand.h64
-rw-r--r--src/commands/segment/SetTriggerSegmentDefaultTimeAdjustCommand.cpp74
-rw-r--r--src/commands/segment/SetTriggerSegmentDefaultTimeAdjustCommand.h64
-rw-r--r--src/commands/studio/AddControlParameterCommand.cpp75
-rw-r--r--src/commands/studio/AddControlParameterCommand.h75
-rw-r--r--src/commands/studio/CreateOrDeleteDeviceCommand.cpp161
-rw-r--r--src/commands/studio/CreateOrDeleteDeviceCommand.h88
-rw-r--r--src/commands/studio/ModifyControlParameterCommand.cpp75
-rw-r--r--src/commands/studio/ModifyControlParameterCommand.h74
-rw-r--r--src/commands/studio/ModifyDeviceCommand.cpp198
-rw-r--r--src/commands/studio/ModifyDeviceCommand.h109
-rw-r--r--src/commands/studio/ModifyDeviceMappingCommand.cpp147
-rw-r--r--src/commands/studio/ModifyDeviceMappingCommand.h71
-rw-r--r--src/commands/studio/ModifyInstrumentMappingCommand.cpp78
-rw-r--r--src/commands/studio/ModifyInstrumentMappingCommand.h76
-rw-r--r--src/commands/studio/ReconnectDeviceCommand.cpp98
-rw-r--r--src/commands/studio/ReconnectDeviceCommand.h70
-rw-r--r--src/commands/studio/RemoveControlParameterCommand.cpp75
-rw-r--r--src/commands/studio/RemoveControlParameterCommand.h73
-rw-r--r--src/commands/studio/RenameDeviceCommand.cpp52
-rw-r--r--src/commands/studio/RenameDeviceCommand.h71
292 files changed, 25276 insertions, 0 deletions
diff --git a/src/commands/edit/AddDotCommand.cpp b/src/commands/edit/AddDotCommand.cpp
new file mode 100644
index 0000000..b69a25c
--- /dev/null
+++ b/src/commands/edit/AddDotCommand.cpp
@@ -0,0 +1,98 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddDotCommand.h"
+
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+AddDotCommand::modifySegment()
+{
+ std::vector<Event *> toErase;
+ std::vector<Event *> toInsert;
+
+ EventSelection::eventcontainer::iterator i;
+ timeT endTime = getEndTime();
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+
+ Note note = Note::getNearestNote
+ ((*i)->getNotationDuration());
+ int dots = note.getDots();
+ if (++dots > 2)
+ dots = 0;
+
+ toErase.push_back(*i);
+
+ Event *e;
+
+ if (m_notationOnly) {
+ e = new Event(**i,
+ (*i)->getAbsoluteTime(),
+ (*i)->getDuration(),
+ (*i)->getSubOrdering(),
+ (*i)->getNotationAbsoluteTime(),
+ Note(note.getNoteType(),
+ dots).getDuration());
+
+ } else {
+ e = new Event(**i,
+ (*i)->getNotationAbsoluteTime(),
+ Note(note.getNoteType(),
+ dots).getDuration());
+ }
+
+ if (e->getNotationAbsoluteTime() + e->getNotationDuration() > endTime) {
+ endTime = e->getNotationAbsoluteTime() + e->getNotationDuration();
+ }
+
+ toInsert.push_back(e);
+ }
+ }
+
+ for (std::vector<Event *>::iterator i = toErase.begin(); i != toErase.end(); ++i) {
+ m_selection->getSegment().eraseSingle(*i);
+ }
+
+ for (std::vector<Event *>::iterator i = toInsert.begin(); i != toInsert.end(); ++i) {
+ m_selection->getSegment().insert(*i);
+ m_selection->addEvent(*i);
+ }
+
+ m_selection->getSegment().normalizeRests(getStartTime(), endTime);
+}
+
+}
diff --git a/src/commands/edit/AddDotCommand.h b/src/commands/edit/AddDotCommand.h
new file mode 100644
index 0000000..a88da26
--- /dev/null
+++ b/src/commands/edit/AddDotCommand.h
@@ -0,0 +1,68 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADDDOTCOMMAND_H_
+#define _RG_ADDDOTCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class AddDotCommand : public BasicSelectionCommand
+{
+public:
+ AddDotCommand(EventSelection &selection, bool notationOnly) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection),
+ m_notationOnly(notationOnly)
+ { }
+
+ static QString getGlobalName() {
+ return i18n("&Add Dot");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ bool m_notationOnly;
+};
+
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/AddMarkerCommand.cpp b/src/commands/edit/AddMarkerCommand.cpp
new file mode 100644
index 0000000..b7c665a
--- /dev/null
+++ b/src/commands/edit/AddMarkerCommand.cpp
@@ -0,0 +1,67 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddMarkerCommand.h"
+
+#include "base/Composition.h"
+#include "base/Marker.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+AddMarkerCommand::AddMarkerCommand(Composition *comp,
+ timeT time,
+ const std::string &name,
+ const std::string &description):
+ KNamedCommand(getGlobalName()),
+ m_composition(comp),
+ m_detached(true)
+{
+ m_marker = new Marker(time, name, description);
+}
+
+AddMarkerCommand::~AddMarkerCommand()
+{
+ if (m_detached)
+ delete m_marker;
+}
+
+void
+AddMarkerCommand::execute()
+{
+ m_composition->addMarker(m_marker);
+ m_detached = false;
+}
+
+void
+AddMarkerCommand::unexecute()
+{
+ m_composition->detachMarker(m_marker);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/edit/AddMarkerCommand.h b/src/commands/edit/AddMarkerCommand.h
new file mode 100644
index 0000000..80f15c1
--- /dev/null
+++ b/src/commands/edit/AddMarkerCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADDMARKERCOMMAND_H_
+#define _RG_ADDMARKERCOMMAND_H_
+
+#include <string>
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Marker;
+class Composition;
+
+
+class AddMarkerCommand : public KNamedCommand
+{
+public:
+ AddMarkerCommand(Composition *comp,
+ timeT time,
+ const std::string &name,
+ const std::string &description);
+ ~AddMarkerCommand();
+
+ static QString getGlobalName() { return i18n("&Add Marker"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+
+ Composition *m_composition;
+ Marker *m_marker;
+ bool m_detached;
+
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/ChangeVelocityCommand.cpp b/src/commands/edit/ChangeVelocityCommand.cpp
new file mode 100644
index 0000000..fc1c1ea
--- /dev/null
+++ b/src/commands/edit/ChangeVelocityCommand.cpp
@@ -0,0 +1,68 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ChangeVelocityCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+ChangeVelocityCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+
+ long velocity = 100;
+ (*i)->get
+ <Int>(VELOCITY, velocity);
+
+ // round velocity up to the next multiple of delta
+ velocity /= m_delta;
+ velocity *= m_delta;
+ velocity += m_delta;
+
+ if (velocity < 0)
+ velocity = 0;
+ if (velocity > 127)
+ velocity = 127;
+ (*i)->set<Int>(VELOCITY, velocity);
+ }
+ }
+}
+
+}
diff --git a/src/commands/edit/ChangeVelocityCommand.h b/src/commands/edit/ChangeVelocityCommand.h
new file mode 100644
index 0000000..a0a51b1
--- /dev/null
+++ b/src/commands/edit/ChangeVelocityCommand.h
@@ -0,0 +1,68 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CHANGEVELOCITYCOMMAND_H_
+#define _RG_CHANGEVELOCITYCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+/** Add or subtract a constant from all event velocities.
+ Use SelectionPropertyCommand if you want to do something more
+ creative. */
+class ChangeVelocityCommand : public BasicSelectionCommand
+{
+public:
+ ChangeVelocityCommand(int delta, EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(delta), selection, true),
+ m_selection(&selection), m_delta(delta) { }
+
+ static QString getGlobalName(int delta = 0) {
+ if (delta > 0) return i18n("&Increase Velocity");
+ else return i18n("&Reduce Velocity");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ int m_delta;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/edit/ClearTriggersCommand.cpp b/src/commands/edit/ClearTriggersCommand.cpp
new file mode 100644
index 0000000..3b58405
--- /dev/null
+++ b/src/commands/edit/ClearTriggersCommand.cpp
@@ -0,0 +1,53 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ClearTriggersCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+ClearTriggersCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ (*i)->unset(TRIGGER_SEGMENT_ID);
+ (*i)->unset(TRIGGER_SEGMENT_RETUNE);
+ (*i)->unset(TRIGGER_SEGMENT_ADJUST_TIMES);
+ }
+}
+
+}
diff --git a/src/commands/edit/ClearTriggersCommand.h b/src/commands/edit/ClearTriggersCommand.h
new file mode 100644
index 0000000..077e270
--- /dev/null
+++ b/src/commands/edit/ClearTriggersCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CLEARTRIGGERSCOMMAND_H_
+#define _RG_CLEARTRIGGERSCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class ClearTriggersCommand : public BasicSelectionCommand
+{
+public:
+ ClearTriggersCommand(EventSelection &selection,
+ QString name = 0) :
+ BasicSelectionCommand(name ? name : getGlobalName(), selection, true),
+ m_selection(&selection)
+ { }
+
+ static QString getGlobalName() {
+ return i18n("&Clear Triggers");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/CollapseNotesCommand.cpp b/src/commands/edit/CollapseNotesCommand.cpp
new file mode 100644
index 0000000..225d34c
--- /dev/null
+++ b/src/commands/edit/CollapseNotesCommand.cpp
@@ -0,0 +1,79 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "CollapseNotesCommand.h"
+
+#include "base/Event.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+CollapseNotesCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+ timeT endTime = getEndTime();
+
+ // This is really nasty stuff. We can't go in forward direction
+ // using the j-iterator trick because collapseNoteAggressively may
+ // erase the following iterator as well as the preceding one. We
+ // can't go backward naively, because collapseNoteAggressively
+ // erases i from the EventSelection now that it's a
+ // SegmentObserver. We need the fancy hybrid j-iterator-backward
+ // technique applied to selections instead of segments.
+
+ EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().end();
+ EventSelection::eventcontainer::iterator j = i;
+ EventSelection::eventcontainer::iterator beg =
+ m_selection->getSegmentEvents().begin();
+ bool thisOne = false;
+
+ while (i != beg && (!thisOne || (*i != *beg))) {
+
+ --j;
+
+ if (thisOne) {
+ helper.collapseNoteAggressively(*i, endTime);
+ }
+
+ // rather than "true" one could perform a test to see
+ // whether j pointed to a candidate for collapsing:
+ thisOne = true;
+
+ i = j;
+ }
+
+ if (thisOne) {
+ helper.collapseNoteAggressively(*i, endTime);
+ }
+}
+
+}
diff --git a/src/commands/edit/CollapseNotesCommand.h b/src/commands/edit/CollapseNotesCommand.h
new file mode 100644
index 0000000..9d3a0fc
--- /dev/null
+++ b/src/commands/edit/CollapseNotesCommand.h
@@ -0,0 +1,65 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUCOLLAPSENOTESCOMMAND_H_
+#define _RG_ADJUSTMENUCOLLAPSENOTESCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+class Collapse;
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class CollapseNotesCommand : public BasicSelectionCommand
+{
+public:
+ CollapseNotesCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("Collapse &Equal-Pitch Notes"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+// Set the (numerical) property of a selection according given pattern.
+//
+
+}
+
+#endif
diff --git a/src/commands/edit/CopyCommand.cpp b/src/commands/edit/CopyCommand.cpp
new file mode 100644
index 0000000..38aa628
--- /dev/null
+++ b/src/commands/edit/CopyCommand.cpp
@@ -0,0 +1,120 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "CopyCommand.h"
+
+#include "misc/Strings.h"
+#include "base/Clipboard.h"
+#include "base/Composition.h"
+#include "base/Selection.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+CopyCommand::CopyCommand(EventSelection &selection,
+ Clipboard *clipboard) :
+ KNamedCommand(getGlobalName()),
+ m_targetClipboard(clipboard)
+{
+ m_sourceClipboard = new Clipboard;
+ m_savedClipboard = 0;
+ m_sourceClipboard->newSegment(&selection)->setLabel
+ (selection.getSegment().getLabel() + " " + qstrtostr(i18n("(excerpt)")));
+}
+
+CopyCommand::CopyCommand(SegmentSelection &selection,
+ Clipboard *clipboard) :
+ KNamedCommand(getGlobalName()),
+ m_targetClipboard(clipboard)
+{
+ m_sourceClipboard = new Clipboard;
+ m_savedClipboard = 0;
+
+ for (SegmentSelection::iterator i = selection.begin();
+ i != selection.end(); ++i) {
+ QString newLabel = strtoqstr((*i)->getLabel());
+ if (newLabel.contains(i18n("(copied)"))) {
+ m_sourceClipboard->newSegment(*i);
+ } else {
+ m_sourceClipboard->newSegment(*i)->
+ setLabel(qstrtostr(i18n("%1 (copied)").arg(newLabel)));
+ }
+ }
+}
+
+CopyCommand::CopyCommand(Composition *composition,
+ timeT beginTime,
+ timeT endTime,
+ Clipboard *clipboard) :
+ KNamedCommand(i18n("Copy Range")),
+ m_targetClipboard(clipboard)
+{
+ m_sourceClipboard = new Clipboard;
+ m_savedClipboard = 0;
+
+ for (Composition::iterator i = composition->begin();
+ i != composition->end(); ++i) {
+ if ((*i)->getStartTime() < endTime &&
+ (*i)->getRepeatEndTime() > beginTime) {
+ m_sourceClipboard->newSegment(*i, beginTime, endTime, true);
+ }
+ }
+
+ TimeSignatureSelection tsigsel
+ (*composition, beginTime, endTime, true);
+ m_sourceClipboard->setTimeSignatureSelection(tsigsel);
+
+ TempoSelection temposel
+ (*composition, beginTime, endTime, true);
+ m_sourceClipboard->setTempoSelection(temposel);
+
+ m_sourceClipboard->setNominalRange(beginTime, endTime);
+}
+
+CopyCommand::~CopyCommand()
+{
+ delete m_sourceClipboard;
+ delete m_savedClipboard;
+}
+
+void
+CopyCommand::execute()
+{
+ if (!m_savedClipboard) {
+ m_savedClipboard = new Clipboard(*m_targetClipboard);
+ }
+
+ m_targetClipboard->copyFrom(m_sourceClipboard);
+}
+
+void
+CopyCommand::unexecute()
+{
+ m_targetClipboard->copyFrom(m_savedClipboard);
+}
+
+}
diff --git a/src/commands/edit/CopyCommand.h b/src/commands/edit/CopyCommand.h
new file mode 100644
index 0000000..29d6dc7
--- /dev/null
+++ b/src/commands/edit/CopyCommand.h
@@ -0,0 +1,82 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_COPYCOMMAND_H_
+#define _RG_COPYCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class SegmentSelection;
+class EventSelection;
+class Composition;
+class Clipboard;
+
+
+/// Copy a selection
+
+class CopyCommand : public KNamedCommand
+{
+public:
+ /// Make a CopyCommand that copies events from within a Segment
+ CopyCommand(EventSelection &selection,
+ Clipboard *clipboard);
+
+ /// Make a CopyCommand that copies whole Segments
+ CopyCommand(SegmentSelection &selection,
+ Clipboard *clipboard);
+
+ /// Make a CopyCommand that copies a range of a Composition
+ CopyCommand(Composition *composition,
+ timeT beginTime,
+ timeT endTime,
+ Clipboard *clipboard);
+
+ virtual ~CopyCommand();
+
+ static QString getGlobalName() { return i18n("&Copy"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Clipboard *m_sourceClipboard;
+ Clipboard *m_targetClipboard;
+ Clipboard *m_savedClipboard;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/CutAndCloseCommand.cpp b/src/commands/edit/CutAndCloseCommand.cpp
new file mode 100644
index 0000000..a99b4ef
--- /dev/null
+++ b/src/commands/edit/CutAndCloseCommand.cpp
@@ -0,0 +1,163 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "CutAndCloseCommand.h"
+
+#include "base/Clipboard.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "CutCommand.h"
+#include <qstring.h>
+#include "misc/Debug.h"
+
+
+namespace Rosegarden
+{
+
+CutAndCloseCommand::CutAndCloseCommand(EventSelection &selection,
+ Clipboard *clipboard) :
+ KMacroCommand(getGlobalName())
+{
+ addCommand(new CutCommand(selection, clipboard));
+ addCommand(new CloseCommand(&selection.getSegment(),
+ selection.getEndTime(),
+ selection.getStartTime()));
+}
+
+void
+CutAndCloseCommand::CloseCommand::execute()
+{
+ // We shift all the events from m_gapEnd to the end of the
+ // segment back so that they start at m_gapStart instead of m_gapEnd.
+
+ assert(m_gapEnd >= m_gapStart);
+ if (m_gapEnd == m_gapStart)
+ return ;
+
+ // We also need to record how many events there are already at
+ // m_gapStart so that we can leave those unchanged when we undo.
+ // (This command is executed on the understanding that the area
+ // between m_gapStart and m_gapEnd is empty of all but rests, but
+ // in practice there may be other things such as a clef at the
+ // same time as m_gapStart. This will only work for events that
+ // have smaller subordering than notes etc.)
+
+ m_staticEvents = 0;
+ for (Segment::iterator i = m_segment->findTime(m_gapStart);
+ m_segment->isBeforeEndMarker(i); ++i) {
+ if ((*i)->getAbsoluteTime() > m_gapStart)
+ break;
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+ ++m_staticEvents;
+ }
+
+ std::vector<Event *> events;
+ timeT timeDifference = m_gapEnd - m_gapStart;
+
+ for (Segment::iterator i = m_segment->findTime(m_gapEnd);
+ m_segment->isBeforeEndMarker(i); ++i) {
+ events.push_back((*i)->copyMoving( -timeDifference));
+ }
+
+ timeT oldEndTime = m_segment->getEndTime();
+
+ // remove rests from target area, and everything thereafter
+ for (Segment::iterator i = m_segment->findTime(m_gapStart);
+ m_segment->isBeforeEndMarker(i); ) {
+ if ((*i)->getAbsoluteTime() >= m_gapEnd ||
+ (*i)->isa(Note::EventRestType)) {
+ Segment::iterator j(i);
+ ++j;
+ m_segment->erase(i);
+ i = j;
+ } else {
+ ++i;
+ }
+ }
+
+ for (unsigned int i = 0; i < events.size(); ++i) {
+ m_segment->insert(events[i]);
+ }
+
+ m_segment->normalizeRests(m_segment->getEndTime(), oldEndTime);
+}
+
+void
+CutAndCloseCommand::CloseCommand::unexecute()
+{
+ // We want to shift events from m_gapStart to the end of the
+ // segment forward so as to start at m_gapEnd instead of
+ // m_gapStart.
+
+ assert(m_gapEnd >= m_gapStart);
+ if (m_gapEnd == m_gapStart)
+ return ;
+
+ // May need to ignore some static events at m_gapStart.
+ // These are assumed to have smaller subordering than whatever
+ // we're not ignoring. Actually this still isn't quite right:
+ // it'll do the wrong thing where we have, say, a clef then
+ // some notes then another clef and we cut-and-close all the
+ // notes and then undo. But it's better than we were doing
+ // before.
+
+ Segment::iterator starti = m_segment->findTime(m_gapStart);
+
+ while (m_segment->isBeforeEndMarker(starti)) {
+ if (m_staticEvents == 0)
+ break;
+ if ((*starti)->getAbsoluteTime() > m_gapStart)
+ break;
+ if (!(*starti)->isa(Note::EventRestType))
+ --m_staticEvents;
+ ++starti;
+ }
+
+ std::vector<Event *> events;
+ timeT timeDifference = m_gapEnd - m_gapStart;
+
+ for (Segment::iterator i = starti; m_segment->isBeforeEndMarker(i); ) {
+ Segment::iterator j(i);
+ ++j;
+ events.push_back((*i)->copyMoving(timeDifference));
+ m_segment->erase(i);
+ i = j;
+ }
+
+ for (unsigned int i = 0; i < events.size(); ++i) {
+ m_segment->insert(events[i]);
+ }
+
+ timeT endTime = m_segment->getEndTime();
+ NOTATION_DEBUG << "setting end time to " << (endTime - timeDifference) << endl;
+ //!!! this following is not working for bugaccidentals.rg:
+ m_segment->setEndTime(endTime - timeDifference);
+
+ m_segment->normalizeRests(m_gapStart, m_gapEnd);
+}
+
+}
diff --git a/src/commands/edit/CutAndCloseCommand.h b/src/commands/edit/CutAndCloseCommand.h
new file mode 100644
index 0000000..4be5809
--- /dev/null
+++ b/src/commands/edit/CutAndCloseCommand.h
@@ -0,0 +1,82 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CUTANDCLOSECOMMAND_H_
+#define _RG_CUTANDCLOSECOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class EventSelection;
+class Clipboard;
+
+
+/// Cut a selection and close the gap
+
+class CutAndCloseCommand : public KMacroCommand
+{
+public:
+ CutAndCloseCommand(EventSelection &selection,
+ Clipboard *clipboard);
+
+ static QString getGlobalName() { return i18n("C&ut and Close"); }
+
+protected:
+ class CloseCommand : public KNamedCommand
+ {
+ public:
+ CloseCommand(Segment *segment,
+ timeT fromTime,
+ timeT toTime) :
+ KNamedCommand("Close"),
+ m_segment(segment),
+ m_gapEnd(fromTime),
+ m_gapStart(toTime) { }
+
+ virtual void execute();
+ virtual void unexecute();
+
+ private:
+ Segment *m_segment;
+ timeT m_gapEnd;
+ timeT m_gapStart;
+ int m_staticEvents;
+ };
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/CutCommand.cpp b/src/commands/edit/CutCommand.cpp
new file mode 100644
index 0000000..9d54089
--- /dev/null
+++ b/src/commands/edit/CutCommand.cpp
@@ -0,0 +1,59 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "CutCommand.h"
+
+#include "base/Clipboard.h"
+#include "base/Selection.h"
+#include "commands/segment/SegmentEraseCommand.h"
+#include "CopyCommand.h"
+#include "EraseCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+CutCommand::CutCommand(EventSelection &selection,
+ Clipboard *clipboard) :
+ KMacroCommand(getGlobalName())
+{
+ addCommand(new CopyCommand(selection, clipboard));
+ addCommand(new EraseCommand(selection));
+}
+
+CutCommand::CutCommand(SegmentSelection &selection,
+ Clipboard *clipboard) :
+ KMacroCommand(getGlobalName())
+{
+ addCommand(new CopyCommand(selection, clipboard));
+
+ for (SegmentSelection::iterator i = selection.begin();
+ i != selection.end(); ++i) {
+ addCommand(new SegmentEraseCommand(*i));
+ }
+}
+
+}
diff --git a/src/commands/edit/CutCommand.h b/src/commands/edit/CutCommand.h
new file mode 100644
index 0000000..186736c
--- /dev/null
+++ b/src/commands/edit/CutCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CUTCOMMAND_H_
+#define _RG_CUTCOMMAND_H_
+
+#include <qstring.h>
+#include <klocale.h>
+#include <kcommand.h>
+
+
+namespace Rosegarden
+{
+
+class SegmentSelection;
+class EventSelection;
+class Clipboard;
+
+
+/// Cut a selection
+
+class CutCommand : public KMacroCommand
+{
+public:
+ /// Make a CutCommand that cuts events from within a Segment
+ CutCommand(EventSelection &selection,
+ Clipboard *clipboard);
+
+ /// Make a CutCommand that cuts whole Segments
+ CutCommand(SegmentSelection &selection,
+ Clipboard *clipboard);
+
+ static QString getGlobalName() { return i18n("Cu&t"); }
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/EraseCommand.cpp b/src/commands/edit/EraseCommand.cpp
new file mode 100644
index 0000000..8649885
--- /dev/null
+++ b/src/commands/edit/EraseCommand.cpp
@@ -0,0 +1,86 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "EraseCommand.h"
+
+#include "misc/Debug.h"
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+EraseCommand::EraseCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection),
+ m_relayoutEndTime(getEndTime())
+{
+ // nothing else
+}
+
+void
+EraseCommand::modifySegment()
+{
+ RG_DEBUG << "EraseCommand::modifySegment" << endl;
+
+ std::vector<Event *> toErase;
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Clef::EventType) ||
+ (*i)->isa(Key ::EventType)) {
+ m_relayoutEndTime = getSegment().getEndTime();
+ }
+
+ // We used to do this by calling SegmentNotationHelper::deleteEvent
+ // on each event in the selection, but it's probably easier to
+ // cope with general selections by deleting everything in the
+ // selection and then normalizing the rests. The deleteEvent
+ // mechanism is still the more sensitive way to do it for single
+ // events, and it's what's used by EraseEventCommand and thus
+ // the notation eraser tool.
+
+ toErase.push_back(*i);
+ }
+
+ for (unsigned int j = 0; j < toErase.size(); ++j) {
+ getSegment().eraseSingle(toErase[j]);
+ }
+
+ getSegment().normalizeRests(getStartTime(), getEndTime());
+}
+
+timeT
+EraseCommand::getRelayoutEndTime()
+{
+ return m_relayoutEndTime;
+}
+
+}
diff --git a/src/commands/edit/EraseCommand.h b/src/commands/edit/EraseCommand.h
new file mode 100644
index 0000000..4e583ad
--- /dev/null
+++ b/src/commands/edit/EraseCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ERASECOMMAND_H_
+#define _RG_ERASECOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+/// Erase a selection from within a segment
+
+class EraseCommand : public BasicSelectionCommand
+{
+public:
+ EraseCommand(EventSelection &selection);
+
+ static QString getGlobalName() { return i18n("&Erase"); }
+
+ virtual timeT getRelayoutEndTime();
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ timeT m_relayoutEndTime;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/EventEditCommand.cpp b/src/commands/edit/EventEditCommand.cpp
new file mode 100644
index 0000000..ef31be2
--- /dev/null
+++ b/src/commands/edit/EventEditCommand.cpp
@@ -0,0 +1,64 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "EventEditCommand.h"
+
+#include "base/Event.h"
+#include "base/Segment.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+EventEditCommand::EventEditCommand(Segment &segment,
+ Event *eventToModify,
+ const Event &newEvent) :
+ BasicCommand(getGlobalName(),
+ segment,
+ std::min(eventToModify->getAbsoluteTime(),
+ newEvent.getAbsoluteTime()),
+ std::max(eventToModify->getAbsoluteTime() +
+ eventToModify->getDuration(),
+ newEvent.getAbsoluteTime() +
+ newEvent.getDuration()),
+ true), // bruteForceRedo
+ m_oldEvent(eventToModify),
+ m_newEvent(newEvent)
+{
+ // nothing else to see here
+}
+
+void
+EventEditCommand::modifySegment()
+{
+ Segment &segment(getSegment());
+ segment.eraseSingle(m_oldEvent);
+ segment.insert(new Event(m_newEvent));
+ segment.normalizeRests(getStartTime(), getEndTime());
+}
+
+}
diff --git a/src/commands/edit/EventEditCommand.h b/src/commands/edit/EventEditCommand.h
new file mode 100644
index 0000000..5f22a1e
--- /dev/null
+++ b/src/commands/edit/EventEditCommand.h
@@ -0,0 +1,69 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_EVENTEDITCOMMAND_H_
+#define _RG_EVENTEDITCOMMAND_H_
+
+#include "base/Event.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+/**
+ * Replace an event with another one (likely to be used in
+ * conjunction with EventEditDialog)
+ */
+
+class EventEditCommand : public BasicCommand
+{
+public:
+ EventEditCommand(Segment &segment,
+ Event *eventToModify,
+ const Event &newEvent);
+
+ static QString getGlobalName() { return i18n("Edit E&vent"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ Event *m_oldEvent; // only used on 1st execute
+ Event m_newEvent; // only used on 1st execute
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/EventInsertionCommand.cpp b/src/commands/edit/EventInsertionCommand.cpp
new file mode 100644
index 0000000..a684883
--- /dev/null
+++ b/src/commands/edit/EventInsertionCommand.cpp
@@ -0,0 +1,58 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "EventInsertionCommand.h"
+
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/Segment.h"
+#include "document/BasicCommand.h"
+
+
+namespace Rosegarden
+{
+
+EventInsertionCommand::EventInsertionCommand(Segment &segment,
+ Event *event) :
+ BasicCommand(i18n("Insert Event"), segment, event->getAbsoluteTime(),
+ event->getAbsoluteTime() + event->getDuration()),
+ m_event(new Event(*event))
+{
+ // nothing
+}
+
+EventInsertionCommand::~EventInsertionCommand()
+{
+ delete m_event;
+ // don't want to delete m_lastInsertedEvent, it's just an alias
+}
+
+void EventInsertionCommand::modifySegment()
+{
+ m_lastInsertedEvent = new Event(*m_event);
+ getSegment().insert(m_lastInsertedEvent);
+}
+
+}
diff --git a/src/commands/edit/EventInsertionCommand.h b/src/commands/edit/EventInsertionCommand.h
new file mode 100644
index 0000000..aee9c8b
--- /dev/null
+++ b/src/commands/edit/EventInsertionCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_EVENTINSERTIONCOMMAND_H_
+#define _RG_EVENTINSERTIONCOMMAND_H_
+
+#include "document/BasicCommand.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class EventInsertionCommand : public BasicCommand
+{
+public:
+ EventInsertionCommand(Segment &segment,
+ Event *event);
+
+ virtual ~EventInsertionCommand();
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ Event *m_event;
+ Event *m_lastInsertedEvent; // an alias for another event
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/EventQuantizeCommand.cpp b/src/commands/edit/EventQuantizeCommand.cpp
new file mode 100644
index 0000000..775a32f
--- /dev/null
+++ b/src/commands/edit/EventQuantizeCommand.cpp
@@ -0,0 +1,273 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "EventQuantizeCommand.h"
+
+#include <klocale.h>
+#include "base/NotationTypes.h"
+#include "base/Profiler.h"
+#include "base/Quantizer.h"
+#include "base/BasicQuantizer.h"
+#include "base/LegatoQuantizer.h"
+#include "base/NotationQuantizer.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicCommand.h"
+#include <kconfig.h>
+#include <qstring.h>
+#include "base/BaseProperties.h"
+#include "gui/application/RosegardenApplication.h"
+#include <kapplication.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+EventQuantizeCommand::EventQuantizeCommand(Segment &segment,
+ timeT startTime,
+ timeT endTime,
+ Quantizer *quantizer):
+ BasicCommand(getGlobalName(quantizer), segment, startTime, endTime,
+ true), // bruteForceRedo
+ m_quantizer(quantizer),
+ m_selection(0)
+{
+ // nothing else
+}
+
+EventQuantizeCommand::EventQuantizeCommand(EventSelection &selection,
+ Quantizer *quantizer):
+ BasicCommand(getGlobalName(quantizer),
+ selection.getSegment(),
+ selection.getStartTime(),
+ selection.getEndTime(),
+ true), // bruteForceRedo
+ m_quantizer(quantizer),
+ m_selection(&selection)
+{
+ // nothing else
+}
+
+EventQuantizeCommand::EventQuantizeCommand(Segment &segment,
+ timeT startTime,
+ timeT endTime,
+ QString configGroup,
+ bool notation):
+ BasicCommand(getGlobalName(makeQuantizer(configGroup, notation)),
+ segment, startTime, endTime,
+ true), // bruteForceRedo
+ m_selection(0),
+ m_configGroup(configGroup)
+{
+ // nothing else -- m_quantizer set by makeQuantizer
+}
+
+EventQuantizeCommand::EventQuantizeCommand(EventSelection &selection,
+ QString configGroup,
+ bool notation):
+ BasicCommand(getGlobalName(makeQuantizer(configGroup, notation)),
+ selection.getSegment(),
+ selection.getStartTime(),
+ selection.getEndTime(),
+ true), // bruteForceRedo
+ m_selection(&selection),
+ m_configGroup(configGroup)
+{
+ // nothing else -- m_quantizer set by makeQuantizer
+}
+
+EventQuantizeCommand::~EventQuantizeCommand()
+{
+ delete m_quantizer;
+}
+
+QString
+EventQuantizeCommand::getGlobalName(Quantizer *quantizer)
+{
+ if (quantizer) {
+ if (dynamic_cast<NotationQuantizer *>(quantizer)) {
+ return i18n("Heuristic Notation &Quantize");
+ } else {
+ return i18n("Grid &Quantize");
+ }
+ }
+
+ return i18n("&Quantize...");
+}
+
+void
+EventQuantizeCommand::modifySegment()
+{
+ Profiler profiler("EventQuantizeCommand::modifySegment", true);
+
+ Segment &segment = getSegment();
+ SegmentNotationHelper helper(segment);
+
+ bool rebeam = false;
+ bool makeviable = false;
+ bool decounterpoint = false;
+
+ if (m_configGroup) {
+ //!!! need way to decide whether to do these even if no config group (i.e. through args to the command)
+ KConfig *config = kapp->config();
+ config->setGroup(m_configGroup);
+
+ rebeam = config->readBoolEntry("quantizerebeam", true);
+ makeviable = config->readBoolEntry("quantizemakeviable", false);
+ decounterpoint = config->readBoolEntry("quantizedecounterpoint", false);
+ }
+
+ if (m_selection) {
+ m_quantizer->quantize(m_selection);
+
+ } else {
+ m_quantizer->quantize(&segment,
+ segment.findTime(getStartTime()),
+ segment.findTime(getEndTime()));
+ }
+
+ if (m_progressTotal > 0) {
+ if (rebeam || makeviable || decounterpoint) {
+ emit incrementProgress(m_progressTotal / 2);
+ rgapp->refreshGUI(50);
+ } else {
+ emit incrementProgress(m_progressTotal);
+ rgapp->refreshGUI(50);
+ }
+ }
+
+ if (m_selection) {
+ EventSelection::RangeTimeList ranges(m_selection->getRangeTimes());
+ for (EventSelection::RangeTimeList::iterator i = ranges.begin();
+ i != ranges.end(); ++i) {
+ if (makeviable) {
+ helper.makeNotesViable(i->first, i->second, true);
+ }
+ if (decounterpoint) {
+ helper.deCounterpoint(i->first, i->second);
+ }
+ if (rebeam) {
+ helper.autoBeam(i->first, i->second, GROUP_TYPE_BEAMED);
+ helper.autoSlur(i->first, i->second, true);
+ }
+ }
+ } else {
+ if (makeviable) {
+ helper.makeNotesViable(getStartTime(), getEndTime(), true);
+ }
+ if (decounterpoint) {
+ helper.deCounterpoint(getStartTime(), getEndTime());
+ }
+ if (rebeam) {
+ helper.autoBeam(getStartTime(), getEndTime(), GROUP_TYPE_BEAMED);
+ helper.autoSlur(getStartTime(), getEndTime(), true);
+ }
+ }
+
+ if (m_progressTotal > 0) {
+ if (rebeam || makeviable || decounterpoint) {
+ emit incrementProgress(m_progressTotal / 2);
+ rgapp->refreshGUI(50);
+ }
+ }
+}
+
+Quantizer *
+EventQuantizeCommand::makeQuantizer(QString configGroup,
+ bool notationDefault)
+{
+ //!!! Excessive duplication with
+ // QuantizeParameters::getQuantizer in widgets.cpp
+
+ KConfig *config = kapp->config();
+ config->setGroup(configGroup);
+
+ timeT defaultUnit =
+ Note(Note::Demisemiquaver).getDuration();
+
+ int type = config->readNumEntry("quantizetype", notationDefault ? 2 : 0);
+ timeT unit = config->readNumEntry("quantizeunit", defaultUnit);
+ bool notateOnly = config->readBoolEntry("quantizenotationonly", notationDefault);
+ bool durations = config->readBoolEntry("quantizedurations", false);
+ int simplicity = config->readNumEntry("quantizesimplicity", 13);
+ int maxTuplet = config->readNumEntry("quantizemaxtuplet", 3);
+ bool counterpoint = config->readNumEntry("quantizecounterpoint", false);
+ bool articulate = config->readBoolEntry("quantizearticulate", true);
+ int swing = config->readNumEntry("quantizeswing", 0);
+ int iterate = config->readNumEntry("quantizeiterate", 100);
+
+ m_quantizer = 0;
+
+ if (type == 0) {
+ if (notateOnly) {
+ m_quantizer = new BasicQuantizer
+ (Quantizer::RawEventData,
+ Quantizer::NotationPrefix,
+ unit, durations, swing, iterate);
+ } else {
+ m_quantizer = new BasicQuantizer
+ (Quantizer::RawEventData,
+ Quantizer::RawEventData,
+ unit, durations, swing, iterate);
+ }
+ } else if (type == 1) {
+ if (notateOnly) {
+ m_quantizer = new LegatoQuantizer
+ (Quantizer::RawEventData,
+ Quantizer::NotationPrefix, unit);
+ } else {
+ m_quantizer = new LegatoQuantizer
+ (Quantizer::RawEventData,
+ Quantizer::RawEventData, unit);
+ }
+ } else {
+
+ NotationQuantizer *nq;
+
+ if (notateOnly) {
+ nq = new NotationQuantizer();
+ } else {
+ nq = new NotationQuantizer
+ (Quantizer::RawEventData,
+ Quantizer::RawEventData);
+ }
+
+ nq->setUnit(unit);
+ nq->setSimplicityFactor(simplicity);
+ nq->setMaxTuplet(maxTuplet);
+ nq->setContrapuntal(counterpoint);
+ nq->setArticulate(articulate);
+
+ m_quantizer = nq;
+ }
+
+ return m_quantizer;
+}
+
+}
+#include "EventQuantizeCommand.moc"
diff --git a/src/commands/edit/EventQuantizeCommand.h b/src/commands/edit/EventQuantizeCommand.h
new file mode 100644
index 0000000..6ae1303
--- /dev/null
+++ b/src/commands/edit/EventQuantizeCommand.h
@@ -0,0 +1,98 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_EVENTQUANTIZECOMMAND_H_
+#define _RG_EVENTQUANTIZECOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qobject.h>
+#include <qstring.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Quantizer;
+class EventSelection;
+
+
+class EventQuantizeCommand : public QObject, public BasicCommand
+{
+ Q_OBJECT
+
+public:
+ /// Quantizer must be on heap (EventQuantizeCommand dtor will delete)
+ EventQuantizeCommand(Segment &segment,
+ timeT startTime,
+ timeT endTime,
+ Quantizer *);
+
+ /// Quantizer must be on heap (EventQuantizeCommand dtor will delete)
+ EventQuantizeCommand(EventSelection &selection,
+ Quantizer *);
+
+ /// Constructs own quantizer based on KConfig data in given group
+ EventQuantizeCommand(Segment &segment,
+ timeT startTime,
+ timeT endTime,
+ QString configGroup,
+ bool notationDefault);
+
+ /// Constructs own quantizer based on KConfig data in given group
+ EventQuantizeCommand(EventSelection &selection,
+ QString configGroup,
+ bool notationDefault);
+
+ ~EventQuantizeCommand();
+
+ static QString getGlobalName(Quantizer *quantizer = 0);
+ void setProgressTotal(int total) { m_progressTotal = total; }
+
+signals:
+ void incrementProgress(int);
+
+protected:
+ virtual void modifySegment();
+
+private:
+ Quantizer *m_quantizer; // I own this
+ EventSelection *m_selection;
+ QString m_configGroup;
+ int m_progressTotal;
+
+ /// Sets to m_quantizer as well as returning value
+ Quantizer *makeQuantizer(QString, bool);
+};
+
+// Collapse equal-pitch notes into one event
+//
+
+}
+
+#endif
diff --git a/src/commands/edit/EventUnquantizeCommand.cpp b/src/commands/edit/EventUnquantizeCommand.cpp
new file mode 100644
index 0000000..5a8a07e
--- /dev/null
+++ b/src/commands/edit/EventUnquantizeCommand.cpp
@@ -0,0 +1,106 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "EventUnquantizeCommand.h"
+
+#include <klocale.h>
+#include "base/Quantizer.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+EventUnquantizeCommand::EventUnquantizeCommand(Segment &segment,
+ timeT startTime,
+ timeT endTime,
+ Quantizer *quantizer) :
+ BasicCommand(i18n("Unquantize Events"), segment, startTime, endTime,
+ true), // bruteForceRedo
+ m_quantizer(quantizer),
+ m_selection(0)
+{
+ // nothing else
+}
+
+EventUnquantizeCommand::EventUnquantizeCommand(
+ EventSelection &selection,
+ Quantizer *quantizer) :
+ BasicCommand(i18n("Unquantize Events"),
+ selection.getSegment(),
+ selection.getStartTime(),
+ selection.getEndTime(),
+ true), // bruteForceRedo
+ m_quantizer(quantizer),
+ m_selection(&selection)
+{
+ // nothing else
+}
+
+EventUnquantizeCommand::~EventUnquantizeCommand()
+{
+ delete m_quantizer;
+}
+
+QString
+EventUnquantizeCommand::getGlobalName(Quantizer *)
+{
+ /*!!!
+ if (quantizer) {
+ switch (quantizer->getType()) {
+ case Quantizer::PositionQuantize:
+ return i18n("Position &Quantize");
+ case Quantizer::UnitQuantize:
+ return i18n("Unit &Quantize");
+ case Quantizer::NoteQuantize:
+ return i18n("Note &Quantize");
+ case Quantizer::LegatoQuantize:
+ return i18n("Smoothing &Quantize");
+ }
+ }
+ */
+ return i18n("&Quantize...");
+}
+
+void
+EventUnquantizeCommand::modifySegment()
+{
+ Segment &segment = getSegment();
+
+ if (m_selection) {
+
+ m_quantizer->unquantize(m_selection);
+
+ } else {
+ m_quantizer->unquantize(&segment,
+ segment.findTime(getStartTime()),
+ segment.findTime(getEndTime()));
+ }
+}
+
+}
diff --git a/src/commands/edit/EventUnquantizeCommand.h b/src/commands/edit/EventUnquantizeCommand.h
new file mode 100644
index 0000000..fca3a3c
--- /dev/null
+++ b/src/commands/edit/EventUnquantizeCommand.h
@@ -0,0 +1,73 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_EVENTUNQUANTIZECOMMAND_H_
+#define _RG_EVENTUNQUANTIZECOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Quantizer;
+class EventSelection;
+
+
+class EventUnquantizeCommand : public BasicCommand
+{
+public:
+ /// Quantizer must be on heap (EventUnquantizeCommand dtor will delete)
+ EventUnquantizeCommand(Segment &segment,
+ timeT startTime,
+ timeT endTime,
+ Quantizer *);
+
+ /// Quantizer must be on heap (EventUnquantizeCommand dtor will delete)
+ EventUnquantizeCommand(EventSelection &selection,
+ Quantizer *);
+
+ ~EventUnquantizeCommand();
+
+ static QString getGlobalName(Quantizer *quantizer = 0);
+
+protected:
+ virtual void modifySegment();
+
+private:
+ Quantizer *m_quantizer;
+ EventSelection *m_selection;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/InsertTriggerNoteCommand.cpp b/src/commands/edit/InsertTriggerNoteCommand.cpp
new file mode 100644
index 0000000..65696f3
--- /dev/null
+++ b/src/commands/edit/InsertTriggerNoteCommand.cpp
@@ -0,0 +1,132 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "InsertTriggerNoteCommand.h"
+
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentMatrixHelper.h"
+#include "base/Composition.h"
+#include "base/TriggerSegment.h"
+#include "document/BasicCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include "gui/editors/notation/NoteStyleFactory.h"
+#include "base/BaseProperties.h"
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+InsertTriggerNoteCommand::InsertTriggerNoteCommand(Segment &segment,
+ timeT time,
+ Note note,
+ int pitch,
+ int velocity,
+ NoteStyleName noteStyle,
+ TriggerSegmentId id,
+ bool retune,
+ std::string timeAdjust,
+ Mark mark) :
+ BasicCommand(i18n("Insert Trigger Note"), segment,
+ time, time + note.getDuration()),
+ m_time(time),
+ m_note(note),
+ m_pitch(pitch),
+ m_velocity(velocity),
+ m_noteStyle(noteStyle),
+ m_id(id),
+ m_retune(retune),
+ m_timeAdjust(timeAdjust),
+ m_mark(mark)
+{
+ // nothing
+}
+
+InsertTriggerNoteCommand::~InsertTriggerNoteCommand()
+{
+ // nothing
+}
+
+void
+InsertTriggerNoteCommand::modifySegment()
+{
+ // Insert via a model event, so as to apply the note style.
+ // This is a subset of the work done by NoteInsertionCommand
+
+ Event *e = new Event(Note::EventType, m_time, m_note.getDuration());
+
+ e->set
+ <Int>(PITCH, m_pitch);
+ e->set
+ <Int>(VELOCITY, m_velocity);
+
+ if (m_noteStyle != NoteStyleFactory::DefaultStyle) {
+ e->set
+ <String>(NotationProperties::NOTE_STYLE, m_noteStyle);
+ }
+
+ e->set
+ <Int>(TRIGGER_SEGMENT_ID, m_id);
+ e->set
+ <Bool>(TRIGGER_SEGMENT_RETUNE, m_retune);
+ e->set
+ <String>(TRIGGER_SEGMENT_ADJUST_TIMES, m_timeAdjust);
+
+ if (m_mark != Marks::NoMark) {
+ Marks::addMark(*e, m_mark, true);
+ }
+
+ Segment &s(getSegment());
+ Segment::iterator i = SegmentMatrixHelper(s).insertNote(e);
+
+ Segment::iterator j = i;
+ while (++j != s.end()) {
+ if ((*j)->getAbsoluteTime() >
+ (*i)->getAbsoluteTime() + (*i)->getDuration())
+ break;
+ if ((*j)->isa(Note::EventType)) {
+ if ((*j)->getAbsoluteTime() ==
+ (*i)->getAbsoluteTime() + (*i)->getDuration()) {
+ if ((*j)->has(TIED_BACKWARD) && (*j)->get
+ <Bool>(TIED_BACKWARD) &&
+ (*j)->has(PITCH) && ((*j)->get<Int>(PITCH) == m_pitch)) {
+ (*i)->set
+ <Bool>(TIED_FORWARD, true);
+ }
+ }
+ }
+ }
+
+ TriggerSegmentRec *rec =
+ getSegment().getComposition()->getTriggerSegmentRec(m_id);
+
+ if (rec)
+ rec->updateReferences();
+}
+
+}
diff --git a/src/commands/edit/InsertTriggerNoteCommand.h b/src/commands/edit/InsertTriggerNoteCommand.h
new file mode 100644
index 0000000..4dc1b19
--- /dev/null
+++ b/src/commands/edit/InsertTriggerNoteCommand.h
@@ -0,0 +1,78 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_INSERTTRIGGERNOTECOMMAND_H_
+#define _RG_INSERTTRIGGERNOTECOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "base/TriggerSegment.h"
+#include "document/BasicCommand.h"
+#include "gui/editors/notation/NoteStyle.h"
+#include <string>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class InsertTriggerNoteCommand : public BasicCommand
+{
+public:
+ InsertTriggerNoteCommand(Segment &,
+ timeT time,
+ Note note,
+ int pitch,
+ int velocity,
+ NoteStyleName noteStyle,
+ TriggerSegmentId id,
+ bool retune,
+ std::string timeAdjust,
+ Mark mark);
+ virtual ~InsertTriggerNoteCommand();
+
+protected:
+ virtual void modifySegment();
+
+ timeT m_time;
+ Note m_note;
+ int m_pitch;
+ int m_velocity;
+ NoteStyleName m_noteStyle;
+ TriggerSegmentId m_id;
+ bool m_retune;
+ std::string m_timeAdjust;
+ Mark m_mark;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/InvertCommand.cpp b/src/commands/edit/InvertCommand.cpp
new file mode 100644
index 0000000..053bcf9
--- /dev/null
+++ b/src/commands/edit/InvertCommand.cpp
@@ -0,0 +1,85 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "InvertCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+InvertCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+ long highestPitch, lowestPitch;
+
+ bool firstNote = true;
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ try {
+ long pitch = (*i)->get
+ <Int>(PITCH);
+ if (firstNote) {
+ highestPitch = pitch;
+ lowestPitch = pitch;
+ firstNote = false;
+ } else {
+ if (pitch > highestPitch)
+ highestPitch = pitch;
+ else if (pitch < lowestPitch)
+ lowestPitch = pitch;
+ }
+ } catch (...) { }
+ }
+ }
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ try {
+ long pitch = (*i)->get
+ <Int>(PITCH);
+ pitch = lowestPitch + (highestPitch - pitch);
+ pitch += m_semitones;
+ (*i)->set
+ <Int>(PITCH, pitch);
+ (*i)->unset(ACCIDENTAL);
+ } catch (...) { }
+ }
+ }
+}
+
+}
diff --git a/src/commands/edit/InvertCommand.h b/src/commands/edit/InvertCommand.h
new file mode 100644
index 0000000..5bea38d
--- /dev/null
+++ b/src/commands/edit/InvertCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_INVERTCOMMAND_H_
+#define _RG_INVERTCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class InvertCommand : public BasicSelectionCommand
+{
+public:
+ InvertCommand(int semitones, EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(semitones), selection, true),
+ m_selection(&selection), m_semitones(semitones) { }
+
+ static QString getGlobalName(int semitones = 0) {
+ switch (semitones) {
+ default: return i18n("&Invert");
+ }
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ int m_semitones;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/ModifyMarkerCommand.cpp b/src/commands/edit/ModifyMarkerCommand.cpp
new file mode 100644
index 0000000..367f545
--- /dev/null
+++ b/src/commands/edit/ModifyMarkerCommand.cpp
@@ -0,0 +1,95 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ModifyMarkerCommand.h"
+
+#include "base/Composition.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+ModifyMarkerCommand::ModifyMarkerCommand(Composition *comp,
+ int id,
+ timeT time,
+ timeT newTime,
+ const std::string &name,
+ const std::string &des):
+ KNamedCommand(getGlobalName()),
+ m_composition(comp),
+ m_id(id),
+ m_time(time),
+ m_newTime(newTime),
+ m_name(name),
+ m_description(des),
+ m_oldName(""),
+ m_oldDescription("")
+{}
+
+ModifyMarkerCommand::~ModifyMarkerCommand()
+{}
+
+void
+ModifyMarkerCommand::execute()
+{
+ Composition::markercontainer markers =
+ m_composition->getMarkers();
+
+ Composition::markerconstiterator it = markers.begin();
+
+ for (; it != markers.end(); ++it) {
+ if ((*it)->getID() == m_id) {
+ if (m_oldName.empty())
+ m_oldName = (*it)->getName();
+ if (m_oldDescription.empty())
+ m_oldDescription = (*it)->getDescription();
+
+ (*it)->setName(m_name);
+ (*it)->setDescription(m_description);
+ (*it)->setTime(m_newTime);
+ return ;
+ }
+ }
+}
+
+void
+ModifyMarkerCommand::unexecute()
+{
+ Composition::markercontainer markers =
+ m_composition->getMarkers();
+
+ Composition::markerconstiterator it = markers.begin();
+
+ for (; it != markers.end(); ++it) {
+ if ((*it)->getID() == m_id) {
+ (*it)->setName(m_oldName);
+ (*it)->setDescription(m_oldDescription);
+ (*it)->setTime(m_time);
+ }
+ }
+}
+
+}
diff --git a/src/commands/edit/ModifyMarkerCommand.h b/src/commands/edit/ModifyMarkerCommand.h
new file mode 100644
index 0000000..6a7e99f
--- /dev/null
+++ b/src/commands/edit/ModifyMarkerCommand.h
@@ -0,0 +1,78 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MODIFYMARKERCOMMAND_H_
+#define _RG_MODIFYMARKERCOMMAND_H_
+
+#include <string>
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class ModifyMarkerCommand : public KNamedCommand
+{
+public:
+ ModifyMarkerCommand(Composition *comp,
+ int id,
+ timeT time,
+ timeT newTime,
+ const std::string &name,
+ const std::string &des);
+ ~ModifyMarkerCommand();
+
+ static QString getGlobalName() { return i18n("&Modify Marker"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+
+ Composition *m_composition;
+ timeT m_time;
+ timeT m_newTime;
+
+ int m_id;
+ std::string m_name;
+ std::string m_description;
+ std::string m_oldName;
+ std::string m_oldDescription;
+
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/MoveAcrossSegmentsCommand.cpp b/src/commands/edit/MoveAcrossSegmentsCommand.cpp
new file mode 100644
index 0000000..3363d65
--- /dev/null
+++ b/src/commands/edit/MoveAcrossSegmentsCommand.cpp
@@ -0,0 +1,76 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MoveAcrossSegmentsCommand.h"
+
+#include <klocale.h>
+#include "base/Clipboard.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "CutCommand.h"
+#include "PasteEventsCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+MoveAcrossSegmentsCommand::MoveAcrossSegmentsCommand(Segment &,
+ Segment &secondSegment,
+ timeT newStartTime,
+ bool notation,
+ EventSelection &selection) :
+ KMacroCommand(getGlobalName()),
+ m_clipboard(new Clipboard())
+{
+ addCommand(new CutCommand(selection, m_clipboard));
+
+ timeT newEndTime = newStartTime + selection.getEndTime() - selection.getStartTime();
+ Segment::iterator i = secondSegment.findTime(newEndTime);
+ if (i == secondSegment.end())
+ newEndTime = secondSegment.getEndTime();
+ else
+ newEndTime = (*i)->getAbsoluteTime();
+
+ addCommand(new PasteEventsCommand(secondSegment, m_clipboard,
+ newStartTime,
+ newEndTime,
+ notation ?
+ PasteEventsCommand::NoteOverlay :
+ PasteEventsCommand::MatrixOverlay));
+}
+
+MoveAcrossSegmentsCommand::~MoveAcrossSegmentsCommand()
+{
+ delete m_clipboard;
+}
+
+QString
+MoveAcrossSegmentsCommand::getGlobalName()
+{
+ return i18n("&Move Events to Other Segment");
+}
+
+}
diff --git a/src/commands/edit/MoveAcrossSegmentsCommand.h b/src/commands/edit/MoveAcrossSegmentsCommand.h
new file mode 100644
index 0000000..ac3ee39
--- /dev/null
+++ b/src/commands/edit/MoveAcrossSegmentsCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MOVEACROSSSEGMENTSCOMMAND_H_
+#define _RG_MOVEACROSSSEGMENTSCOMMAND_H_
+
+#include <qstring.h>
+#include "base/Event.h"
+#include <kcommand.h>
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class EventSelection;
+class Clipboard;
+
+
+class MoveAcrossSegmentsCommand : public KMacroCommand
+{
+public:
+ MoveAcrossSegmentsCommand(Segment &firstSegment,
+ Segment &secondSegment,
+ timeT newStartTime,
+ bool notation,
+ EventSelection &selection);
+ virtual ~MoveAcrossSegmentsCommand();
+
+ static QString getGlobalName();
+
+private:
+ Clipboard *m_clipboard;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/MoveCommand.cpp b/src/commands/edit/MoveCommand.cpp
new file mode 100644
index 0000000..5df08a7
--- /dev/null
+++ b/src/commands/edit/MoveCommand.cpp
@@ -0,0 +1,159 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MoveCommand.h"
+
+#include "misc/Debug.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+MoveCommand::MoveCommand(Segment &s, timeT delta, bool useNotationTimings,
+ EventSelection &sel) :
+ BasicCommand(getGlobalName(), s,
+ delta < 0 ? sel.getStartTime() + delta : sel.getStartTime(),
+ delta < 0 ? sel.getEndTime() + 1 : sel.getEndTime() + 1 + delta,
+ true),
+ m_selection(&sel),
+ m_delta(delta),
+ m_useNotationTimings(useNotationTimings),
+ m_lastInsertedEvent(0)
+{
+ // nothing else
+}
+
+QString
+MoveCommand::getGlobalName(timeT delta)
+{
+ if (delta == 0) {
+ return "&Move Events";
+ } else if (delta < 0) {
+ return "&Move Events Back";
+ } else {
+ return "&Move Events Forward";
+ }
+}
+
+void
+MoveCommand::modifySegment()
+{
+ RG_DEBUG << "MoveCommand::modifySegment: delta is " << m_delta
+ << ", useNotationTimings " << m_useNotationTimings
+ << ", start time " << m_selection->getStartTime()
+ << ", end time " << m_selection->getEndTime() << endl;
+
+ std::vector<Event *> toErase;
+ std::vector<Event *> toInsert;
+
+ timeT a0 = m_selection->getStartTime();
+ timeT a1 = m_selection->getEndTime();
+ timeT b0 = a0 + m_delta;
+ timeT b1 = b0 + (a1 - a0);
+
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ RG_DEBUG << "MoveCommand::modifySegment: event at " << (*i)->getAbsoluteTime() << " type " << (*i)->getType() << endl;
+
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+
+ toErase.push_back(*i);
+ timeT newTime =
+ (m_useNotationTimings ?
+ (*i)->getNotationAbsoluteTime() : (*i)->getAbsoluteTime()) + m_delta;
+
+ Event *e;
+ if (m_useNotationTimings) {
+ e = new Event(**i, newTime, (*i)->getDuration(), (*i)->getSubOrdering(),
+ newTime, (*i)->getNotationDuration());
+ } else {
+ e = new Event(**i, newTime);
+ }
+
+ toInsert.push_back(e);
+ }
+
+ Segment &segment(m_selection->getSegment());
+
+ for (unsigned int j = 0; j < toErase.size(); ++j) {
+ Segment::iterator jtr(segment.findSingle(toErase[j]));
+ if (jtr != segment.end()) {
+ RG_DEBUG << "found event " << j << endl;
+ segment.erase(jtr);
+ } else {
+ RG_DEBUG << "failed to find event " << j << endl;
+ }
+ }
+
+ for (unsigned int j = 0; j < toInsert.size(); ++j) {
+
+ Segment::iterator jtr = segment.end();
+
+ // somewhat like the NoteOverlay part of PasteEventsCommand::modifySegment
+ /* nah -- let's do a de-counterpoint afterwards perhaps
+ if (m_useNotationTimings && toInsert[j]->isa(Note::EventType)) {
+ long pitch = 0;
+ Accidental explicitAccidental = NoAccidental;
+ toInsert[j]->get<String>(ACCIDENTAL, explicitAccidental);
+ if (toInsert[j]->get<Int>(PITCH, pitch)) {
+ jtr = SegmentNotationHelper(segment).insertNote
+ (toInsert[j]->getAbsoluteTime(),
+ Note::getNearestNote(toInsert[j]->getDuration()),
+ pitch, explicitAccidental);
+ delete toInsert[j];
+ toInsert[j] = *jtr;
+ }
+ } else {
+ */
+ jtr = segment.insert(toInsert[j]);
+ // }
+
+ // insert new event back into selection
+ m_selection->addEvent(toInsert[j]);
+
+ if (jtr != segment.end())
+ m_lastInsertedEvent = toInsert[j];
+ }
+
+ if (m_useNotationTimings) {
+ SegmentNotationHelper(segment).deCounterpoint(b0, b1);
+ }
+
+ segment.normalizeRests(a0, a1);
+ segment.normalizeRests(b0, b1);
+}
+
+}
diff --git a/src/commands/edit/MoveCommand.h b/src/commands/edit/MoveCommand.h
new file mode 100644
index 0000000..79c0081
--- /dev/null
+++ b/src/commands/edit/MoveCommand.h
@@ -0,0 +1,69 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MOVECOMMAND_H_
+#define _RG_MOVECOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class EventSelection;
+class Event;
+
+
+class MoveCommand : public BasicCommand
+{
+public:
+ MoveCommand(Segment &segment,
+ timeT delta,
+ bool useNotationTimings,
+ EventSelection &selection);
+
+ static QString getGlobalName(timeT delta = 0);
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ timeT m_delta;
+ bool m_useNotationTimings;
+ Event *m_lastInsertedEvent;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/edit/PasteEventsCommand.cpp b/src/commands/edit/PasteEventsCommand.cpp
new file mode 100644
index 0000000..f6fd323
--- /dev/null
+++ b/src/commands/edit/PasteEventsCommand.cpp
@@ -0,0 +1,321 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "PasteEventsCommand.h"
+
+#include "misc/Debug.h"
+#include "base/Clipboard.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+PasteEventsCommand::PasteEventsCommand(Segment &segment,
+ Clipboard *clipboard,
+ timeT pasteTime,
+ PasteType pasteType) :
+ BasicCommand(getGlobalName(), segment, pasteTime,
+ getEffectiveEndTime(segment, clipboard, pasteTime)),
+ m_relayoutEndTime(getEndTime()),
+ m_clipboard(new Clipboard(*clipboard)),
+ m_pasteType(pasteType),
+ m_pastedEvents(segment)
+{
+ if (pasteType != OpenAndPaste) {
+
+ // paste clef or key -> relayout to end
+
+ if (clipboard->isSingleSegment()) {
+
+ Segment *s(clipboard->getSingleSegment());
+ for (Segment::iterator i = s->begin(); i != s->end(); ++i) {
+ if ((*i)->isa(Clef::EventType) ||
+ (*i)->isa(Key::EventType)) {
+ m_relayoutEndTime = s->getEndTime();
+ break;
+ }
+ }
+ }
+ }
+}
+
+PasteEventsCommand::PasteEventsCommand(Segment &segment,
+ Clipboard *clipboard,
+ timeT pasteTime,
+ timeT pasteEndTime,
+ PasteType pasteType) :
+ BasicCommand(getGlobalName(), segment, pasteTime, pasteEndTime),
+ m_relayoutEndTime(getEndTime()),
+ m_clipboard(new Clipboard(*clipboard)),
+ m_pasteType(pasteType),
+ m_pastedEvents(segment)
+{}
+
+PasteEventsCommand::~PasteEventsCommand()
+{
+ delete m_clipboard;
+}
+
+PasteEventsCommand::PasteTypeMap
+
+PasteEventsCommand::getPasteTypes()
+{
+ static PasteTypeMap types;
+ static bool haveTypes = false;
+ if (!haveTypes) {
+ types[Restricted] =
+ i18n("Paste into an existing gap [\"restricted\"]");
+ types[Simple] =
+ i18n("Erase existing events to make room [\"simple\"]");
+ types[OpenAndPaste] =
+ i18n("Move existing events out of the way [\"open-n-paste\"]");
+ types[NoteOverlay] =
+ i18n("Overlay notes, tying against present notes [\"note-overlay\"]");
+ types[MatrixOverlay] =
+ i18n("Overlay notes, ignoring present notes [\"matrix-overlay\"]");
+ }
+ return types;
+}
+
+timeT
+PasteEventsCommand::getEffectiveEndTime(Segment &segment,
+ Clipboard *clipboard,
+ timeT pasteTime)
+{
+ if (!clipboard->isSingleSegment()) {
+ RG_DEBUG << "PasteEventsCommand::getEffectiveEndTime: not single segment" << endl;
+ return pasteTime;
+ }
+
+ RG_DEBUG << "PasteEventsCommand::getEffectiveEndTime: clipboard "
+ << clipboard->getSingleSegment()->getStartTime()
+ << " -> "
+ << clipboard->getSingleSegment()->getEndTime() << endl;
+
+ timeT d = clipboard->getSingleSegment()->getEndTime() -
+ clipboard->getSingleSegment()->getStartTime();
+
+ if (m_pasteType == OpenAndPaste) {
+ return segment.getEndTime() + d;
+ } else {
+ Segment::iterator i = segment.findTime(pasteTime + d);
+ if (i == segment.end())
+ return segment.getEndTime();
+ else
+ return (*i)->getAbsoluteTime();
+ }
+}
+
+timeT
+PasteEventsCommand::getRelayoutEndTime()
+{
+ return m_relayoutEndTime;
+}
+
+bool
+PasteEventsCommand::isPossible()
+{
+ if (m_clipboard->isEmpty() || !m_clipboard->isSingleSegment()) {
+ return false;
+ }
+
+ if (m_pasteType != Restricted) {
+ return true;
+ }
+
+ Segment *source = m_clipboard->getSingleSegment();
+
+ timeT pasteTime = getStartTime();
+ timeT origin = source->getStartTime();
+ timeT duration = source->getEndTime() - origin;
+
+ RG_DEBUG << "PasteEventsCommand::isPossible: paste time is " << pasteTime << ", origin is " << origin << ", duration is " << duration << endl;
+
+ SegmentNotationHelper helper(getSegment());
+ return helper.removeRests(pasteTime, duration, true);
+}
+
+void
+PasteEventsCommand::modifySegment()
+{
+ RG_DEBUG << "PasteEventsCommand::modifySegment" << endl;
+
+ if (!m_clipboard->isSingleSegment())
+ return ;
+
+ Segment *source = m_clipboard->getSingleSegment();
+
+ timeT pasteTime = getStartTime();
+ timeT origin = source->getStartTime();
+ timeT duration = source->getEndTime() - origin;
+
+ Segment *destination(&getSegment());
+ SegmentNotationHelper helper(*destination);
+
+ RG_DEBUG << "PasteEventsCommand::modifySegment() : paste type = "
+ << m_pasteType << " - pasteTime = "
+ << pasteTime << " - origin = " << origin << endl;
+
+ // First check for group IDs, which we want to make unique in the
+ // copies in the destination segment
+
+ std::map<long, long> groupIdMap;
+ for (Segment::iterator i = source->begin(); i != source->end(); ++i) {
+ long groupId = -1;
+ if ((*i)->get
+ <Int>(BEAMED_GROUP_ID, groupId)) {
+ if (groupIdMap.find(groupId) == groupIdMap.end()) {
+ groupIdMap[groupId] = destination->getNextId();
+ }
+ }
+ }
+
+ switch (m_pasteType) {
+
+ // Do some preliminary work to make space or whatever;
+ // we do the actual paste after this switch statement
+ // (except where individual cases do the work and return)
+
+ case Restricted:
+ if (!helper.removeRests(pasteTime, duration))
+ return ;
+ break;
+
+ case Simple:
+ destination->erase(destination->findTime(pasteTime),
+ destination->findTime(pasteTime + duration));
+ break;
+
+ case OpenAndPaste: {
+ std::vector<Event *> copies;
+ for (Segment::iterator i = destination->findTime(pasteTime);
+ i != destination->end(); ++i) {
+ Event *e = (*i)->copyMoving(duration);
+ if (e->has(BEAMED_GROUP_ID)) {
+ e->set
+ <Int>(BEAMED_GROUP_ID, groupIdMap[e->get
+ <Int>(BEAMED_GROUP_ID)]);
+ }
+ copies.push_back(e);
+ }
+
+ destination->erase(destination->findTime(pasteTime),
+ destination->end());
+
+ for (unsigned int i = 0; i < copies.size(); ++i) {
+ destination->insert(copies[i]);
+ m_pastedEvents.addEvent(copies[i]);
+ }
+
+ break;
+ }
+
+ case NoteOverlay:
+ for (Segment::iterator i = source->begin(); i != source->end(); ++i) {
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+ Event *e = (*i)->copyMoving(pasteTime - origin);
+ if (e->has(BEAMED_GROUP_ID)) {
+ e->set<Int>(BEAMED_GROUP_ID,
+ groupIdMap[e->get<Int>(BEAMED_GROUP_ID)]);
+ }
+ if ((*i)->isa(Note::EventType)) {
+ // e is model event: we retain ownership of it
+ Segment::iterator i = helper.insertNote(e);
+ delete e;
+ if (i != destination->end()) m_pastedEvents.addEvent(*i);
+ } else {
+ destination->insert(e);
+ m_pastedEvents.addEvent(e);
+ }
+ }
+
+ return ;
+
+ case MatrixOverlay:
+
+ for (Segment::iterator i = source->begin(); i != source->end(); ++i) {
+
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+
+ Event *e = (*i)->copyMoving(pasteTime - origin);
+
+ if (e->has(BEAMED_GROUP_TYPE) &&
+ e->get
+ <String>(BEAMED_GROUP_TYPE) == GROUP_TYPE_BEAMED) {
+ e->unset(BEAMED_GROUP_ID);
+ e->unset(BEAMED_GROUP_TYPE);
+ }
+
+ if (e->has(BEAMED_GROUP_ID)) {
+ e->set
+ <Int>(BEAMED_GROUP_ID, groupIdMap[e->get
+ <Int>(BEAMED_GROUP_ID)]);
+ }
+
+ destination->insert(e);
+ m_pastedEvents.addEvent(e);
+ }
+
+ destination->normalizeRests
+ (source->getStartTime(), source->getEndTime());
+
+ return ;
+ }
+
+ RG_DEBUG << "PasteEventsCommand::modifySegment() - inserting\n";
+
+ for (Segment::iterator i = source->begin(); i != source->end(); ++i) {
+ Event *e = (*i)->copyMoving(pasteTime - origin);
+ if (e->has(BEAMED_GROUP_ID)) {
+ e->set
+ <Int>(BEAMED_GROUP_ID, groupIdMap[e->get
+ <Int>(BEAMED_GROUP_ID)]);
+ }
+ destination->insert(e);
+ m_pastedEvents.addEvent(e);
+ }
+
+ destination->normalizeRests
+ (source->getStartTime(), source->getEndTime());
+}
+
+EventSelection
+PasteEventsCommand::getPastedEvents()
+{
+ return m_pastedEvents;
+}
+
+}
diff --git a/src/commands/edit/PasteEventsCommand.h b/src/commands/edit/PasteEventsCommand.h
new file mode 100644
index 0000000..3a26b25
--- /dev/null
+++ b/src/commands/edit/PasteEventsCommand.h
@@ -0,0 +1,112 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_PASTEEVENTSCOMMAND_H_
+#define _RG_PASTEEVENTSCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include "base/Selection.h"
+#include <map>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Clipboard;
+
+
+/// Paste from a single-segment clipboard to a segment
+
+class PasteEventsCommand : public BasicCommand
+{
+public:
+ enum PasteType {
+ Restricted, // paste into existing gap
+ Simple, // erase existing events to make room
+ OpenAndPaste, // bump up existing events to make room
+ NoteOverlay, // overlay and tie notation-style
+ MatrixOverlay // overlay raw matrix-style
+ };
+
+ typedef std::map<PasteType, QString> PasteTypeMap;
+ static PasteTypeMap getPasteTypes(); // type, descrip
+
+ /**
+ * Construct a Paste command from a clipboard that already contains
+ * the events to be pasted.
+ */
+ PasteEventsCommand(Segment &segment,
+ Clipboard *clipboard,
+ timeT pasteTime,
+ PasteType pasteType);
+
+ /**
+ * Construct a Paste command from a clipboard that will contain
+ * the events to be pasted by the time the Paste command is
+ * executed, but might not do so yet. This is necessary if the
+ * Paste command is to follow another clipboard-based command
+ * in a KMacroCommand sequence. pasteEndTime must supply the
+ * latest time in the destination segment that may be modified
+ * by the paste.
+ */
+ PasteEventsCommand(Segment &segment,
+ Clipboard *clipboard,
+ timeT pasteTime,
+ timeT pasteEndTime,
+ PasteType pasteType);
+
+ virtual ~PasteEventsCommand();
+
+ EventSelection getPastedEvents();
+
+ static QString getGlobalName() { return i18n("&Paste"); }
+
+ /// Determine whether this paste will succeed (without executing it yet)
+ bool isPossible();
+
+ virtual timeT getRelayoutEndTime();
+
+protected:
+ virtual void modifySegment();
+ timeT getEffectiveEndTime(Segment &,
+ Clipboard *,
+ timeT);
+ timeT m_relayoutEndTime;
+ Clipboard *m_clipboard;
+ PasteType m_pasteType;
+ EventSelection m_pastedEvents;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/PasteSegmentsCommand.cpp b/src/commands/edit/PasteSegmentsCommand.cpp
new file mode 100644
index 0000000..ab3372a
--- /dev/null
+++ b/src/commands/edit/PasteSegmentsCommand.cpp
@@ -0,0 +1,153 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "PasteSegmentsCommand.h"
+
+#include "base/Clipboard.h"
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include "base/Track.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+PasteSegmentsCommand::PasteSegmentsCommand(Composition *composition,
+ Clipboard *clipboard,
+ timeT pasteTime,
+ TrackId baseTrack,
+ bool useExactTracks) :
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_clipboard(new Clipboard(*clipboard)),
+ m_pasteTime(pasteTime),
+ m_baseTrack(baseTrack),
+ m_exactTracks(useExactTracks),
+ m_detached(false)
+{
+ // nothing else
+}
+
+PasteSegmentsCommand::~PasteSegmentsCommand()
+{
+ if (m_detached) {
+ for (unsigned int i = 0; i < m_addedSegments.size(); ++i) {
+ delete m_addedSegments[i];
+ }
+ }
+
+ delete m_clipboard;
+}
+
+void
+PasteSegmentsCommand::execute()
+{
+ if (m_addedSegments.size() > 0) {
+ // been here before
+ for (unsigned int i = 0; i < m_addedSegments.size(); ++i) {
+ m_composition->addSegment(m_addedSegments[i]);
+ }
+ return ;
+ }
+
+ if (m_clipboard->isEmpty())
+ return ;
+
+ // We want to paste such that the earliest Segment starts at
+ // m_pasteTime and the others start at the same times relative to
+ // that as they did before. Likewise for track, unless
+ // m_exactTracks is set.
+
+ timeT earliestStartTime = m_clipboard->getBaseTime();
+ timeT latestEndTime = 0;
+ int lowestTrackPos = -1;
+
+ for (Clipboard::iterator i = m_clipboard->begin();
+ i != m_clipboard->end(); ++i) {
+
+ int trackPos = m_composition->getTrackPositionById((*i)->getTrack());
+ if (trackPos >= 0 &&
+ (lowestTrackPos < 0 || trackPos < lowestTrackPos)) {
+ lowestTrackPos = trackPos;
+ }
+
+ if ((*i)->getEndMarkerTime() > latestEndTime) {
+ latestEndTime = (*i)->getEndMarkerTime();
+ }
+ }
+
+ if (m_exactTracks)
+ lowestTrackPos = 0;
+ if (lowestTrackPos < 0)
+ lowestTrackPos = 0;
+ timeT offset = m_pasteTime - earliestStartTime;
+ int baseTrackPos = m_composition->getTrackPositionById(m_baseTrack);
+ int trackOffset = baseTrackPos - lowestTrackPos;
+
+ for (Clipboard::iterator i = m_clipboard->begin();
+ i != m_clipboard->end(); ++i) {
+
+ int newTrackPos = trackOffset +
+ m_composition->getTrackPositionById((*i)->getTrack());
+
+ Track *track = m_composition->getTrackByPosition(newTrackPos);
+
+ if (!track) {
+ newTrackPos = 0;
+ track = m_composition->getTrackByPosition(newTrackPos);
+ }
+
+ TrackId newTrackId = track->getId();
+
+ Segment *segment = new Segment(**i);
+ segment->setStartTime(segment->getStartTime() + offset);
+ segment->setTrack(newTrackId);
+ m_composition->addSegment(segment);
+ if (m_clipboard->isPartial()) {
+ segment->normalizeRests(segment->getStartTime(),
+ segment->getEndMarkerTime());
+ }
+ m_addedSegments.push_back(segment);
+ }
+
+ // User preference? Update song pointer position on paste
+ m_composition->setPosition(latestEndTime
+ + m_pasteTime
+ - earliestStartTime);
+
+ m_detached = false;
+}
+
+void
+PasteSegmentsCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_addedSegments.size(); ++i) {
+ m_composition->detachSegment(m_addedSegments[i]);
+ }
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/edit/PasteSegmentsCommand.h b/src/commands/edit/PasteSegmentsCommand.h
new file mode 100644
index 0000000..3f45914
--- /dev/null
+++ b/src/commands/edit/PasteSegmentsCommand.h
@@ -0,0 +1,79 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_PASTESEGMENTSCOMMAND_H_
+#define _RG_PASTESEGMENTSCOMMAND_H_
+
+#include "base/Track.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+class Clipboard;
+
+
+/// Paste one or more segments from the clipboard into the composition
+
+class PasteSegmentsCommand : public KNamedCommand
+{
+public:
+ PasteSegmentsCommand(Composition *composition,
+ Clipboard *clipboard,
+ timeT pasteTime,
+ TrackId baseTrack,
+ bool useExactTracks);
+
+ virtual ~PasteSegmentsCommand();
+
+ static QString getGlobalName() { return i18n("&Paste"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ Clipboard *m_clipboard;
+ timeT m_pasteTime;
+ TrackId m_baseTrack;
+ bool m_exactTracks;
+ std::vector<Segment *> m_addedSegments;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/RemoveMarkerCommand.cpp b/src/commands/edit/RemoveMarkerCommand.cpp
new file mode 100644
index 0000000..af3c839
--- /dev/null
+++ b/src/commands/edit/RemoveMarkerCommand.cpp
@@ -0,0 +1,83 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RemoveMarkerCommand.h"
+
+#include "base/Composition.h"
+#include "base/Marker.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+RemoveMarkerCommand::RemoveMarkerCommand(Composition *comp,
+ int id,
+ timeT time,
+ const std::string &name,
+ const std::string &description):
+ KNamedCommand(getGlobalName()),
+ m_composition(comp),
+ m_marker(0),
+ m_id(id),
+ m_time(time),
+ m_name(name),
+ m_descr(description),
+ m_detached(false)
+{}
+
+RemoveMarkerCommand::~RemoveMarkerCommand()
+{
+ if (m_detached)
+ delete m_marker;
+}
+
+void
+RemoveMarkerCommand::execute()
+{
+ Composition::markercontainer markers =
+ m_composition->getMarkers();
+
+ Composition::markerconstiterator it = markers.begin();
+
+ for (; it != markers.end(); ++it) {
+ if ((*it)->getID() == m_id) {
+ m_marker = (*it);
+ m_composition->detachMarker(m_marker);
+ m_detached = true;
+ return ;
+ }
+ }
+}
+
+void
+RemoveMarkerCommand::unexecute()
+{
+ if (m_marker)
+ m_composition->addMarker(m_marker);
+ m_detached = false;
+}
+
+}
diff --git a/src/commands/edit/RemoveMarkerCommand.h b/src/commands/edit/RemoveMarkerCommand.h
new file mode 100644
index 0000000..2acaf53
--- /dev/null
+++ b/src/commands/edit/RemoveMarkerCommand.h
@@ -0,0 +1,75 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_REMOVEMARKERCOMMAND_H_
+#define _RG_REMOVEMARKERCOMMAND_H_
+
+#include <string>
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Marker;
+class Composition;
+
+
+class RemoveMarkerCommand : public KNamedCommand
+{
+public:
+ RemoveMarkerCommand(Composition *comp,
+ int id,
+ timeT time,
+ const std::string &name,
+ const std::string &description);
+ ~RemoveMarkerCommand();
+
+ static QString getGlobalName() { return i18n("&Remove Marker"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+
+ Composition *m_composition;
+ Marker *m_marker;
+ int m_id;
+ timeT m_time;
+ std::string m_name;
+ std::string m_descr;
+ bool m_detached;
+
+};
+
+
+}
+
+#endif
diff --git a/src/commands/edit/RescaleCommand.cpp b/src/commands/edit/RescaleCommand.cpp
new file mode 100644
index 0000000..764969c
--- /dev/null
+++ b/src/commands/edit/RescaleCommand.cpp
@@ -0,0 +1,138 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RescaleCommand.h"
+
+#include "base/Event.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+RescaleCommand::RescaleCommand(EventSelection &sel,
+ timeT newDuration,
+ bool closeGap) :
+ BasicCommand(getGlobalName(), sel.getSegment(),
+ sel.getStartTime(),
+ getAffectedEndTime(sel, newDuration, closeGap),
+ true),
+ m_selection(&sel),
+ m_oldDuration(sel.getTotalDuration()),
+ m_newDuration(newDuration),
+ m_closeGap(closeGap)
+{
+ // nothing else
+}
+
+timeT
+RescaleCommand::getAffectedEndTime(EventSelection &sel,
+ timeT newDuration,
+ bool closeGap)
+{
+ timeT preScaleEnd = sel.getEndTime();
+ if (closeGap)
+ preScaleEnd = sel.getSegment().getEndMarkerTime();
+
+ // dupe of rescale(), but we can't use that here as the m_
+ // variables may not have been set
+ double d = preScaleEnd;
+ d *= newDuration;
+ d /= sel.getTotalDuration();
+ d += 0.5;
+ timeT postScaleEnd = (timeT)d;
+
+ return std::max(preScaleEnd, postScaleEnd);
+}
+
+timeT
+RescaleCommand::rescale(timeT t)
+{
+ // avoid overflows by using doubles
+ double d = t;
+ d *= m_newDuration;
+ d /= m_oldDuration;
+ d += 0.5;
+ return (timeT)d;
+}
+
+void
+RescaleCommand::modifySegment()
+{
+ if (m_oldDuration == m_newDuration)
+ return ;
+
+ timeT startTime = m_selection->getStartTime();
+ timeT diff = m_newDuration - m_oldDuration;
+ std::vector<Event *> toErase;
+ std::vector<Event *> toInsert;
+
+ Segment &segment = m_selection->getSegment();
+
+ for (EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ toErase.push_back(*i);
+
+ timeT t = (*i)->getAbsoluteTime() - startTime;
+ timeT d = (*i)->getDuration();
+ t = rescale(t);
+ d = rescale(d);
+
+ toInsert.push_back(new Event(**i, startTime + t, d));
+ }
+
+ if (m_closeGap) {
+ for (Segment::iterator i = segment.findTime(startTime + m_oldDuration);
+ i != segment.end(); ++i) {
+ // move all events including any following the end marker
+ toErase.push_back(*i);
+ toInsert.push_back((*i)->copyMoving(diff));
+ }
+ }
+
+ for (std::vector<Event *>::iterator i = toErase.begin(); i != toErase.end(); ++i) {
+ m_selection->removeEvent(*i); // remove from selection
+ segment.eraseSingle(*i);
+ }
+
+ for (std::vector<Event *>::iterator i = toInsert.begin(); i != toInsert.end(); ++i) {
+ segment.insert(*i);
+ m_selection->addEvent(*i); // add to selection
+ }
+
+ if (m_closeGap && diff > 0) {
+ segment.setEndMarkerTime(startTime +
+ rescale(segment.getEndMarkerTime() - startTime));
+ }
+
+ segment.normalizeRests(getStartTime(), getEndTime());
+}
+
+}
diff --git a/src/commands/edit/RescaleCommand.h b/src/commands/edit/RescaleCommand.h
new file mode 100644
index 0000000..362de24
--- /dev/null
+++ b/src/commands/edit/RescaleCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RESCALECOMMAND_H_
+#define _RG_RESCALECOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RescaleCommand : public BasicCommand
+{
+public:
+ RescaleCommand(EventSelection &selection,
+ timeT newDuration,
+ bool closeGap);
+
+ static QString getGlobalName() { return i18n("Stretch or S&quash..."); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ timeT rescale(timeT);
+ timeT getAffectedEndTime(EventSelection &selection,
+ timeT newDuration,
+ bool closeGap);
+
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ timeT m_oldDuration;
+ timeT m_newDuration;
+ bool m_closeGap;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/RetrogradeCommand.cpp b/src/commands/edit/RetrogradeCommand.cpp
new file mode 100644
index 0000000..955f066
--- /dev/null
+++ b/src/commands/edit/RetrogradeCommand.cpp
@@ -0,0 +1,121 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RetrogradeCommand.h"
+
+#include "base/Event.h"
+#include "misc/Debug.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RetrogradeCommand::modifySegment()
+{
+ std::vector<Event *> toErase;
+ std::vector<Event *> toInsert;
+
+ timeT a0 = m_selection->getStartTime();
+ timeT a1 = m_selection->getEndTime();
+
+ EventSelection::eventcontainer::iterator i;
+
+ bool useNotationTimings = false;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ RG_DEBUG << "RetrogradeCommand::modifySegment: event at " << (*i)->getAbsoluteTime() << " type " << (*i)->getType() << endl;
+
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+
+ toErase.push_back(*i);
+ timeT newTime = a0 + a1 - (*i)->getDuration() -
+ (useNotationTimings ?
+ (*i)->getNotationAbsoluteTime() : (*i)->getAbsoluteTime());
+
+ Event *e;
+ if (useNotationTimings) {
+ e = new Event(**i, newTime, (*i)->getDuration(), (*i)->getSubOrdering(),
+ newTime, (*i)->getNotationDuration());
+ } else {
+ e = new Event(**i, newTime);
+ }
+
+ toInsert.push_back(e);
+ }
+
+ Segment &segment(m_selection->getSegment());
+
+ for (unsigned int j = 0; j < toErase.size(); ++j) {
+ Segment::iterator jtr(segment.findSingle(toErase[j]));
+ if (jtr != segment.end()) {
+ RG_DEBUG << "found event " << j << endl;
+ segment.erase(jtr);
+ } else {
+ RG_DEBUG << "failed to find event " << j << endl;
+ }
+ }
+
+ for (unsigned int j = 0; j < toInsert.size(); ++j) {
+
+ Segment::iterator jtr = segment.end();
+
+ // somewhat like the NoteOverlay part of PasteEventsCommand::modifySegment
+ /* nah -- let's do a de-counterpoint afterwards perhaps
+ if (m_useNotationTimings && toInsert[j]->isa(Note::EventType)) {
+ long pitch = 0;
+ Accidental explicitAccidental = NoAccidental;
+ toInsert[j]->get<String>(ACCIDENTAL, explicitAccidental);
+ if (toInsert[j]->get<Int>(PITCH, pitch)) {
+ jtr = SegmentNotationHelper(segment).insertNote
+ (toInsert[j]->getAbsoluteTime(),
+ Note::getNearestNote(toInsert[j]->getDuration()),
+ pitch, explicitAccidental);
+ delete toInsert[j];
+ toInsert[j] = *jtr;
+ }
+ } else {
+ */
+ jtr = segment.insert(toInsert[j]);
+ // }
+
+ // insert new event back into selection
+ m_selection->addEvent(toInsert[j]);
+
+ // if (jtr != segment.end()) m_lastInsertedEvent = toInsert[j];
+ }
+
+ segment.normalizeRests(a0, a1);
+}
+
+}
diff --git a/src/commands/edit/RetrogradeCommand.h b/src/commands/edit/RetrogradeCommand.h
new file mode 100644
index 0000000..526a95d
--- /dev/null
+++ b/src/commands/edit/RetrogradeCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RETROGRADECOMMAND_H_
+#define _RG_RETROGRADECOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RetrogradeCommand : public BasicSelectionCommand
+{
+public:
+ RetrogradeCommand(int semitones, EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(semitones), selection, true),
+ m_selection(&selection), m_semitones(semitones) { }
+
+ static QString getGlobalName(int semitones = 0) {
+ switch (semitones) {
+ default: return i18n("&Retrograde");
+ }
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ int m_semitones;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/RetrogradeInvertCommand.cpp b/src/commands/edit/RetrogradeInvertCommand.cpp
new file mode 100644
index 0000000..3387c9b
--- /dev/null
+++ b/src/commands/edit/RetrogradeInvertCommand.cpp
@@ -0,0 +1,163 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RetrogradeInvertCommand.h"
+
+#include "base/Event.h"
+#include "misc/Debug.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+RetrogradeInvertCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ long highestPitch, lowestPitch;
+
+ bool firstNote = true;
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ try {
+ long pitch = (*i)->get
+ <Int>(PITCH);
+ if (firstNote) {
+ highestPitch = pitch;
+ lowestPitch = pitch;
+ firstNote = false;
+ } else {
+ if (pitch > highestPitch)
+ highestPitch = pitch;
+ else if (pitch < lowestPitch)
+ lowestPitch = pitch;
+ }
+ } catch (...) { }
+ }
+ }
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ try {
+ long pitch = (*i)->get
+ <Int>(PITCH);
+ pitch = lowestPitch + (highestPitch - pitch);
+ pitch += m_semitones;
+ (*i)->set
+ <Int>(PITCH, pitch);
+ (*i)->unset(ACCIDENTAL);
+ } catch (...) { }
+ }
+ }
+ std::vector<Event *> toErase;
+ std::vector<Event *> toInsert;
+
+ timeT a0 = m_selection->getStartTime();
+ timeT a1 = m_selection->getEndTime();
+
+ bool useNotationTimings = false;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ RG_DEBUG << "RetrogradeCommand::modifySegment: event at " << (*i)->getAbsoluteTime() << " type " << (*i)->getType() << endl;
+
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+
+ toErase.push_back(*i);
+ timeT newTime = a0 + a1 - (*i)->getDuration() -
+ (useNotationTimings ?
+ (*i)->getNotationAbsoluteTime() : (*i)->getAbsoluteTime());
+
+ Event *e;
+ if (useNotationTimings) {
+ e = new Event(**i, newTime, (*i)->getDuration(), (*i)->getSubOrdering(),
+ newTime, (*i)->getNotationDuration());
+ } else {
+ e = new Event(**i, newTime);
+ }
+
+ toInsert.push_back(e);
+ }
+
+ Segment &segment(m_selection->getSegment());
+
+ for (unsigned int j = 0; j < toErase.size(); ++j) {
+ Segment::iterator jtr(segment.findSingle(toErase[j]));
+ if (jtr != segment.end()) {
+ RG_DEBUG << "found event " << j << endl;
+ segment.erase(jtr);
+ } else {
+ RG_DEBUG << "failed to find event " << j << endl;
+ }
+ }
+
+ for (unsigned int j = 0; j < toInsert.size(); ++j) {
+
+ Segment::iterator jtr = segment.end();
+
+ // somewhat like the NoteOverlay part of PasteEventsCommand::modifySegment
+ /* nah -- let's do a de-counterpoint afterwards perhaps
+ if (m_useNotationTimings && toInsert[j]->isa(Note::EventType)) {
+ long pitch = 0;
+ Accidental explicitAccidental = NoAccidental;
+ toInsert[j]->get<String>(ACCIDENTAL, explicitAccidental);
+ if (toInsert[j]->get<Int>(PITCH, pitch)) {
+ jtr = SegmentNotationHelper(segment).insertNote
+ (toInsert[j]->getAbsoluteTime(),
+ Note::getNearestNote(toInsert[j]->getDuration()),
+ pitch, explicitAccidental);
+ delete toInsert[j];
+ toInsert[j] = *jtr;
+ }
+ } else {
+ */
+ jtr = segment.insert(toInsert[j]);
+ // }
+
+ // insert new event back into selection
+ m_selection->addEvent(toInsert[j]);
+
+ // if (jtr != segment.end()) m_lastInsertedEvent = toInsert[j];
+ }
+
+ segment.normalizeRests(a0, a1);
+}
+
+}
diff --git a/src/commands/edit/RetrogradeInvertCommand.h b/src/commands/edit/RetrogradeInvertCommand.h
new file mode 100644
index 0000000..ea7d540
--- /dev/null
+++ b/src/commands/edit/RetrogradeInvertCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RETROGRADEINVERTCOMMAND_H_
+#define _RG_RETROGRADEINVERTCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RetrogradeInvertCommand : public BasicSelectionCommand
+{
+public:
+ RetrogradeInvertCommand(int semitones, EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(semitones), selection, true),
+ m_selection(&selection), m_semitones(semitones) { }
+
+ static QString getGlobalName(int semitones = 0) {
+ switch (semitones) {
+ default: return i18n("Re&trograde Invert");
+ }
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ int m_semitones;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/SelectionPropertyCommand.cpp b/src/commands/edit/SelectionPropertyCommand.cpp
new file mode 100644
index 0000000..3501e5b
--- /dev/null
+++ b/src/commands/edit/SelectionPropertyCommand.cpp
@@ -0,0 +1,128 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SelectionPropertyCommand.h"
+
+#include "base/Event.h"
+#include "base/PropertyName.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SelectionPropertyCommand::SelectionPropertyCommand(
+ EventSelection *selection,
+ const PropertyName &property,
+ PropertyPattern pattern,
+ int value1,
+ int value2):
+ BasicSelectionCommand(getGlobalName(), *selection, true),
+ m_selection(selection),
+ m_property(property),
+ m_pattern(pattern),
+ m_value1(value1),
+ m_value2(value2)
+{}
+
+void
+SelectionPropertyCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+
+ int count = 0;
+
+ timeT endTime = 0;
+ timeT startTime = 0;
+ bool haveStart = false, haveEnd = false;
+
+ // Get start and end times
+ //
+ for (;i != m_selection->getSegmentEvents().end(); ++i) {
+ if ((*i)->getAbsoluteTime() < startTime || !haveStart) {
+ startTime = (*i)->getAbsoluteTime();
+ haveStart = true;
+ }
+
+ if ((*i)->getAbsoluteTime() > endTime || !haveEnd) {
+ endTime = (*i)->getAbsoluteTime();
+ haveEnd = true;
+ }
+ }
+
+ double step = double(m_value1 - m_value2) / double(endTime - startTime);
+ double lowStep = double(m_value2) / double(endTime - startTime);
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+ // flat
+ if (m_pattern == FlatPattern)
+ (*i)->set
+ <Int>(m_property, m_value1);
+ else if (m_pattern == AlternatingPattern) {
+ if (count % 2 == 0)
+ (*i)->set
+ <Int>(m_property, m_value1);
+ else
+ (*i)->set
+ <Int>(m_property, m_value2);
+
+ // crescendo, decrescendo
+ // (determined by step, above, which is in turn influenced by whether
+ // value1 is greater than value2)
+ } else if ((m_pattern == CrescendoPattern) ||
+ (m_pattern == DecrescendoPattern)) {
+ (*i)->set
+ <Int>(m_property,
+ m_value1 -
+ int(step *
+ ((*i)->getAbsoluteTime() - startTime)));
+ // ringing
+ } else if (m_pattern == RingingPattern) {
+ if (count % 2 == 0)
+ (*i)->set
+ <Int>
+ (m_property,
+ m_value1 - int(step *
+ ((*i)->getAbsoluteTime() - startTime)));
+ else {
+ int value = m_value2 - int(lowStep *
+ ((*i)->getAbsoluteTime() - startTime));
+ if (value < 0)
+ value = 0;
+
+ (*i)->set
+ <Int>(m_property, value);
+ }
+ }
+
+ count++;
+ }
+}
+
+}
diff --git a/src/commands/edit/SelectionPropertyCommand.h b/src/commands/edit/SelectionPropertyCommand.h
new file mode 100644
index 0000000..34c5352
--- /dev/null
+++ b/src/commands/edit/SelectionPropertyCommand.h
@@ -0,0 +1,82 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SELECTIONPROPERTYCOMMAND_H_
+#define _RG_SELECTIONPROPERTYCOMMAND_H_
+
+#include "base/PropertyName.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+class Set;
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+// Patterns of properties
+//
+typedef enum
+{
+ FlatPattern, // set selection to velocity 1.
+ AlternatingPattern, // alternate between velocity 1 and 2 on
+ // subsequent events.
+ CrescendoPattern, // increasing from velocity 1 to velocity 2.
+ DecrescendoPattern, // decreasing from velocity 1 to velocity 2.
+ RingingPattern // between velocity 1 and 2, dying away.
+} PropertyPattern;
+
+
+class SelectionPropertyCommand : public BasicSelectionCommand
+{
+public:
+
+ SelectionPropertyCommand(EventSelection *selection,
+ const PropertyName &property,
+ PropertyPattern pattern,
+ int value1,
+ int value2);
+
+ static QString getGlobalName() { return i18n("Set &Property"); }
+
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;
+ PropertyName m_property;
+ PropertyPattern m_pattern;
+ int m_value1;
+ int m_value2;
+
+};
+
+
+}
+
+#endif
diff --git a/src/commands/edit/SetLyricsCommand.cpp b/src/commands/edit/SetLyricsCommand.cpp
new file mode 100644
index 0000000..16f5be4
--- /dev/null
+++ b/src/commands/edit/SetLyricsCommand.cpp
@@ -0,0 +1,192 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SetLyricsCommand.h"
+
+#include "base/Event.h"
+#include "misc/Strings.h"
+#include "misc/Debug.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/BaseProperties.h"
+#include <qregexp.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+SetLyricsCommand::SetLyricsCommand(Segment *segment, int verse, QString newLyricData) :
+ KNamedCommand(getGlobalName()),
+ m_segment(segment),
+ m_verse(verse),
+ m_newLyricData(newLyricData)
+{
+ // nothing
+}
+
+SetLyricsCommand::~SetLyricsCommand()
+{
+ for (std::vector<Event *>::iterator i = m_oldLyricEvents.begin();
+ i != m_oldLyricEvents.end(); ++i) {
+ delete *i;
+ }
+}
+
+void
+SetLyricsCommand::execute()
+{
+ // This and LyricEditDialog::unparse() are opposites that will
+ // need to be kept in sync with any changes to one another. (They
+ // should really both be in a common lyric management class.)
+
+ // first remove old lyric events
+
+ Segment::iterator i = m_segment->begin();
+
+ while (i != m_segment->end()) {
+
+ Segment::iterator j = i;
+ ++j;
+
+ if ((*i)->isa(Text::EventType)) {
+ std::string textType;
+ if ((*i)->get<String>(Text::TextTypePropertyName, textType) &&
+ textType == Text::Lyric) {
+ long verse = 0;
+ (*i)->get<Int>(Text::LyricVersePropertyName, verse);
+ if (verse == m_verse) {
+ m_oldLyricEvents.push_back(new Event(**i));
+ m_segment->erase(i);
+ }
+ }
+ }
+
+ i = j;
+ }
+
+ // now parse the new string
+
+ QStringList barStrings =
+ QStringList::split("/", m_newLyricData, true); // empties ok
+
+ Composition *comp = m_segment->getComposition();
+ int barNo = comp->getBarNumber(m_segment->getStartTime());
+
+ for (QStringList::Iterator bsi = barStrings.begin();
+ bsi != barStrings.end(); ++bsi) {
+
+ NOTATION_DEBUG << "Parsing lyrics for bar number " << barNo << ": \"" << *bsi << "\"" << endl;
+
+ std::pair<timeT, timeT> barRange = comp->getBarRange(barNo++);
+ QString syllables = *bsi;
+ syllables.replace(QRegExp("\\[\\d+\\] "), " ");
+ QStringList syllableList = QStringList::split(" ", syllables); // no empties
+
+ i = m_segment->findTime(barRange.first);
+ timeT laterThan = barRange.first - 1;
+
+ for (QStringList::Iterator ssi = syllableList.begin();
+ ssi != syllableList.end(); ++ssi) {
+
+ while (m_segment->isBeforeEndMarker(i) &&
+ (*i)->getAbsoluteTime() < barRange.second &&
+ (!(*i)->isa(Note::EventType) ||
+ (*i)->getNotationAbsoluteTime() <= laterThan ||
+ ((*i)->has(TIED_BACKWARD) &&
+ (*i)->get
+ <Bool>(TIED_BACKWARD)))) ++i;
+
+ timeT time = m_segment->getEndMarkerTime();
+ timeT notationTime = time;
+ if (m_segment->isBeforeEndMarker(i)) {
+ time = (*i)->getAbsoluteTime();
+ notationTime = (*i)->getNotationAbsoluteTime();
+ }
+
+ QString syllable = *ssi;
+ syllable.replace(QRegExp("~"), " ");
+ syllable = syllable.simplifyWhiteSpace();
+ if (syllable == "")
+ continue;
+ laterThan = notationTime + 1;
+ if (syllable == ".")
+ continue;
+
+ NOTATION_DEBUG << "Syllable \"" << syllable << "\" at time " << time << endl;
+
+ Text text(qstrtostr(syllable), Text::Lyric);
+ Event *event = text.getAsEvent(time);
+ event->set<Int>(Text::LyricVersePropertyName, m_verse);
+ m_segment->insert(event);
+ }
+ }
+}
+
+void
+SetLyricsCommand::unexecute()
+{
+ // Before we inserted the new lyric events (in execute()), we
+ // removed all the existing ones. That means we know any lyric
+ // events found now must have been inserted by execute(), so we
+ // can safely remove them before restoring the old ones.
+
+ Segment::iterator i = m_segment->begin();
+
+ while (i != m_segment->end()) {
+
+ Segment::iterator j = i;
+ ++j;
+
+ if ((*i)->isa(Text::EventType)) {
+ std::string textType;
+ if ((*i)->get<String>(Text::TextTypePropertyName, textType) &&
+ textType == Text::Lyric) {
+ long verse = 0;
+ (*i)->get<Int>(Text::LyricVersePropertyName, verse);
+ if (verse == m_verse) {
+ m_segment->erase(i);
+ }
+ }
+ }
+
+ i = j;
+ }
+
+ // Now restore the old ones and clear out the vector.
+
+ for (std::vector<Event *>::iterator i = m_oldLyricEvents.begin();
+ i != m_oldLyricEvents.end(); ++i) {
+ m_segment->insert(*i);
+ }
+
+ m_oldLyricEvents.clear();
+}
+
+}
diff --git a/src/commands/edit/SetLyricsCommand.h b/src/commands/edit/SetLyricsCommand.h
new file mode 100644
index 0000000..499f12a
--- /dev/null
+++ b/src/commands/edit/SetLyricsCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SETLYRICSCOMMAND_H_
+#define _RG_SETLYRICSCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class SetLyricsCommand : public KNamedCommand
+{
+public:
+ SetLyricsCommand(Segment *segment, int verse, QString newLyricData);
+ ~SetLyricsCommand();
+
+ static QString getGlobalName() { return i18n("Edit L&yrics"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Segment *m_segment;
+ int m_verse;
+ std::vector<Event *> m_oldLyricEvents;
+ QString m_newLyricData;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/SetNoteTypeCommand.cpp b/src/commands/edit/SetNoteTypeCommand.cpp
new file mode 100644
index 0000000..4dc97b1
--- /dev/null
+++ b/src/commands/edit/SetNoteTypeCommand.cpp
@@ -0,0 +1,87 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SetNoteTypeCommand.h"
+
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+SetNoteTypeCommand::modifySegment()
+{
+ std::vector<Event *> toErase;
+ std::vector<Event *> toInsert;
+
+ EventSelection::eventcontainer::iterator i;
+ timeT endTime = getEndTime();
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ toErase.push_back(*i);
+
+ Event *e;
+ if (m_notationOnly) {
+ e = new Event(**i,
+ (*i)->getAbsoluteTime(),
+ (*i)->getDuration(),
+ (*i)->getSubOrdering(),
+ (*i)->getNotationAbsoluteTime(),
+ Note(m_type).getDuration());
+ } else {
+ e = new Event(**i,
+ (*i)->getNotationAbsoluteTime(),
+ Note(m_type).getDuration());
+ }
+
+ if (e->getNotationAbsoluteTime() + e->getNotationDuration() > endTime) {
+ endTime = e->getNotationAbsoluteTime() + e->getNotationDuration();
+ }
+
+ toInsert.push_back(e);
+ }
+ }
+
+ for (std::vector<Event *>::iterator i = toErase.begin(); i != toErase.end(); ++i) {
+ m_selection->getSegment().eraseSingle(*i);
+ }
+
+ for (std::vector<Event *>::iterator i = toInsert.begin(); i != toInsert.end(); ++i) {
+ m_selection->getSegment().insert(*i);
+ m_selection->addEvent(*i);
+ }
+
+ m_selection->getSegment().normalizeRests(getStartTime(), endTime);
+}
+
+}
diff --git a/src/commands/edit/SetNoteTypeCommand.h b/src/commands/edit/SetNoteTypeCommand.h
new file mode 100644
index 0000000..eec4a4c
--- /dev/null
+++ b/src/commands/edit/SetNoteTypeCommand.h
@@ -0,0 +1,72 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SETNOTETYPECOMMAND_H_
+#define _RG_SETNOTETYPECOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class SetNoteTypeCommand : public BasicSelectionCommand
+{
+public:
+ SetNoteTypeCommand(EventSelection &selection,
+ Note::Type type,
+ bool notationOnly) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection),
+ m_type(type),
+ m_notationOnly(notationOnly)
+ { }
+
+ static QString getGlobalName() {
+ return i18n("&Set Note Type");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ Note::Type m_type;
+ bool m_notationOnly;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/SetTriggerCommand.cpp b/src/commands/edit/SetTriggerCommand.cpp
new file mode 100644
index 0000000..861796e
--- /dev/null
+++ b/src/commands/edit/SetTriggerCommand.cpp
@@ -0,0 +1,74 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SetTriggerCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "base/TriggerSegment.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+using namespace BaseProperties;
+
+void
+SetTriggerCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if (!m_notesOnly || (*i)->isa(Note::EventType)) {
+ (*i)->set
+ <Int>(TRIGGER_SEGMENT_ID, m_triggerSegmentId);
+ (*i)->set
+ <Bool>(TRIGGER_SEGMENT_RETUNE, m_retune);
+ (*i)->set
+ <String>(TRIGGER_SEGMENT_ADJUST_TIMES, m_timeAdjust);
+ if (m_mark != Marks::NoMark) {
+ Marks::addMark(**i, m_mark, true);
+ }
+ }
+ }
+
+ // Update the rec references here, without bothering to do so in unexecute
+ // or in ClearTriggersCommand -- because it doesn't matter if a trigger
+ // has references to segments that don't actually trigger it, whereas it
+ // does matter if it loses a reference to something that does
+
+ TriggerSegmentRec *rec =
+ m_selection->getSegment().getComposition()->getTriggerSegmentRec
+ (m_triggerSegmentId);
+
+ if (rec)
+ rec->updateReferences();
+}
+
+}
diff --git a/src/commands/edit/SetTriggerCommand.h b/src/commands/edit/SetTriggerCommand.h
new file mode 100644
index 0000000..579bb61
--- /dev/null
+++ b/src/commands/edit/SetTriggerCommand.h
@@ -0,0 +1,83 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SETTRIGGERCOMMAND_H_
+#define _RG_SETTRIGGERCOMMAND_H_
+
+#include "base/TriggerSegment.h"
+#include "document/BasicSelectionCommand.h"
+#include <string>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class SetTriggerCommand : public BasicSelectionCommand
+{
+public:
+ SetTriggerCommand(EventSelection &selection,
+ TriggerSegmentId triggerSegmentId,
+ bool notesOnly,
+ bool retune,
+ std::string timeAdjust,
+ Mark mark,
+ QString name = 0) :
+ BasicSelectionCommand(name ? name : getGlobalName(), selection, true),
+ m_selection(&selection),
+ m_triggerSegmentId(triggerSegmentId),
+ m_notesOnly(notesOnly),
+ m_retune(retune),
+ m_timeAdjust(timeAdjust),
+ m_mark(mark)
+ { }
+
+ static QString getGlobalName() {
+ return i18n("Tri&gger Segment");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ TriggerSegmentId m_triggerSegmentId;
+ bool m_notesOnly;
+ bool m_retune;
+ std::string m_timeAdjust;
+ Mark m_mark;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/edit/TransposeCommand.cpp b/src/commands/edit/TransposeCommand.cpp
new file mode 100644
index 0000000..4d08079
--- /dev/null
+++ b/src/commands/edit/TransposeCommand.cpp
@@ -0,0 +1,83 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "TransposeCommand.h"
+
+#include <iostream>
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+using namespace Accidentals;
+
+void
+TransposeCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+
+ if (m_diatonic)
+ {
+
+ Pitch oldPitch(**i);
+
+ timeT noteTime = (*i)->getAbsoluteTime();
+ Key key = m_selection->getSegment().getKeyAtTime(noteTime);
+ Pitch newPitch = oldPitch.transpose(key, m_semitones, m_steps);
+ Event * newNoteEvent = newPitch.getAsNoteEvent(0, 0);
+ Accidental newAccidental;
+ newNoteEvent->get<String>(BaseProperties::ACCIDENTAL, newAccidental);
+
+ (*i)->set<Int>(PITCH, newPitch.getPerformancePitch());
+ (*i)->set<String>(ACCIDENTAL, newAccidental);
+ }
+ else
+ {
+ try {
+ long pitch = (*i)->get<Int>(PITCH);
+ pitch += m_semitones;
+ (*i)->set<Int>(PITCH, pitch);
+ if ((m_semitones % 12) != 0) {
+ (*i)->unset(ACCIDENTAL);
+ }
+ } catch (...) { }
+ }
+
+ }
+ }
+}
+
+}
diff --git a/src/commands/edit/TransposeCommand.h b/src/commands/edit/TransposeCommand.h
new file mode 100644
index 0000000..764f72b
--- /dev/null
+++ b/src/commands/edit/TransposeCommand.h
@@ -0,0 +1,83 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_TRANSPOSECOMMAND_H_
+#define _RG_TRANSPOSECOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class TransposeCommand : public BasicSelectionCommand
+{
+public:
+ TransposeCommand(int semitones, EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(semitones), selection, true),
+ m_selection(&selection), m_semitones(semitones), m_diatonic(false) { }
+
+ TransposeCommand(int semitones, int steps, EventSelection &selection) :
+ BasicSelectionCommand(getDiatonicGlobalName(semitones, steps), selection, true),
+ m_selection(&selection), m_semitones(semitones), m_steps(steps), m_diatonic(true) { }
+
+ static QString getDiatonicGlobalName(int semitones = 0, int step = 0) {
+ switch (semitones) {
+ default: return i18n("Transpose by &Interval...");
+ }
+ }
+
+ static QString getGlobalName(int semitones = 0) {
+ switch (semitones) {
+ case 1: return i18n("&Up a Semitone");
+ case -1: return i18n("&Down a Semitone");
+ case 12: return i18n("Up an &Octave");
+ case -12: return i18n("Down an Octa&ve");
+ default: return i18n("&Transpose by Semitones...");
+ }
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ int m_semitones;
+ int m_steps;
+ bool m_diatonic;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/matrix/MatrixEraseCommand.cpp b/src/commands/matrix/MatrixEraseCommand.cpp
new file mode 100644
index 0000000..c35259e
--- /dev/null
+++ b/src/commands/matrix/MatrixEraseCommand.cpp
@@ -0,0 +1,70 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MatrixEraseCommand.h"
+
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentMatrixHelper.h"
+#include "document/BasicCommand.h"
+
+
+namespace Rosegarden
+{
+
+MatrixEraseCommand::MatrixEraseCommand(Segment &segment,
+ Event *event) :
+ BasicCommand(i18n("Erase Note"),
+ segment,
+ event->getAbsoluteTime(),
+ event->getAbsoluteTime() + event->getDuration(),
+ true),
+ m_event(event),
+ m_relayoutEndTime(getEndTime())
+{
+ // nothing
+}
+
+timeT MatrixEraseCommand::getRelayoutEndTime()
+{
+ return m_relayoutEndTime;
+}
+
+void MatrixEraseCommand::modifySegment()
+{
+ SegmentMatrixHelper helper(getSegment());
+
+ std::string eventType = m_event->getType();
+
+ if (eventType == Note::EventType) {
+
+ helper.deleteNote(m_event, false);
+
+ }
+}
+
+}
diff --git a/src/commands/matrix/MatrixEraseCommand.h b/src/commands/matrix/MatrixEraseCommand.h
new file mode 100644
index 0000000..244c0f9
--- /dev/null
+++ b/src/commands/matrix/MatrixEraseCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MATRIXERASECOMMAND_H_
+#define _RG_MATRIXERASECOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class MatrixEraseCommand : public BasicCommand
+{
+public:
+ MatrixEraseCommand(Segment &segment,
+ Event *event);
+
+ virtual timeT getRelayoutEndTime();
+
+protected:
+ virtual void modifySegment();
+
+ Event *m_event; // only used on 1st execute (cf bruteForceRedo)
+ timeT m_relayoutEndTime;
+};
+
+//------------------------------
+
+
+}
+
+#endif
diff --git a/src/commands/matrix/MatrixInsertionCommand.cpp b/src/commands/matrix/MatrixInsertionCommand.cpp
new file mode 100644
index 0000000..5b03d1a
--- /dev/null
+++ b/src/commands/matrix/MatrixInsertionCommand.cpp
@@ -0,0 +1,74 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MatrixInsertionCommand.h"
+
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/Segment.h"
+#include "base/SegmentMatrixHelper.h"
+#include "document/BasicCommand.h"
+#include "base/BaseProperties.h"
+#include "misc/Debug.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+MatrixInsertionCommand::MatrixInsertionCommand(Segment &segment,
+ timeT time,
+ timeT endTime,
+ Event *event) :
+ BasicCommand(i18n("Insert Note"), segment, time, endTime),
+ m_event(new Event(*event,
+ std::min(time, endTime),
+ (time < endTime) ? endTime - time : time - endTime))
+{
+ // nothing
+}
+
+MatrixInsertionCommand::~MatrixInsertionCommand()
+{
+ delete m_event;
+ // don't want to delete m_lastInsertedEvent, it's just an alias
+}
+
+void MatrixInsertionCommand::modifySegment()
+{
+ MATRIX_DEBUG << "MatrixInsertionCommand::modifySegment()\n";
+
+ if (!m_event->has(VELOCITY)) {
+ m_event->set
+ <Int>(VELOCITY, 100);
+ }
+
+ SegmentMatrixHelper helper(getSegment());
+ m_lastInsertedEvent = new Event(*m_event);
+ helper.insertNote(m_lastInsertedEvent);
+}
+
+}
diff --git a/src/commands/matrix/MatrixInsertionCommand.h b/src/commands/matrix/MatrixInsertionCommand.h
new file mode 100644
index 0000000..bca8e0a
--- /dev/null
+++ b/src/commands/matrix/MatrixInsertionCommand.h
@@ -0,0 +1,64 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MATRIXINSERTIONCOMMAND_H_
+#define _RG_MATRIXINSERTIONCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class MatrixInsertionCommand : public BasicCommand
+{
+public:
+ MatrixInsertionCommand(Segment &segment,
+ timeT time,
+ timeT endTime,
+ Event *event);
+
+ virtual ~MatrixInsertionCommand();
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ Event *m_event;
+ Event *m_lastInsertedEvent; // an alias for another event
+};
+
+
+}
+
+#endif
diff --git a/src/commands/matrix/MatrixModifyCommand.cpp b/src/commands/matrix/MatrixModifyCommand.cpp
new file mode 100644
index 0000000..b78d6f3
--- /dev/null
+++ b/src/commands/matrix/MatrixModifyCommand.cpp
@@ -0,0 +1,81 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MatrixModifyCommand.h"
+
+#include "base/Event.h"
+#include <klocale.h>
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "document/BasicCommand.h"
+
+
+namespace Rosegarden
+{
+
+MatrixModifyCommand::MatrixModifyCommand(Segment &segment,
+ Event *oldEvent,
+ Event *newEvent,
+ bool isMove,
+ bool normalize):
+ BasicCommand((isMove ? i18n("Move Note") : i18n("Modify Note")),
+ segment,
+ std::min(newEvent->getAbsoluteTime(),
+ oldEvent->getAbsoluteTime()),
+ std::max(oldEvent->getAbsoluteTime() +
+ oldEvent->getDuration(),
+ newEvent->getAbsoluteTime() +
+ newEvent->getDuration()),
+ true),
+ m_normalize(normalize),
+ m_oldEvent(oldEvent),
+ m_newEvent(newEvent)
+{}
+
+void MatrixModifyCommand::modifySegment()
+{
+ std::string eventType = m_oldEvent->getType();
+
+ if (eventType == Note::EventType) {
+
+ timeT normalizeStart = std::min(m_newEvent->getAbsoluteTime(),
+ m_oldEvent->getAbsoluteTime());
+
+ timeT normalizeEnd = std::max(m_newEvent->getAbsoluteTime() +
+ m_newEvent->getDuration(),
+ m_oldEvent->getAbsoluteTime() +
+ m_oldEvent->getDuration());
+
+ Segment &segment(getSegment());
+ segment.insert(m_newEvent);
+ segment.eraseSingle(m_oldEvent);
+
+ if (m_normalize) {
+ segment.normalizeRests(normalizeStart, normalizeEnd);
+ }
+ }
+}
+
+}
diff --git a/src/commands/matrix/MatrixModifyCommand.h b/src/commands/matrix/MatrixModifyCommand.h
new file mode 100644
index 0000000..df9bdc0
--- /dev/null
+++ b/src/commands/matrix/MatrixModifyCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MATRIXMODIFYCOMMAND_H_
+#define _RG_MATRIXMODIFYCOMMAND_H_
+
+#include "document/BasicCommand.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class MatrixModifyCommand : public BasicCommand
+{
+public:
+ MatrixModifyCommand(Segment &segment,
+ Event *oldEvent,
+ Event *newEvent,
+ bool isMove,
+ bool normalize);
+
+protected:
+ virtual void modifySegment();
+
+ bool m_normalize;
+
+ Event *m_oldEvent;
+ Event *m_newEvent;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/matrix/MatrixPercussionInsertionCommand.cpp b/src/commands/matrix/MatrixPercussionInsertionCommand.cpp
new file mode 100644
index 0000000..513663d
--- /dev/null
+++ b/src/commands/matrix/MatrixPercussionInsertionCommand.cpp
@@ -0,0 +1,192 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MatrixPercussionInsertionCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentMatrixHelper.h"
+#include "document/BasicCommand.h"
+#include "base/BaseProperties.h"
+#include "misc/Debug.h"
+
+
+namespace Rosegarden
+{
+using namespace BaseProperties;
+
+
+MatrixPercussionInsertionCommand::MatrixPercussionInsertionCommand(Segment &segment,
+ timeT time,
+ Event *event) :
+ BasicCommand(i18n("Insert Percussion Note"), segment,
+ getEffectiveStartTime(segment, time, *event),
+ getEndTime(segment, time, *event)),
+ m_event(0),
+ m_time(time)
+{
+ timeT endTime = getEndTime(segment, time, *event);
+ m_event = new Event(*event, time, endTime - time);
+}
+
+MatrixPercussionInsertionCommand::~MatrixPercussionInsertionCommand()
+{
+ delete m_event;
+ // don't want to delete m_lastInsertedEvent, it's just an alias
+}
+
+void MatrixPercussionInsertionCommand::modifySegment()
+{
+ MATRIX_DEBUG << "MatrixPercussionInsertionCommand::modifySegment()\n";
+
+ if (!m_event->has(VELOCITY)) {
+ m_event->set
+ <Int>(VELOCITY, 100);
+ }
+
+ Segment &s = getSegment();
+
+ Segment::iterator i = s.findTime(m_time);
+
+ int pitch = 0;
+ if (m_event->has(PITCH)) {
+ pitch = m_event->get
+ <Int>(PITCH);
+ }
+
+ while (i != s.begin()) {
+
+ --i;
+
+ if ((*i)->getAbsoluteTime() < m_time &&
+ (*i)->isa(Note::EventType)) {
+
+ if ((*i)->has(PITCH) &&
+ (*i)->get
+ <Int>(PITCH) == pitch) {
+
+ if ((*i)->getAbsoluteTime() + (*i)->getDuration() > m_time) {
+ Event *newPrevious = new Event
+ (**i, (*i)->getAbsoluteTime(), m_time - (*i)->getAbsoluteTime());
+ s.erase(i);
+ i = s.insert(newPrevious);
+ } else {
+ break;
+ }
+ }
+ }
+ }
+
+ SegmentMatrixHelper helper(s);
+ m_lastInsertedEvent = new Event(*m_event);
+ helper.insertNote(m_lastInsertedEvent);
+}
+
+timeT
+MatrixPercussionInsertionCommand::getEffectiveStartTime(Segment &segment,
+ timeT time,
+ Event &event)
+{
+ timeT startTime = time;
+
+ int pitch = 0;
+ if (event.has(PITCH)) {
+ pitch = event.get<Int>(PITCH);
+ }
+
+ Segment::iterator i = segment.findTime(time);
+ while (i != segment.begin()) {
+ --i;
+
+ if ((*i)->has(PITCH) &&
+ (*i)->get
+ <Int>(PITCH) == pitch) {
+
+ if ((*i)->getAbsoluteTime() < time &&
+ (*i)->isa(Note::EventType)) {
+ if ((*i)->getAbsoluteTime() + (*i)->getDuration() > time) {
+ startTime = (*i)->getAbsoluteTime();
+ } else {
+ break;
+ }
+ }
+ }
+ }
+
+ return startTime;
+}
+
+timeT
+MatrixPercussionInsertionCommand::getEndTime(Segment &segment,
+ timeT time,
+ Event &event)
+{
+ timeT endTime =
+ time + Note(Note::Semibreve,
+ 0).getDuration();
+ timeT barEndTime = segment.getBarEndForTime(time);
+ timeT segmentEndTime = segment.getEndMarkerTime();
+
+ if (barEndTime > endTime)
+ endTime = barEndTime;
+ if (endTime > segmentEndTime)
+ endTime = segmentEndTime;
+
+ int pitch = 0;
+ if (event.has(PITCH)) {
+ pitch = event.get<Int>(PITCH);
+ }
+
+ for (Segment::iterator i = segment.findTime(time);
+ segment.isBeforeEndMarker(i); ++i) {
+
+ if ((*i)->has(PITCH) &&
+ (*i)->get
+ <Int>(PITCH) == pitch) {
+
+ if ((*i)->getAbsoluteTime() > time &&
+ (*i)->isa(Note::EventType)) {
+ endTime = (*i)->getAbsoluteTime();
+ }
+ }
+ }
+
+ Composition *comp = segment.getComposition();
+ std::pair<timeT, timeT> barRange =
+ comp->getBarRangeForTime(time);
+ timeT barDuration = barRange.second - barRange.first;
+
+
+ if (endTime > time + barDuration) {
+ endTime = time + barDuration;
+ }
+
+ return endTime;
+}
+
+}
diff --git a/src/commands/matrix/MatrixPercussionInsertionCommand.h b/src/commands/matrix/MatrixPercussionInsertionCommand.h
new file mode 100644
index 0000000..513754d
--- /dev/null
+++ b/src/commands/matrix/MatrixPercussionInsertionCommand.h
@@ -0,0 +1,73 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MATRIXPERCUSSIONINSERTIONCOMMAND_H_
+#define _RG_MATRIXPERCUSSIONINSERTIONCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class MatrixPercussionInsertionCommand : public BasicCommand
+{
+public:
+ MatrixPercussionInsertionCommand(Segment &segment,
+ timeT time,
+ Event *event);
+
+ virtual ~MatrixPercussionInsertionCommand();
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ timeT getEffectiveStartTime(Segment &segment,
+ timeT startTime,
+ Event &event);
+ timeT getEndTime(Segment &segment,
+ timeT endTime,
+ Event &event);
+
+ Event *m_event;
+ timeT m_time;
+ Event *m_lastInsertedEvent; // an alias for another event
+};
+
+//------------------------------
+
+
+}
+
+#endif
diff --git a/src/commands/notation/AddFingeringMarkCommand.cpp b/src/commands/notation/AddFingeringMarkCommand.cpp
new file mode 100644
index 0000000..0c2e895
--- /dev/null
+++ b/src/commands/notation/AddFingeringMarkCommand.cpp
@@ -0,0 +1,119 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddFingeringMarkCommand.h"
+
+#include <klocale.h>
+#include "base/NotationTypes.h"
+#include "base/NotationQuantizer.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "base/Sets.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+QString
+AddFingeringMarkCommand::getGlobalName(QString fingering)
+{
+ if (fingering == "")
+ return i18n("Add Other &Fingering...");
+ else if (fingering == "0")
+ return i18n("Add Fingering &0 (Thumb)");
+ else
+ return i18n("Add Fingering &%1").arg(fingering);
+}
+
+void
+AddFingeringMarkCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+ Segment &segment(m_selection->getSegment());
+
+ std::set
+ <Event *> done;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if (done.find(*i) != done.end())
+ continue;
+ if (!(*i)->isa(Note::EventType))
+ continue;
+
+ // We should do this on a chord-by-chord basis, considering
+ // only those notes in a chord that are also in the selection.
+ // Apply this fingering to the first note in the chord that
+ // does not already have a fingering. If they all already do,
+ // then clear them all and start again.
+
+ Chord chord(segment, segment.findSingle(*i),
+ segment.getComposition()->getNotationQuantizer());
+
+ int attempt = 0;
+
+ while (attempt < 2) {
+
+ int count = 0;
+
+ for (Chord::iterator ci = chord.begin();
+ ci != chord.end(); ++ci) {
+
+ if (!m_selection->contains(**ci))
+ continue;
+
+ if (attempt < 2 &&
+ Marks::getFingeringMark(***ci) ==
+ Marks::NoMark) {
+ Marks::addMark
+ (***ci, Marks::getFingeringMark(m_text), true);
+ attempt = 2;
+ }
+
+ done.insert(**ci);
+ ++count;
+ }
+
+ if (attempt < 2) {
+ if (count == 0)
+ break;
+ for (Chord::iterator ci = chord.begin();
+ ci != chord.end(); ++ci) {
+ if (m_selection->contains(**ci)) {
+ Marks::removeMark
+ (***ci,
+ Marks::getFingeringMark(***ci));
+ }
+ }
+ ++attempt;
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/AddFingeringMarkCommand.h b/src/commands/notation/AddFingeringMarkCommand.h
new file mode 100644
index 0000000..1d95002
--- /dev/null
+++ b/src/commands/notation/AddFingeringMarkCommand.h
@@ -0,0 +1,64 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUADDFINGERINGMARKCOMMAND_H_
+#define _RG_NOTESMENUADDFINGERINGMARKCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <string>
+#include <qstring.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class AddFingeringMarkCommand : public BasicSelectionCommand
+{
+public:
+ AddFingeringMarkCommand(std::string text,
+ EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection), m_text(text) { }
+
+ static QString getGlobalName(QString fingering = "");
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ std::string m_text;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/AddIndicationCommand.cpp b/src/commands/notation/AddIndicationCommand.cpp
new file mode 100644
index 0000000..717463d
--- /dev/null
+++ b/src/commands/notation/AddIndicationCommand.cpp
@@ -0,0 +1,171 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddIndicationCommand.h"
+
+#include <klocale.h>
+#include "misc/Strings.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+AddIndicationCommand::AddIndicationCommand(std::string indicationType,
+ EventSelection &selection) :
+ BasicCommand(getGlobalName(indicationType),
+ selection.getSegment(),
+ selection.getStartTime(),
+ selection.getEndTime()),
+ m_indicationType(indicationType),
+ m_indicationDuration(selection.getEndTime() - selection.getStartTime()),
+ m_lastInsertedEvent(0)
+{
+ // nothing else
+}
+
+AddIndicationCommand::~AddIndicationCommand()
+{
+ // empty
+}
+
+bool
+AddIndicationCommand::canExecute()
+{
+ Segment &s(getSegment());
+
+ for (Segment::iterator i = s.begin(); s.isBeforeEndMarker(i); ++i) {
+
+ if ((*i)->getAbsoluteTime() >= getStartTime() + m_indicationDuration) {
+ return true;
+ }
+
+ if ((*i)->isa(Indication::EventType)) {
+
+ try {
+ Indication indication(**i);
+
+ if ((*i)->getAbsoluteTime() + indication.getIndicationDuration() <=
+ getStartTime())
+ continue;
+
+ std::string type = indication.getIndicationType();
+
+ if (type == m_indicationType) {
+ // for all indications (including slur), we reject an
+ // exact overlap
+ if ((*i)->getAbsoluteTime() == getStartTime() &&
+ indication.getIndicationDuration() == m_indicationDuration) {
+ return false;
+ }
+ } else if (m_indicationType == Indication::Slur) {
+ continue;
+ }
+
+ // for non-slur indications we reject a partial
+ // overlap such as this one, if it's an overlap with
+ // an indication of the same "sort"
+
+ if (m_indicationType == Indication::Crescendo ||
+ m_indicationType == Indication::Decrescendo) {
+ if (type == Indication::Crescendo ||
+ type == Indication::Decrescendo)
+ return false;
+ }
+
+ if (m_indicationType == Indication::QuindicesimaUp ||
+ m_indicationType == Indication::OttavaUp ||
+ m_indicationType == Indication::OttavaDown ||
+ m_indicationType == Indication::QuindicesimaDown) {
+ if (indication.isOttavaType())
+ return false;
+ }
+ } catch (...) {}
+ }
+ }
+
+ return true;
+}
+
+void
+AddIndicationCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+
+ Indication indication(m_indicationType, m_indicationDuration);
+ Event *e = indication.getAsEvent(getStartTime());
+ helper.segment().insert(e);
+ m_lastInsertedEvent = e;
+
+ if (indication.isOttavaType()) {
+ for (Segment::iterator i = getSegment().findTime(getStartTime());
+ i != getSegment().findTime(getStartTime() + m_indicationDuration);
+ ++i) {
+ if ((*i)->isa(Note::EventType)) {
+ (*i)->setMaybe<Int>(NotationProperties::OTTAVA_SHIFT,
+ indication.getOttavaShift());
+ }
+ }
+ }
+}
+
+QString
+AddIndicationCommand::getGlobalName(std::string indicationType)
+{
+ if (indicationType == Indication::Slur) {
+ return i18n("Add S&lur");
+ } else if (indicationType == Indication::PhrasingSlur) {
+ return i18n("Add &Phrasing Slur");
+ } else if (indicationType == Indication::QuindicesimaUp) {
+ return i18n("Add Double-Octave Up");
+ } else if (indicationType == Indication::OttavaUp) {
+ return i18n("Add Octave &Up");
+ } else if (indicationType == Indication::OttavaDown) {
+ return i18n("Add Octave &Down");
+ } else if (indicationType == Indication::QuindicesimaDown) {
+ return i18n("Add Double Octave Down");
+
+ // We used to generate these ones from the internal names plus
+ // caps, but that makes them untranslateable:
+ } else if (indicationType == Indication::Crescendo) {
+ return i18n("Add &Crescendo");
+ } else if (indicationType == Indication::Decrescendo) {
+ return i18n("Add &Decrescendo");
+ } else if (indicationType == Indication::Glissando) {
+ return i18n("Add &Glissando");
+ }
+
+ QString n = i18n("Add &%1%2").arg((char)toupper(indicationType[0])).arg(strtoqstr(indicationType.substr(1)));
+ return n;
+}
+
+}
diff --git a/src/commands/notation/AddIndicationCommand.h b/src/commands/notation/AddIndicationCommand.h
new file mode 100644
index 0000000..c43dc3a
--- /dev/null
+++ b/src/commands/notation/AddIndicationCommand.h
@@ -0,0 +1,76 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUADDINDICATIONCOMMAND_H_
+#define _RG_NOTESMENUADDINDICATIONCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <string>
+#include <qstring.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+class Event;
+
+
+class AddIndicationCommand : public BasicCommand
+{
+public:
+ AddIndicationCommand(std::string indicationType,
+ EventSelection &selection);
+ virtual ~AddIndicationCommand();
+
+ // tests whether the indication can be added without overlapping
+ // another one of the same type
+ bool canExecute();
+
+ Event *getLastInsertedEvent() {
+ return m_lastInsertedEvent;
+ }
+ virtual timeT getRelayoutEndTime() {
+ return getStartTime() + m_indicationDuration;
+ }
+
+ static QString getGlobalName(std::string indicationType);
+
+protected:
+ virtual void modifySegment();
+
+ std::string m_indicationType;
+ timeT m_indicationDuration;
+ Event *m_lastInsertedEvent;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/AddMarkCommand.cpp b/src/commands/notation/AddMarkCommand.cpp
new file mode 100644
index 0000000..5b30431
--- /dev/null
+++ b/src/commands/notation/AddMarkCommand.cpp
@@ -0,0 +1,112 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddMarkCommand.h"
+
+#include <klocale.h>
+#include "misc/Strings.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+QString
+AddMarkCommand::getGlobalName(Mark markType)
+{
+ QString m = strtoqstr(markType);
+
+ // Gosh, lots of collisions
+ if (markType == Marks::Sforzando)
+ m = i18n("S&forzando");
+ else if (markType == Marks::Staccato)
+ m = i18n("Sta&ccato");
+ else if (markType == Marks::Rinforzando)
+ m = i18n("R&inforzando");
+ else if (markType == Marks::Tenuto)
+ m = i18n("T&enuto");
+ else if (markType == Marks::Trill)
+ m = i18n("Tri&ll");
+ else if (markType == Marks::LongTrill)
+ m = i18n("Trill &with Line");
+ else if (markType == Marks::TrillLine)
+ m = i18n("Trill Line");
+ else if (markType == Marks::Turn)
+ m = i18n("&Turn");
+ else if (markType == Marks::Accent)
+ m = i18n("&Accent");
+ else if (markType == Marks::Staccatissimo)
+ m = i18n("&Staccatissimo");
+ else if (markType == Marks::Marcato)
+ m = i18n("&Marcato");
+ else if (markType == Marks::Pause)
+ m = i18n("&Pause");
+ else if (markType == Marks::UpBow)
+ m = i18n("&Up-Bow");
+ else if (markType == Marks::DownBow)
+ m = i18n("&Down-Bow");
+ else if (markType == Marks::Mordent)
+ m = i18n("Mo&rdent");
+ else if (markType == Marks::MordentInverted)
+ m = i18n("Inverted Mordent");
+ else if (markType == Marks::MordentLong)
+ m = i18n("Long Mordent");
+ else if (markType == Marks::MordentLongInverted)
+ m = i18n("Lon&g Inverted Mordent");
+ else
+ m = i18n("&%1%2").arg(m[0].upper()).arg(m.right(m.length() - 1));
+ // FIXME: That last i18n has very little chance of working, unless
+ // by some miracle the exact same string was translated elsewhere already
+ // but we'll leave it as a warning
+
+ m = i18n("Add %1").arg(m);
+ return m;
+}
+
+void
+AddMarkCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ long n = 0;
+ (*i)->get
+ <Int>(MARK_COUNT, n);
+ (*i)->set
+ <Int>(MARK_COUNT, n + 1);
+ (*i)->set
+ <String>(getMarkPropertyName(n),
+ m_mark);
+ }
+}
+
+}
diff --git a/src/commands/notation/AddMarkCommand.h b/src/commands/notation/AddMarkCommand.h
new file mode 100644
index 0000000..5bc36b4
--- /dev/null
+++ b/src/commands/notation/AddMarkCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUADDMARKCOMMAND_H_
+#define _RG_NOTESMENUADDMARKCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class AddMarkCommand : public BasicSelectionCommand
+{
+public:
+ AddMarkCommand(Mark mark,
+ EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(mark), selection, true),
+ m_selection(&selection), m_mark(mark) { }
+
+ static QString getGlobalName(Mark mark);
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ Mark m_mark;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/AddSlashesCommand.cpp b/src/commands/notation/AddSlashesCommand.cpp
new file mode 100644
index 0000000..1e2e5a6
--- /dev/null
+++ b/src/commands/notation/AddSlashesCommand.cpp
@@ -0,0 +1,53 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddSlashesCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+
+
+namespace Rosegarden
+{
+
+void
+AddSlashesCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if (m_number < 1) {
+ (*i)->unset(NotationProperties::SLASHES);
+ } else {
+ (*i)->set
+ <Int>(NotationProperties::SLASHES, m_number);
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/AddSlashesCommand.h b/src/commands/notation/AddSlashesCommand.h
new file mode 100644
index 0000000..4c85cd4
--- /dev/null
+++ b/src/commands/notation/AddSlashesCommand.h
@@ -0,0 +1,60 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUADDSLASHESCOMMAND_H_
+#define _RG_NOTESMENUADDSLASHESCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class AddSlashesCommand : public BasicSelectionCommand
+{
+public:
+ AddSlashesCommand(int number,
+ EventSelection &selection) :
+ BasicSelectionCommand(i18n("Slashes"), selection, true),
+ m_selection(&selection), m_number(number) { }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ int m_number;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/AddTextMarkCommand.cpp b/src/commands/notation/AddTextMarkCommand.cpp
new file mode 100644
index 0000000..d3de487
--- /dev/null
+++ b/src/commands/notation/AddTextMarkCommand.cpp
@@ -0,0 +1,58 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddTextMarkCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+AddTextMarkCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ long n = 0;
+ (*i)->get
+ <Int>(MARK_COUNT, n);
+ (*i)->set
+ <Int>(MARK_COUNT, n + 1);
+ (*i)->set
+ <String>(getMarkPropertyName(n),
+ Marks::getTextMark(m_text));
+ }
+}
+
+}
diff --git a/src/commands/notation/AddTextMarkCommand.h b/src/commands/notation/AddTextMarkCommand.h
new file mode 100644
index 0000000..b4037cc
--- /dev/null
+++ b/src/commands/notation/AddTextMarkCommand.h
@@ -0,0 +1,65 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUADDTEXTMARKCOMMAND_H_
+#define _RG_NOTESMENUADDTEXTMARKCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <string>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class AddTextMarkCommand : public BasicSelectionCommand
+{
+public:
+ AddTextMarkCommand(std::string text,
+ EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection), m_text(text) { }
+
+ static QString getGlobalName() { return i18n("Add Te&xt Mark..."); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ std::string m_text;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/AutoBeamCommand.cpp b/src/commands/notation/AutoBeamCommand.cpp
new file mode 100644
index 0000000..04c243d
--- /dev/null
+++ b/src/commands/notation/AutoBeamCommand.cpp
@@ -0,0 +1,48 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AutoBeamCommand.h"
+
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+AutoBeamCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+ helper.autoBeam(getStartTime(), getEndTime(), GROUP_TYPE_BEAMED);
+}
+
+}
diff --git a/src/commands/notation/AutoBeamCommand.h b/src/commands/notation/AutoBeamCommand.h
new file mode 100644
index 0000000..b26caf1
--- /dev/null
+++ b/src/commands/notation/AutoBeamCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUAUTOBEAMCOMMAND_H_
+#define _RG_NOTESMENUAUTOBEAMCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class EventSelection;
+
+
+class AutoBeamCommand : public BasicSelectionCommand
+{
+public:
+ AutoBeamCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection) { }
+
+ AutoBeamCommand(Segment &segment) :
+ BasicSelectionCommand(getGlobalName(), segment) { }
+
+ static QString getGlobalName() { return i18n("&Auto-Beam"); }
+
+protected:
+ virtual void modifySegment();
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/BeamCommand.cpp b/src/commands/notation/BeamCommand.cpp
new file mode 100644
index 0000000..fb75dcb
--- /dev/null
+++ b/src/commands/notation/BeamCommand.cpp
@@ -0,0 +1,58 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "BeamCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+BeamCommand::modifySegment()
+{
+ int id = getSegment().getNextId();
+
+ for (EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ (*i)->set
+ <Int>(BEAMED_GROUP_ID, id);
+ (*i)->set
+ <String>(BEAMED_GROUP_TYPE, GROUP_TYPE_BEAMED);
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/BeamCommand.h b/src/commands/notation/BeamCommand.h
new file mode 100644
index 0000000..9fd112b
--- /dev/null
+++ b/src/commands/notation/BeamCommand.h
@@ -0,0 +1,60 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUBEAMCOMMAND_H_
+#define _RG_NOTESMENUBEAMCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class BeamCommand : public BasicSelectionCommand
+{
+public:
+ BeamCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Beam Group"); }
+
+protected:
+ virtual void modifySegment();
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/BreakCommand.cpp b/src/commands/notation/BreakCommand.cpp
new file mode 100644
index 0000000..ae74e37
--- /dev/null
+++ b/src/commands/notation/BreakCommand.cpp
@@ -0,0 +1,54 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "BreakCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+BreakCommand::modifySegment()
+{
+ for (EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ (*i)->unset(NotationProperties::BEAMED);
+ (*i)->unset(BEAMED_GROUP_ID);
+ (*i)->unset(BEAMED_GROUP_TYPE);
+ (*i)->clearNonPersistentProperties();
+ }
+}
+
+}
diff --git a/src/commands/notation/BreakCommand.h b/src/commands/notation/BreakCommand.h
new file mode 100644
index 0000000..5c95a33
--- /dev/null
+++ b/src/commands/notation/BreakCommand.h
@@ -0,0 +1,60 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUBREAKCOMMAND_H_
+#define _RG_NOTESMENUBREAKCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class BreakCommand : public BasicSelectionCommand
+{
+public:
+ BreakCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Unbeam"); }
+
+protected:
+ virtual void modifySegment();
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/ChangeSlurPositionCommand.cpp b/src/commands/notation/ChangeSlurPositionCommand.cpp
new file mode 100644
index 0000000..dc2ff0b
--- /dev/null
+++ b/src/commands/notation/ChangeSlurPositionCommand.cpp
@@ -0,0 +1,58 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ChangeSlurPositionCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+ChangeSlurPositionCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Indication::EventType)) {
+ std::string indicationType;
+ if ((*i)->get<String>
+ (Indication::IndicationTypePropertyName, indicationType)
+ && (indicationType == Indication::Slur ||
+ indicationType == Indication::PhrasingSlur)) {
+ (*i)->set<Bool>(NotationProperties::SLUR_ABOVE, m_above);
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/ChangeSlurPositionCommand.h b/src/commands/notation/ChangeSlurPositionCommand.h
new file mode 100644
index 0000000..11c4bce
--- /dev/null
+++ b/src/commands/notation/ChangeSlurPositionCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUCHANGESLURPOSITIONCOMMAND_H_
+#define _RG_ADJUSTMENUCHANGESLURPOSITIONCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+class Slur;
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class ChangeSlurPositionCommand : public BasicSelectionCommand
+{
+public:
+ ChangeSlurPositionCommand(bool above, EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(above), selection, true),
+ m_selection(&selection), m_above(above) { }
+
+ static QString getGlobalName(bool above) {
+ return above ? i18n("Slur &Above") : i18n("Slur &Below");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ bool m_above;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/ChangeStemsCommand.cpp b/src/commands/notation/ChangeStemsCommand.cpp
new file mode 100644
index 0000000..413f9d2
--- /dev/null
+++ b/src/commands/notation/ChangeStemsCommand.cpp
@@ -0,0 +1,53 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ChangeStemsCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+ChangeStemsCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ (*i)->set
+ <Bool>(NotationProperties::STEM_UP, m_up);
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/ChangeStemsCommand.h b/src/commands/notation/ChangeStemsCommand.h
new file mode 100644
index 0000000..40b48bf
--- /dev/null
+++ b/src/commands/notation/ChangeStemsCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUCHANGESTEMSCOMMAND_H_
+#define _RG_ADJUSTMENUCHANGESTEMSCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+class Stems;
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class ChangeStemsCommand : public BasicSelectionCommand
+{
+public:
+ ChangeStemsCommand(bool up, EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(up), selection, true),
+ m_selection(&selection), m_up(up) { }
+
+ static QString getGlobalName(bool up) {
+ return up ? i18n("Stems &Up") : i18n("Stems &Down");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ bool m_up;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/ChangeStyleCommand.cpp b/src/commands/notation/ChangeStyleCommand.cpp
new file mode 100644
index 0000000..f8d5c04
--- /dev/null
+++ b/src/commands/notation/ChangeStyleCommand.cpp
@@ -0,0 +1,66 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ChangeStyleCommand.h"
+
+#include "misc/Strings.h"
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include "gui/editors/notation/NoteStyleFactory.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+QString
+ChangeStyleCommand::getGlobalName(NoteStyleName style)
+{
+ return strtoqstr(style);
+}
+
+void
+ChangeStyleCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ if (m_style == NoteStyleFactory::DefaultStyle) {
+ (*i)->unset(NotationProperties::NOTE_STYLE);
+ } else {
+ (*i)->set
+ <String>
+ (NotationProperties::NOTE_STYLE, m_style);
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/ChangeStyleCommand.h b/src/commands/notation/ChangeStyleCommand.h
new file mode 100644
index 0000000..d5edbab
--- /dev/null
+++ b/src/commands/notation/ChangeStyleCommand.h
@@ -0,0 +1,70 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUCHANGESTYLECOMMAND_H_
+#define _RG_ADJUSTMENUCHANGESTYLECOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NoteStyle.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+class Change;
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class ChangeStyleCommand : public BasicSelectionCommand
+{
+public:
+ ChangeStyleCommand(NoteStyleName style,
+ EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(style), selection, true),
+ m_selection(&selection), m_style(style) { }
+
+ static QString getGlobalName() {
+ return i18n("Change &Note Style");
+ }
+
+ static QString getGlobalName(NoteStyleName style);
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ NoteStyleName m_style;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/ChangeTiePositionCommand.cpp b/src/commands/notation/ChangeTiePositionCommand.cpp
new file mode 100644
index 0000000..42f67e6
--- /dev/null
+++ b/src/commands/notation/ChangeTiePositionCommand.cpp
@@ -0,0 +1,54 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ChangeTiePositionCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "base/BaseProperties.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+ChangeTiePositionCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->has(BaseProperties::TIED_FORWARD) &&
+ (*i)->get<Bool>(BaseProperties::TIED_FORWARD)) {
+ (*i)->set<Bool>(BaseProperties::TIE_IS_ABOVE, m_above);
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/ChangeTiePositionCommand.h b/src/commands/notation/ChangeTiePositionCommand.h
new file mode 100644
index 0000000..c4c58a7
--- /dev/null
+++ b/src/commands/notation/ChangeTiePositionCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUCHANGETIEPOSITIONCOMMAND_H_
+#define _RG_ADJUSTMENUCHANGETIEPOSITIONCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+class ChangeTiePositionCommand : public BasicSelectionCommand
+{
+public:
+ ChangeTiePositionCommand(bool above, EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(above), selection, true),
+ m_selection(&selection), m_above(above) { }
+
+ static QString getGlobalName(bool above) {
+ return above ? i18n("Tie &Above") : i18n("Tie &Below");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ bool m_above;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/ClefInsertionCommand.cpp b/src/commands/notation/ClefInsertionCommand.cpp
new file mode 100644
index 0000000..f21c1b0
--- /dev/null
+++ b/src/commands/notation/ClefInsertionCommand.cpp
@@ -0,0 +1,137 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ClefInsertionCommand.h"
+
+#include <klocale.h>
+#include "misc/Strings.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/BaseProperties.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+ClefInsertionCommand::ClefInsertionCommand(Segment &segment, timeT time,
+ Clef clef,
+ bool shouldChangeOctave,
+ bool shouldTranspose) :
+ BasicCommand(getGlobalName(&clef), segment, time,
+ ((shouldChangeOctave || shouldTranspose) ?
+ segment.getEndTime() : time + 1)),
+ m_clef(clef),
+ m_shouldChangeOctave(shouldChangeOctave),
+ m_shouldTranspose(shouldTranspose),
+ m_lastInsertedEvent(0)
+{
+ // nothing
+}
+
+ClefInsertionCommand::~ClefInsertionCommand()
+{
+ // nothing
+}
+
+QString
+ClefInsertionCommand::getGlobalName(Clef *)
+{
+ /* doesn't handle octave offset -- leave it for now
+ if (clef) {
+ QString name(strtoqstr(clef->getClefType()));
+ name = name.left(1).upper() + name.right(name.length()-1);
+ return i18n("Change to %1 Cle&f...").arg(name);
+ } else {
+ */
+ return i18n("Add Cle&f Change...");
+ /*
+ }
+ */
+}
+
+timeT
+ClefInsertionCommand::getRelayoutEndTime()
+{
+ // Inserting a clef can change the y-coord of every subsequent note
+ return getSegment().getEndTime();
+}
+
+void
+ClefInsertionCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+ Clef oldClef(getSegment().getClefAtTime(getStartTime()));
+
+ Segment::iterator i = getSegment().findTime(getStartTime());
+ while (getSegment().isBeforeEndMarker(i)) {
+ if ((*i)->getAbsoluteTime() > getStartTime()) {
+ break;
+ }
+ if ((*i)->isa(Clef::EventType)) {
+ getSegment().erase(i);
+ break;
+ }
+ ++i;
+ }
+
+ i = helper.insertClef(getStartTime(), m_clef);
+ if (i != helper.segment().end())
+ m_lastInsertedEvent = *i;
+
+ if (m_clef != oldClef) {
+
+ int semitones = 0;
+
+ if (m_shouldChangeOctave) {
+ semitones += 12 * (m_clef.getOctave() - oldClef.getOctave());
+ }
+ if (m_shouldTranspose) {
+ semitones -= m_clef.getPitchOffset() - oldClef.getPitchOffset();
+ }
+
+ if (semitones != 0) {
+ while (i != helper.segment().end()) {
+ if ((*i)->isa(Note::EventType)) {
+ long pitch = 0;
+ if ((*i)->get
+ <Int>(PITCH, pitch)) {
+ pitch += semitones;
+ (*i)->set
+ <Int>(PITCH, pitch);
+ }
+ }
+ ++i;
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/ClefInsertionCommand.h b/src/commands/notation/ClefInsertionCommand.h
new file mode 100644
index 0000000..3e9b940
--- /dev/null
+++ b/src/commands/notation/ClefInsertionCommand.h
@@ -0,0 +1,72 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CLEFINSERTIONCOMMAND_H_
+#define _RG_CLEFINSERTIONCOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class ClefInsertionCommand : public BasicCommand
+{
+public:
+ ClefInsertionCommand(Segment &segment,
+ timeT time,
+ Clef clef,
+ bool shouldChangeOctave = false,
+ bool shouldTranspose = false);
+ virtual ~ClefInsertionCommand();
+
+ static QString getGlobalName(Clef *clef = 0);
+ virtual timeT getRelayoutEndTime();
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ Clef m_clef;
+ bool m_shouldChangeOctave;
+ bool m_shouldTranspose;
+
+ Event *m_lastInsertedEvent;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/CollapseRestsCommand.cpp b/src/commands/notation/CollapseRestsCommand.cpp
new file mode 100644
index 0000000..655b3b6
--- /dev/null
+++ b/src/commands/notation/CollapseRestsCommand.cpp
@@ -0,0 +1,54 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "CollapseRestsCommand.h"
+
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+CollapseRestsCommand::CollapseRestsCommand
+(EventSelection &selection) :
+ BasicCommand(getGlobalName(),
+ selection.getSegment(),
+ selection.getStartTime(),
+ selection.getEndTime())
+{
+ // nothing else
+}
+
+void CollapseRestsCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+ helper.collapseRestsAggressively(getStartTime(), getEndTime());
+}
+
+}
diff --git a/src/commands/notation/CollapseRestsCommand.h b/src/commands/notation/CollapseRestsCommand.h
new file mode 100644
index 0000000..337fe04
--- /dev/null
+++ b/src/commands/notation/CollapseRestsCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUCOLLAPSERESTSCOMMAND_H_
+#define _RG_ADJUSTMENUCOLLAPSERESTSCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class EventSelection;
+
+
+class CollapseRestsCommand : public BasicCommand
+{
+public:
+ CollapseRestsCommand(Segment &s,
+ timeT startTime,
+ timeT endTime) :
+ BasicCommand(getGlobalName(), s, startTime, endTime) { }
+
+ CollapseRestsCommand(EventSelection &selection);
+
+ static QString getGlobalName() { return i18n("&Collapse Rests"); }
+
+protected:
+ virtual void modifySegment();
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/DeCounterpointCommand.cpp b/src/commands/notation/DeCounterpointCommand.cpp
new file mode 100644
index 0000000..1f97476
--- /dev/null
+++ b/src/commands/notation/DeCounterpointCommand.cpp
@@ -0,0 +1,57 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "DeCounterpointCommand.h"
+
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+DeCounterpointCommand::modifySegment()
+{
+ Segment &segment(getSegment());
+ SegmentNotationHelper helper(segment);
+
+ if (m_selection) {
+ EventSelection::RangeTimeList ranges(m_selection->getRangeTimes());
+ for (EventSelection::RangeTimeList::iterator i = ranges.begin();
+ i != ranges.end(); ++i) {
+ helper.deCounterpoint(i->first, i->second);
+ segment.normalizeRests(i->first, i->second);
+ }
+ } else {
+ helper.deCounterpoint(getStartTime(), getEndTime());
+ segment.normalizeRests(getStartTime(), getEndTime());
+ }
+}
+
+}
diff --git a/src/commands/notation/DeCounterpointCommand.h b/src/commands/notation/DeCounterpointCommand.h
new file mode 100644
index 0000000..e0cda37
--- /dev/null
+++ b/src/commands/notation/DeCounterpointCommand.h
@@ -0,0 +1,68 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUDECOUNTERPOINTCOMMAND_H_
+#define _RG_ADJUSTMENUDECOUNTERPOINTCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+class Overlapping;
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class EventSelection;
+
+
+class DeCounterpointCommand : public BasicSelectionCommand
+{
+public:
+ DeCounterpointCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ DeCounterpointCommand(Segment &segment) :
+ BasicSelectionCommand(getGlobalName(), segment, true),
+ m_selection(0) { }
+
+ static QString getGlobalName() { return i18n("Split-and-Tie Overlapping &Chords"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/EraseEventCommand.cpp b/src/commands/notation/EraseEventCommand.cpp
new file mode 100644
index 0000000..e599079
--- /dev/null
+++ b/src/commands/notation/EraseEventCommand.cpp
@@ -0,0 +1,105 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "EraseEventCommand.h"
+
+#include "misc/Strings.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "document/BasicCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+
+
+namespace Rosegarden
+{
+
+EraseEventCommand::EraseEventCommand(Segment &segment,
+ Event *event,
+ bool collapseRest) :
+ BasicCommand(strtoqstr(makeName(event->getType())),
+ segment,
+ event->getAbsoluteTime(),
+ event->getAbsoluteTime() + event->getDuration(),
+ true),
+ m_collapseRest(collapseRest),
+ m_event(event),
+ m_relayoutEndTime(getEndTime())
+{
+ // nothing
+}
+
+EraseEventCommand::~EraseEventCommand()
+{
+ // nothing
+}
+
+std::string
+EraseEventCommand::makeName(std::string e)
+{
+ std::string n = "Erase ";
+ n += (char)toupper(e[0]);
+ n += e.substr(1);
+ return n;
+}
+
+timeT
+EraseEventCommand::getRelayoutEndTime()
+{
+ return m_relayoutEndTime;
+}
+
+void
+EraseEventCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+
+ if (m_event->isa(Clef::EventType) ||
+ m_event->isa(Key ::EventType)) {
+
+ m_relayoutEndTime = helper.segment().getEndTime();
+
+ } else if (m_event->isa(Indication::EventType)) {
+
+ try {
+ Indication indication(*m_event);
+ if (indication.isOttavaType()) {
+
+ for (Segment::iterator i = getSegment().findTime
+ (m_event->getAbsoluteTime());
+ i != getSegment().findTime
+ (m_event->getAbsoluteTime() + indication.getIndicationDuration());
+ ++i) {
+ (*i)->unset(NotationProperties::OTTAVA_SHIFT);
+ }
+ }
+ } catch (...) {}
+ }
+
+ helper.deleteEvent(m_event, m_collapseRest);
+}
+
+}
diff --git a/src/commands/notation/EraseEventCommand.h b/src/commands/notation/EraseEventCommand.h
new file mode 100644
index 0000000..07043fa
--- /dev/null
+++ b/src/commands/notation/EraseEventCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ERASEEVENTCOMMAND_H_
+#define _RG_ERASEEVENTCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <string>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class EraseEventCommand : public BasicCommand
+{
+public:
+ EraseEventCommand(Segment &segment,
+ Event *event,
+ bool collapseRest);
+ virtual ~EraseEventCommand();
+
+ virtual timeT getRelayoutEndTime();
+
+protected:
+ virtual void modifySegment();
+
+ bool m_collapseRest;
+
+ Event *m_event; // only used on 1st execute (cf bruteForceRedo)
+ timeT m_relayoutEndTime;
+ std::string makeName(std::string);
+};
+
+
+
+// Group menu commands
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/FixNotationQuantizeCommand.cpp b/src/commands/notation/FixNotationQuantizeCommand.cpp
new file mode 100644
index 0000000..014d610
--- /dev/null
+++ b/src/commands/notation/FixNotationQuantizeCommand.cpp
@@ -0,0 +1,87 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "FixNotationQuantizeCommand.h"
+
+#include "base/Event.h"
+#include "base/Quantizer.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+FixNotationQuantizeCommand::modifySegment()
+{
+ std::vector<Event *> toErase;
+ std::vector<Event *> toInsert;
+ Segment &segment(m_selection->getSegment());
+
+ EventSelection::eventcontainer::iterator i;
+
+ //!!! the Quantizer needs a fixQuantizedValues(EventSelection*)
+ //method, but it hasn't got one yet so for the moment we're doing
+ //this by hand.
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ timeT ut = (*i)->getAbsoluteTime();
+ timeT ud = (*i)->getDuration();
+ timeT qt = (*i)->getNotationAbsoluteTime();
+ timeT qd = (*i)->getNotationDuration();
+
+ if ((ut != qt) || (ud != qd)) {
+ toErase.push_back(*i);
+ toInsert.push_back(new Event(**i, qt, qd));
+ }
+ }
+
+ for (unsigned int j = 0; j < toErase.size(); ++j) {
+ Segment::iterator jtr(segment.findSingle(toErase[j]));
+ if (jtr != segment.end())
+ segment.erase(jtr);
+ }
+
+ for (unsigned int j = 0; j < toInsert.size(); ++j) {
+ segment.insert(toInsert[j]);
+ }
+
+ /*!!!
+ Segment *segment(&m_selection->getSegment());
+ m_quantizer->fixQuantizedValues
+ (segment,
+ segment->findTime(m_selection->getStartTime()),
+ segment->findTime(m_selection->getEndTime()));
+ */
+
+ //!!! normalizeRests?
+}
+
+}
diff --git a/src/commands/notation/FixNotationQuantizeCommand.h b/src/commands/notation/FixNotationQuantizeCommand.h
new file mode 100644
index 0000000..dfce3e9
--- /dev/null
+++ b/src/commands/notation/FixNotationQuantizeCommand.h
@@ -0,0 +1,61 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUFIXNOTATIONQUANTIZECOMMAND_H_
+#define _RG_ADJUSTMENUFIXNOTATIONQUANTIZECOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class FixNotationQuantizeCommand : public BasicSelectionCommand
+{
+public:
+ FixNotationQuantizeCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("Fi&x Notation Quantization"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/GraceCommand.cpp b/src/commands/notation/GraceCommand.cpp
new file mode 100644
index 0000000..99b8e5a
--- /dev/null
+++ b/src/commands/notation/GraceCommand.cpp
@@ -0,0 +1,115 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "GraceCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "document/BasicCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+/*!!!
+
+GraceCommand::GraceCommand(EventSelection &selection) :
+ BasicCommand(getGlobalName(),
+ selection.getSegment(),
+ selection.getStartTime(),
+ getEffectiveEndTime(selection),
+ true),
+ m_selection(&selection)
+{}
+
+timeT
+GraceCommand::getEffectiveEndTime(EventSelection &
+ selection)
+{
+ EventSelection::eventcontainer::iterator i =
+ selection.getSegmentEvents().end();
+ if (i == selection.getSegmentEvents().begin())
+ return selection.getEndTime();
+ --i;
+
+ Segment::iterator si = selection.getSegment().findTime
+ ((*i)->getAbsoluteTime() + (*i)->getDuration());
+ if (si == selection.getSegment().end())
+ return selection.getEndTime();
+ else
+ return (*si)->getAbsoluteTime() + 1;
+}
+
+void
+GraceCommand::modifySegment()
+{
+ Segment &s(getSegment());
+ timeT startTime = getStartTime();
+ timeT endOfLastGraceNote = startTime;
+ int id = s.getNextId();
+
+ // first turn the selected events into grace notes
+
+ for (EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ (*i)->set<Bool>(IS_GRACE_NOTE, true);
+ (*i)->set<Int>(BEAMED_GROUP_ID, id);
+ (*i)->set<String>(BEAMED_GROUP_TYPE, GROUP_TYPE_GRACE);
+ }
+
+ if ((*i)->getAbsoluteTime() + (*i)->getDuration() >
+ endOfLastGraceNote) {
+ endOfLastGraceNote =
+ (*i)->getAbsoluteTime() + (*i)->getDuration();
+ }
+ }
+
+ // then indicate that the following chord has grace notes
+
+ Segment::iterator i0, i1;
+ s.getTimeSlice(endOfLastGraceNote, i0, i1);
+
+ while (i0 != i1 && i0 != s.end()) {
+ if (!(*i0)->isa(Note::EventType)) {
+ ++i0;
+ continue;
+ }
+ (*i0)->set
+ <Bool>(HAS_GRACE_NOTES, true);
+ ++i0;
+ }
+}
+
+*/
+
+}
diff --git a/src/commands/notation/GraceCommand.h b/src/commands/notation/GraceCommand.h
new file mode 100644
index 0000000..08dcd87
--- /dev/null
+++ b/src/commands/notation/GraceCommand.h
@@ -0,0 +1,60 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUGRACECOMMAND_H_
+#define _RG_ADJUSTMENUGRACECOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+class Make;
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+/*!!!
+class GraceCommand : public BasicCommand
+{
+public:
+ GraceCommand(EventSelection &selection);
+
+ static QString getGlobalName() { return i18n("Make &Grace Notes"); }
+
+protected:
+ virtual void modifySegment();
+ timeT getEffectiveEndTime(EventSelection &);
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+*/
+
+}
+
+#endif
diff --git a/src/commands/notation/GuitarChordInsertionCommand.cpp b/src/commands/notation/GuitarChordInsertionCommand.cpp
new file mode 100644
index 0000000..79e2b44
--- /dev/null
+++ b/src/commands/notation/GuitarChordInsertionCommand.cpp
@@ -0,0 +1,59 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "GuitarChordInsertionCommand.h"
+
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/Segment.h"
+#include "document/BasicCommand.h"
+
+
+namespace Rosegarden
+{
+
+GuitarChordInsertionCommand::GuitarChordInsertionCommand(Segment &segment,
+ timeT time,
+ const Guitar::Chord& chord) :
+ BasicCommand(i18n("Insert Guitar Chord"), segment, time, time + 1, true),
+ m_chord(chord)
+{
+ // nothing
+}
+
+GuitarChordInsertionCommand::~GuitarChordInsertionCommand()
+{}
+
+void
+
+GuitarChordInsertionCommand::modifySegment()
+{
+ Segment::iterator i = getSegment().insert(m_chord.getAsEvent(getStartTime()));
+ if (i != getSegment().end()) {
+ m_lastInsertedEvent = *i;
+ }
+}
+
+}
diff --git a/src/commands/notation/GuitarChordInsertionCommand.h b/src/commands/notation/GuitarChordInsertionCommand.h
new file mode 100644
index 0000000..0a2db02
--- /dev/null
+++ b/src/commands/notation/GuitarChordInsertionCommand.h
@@ -0,0 +1,61 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_GUITARCHORDINSERTIONCOMMAND_H_
+#define _RG_GUITARCHORDINSERTIONCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include "base/Event.h"
+#include "gui/editors/guitar/Chord.h"
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class GuitarChordInsertionCommand : public BasicCommand
+{
+public:
+ GuitarChordInsertionCommand(Segment &segment,
+ timeT time,
+ const Guitar::Chord& chord);
+ virtual ~GuitarChordInsertionCommand();
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ Guitar::Chord m_chord;
+ Event *m_lastInsertedEvent;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/IncrementDisplacementsCommand.cpp b/src/commands/notation/IncrementDisplacementsCommand.cpp
new file mode 100644
index 0000000..2ac44df
--- /dev/null
+++ b/src/commands/notation/IncrementDisplacementsCommand.cpp
@@ -0,0 +1,57 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "IncrementDisplacementsCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+IncrementDisplacementsCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ long prevX = 0, prevY = 0;
+ (*i)->get
+ <Int>(DISPLACED_X, prevX);
+ (*i)->get
+ <Int>(DISPLACED_Y, prevY);
+ (*i)->setMaybe<Int>(DISPLACED_X, prevX + long(m_dx));
+ (*i)->setMaybe<Int>(DISPLACED_Y, prevY + long(m_dy));
+ }
+}
+
+}
diff --git a/src/commands/notation/IncrementDisplacementsCommand.h b/src/commands/notation/IncrementDisplacementsCommand.h
new file mode 100644
index 0000000..4272b6a
--- /dev/null
+++ b/src/commands/notation/IncrementDisplacementsCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_INCREMENTDISPLACEMENTSCOMMAND_H_
+#define _RG_INCREMENTDISPLACEMENTSCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class IncrementDisplacementsCommand : public BasicSelectionCommand
+{
+public:
+ IncrementDisplacementsCommand(EventSelection &selection,
+ long dx, long dy) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection),
+ m_dx(dx),
+ m_dy(dy) { }
+
+ static QString getGlobalName() { return i18n("Fine Reposition"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ long m_dx;
+ long m_dy;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/InterpretCommand.cpp b/src/commands/notation/InterpretCommand.cpp
new file mode 100644
index 0000000..d8a82cd
--- /dev/null
+++ b/src/commands/notation/InterpretCommand.cpp
@@ -0,0 +1,602 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "InterpretCommand.h"
+
+#include "base/Composition.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "misc/Debug.h"
+#include "base/Quantizer.h"
+#include "base/Segment.h"
+#include "base/Sets.h"
+#include "base/BaseProperties.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+const int InterpretCommand::NoInterpretation = 0;
+const int InterpretCommand::GuessDirections = (1<<0);
+const int InterpretCommand::ApplyTextDynamics = (1<<1);
+const int InterpretCommand::ApplyHairpins = (1<<2);
+const int InterpretCommand::StressBeats = (1<<3);
+const int InterpretCommand::Articulate = (1<<4);
+const int InterpretCommand::AllInterpretations= (1<<5) - 1;
+
+InterpretCommand::~InterpretCommand()
+{
+ for (IndicationMap::iterator i = m_indications.begin();
+ i != m_indications.end(); ++i) {
+ delete i->second;
+ }
+}
+
+void
+InterpretCommand::modifySegment()
+{
+ // Of all the interpretations, Articulate is the only one that
+ // changes event times or durations. This means we must apply it
+ // last, as the selection cannot be used after it's been applied,
+ // because the events in the selection will have been recreated
+ // with their new timings.
+
+ // The default velocity for new notes is 100, and the range is
+ // 0-127 (in practice this seems to be roughly logarithmic rather
+ // than linear, though perhaps that's an illusion).
+
+ // We should only apply interpretation to those events actually
+ // selected, but when applying things like hairpins and text
+ // dynamics we need to take into account all dynamics that may
+ // cover our events even if they're not selected or are not within
+ // the time range of the selection at all. So first we'd better
+ // find all the likely indications, starting at (for the sake of
+ // argument) three bars before the start of the selection:
+
+ Segment &segment(getSegment());
+
+ timeT t = m_selection->getStartTime();
+ for (int i = 0; i < 3; ++i)
+ t = segment.getBarStartForTime(t);
+
+ Segment::iterator itr = segment.findTime(t);
+
+ while (itr != segment.end()) {
+ timeT eventTime = (*itr)->getAbsoluteTime();
+ if (eventTime > m_selection->getEndTime())
+ break;
+ if ((*itr)->isa(Indication::EventType)) {
+ m_indications[eventTime] = new Indication(**itr);
+ }
+ ++itr;
+ }
+
+ //!!! need the option of ignoring current velocities or adjusting
+ //them: at the moment ApplyTextDynamics ignores them and the
+ //others adjust them
+
+ if (m_interpretations & GuessDirections)
+ guessDirections();
+ if (m_interpretations & ApplyTextDynamics)
+ applyTextDynamics();
+ if (m_interpretations & ApplyHairpins)
+ applyHairpins();
+ if (m_interpretations & StressBeats)
+ stressBeats();
+ if (m_interpretations & Articulate)
+ articulate();
+
+ //!!! Finally, in future we should extend this to allow
+ // indications on one segment (e.g. top line of piano staff) to
+ // affect another (e.g. bottom line). All together now: "Even
+ // Rosegarden 2.1 could do that!"
+}
+
+void
+InterpretCommand::guessDirections()
+{
+ //...
+}
+
+void
+InterpretCommand::applyTextDynamics()
+{
+ // laborious
+
+ Segment &segment(getSegment());
+ int velocity = 100;
+
+ timeT startTime = m_selection->getStartTime();
+ timeT endTime = m_selection->getEndTime();
+
+ for (Segment::iterator i = segment.begin();
+ segment.isBeforeEndMarker(i); ++i) {
+
+ timeT t = (*i)->getAbsoluteTime();
+
+ if (t > endTime)
+ break;
+
+ if (Text::isTextOfType(*i, Text::Dynamic)) {
+
+ std::string text;
+ if ((*i)->get
+ <String>(Text::TextPropertyName, text)) {
+ velocity = getVelocityForDynamic(text);
+ }
+ }
+
+ if (t >= startTime &&
+ (*i)->isa(Note::EventType) && m_selection->contains(*i)) {
+ (*i)->set
+ <Int>(VELOCITY, velocity);
+ }
+ }
+}
+
+int
+InterpretCommand::getVelocityForDynamic(std::string text)
+{
+ int velocity = 100;
+
+ // should do case-insensitive matching with whitespace
+ // removed. can surely be cleverer about this too!
+
+ if (text == "ppppp")
+ velocity = 10;
+ else if (text == "pppp")
+ velocity = 20;
+ else if (text == "ppp")
+ velocity = 30;
+ else if (text == "pp")
+ velocity = 40;
+ else if (text == "p")
+ velocity = 60;
+ else if (text == "mp")
+ velocity = 80;
+ else if (text == "mf")
+ velocity = 90;
+ else if (text == "f")
+ velocity = 105;
+ else if (text == "ff")
+ velocity = 110;
+ else if (text == "fff")
+ velocity = 115;
+ else if (text == "ffff")
+ velocity = 120;
+ else if (text == "fffff")
+ velocity = 125;
+
+ NOTATION_DEBUG << "InterpretCommand::getVelocityForDynamic: unrecognised dynamic " << text << endl;
+
+ return velocity;
+}
+
+void
+InterpretCommand::applyHairpins()
+{
+ Segment &segment(getSegment());
+ int velocityToApply = -1;
+
+ for (EventSelection::eventcontainer::iterator ecitr =
+ m_selection->getSegmentEvents().begin();
+ ecitr != m_selection->getSegmentEvents().end(); ++ecitr) {
+
+ Event *e = *ecitr;
+ if (Text::isTextOfType(e, Text::Dynamic)) {
+ velocityToApply = -1;
+ }
+ if (!e->isa(Note::EventType))
+ continue;
+ bool crescendo = true;
+
+ IndicationMap::iterator inditr =
+ findEnclosingIndication(e, Indication::Crescendo);
+
+ // we can't be in both crescendo and decrescendo -- at least,
+ // not meaningfully
+
+ if (inditr == m_indications.end()) {
+ inditr = findEnclosingIndication(e, Indication::Decrescendo);
+ if (inditr == m_indications.end()) {
+ if (velocityToApply > 0) {
+ e->set
+ <Int>(VELOCITY, velocityToApply);
+ }
+ continue;
+ }
+ crescendo = false;
+ }
+
+ // The starting velocity for the indication is easy -- it's
+ // just the velocity of the last note at or before the
+ // indication begins that has a velocity
+
+ timeT hairpinStartTime = inditr->first;
+ // ensure we scan all of the events at this time:
+ Segment::iterator itr(segment.findTime(hairpinStartTime + 1));
+ while (itr == segment.end() ||
+ (*itr)->getAbsoluteTime() > hairpinStartTime ||
+ !(*itr)->isa(Note::EventType) ||
+ !(*itr)->has(VELOCITY)) {
+ if (itr == segment.begin()) {
+ itr = segment.end();
+ break;
+ }
+ --itr;
+ }
+
+ long startingVelocity = 100;
+ if (itr != segment.end()) {
+ (*itr)->get
+ <Int>(VELOCITY, startingVelocity);
+ }
+
+ // The ending velocity is harder. If there's a dynamic change
+ // directly after the hairpin, then we want to use that
+ // dynamic's velocity unless it opposes the hairpin's
+ // direction. If there isn't, or it does oppose the hairpin,
+ // we should probably make the degree of change caused by the
+ // hairpin depend on its total duration.
+
+ long endingVelocity = startingVelocity;
+ timeT hairpinEndTime = inditr->first +
+ inditr->second->getIndicationDuration();
+ itr = segment.findTime(hairpinEndTime);
+ while (itr != segment.end()) {
+ if (Text::isTextOfType(*itr, Text::Dynamic)) {
+ std::string text;
+ if ((*itr)->get
+ <String>(Text::TextPropertyName, text)) {
+ endingVelocity = getVelocityForDynamic(text);
+ break;
+ }
+ }
+ if ((*itr)->getAbsoluteTime() >
+ (hairpinEndTime + Note(Note::Crotchet).getDuration()))
+ break;
+ ++itr;
+ }
+
+ if (( crescendo && (endingVelocity < startingVelocity)) ||
+ (!crescendo && (endingVelocity > startingVelocity))) {
+ // we've got it wrong; prefer following the hairpin to
+ // following whatever direction we got the dynamic from
+ endingVelocity = startingVelocity;
+ // and then fall into the next conditional to set up the
+ // velocities
+ }
+
+ if (endingVelocity == startingVelocity) {
+ // calculate an ending velocity based on starting velocity
+ // and hairpin duration (okay, we'll leave that bit for later)
+ endingVelocity = startingVelocity * (crescendo ? 120 : 80) / 100;
+ }
+
+ double proportion =
+ (double(e->getAbsoluteTime() - hairpinStartTime) /
+ double(hairpinEndTime - hairpinStartTime));
+ long velocity =
+ int((endingVelocity - startingVelocity) * proportion +
+ startingVelocity);
+
+ NOTATION_DEBUG << "InterpretCommand::applyHairpins: velocity of note at " << e->getAbsoluteTime() << " is " << velocity << " (" << proportion << " through hairpin from " << startingVelocity << " to " << endingVelocity << ")" << endl;
+ if (velocity < 10)
+ velocity = 10;
+ if (velocity > 127)
+ velocity = 127;
+ e->set
+ <Int>(VELOCITY, velocity);
+ velocityToApply = velocity;
+ }
+}
+
+void
+InterpretCommand::stressBeats()
+{
+ Composition *c = getSegment().getComposition();
+
+ for (EventSelection::eventcontainer::iterator itr =
+ m_selection->getSegmentEvents().begin();
+ itr != m_selection->getSegmentEvents().end(); ++itr) {
+
+ Event *e = *itr;
+ if (!e->isa(Note::EventType))
+ continue;
+
+ timeT t = e->getNotationAbsoluteTime();
+ TimeSignature timeSig = c->getTimeSignatureAt(t);
+ timeT barStart = getSegment().getBarStartForTime(t);
+ int stress = timeSig.getEmphasisForTime(t - barStart);
+
+ // stresses are from 0 to 4, so we add 12% to the velocity
+ // at the maximum stress, subtract 4% at the minimum
+ int velocityChange = stress * 4 - 4;
+
+ // do this even if velocityChange == 0, in case the event
+ // has no velocity yet
+ long velocity = 100;
+ e->get
+ <Int>(VELOCITY, velocity);
+ velocity += velocity * velocityChange / 100;
+ if (velocity < 10)
+ velocity = 10;
+ if (velocity > 127)
+ velocity = 127;
+ e->set
+ <Int>(VELOCITY, velocity);
+ }
+}
+
+void
+InterpretCommand::articulate()
+{
+ // Basic articulations:
+ //
+ // -- Anything marked tenuto or within a slur gets 100% of its
+ // nominal duration (that's what we need the quantizer for,
+ // to get the display nominal duration), and its velocity
+ // is unchanged.
+ //
+ // -- Anything marked marcato gets 60%, or 70% if slurred (!),
+ // and gets an extra 15% of velocity.
+ //
+ // -- Anything marked staccato gets 55%, or 70% if slurred,
+ // and unchanged velocity.
+ //
+ // -- Anything marked staccatissimo gets 30%, or 50% if slurred (!),
+ // and loses 5% of velocity.
+ //
+ // -- Anything marked sforzando gains 35% of velocity.
+ //
+ // -- Anything marked with an accent gains 30% of velocity.
+ //
+ // -- Anything marked rinforzando gains 15% of velocity and has
+ // its full duration. Guess we really need to use some proper
+ // controllers here.
+ //
+ // -- Anything marked down-bow gains 5% of velocity, anything
+ // marked up-bow loses 5%.
+ //
+ // -- Anything unmarked and unslurred, or marked tenuto and
+ // slurred, gets 90% of duration.
+
+ std::set
+ <Event *> toErase;
+ std::set
+ <Event *> toInsert;
+ Segment &segment(getSegment());
+
+ for (EventSelection::eventcontainer::iterator ecitr =
+ m_selection->getSegmentEvents().begin();
+ ecitr != m_selection->getSegmentEvents().end(); ++ecitr) {
+
+ Event *e = *ecitr;
+ if (!e->isa(Note::EventType))
+ continue;
+ Segment::iterator itr = segment.findSingle(e);
+ Chord chord(segment, itr, m_quantizer);
+
+ // the things that affect duration
+ bool staccato = false;
+ bool staccatissimo = false;
+ bool marcato = false;
+ bool tenuto = false;
+ bool rinforzando = false;
+ bool slurred = false;
+
+ int velocityChange = 0;
+
+ std::vector<Mark> marks(chord.getMarksForChord());
+
+ for (std::vector<Mark>::iterator i = marks.begin();
+ i != marks.end(); ++i) {
+
+ if (*i == Marks::Accent) {
+ velocityChange += 30;
+ } else if (*i == Marks::Tenuto) {
+ tenuto = true;
+ } else if (*i == Marks::Staccato) {
+ staccato = true;
+ } else if (*i == Marks::Staccatissimo) {
+ staccatissimo = true;
+ velocityChange -= 5;
+ } else if (*i == Marks::Marcato) {
+ marcato = true;
+ velocityChange += 15;
+ } else if (*i == Marks::Sforzando) {
+ velocityChange += 35;
+ } else if (*i == Marks::Rinforzando) {
+ rinforzando = true;
+ velocityChange += 15;
+ } else if (*i == Marks::DownBow) {
+ velocityChange += 5;
+ } else if (*i == Marks::UpBow) {
+ velocityChange -= 5;
+ }
+ }
+
+ IndicationMap::iterator inditr =
+ findEnclosingIndication(e, Indication::Slur);
+
+ if (inditr != m_indications.end())
+ slurred = true;
+ if (slurred) {
+ // last note in a slur should be treated as if unslurred
+ timeT slurEnd =
+ inditr->first + inditr->second->getIndicationDuration();
+ if (slurEnd == e->getNotationAbsoluteTime() + e->getNotationDuration() ||
+ slurEnd == e->getAbsoluteTime() + e->getDuration()) {
+ slurred = false;
+ }
+ /*!!!
+ Segment::iterator slurEndItr = segment.findTime(slurEnd);
+ if (slurEndItr != segment.end() &&
+ (*slurEndItr)->getNotationAbsoluteTime() <=
+ e->getNotationAbsoluteTime()) {
+ slurred = false;
+ }
+ */
+ }
+
+ int durationChange = 0;
+
+ if (slurred) {
+ //!!! doesn't seem to be picking up slurs correctly
+ if (tenuto)
+ durationChange = -10;
+ else if (marcato || staccato)
+ durationChange = -30;
+ else if (staccatissimo)
+ durationChange = -50;
+ else
+ durationChange = 0;
+ } else {
+ if (tenuto)
+ durationChange = 0;
+ else if (marcato)
+ durationChange = -40;
+ else if (staccato)
+ durationChange = -45;
+ else if (staccatissimo)
+ durationChange = -70;
+ else if (rinforzando)
+ durationChange = 0;
+ else
+ durationChange = -10;
+ }
+
+ NOTATION_DEBUG << "InterpretCommand::modifySegment: chord has " << chord.size() << " notes in it" << endl;
+
+ for (Chord::iterator ci = chord.begin();
+ ci != chord.end(); ++ci) {
+
+ e = **ci;
+
+ NOTATION_DEBUG << "InterpretCommand::modifySegment: For note at " << e->getAbsoluteTime() << ", velocityChange is " << velocityChange << " and durationChange is " << durationChange << endl;
+
+ // do this even if velocityChange == 0, in case the event
+ // has no velocity yet
+ long velocity = 100;
+ e->get
+ <Int>(VELOCITY, velocity);
+ velocity += velocity * velocityChange / 100;
+ if (velocity < 10)
+ velocity = 10;
+ if (velocity > 127)
+ velocity = 127;
+ e->set
+ <Int>(VELOCITY, velocity);
+
+ timeT duration = e->getNotationDuration();
+
+ // don't mess with the duration of a tied note
+ bool tiedForward = false;
+ if (e->get
+ <Bool>(TIED_FORWARD, tiedForward) && tiedForward) {
+ durationChange = 0;
+ }
+
+ timeT newDuration = duration + duration * durationChange / 100;
+
+ // this comparison instead of "durationChange != 0"
+ // because we want to permit the possibility of resetting
+ // the performance duration of a note (that's perhaps been
+ // articulated wrongly) based on the notation duration:
+
+ if (e->getDuration() != newDuration) {
+
+ if (toErase.find(e) == toErase.end()) {
+
+ //!!! deal with tuplets
+
+ Event *newEvent = new Event(*e,
+ e->getAbsoluteTime(),
+ newDuration,
+ e->getSubOrdering(),
+ e->getNotationAbsoluteTime(),
+ duration);
+ toInsert.insert(newEvent);
+ toErase.insert(e);
+ }
+ }
+ }
+
+ // what we want to do here is jump our iterator to the final
+ // element in the chord -- but that doesn't work because we're
+ // iterating through the selection, not the segment. So for
+ // now we just accept the fact that notes in chords might be
+ // processed multiple times (slow) and added into the toErase
+ // set more than once (hence the nasty tests in the loop just
+ // after the close of this loop).
+ }
+
+ for (std::set
+ <Event *>::iterator j = toErase.begin(); j != toErase.end(); ++j) {
+ Segment::iterator jtr(segment.findSingle(*j));
+ if (jtr != segment.end())
+ segment.erase(jtr);
+ }
+
+ for (std::set
+ <Event *>::iterator j = toInsert.begin(); j != toInsert.end(); ++j) {
+ segment.insert(*j);
+ }
+}
+
+InterpretCommand::IndicationMap::iterator
+
+InterpretCommand::findEnclosingIndication(Event *e,
+ std::string type)
+{
+ // a bit slow, but let's wait and see whether it's a bottleneck
+ // before we worry about that
+
+ timeT t = e->getAbsoluteTime();
+ IndicationMap::iterator itr = m_indications.lower_bound(t);
+
+ while (1) {
+ if (itr != m_indications.end()) {
+
+ if (itr->second->getIndicationType() == type &&
+ itr->first <= t &&
+ itr->first + itr->second->getIndicationDuration() > t) {
+ return itr;
+ }
+ }
+ if (itr == m_indications.begin())
+ break;
+ --itr;
+ }
+
+ return m_indications.end();
+}
+
+}
diff --git a/src/commands/notation/InterpretCommand.h b/src/commands/notation/InterpretCommand.h
new file mode 100644
index 0000000..e1ace8f
--- /dev/null
+++ b/src/commands/notation/InterpretCommand.h
@@ -0,0 +1,100 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUINTERPRETCOMMAND_H_
+#define _RG_ADJUSTMENUINTERPRETCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <map>
+#include <string>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Quantizer;
+class Indication;
+class EventSelection;
+class Event;
+
+
+class InterpretCommand : public BasicSelectionCommand
+{
+public:
+ // bit masks: pass an OR of these to the constructor
+ static const int NoInterpretation;
+ static const int GuessDirections; // allegro, rit, pause &c: kinda bogus
+ static const int ApplyTextDynamics; // mp, ff
+ static const int ApplyHairpins; // self-evident
+ static const int StressBeats; // stress bar/beat boundaries
+ static const int Articulate; // slurs, marks, legato etc
+ static const int AllInterpretations; // all of the above
+
+ InterpretCommand(EventSelection &selection,
+ const Quantizer *quantizer,
+ int interpretations) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection),
+ m_quantizer(quantizer),
+ m_interpretations(interpretations) { }
+
+ virtual ~InterpretCommand();
+
+ static QString getGlobalName() { return i18n("&Interpret..."); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ const Quantizer *m_quantizer;
+ int m_interpretations;
+
+ typedef std::map<timeT,
+ Indication *> IndicationMap;
+ IndicationMap m_indications;
+
+ void guessDirections();
+ void applyTextDynamics();
+ void applyHairpins();
+ void stressBeats();
+ void articulate(); // must be applied last
+
+ // test if the event is within an indication of the given type, return
+ // an iterator pointing to that indication if so
+ IndicationMap::iterator findEnclosingIndication(Event *,
+ std::string type);
+ int getVelocityForDynamic(std::string dynamic);
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/KeyInsertionCommand.cpp b/src/commands/notation/KeyInsertionCommand.cpp
new file mode 100644
index 0000000..39b87e2
--- /dev/null
+++ b/src/commands/notation/KeyInsertionCommand.cpp
@@ -0,0 +1,264 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "KeyInsertionCommand.h"
+
+#include "misc/Debug.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Studio.h"
+#include "document/BasicCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+
+KeyInsertionCommand::KeyInsertionCommand(Segment &segment, timeT time,
+ Key key,
+ bool convert,
+ bool transpose,
+ bool transposeKey,
+ bool ignorePercussion) :
+ BasicCommand(getGlobalName(&key), segment, time, segment.getEndTime()),
+ m_key(key),
+ m_lastInsertedEvent(0),
+ m_convert(convert),
+ m_transpose(transpose),
+ m_transposeKey(transposeKey),
+ m_ignorePercussion(ignorePercussion)
+
+{
+ // nothing
+}
+
+KeyInsertionCommand::~KeyInsertionCommand()
+{
+ // nothing
+}
+
+void
+KeyInsertionCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+ Key oldKey;
+
+ if (m_convert || m_transpose) {
+ oldKey = getSegment().getKeyAtTime(getStartTime());
+ }
+
+ Segment::iterator i = getSegment().findTime(getStartTime());
+ while (getSegment().isBeforeEndMarker(i)) {
+ if ((*i)->getAbsoluteTime() > getStartTime()) {
+ break;
+ }
+ if ((*i)->isa(Key::EventType)) {
+ getSegment().erase(i);
+ break;
+ }
+ ++i;
+ }
+
+ // transpose if desired, according to new dialog option
+ if (m_transposeKey) {
+ // we don't really care about major/minor for this, so pass it through
+ // from the original key
+ bool keyIsMinor = m_key.isMinor();
+
+ // get whether the original key is flat or sharp, so we know what to
+ // prefer for the new key
+ bool keyIsSharp = m_key.isSharp();
+
+ // get the tonic pitch of the user-specified key, reported as a 0-11 int, then
+ // add an extra octave to it to avoid winding up with negative numbers
+ // (the octave will be stripped back off)
+ int specifiedKeyTonic = m_key.getTonicPitch() + 12;
+
+ // get the transpose factor for the segment we're working on
+ int segTranspose = getSegment().getTranspose();
+
+ // subtract the transpose factor from the tonic pitch of the
+ // user-specified key, because we want to move in the opposite
+ // direction for notation (eg. notation is in C major concert, at Bb
+ // transposition, we have -2 from the segment, and want to go +2 for
+ // the key, from tonic pitch 0 (C) to tonic pitch 2 (D) for the key as
+ // written for a Bb instrument
+ //
+ // sanity check: 0 == C; 0 + 12 == 12; (12 - -2) % 12 == 2; 2 == D
+ int transposedKeyTonic = (specifiedKeyTonic - segTranspose) % 12;
+
+ // create a new key with the new tonic pitch, and major/minor from the
+ // original key
+ std::string newKeyName = "";
+
+ switch (transposedKeyTonic) {
+ // 0 C | 1 C# | 2 D | 3 D# | 4 E | 5 F | 6 F# | 7 G | 8 G# | 9 A | 10 A# | 11 B
+ case 0 : // C
+ newKeyName = "C";
+ break;
+ case 2 : // D
+ newKeyName = "D";
+ break;
+ case 4 : // E
+ newKeyName = "E";
+ break;
+ case 5 : // F
+ newKeyName = "F";
+ break;
+ case 7 : // G
+ newKeyName = "G";
+ break;
+ case 9 : // A
+ newKeyName = "A";
+ break;
+ case 11: // B
+ newKeyName = "B";
+ break;
+ // the glorious, glorious black keys need special treatment
+ // again, so we pick flat or sharp spellings based on the
+ // condition of the original, user-specified key we're
+ // transposing
+ case 1 : // C#/Db
+ newKeyName = (keyIsSharp ? "C#" : "Db");
+ break;
+ case 3 : // D#/Eb
+ newKeyName = (keyIsSharp ? "D#" : "Eb");
+ break;
+ case 6 : // F#/Gb
+ newKeyName = (keyIsSharp ? "F#" : "Gb");
+ break;
+ case 8 : // G#/Ab
+ newKeyName = (keyIsSharp ? "G#" : "Ab");
+ break;
+ case 10: // A#/Bb
+ newKeyName = (keyIsSharp ? "A#" : "Bb");
+ break;
+ default:
+ // if this fails, we won't have a valid key name, and
+ // there will be some crashing exception I don't know how
+ // to intercept and avoid, so I'm doing this lame failsafe
+ // instead, which should never, ever actually run under
+ // any conceivable cirumstance anyway
+ RG_DEBUG << "KeyInsertionCommand: by the pricking of my thumbs, something wicked this way comes. :("
+ << endl;
+ return ;
+ }
+
+ newKeyName += (keyIsMinor ? " minor" : " major");
+
+ //for f in C# D# E# F# G# A# B# Cb Db Eb Fb Gb Ab Bb;do grep "$f
+ //major" NotationTypes.C > /dev/null||echo "invalid key: $f
+ //major";grep "$f minor" NotationTypes.C > /dev/null||echo "invalid
+ //key: $f minor";done|sort
+ //invalid key: A# major
+ //invalid key: B# major
+ //invalid key: B# minor
+ //invalid key: Cb minor
+ //invalid key: Db minor
+ //invalid key: D# major
+ //invalid key: E# major
+ //invalid key: E# minor
+ //invalid key: Fb major
+ //invalid key: Fb minor
+ //invalid key: Gb minor
+ //invalid key: G# major
+
+ // some kludgery to avoid creating invalid key names with some if/then
+ // swapping to manually respell things generated incorrectly by the
+ // above, rather than adding all kinds of nonsense to avoid this
+ // necessity
+ if (newKeyName == "A# major")
+ newKeyName = "Bb major";
+ else if (newKeyName == "B# major")
+ newKeyName = "C major";
+ else if (newKeyName == "Cb minor")
+ newKeyName = "B minor";
+ else if (newKeyName == "Db minor")
+ newKeyName = "C# minor";
+ else if (newKeyName == "D# major")
+ newKeyName = "Eb major";
+ else if (newKeyName == "E# major")
+ newKeyName = "F major";
+ else if (newKeyName == "E# minor")
+ newKeyName = "F minor";
+ else if (newKeyName == "Fb major")
+ newKeyName = "E major";
+ else if (newKeyName == "Fb minor")
+ newKeyName = "E minor";
+ else if (newKeyName == "Gb minor")
+ newKeyName = "F# minor";
+ else if (newKeyName == "G# major")
+ newKeyName = "Ab major";
+
+ // create a new key with the newly derived name, and swap it for the
+ // user-specified version
+ Key k(newKeyName);
+ RG_DEBUG << "KeyInsertCommand: inserting transposed key" << endl
+ << " user key was: " << m_key.getName() << endl
+ << " tranposed key is: " << k.getName() << endl;
+ m_key = k;
+ } // if (m_transposeKey)
+
+ i = helper.insertKey(getStartTime(), m_key);
+
+ if (i != helper.segment().end()) {
+
+ m_lastInsertedEvent = *i;
+ if (!m_convert && !m_transpose)
+ return ;
+
+ while (++i != helper.segment().end()) {
+
+ //!!! what if we get two keys at the same time...?
+ if ((*i)->isa(Key::EventType))
+ break;
+
+ if ((*i)->isa(Note::EventType) &&
+ (*i)->has(PITCH)) {
+
+ long pitch = (*i)->get
+ <Int>(PITCH);
+
+ if (m_convert) {
+ (*i)->set
+ <Int>(PITCH, m_key.convertFrom(pitch, oldKey));
+ } else {
+ (*i)->set
+ <Int>(PITCH, m_key.transposeFrom(pitch, oldKey));
+ }
+
+ (*i)->unset(ACCIDENTAL);
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/KeyInsertionCommand.h b/src/commands/notation/KeyInsertionCommand.h
new file mode 100644
index 0000000..a9caa6a
--- /dev/null
+++ b/src/commands/notation/KeyInsertionCommand.h
@@ -0,0 +1,91 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_KEYINSERTIONCOMMAND_H_
+#define _RG_KEYINSERTIONCOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+#include "misc/Strings.h"
+
+
+class Add;
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+//!!! Note, the shouldIgnorePercussion parameter probably shouldn't have been
+// added to the individual KeyInsertionCommand in the first place, but I haven't
+// made up my mind yet for sure, and I already changed all the calls to this
+// constructor, so I'm leaving this in until after the new code is field
+// tested, and I can determine it really never will be wanted (DMM)
+class KeyInsertionCommand : public BasicCommand
+{
+public:
+ KeyInsertionCommand(Segment &segment,
+ timeT time,
+ Key key,
+ bool shouldConvert,
+ bool shouldTranspose,
+ bool shouldTransposeKey,
+ bool shouldIgnorePercussion);
+ virtual ~KeyInsertionCommand();
+
+ static QString getGlobalName(Key *key = 0) {
+ if (key) {
+ return i18n("Change to &Key %1...").arg(strtoqstr(key->getName()));
+ } else {
+ return i18n("Add &Key Change...");
+ }
+ }
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ Key m_key;
+ Event *m_lastInsertedEvent;
+ bool m_convert;
+ bool m_transpose;
+ bool m_transposeKey;
+ bool m_ignorePercussion;
+};
+
+/*
+ * Inserts a key change into multiple segments at the same time, taking
+ * individual segment transpose into account (fixes #1520716) if desired.
+ */
+
+}
+
+#endif
diff --git a/src/commands/notation/MakeAccidentalsCautionaryCommand.cpp b/src/commands/notation/MakeAccidentalsCautionaryCommand.cpp
new file mode 100644
index 0000000..5716a8b
--- /dev/null
+++ b/src/commands/notation/MakeAccidentalsCautionaryCommand.cpp
@@ -0,0 +1,68 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MakeAccidentalsCautionaryCommand.h"
+
+#include <klocale.h>
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+QString
+MakeAccidentalsCautionaryCommand::getGlobalName(bool cautionary)
+{
+ if (cautionary)
+ return i18n("Use &Cautionary Accidentals");
+ else
+ return i18n("Cancel C&autionary Accidentals");
+}
+
+void
+MakeAccidentalsCautionaryCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ if (m_cautionary) {
+ (*i)->set
+ <Bool>(NotationProperties::USE_CAUTIONARY_ACCIDENTAL,
+ true);
+ } else {
+ (*i)->unset(NotationProperties::USE_CAUTIONARY_ACCIDENTAL);
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/MakeAccidentalsCautionaryCommand.h b/src/commands/notation/MakeAccidentalsCautionaryCommand.h
new file mode 100644
index 0000000..2745dc7
--- /dev/null
+++ b/src/commands/notation/MakeAccidentalsCautionaryCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MAKEACCIDENTALSCAUTIONARYCOMMAND_H_
+#define _RG_MAKEACCIDENTALSCAUTIONARYCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class MakeAccidentalsCautionaryCommand : public BasicSelectionCommand
+{
+public:
+ MakeAccidentalsCautionaryCommand(bool cautionary,
+ EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(cautionary), selection, true),
+ m_selection(&selection),
+ m_cautionary(cautionary) { }
+
+ static QString getGlobalName(bool cautionary);
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ bool m_cautionary;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/MakeChordCommand.cpp b/src/commands/notation/MakeChordCommand.cpp
new file mode 100644
index 0000000..668e627
--- /dev/null
+++ b/src/commands/notation/MakeChordCommand.cpp
@@ -0,0 +1,75 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MakeChordCommand.h"
+
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+MakeChordCommand::modifySegment()
+{
+ // find all the notes in the selection, and bring them back to align
+ // with the start of the selection, giving them the same duration as
+ // the longest note among them
+
+ std::vector<Event *> toErase;
+ std::vector<Event *> toInsert;
+ Segment &segment(m_selection->getSegment());
+
+ for (EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ toErase.push_back(*i);
+ toInsert.push_back(new Event(**i, m_selection->getStartTime()));
+ }
+ }
+
+ for (unsigned int j = 0; j < toErase.size(); ++j) {
+ Segment::iterator jtr(segment.findSingle(toErase[j]));
+ if (jtr != segment.end())
+ segment.erase(jtr);
+ }
+
+ for (unsigned int j = 0; j < toInsert.size(); ++j) {
+ segment.insert(toInsert[j]);
+ }
+
+ segment.normalizeRests(getStartTime(), getEndTime());
+
+ //!!! should select all notes in chord now
+}
+
+}
diff --git a/src/commands/notation/MakeChordCommand.h b/src/commands/notation/MakeChordCommand.h
new file mode 100644
index 0000000..9c85ea2
--- /dev/null
+++ b/src/commands/notation/MakeChordCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUMAKECHORDCOMMAND_H_
+#define _RG_ADJUSTMENUMAKECHORDCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+class Make;
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class MakeChordCommand : public BasicSelectionCommand
+{
+public:
+ MakeChordCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("Make &Chord"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+// Transforms menu commands
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/MakeNotesViableCommand.cpp b/src/commands/notation/MakeNotesViableCommand.cpp
new file mode 100644
index 0000000..26cff3c
--- /dev/null
+++ b/src/commands/notation/MakeNotesViableCommand.cpp
@@ -0,0 +1,57 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MakeNotesViableCommand.h"
+
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+MakeNotesViableCommand::modifySegment()
+{
+ Segment &segment(getSegment());
+ SegmentNotationHelper helper(segment);
+
+ if (m_selection) {
+ EventSelection::RangeTimeList ranges(m_selection->getRangeTimes());
+ for (EventSelection::RangeTimeList::iterator i = ranges.begin();
+ i != ranges.end(); ++i) {
+ helper.makeNotesViable(i->first, i->second, true);
+ segment.normalizeRests(i->first, i->second);
+ }
+ } else {
+ helper.makeNotesViable(getStartTime(), getEndTime(), true);
+ segment.normalizeRests(getStartTime(), getEndTime());
+ }
+}
+
+}
diff --git a/src/commands/notation/MakeNotesViableCommand.h b/src/commands/notation/MakeNotesViableCommand.h
new file mode 100644
index 0000000..f84f76d
--- /dev/null
+++ b/src/commands/notation/MakeNotesViableCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUMAKENOTESVIABLECOMMAND_H_
+#define _RG_ADJUSTMENUMAKENOTESVIABLECOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class EventSelection;
+
+
+/// MakeNotesViable works on a selection or entire segment
+class MakeNotesViableCommand : public BasicSelectionCommand
+{
+public:
+ MakeNotesViableCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ MakeNotesViableCommand(Segment &segment) :
+ BasicSelectionCommand(getGlobalName(), segment, true),
+ m_selection(0) { }
+
+ static QString getGlobalName() { return i18n("Tie Notes at &Barlines"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/MakeRegionViableCommand.cpp b/src/commands/notation/MakeRegionViableCommand.cpp
new file mode 100644
index 0000000..597b232
--- /dev/null
+++ b/src/commands/notation/MakeRegionViableCommand.cpp
@@ -0,0 +1,48 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MakeRegionViableCommand.h"
+
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+MakeRegionViableCommand::modifySegment()
+{
+ Segment &segment(getSegment());
+ if (segment.getType() != Segment::Internal) return;
+ SegmentNotationHelper helper(segment);
+
+ helper.makeNotesViable(getStartTime(), getEndTime(), true);
+ segment.normalizeRests(getStartTime(), getEndTime());
+}
+
+}
diff --git a/src/commands/notation/MakeRegionViableCommand.h b/src/commands/notation/MakeRegionViableCommand.h
new file mode 100644
index 0000000..64762cb
--- /dev/null
+++ b/src/commands/notation/MakeRegionViableCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUMAKEREGIONVIABLECOMMAND_H_
+#define _RG_ADJUSTMENUMAKEREGIONVIABLECOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+/// MakeRegionViable works on part of a segment
+class MakeRegionViableCommand : public BasicCommand
+{
+public:
+ MakeRegionViableCommand(Segment &segment,
+ timeT startTime,
+ timeT endTime) :
+ BasicCommand(getGlobalName(), segment, startTime, endTime) { }
+
+ static QString getGlobalName() { return i18n("Tie Notes at &Barlines"); }
+
+protected:
+ virtual void modifySegment();
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/MultiKeyInsertionCommand.cpp b/src/commands/notation/MultiKeyInsertionCommand.cpp
new file mode 100644
index 0000000..77bf625
--- /dev/null
+++ b/src/commands/notation/MultiKeyInsertionCommand.cpp
@@ -0,0 +1,80 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MultiKeyInsertionCommand.h"
+
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "KeyInsertionCommand.h"
+#include <qstring.h>
+#include "document/RosegardenGUIDoc.h"
+#include "base/Studio.h"
+#include "misc/Debug.h"
+
+
+namespace Rosegarden
+{
+
+MultiKeyInsertionCommand::MultiKeyInsertionCommand(RosegardenGUIDoc* doc,
+ timeT time,
+ Key key,
+ bool convert,
+ bool transpose,
+ bool transposeKey,
+ bool ignorePercussion) :
+ KMacroCommand(getGlobalName(&key))
+{
+ Composition &c = doc->getComposition();
+ Studio &s = doc->getStudio();
+
+ for (Composition::iterator i = c.begin(); i != c.end(); ++i) {
+ Segment *segment = *i;
+
+ Instrument *instrument = s.getInstrumentFor(segment);
+ // if (instrument) {
+ // RG_DEBUG << endl <<
+ // "PERC DEBUG: instrument->isPercussion " << instrument->isPercussion() <<
+ // " ignorePercussion " << ignorePercussion << endl << endl << endl;
+ //}
+ if (instrument) if (instrument->isPercussion() && ignorePercussion) continue;
+
+ // no harm in using getEndTime instead of getEndMarkerTime here:
+ if (segment->getStartTime() <= time && segment->getEndTime() > time) {
+ addCommand(new KeyInsertionCommand(*segment, time, key, convert, transpose, transposeKey,
+ ignorePercussion));
+ } else if (segment->getStartTime() > time) {
+ addCommand(new KeyInsertionCommand(*segment, segment->getStartTime(),
+ key, convert, transpose, transposeKey, ignorePercussion));
+ }
+ }
+}
+
+MultiKeyInsertionCommand::~MultiKeyInsertionCommand()
+{
+ // nothing
+}
+
+}
diff --git a/src/commands/notation/MultiKeyInsertionCommand.h b/src/commands/notation/MultiKeyInsertionCommand.h
new file mode 100644
index 0000000..b8ae152
--- /dev/null
+++ b/src/commands/notation/MultiKeyInsertionCommand.h
@@ -0,0 +1,73 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MULTIKEYINSERTIONCOMMAND_H_
+#define _RG_MULTIKEYINSERTIONCOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+#include "misc/Strings.h"
+#include <kcommand.h>
+#include "document/RosegardenGUIDoc.h"
+
+
+class Add;
+
+
+namespace Rosegarden
+{
+
+//class Composition;
+class RosegardenGUIDoc;
+
+
+class MultiKeyInsertionCommand : public KMacroCommand
+{
+public:
+
+ MultiKeyInsertionCommand(RosegardenGUIDoc* doc,
+ timeT time,
+ Key key,
+ bool shouldConvert,
+ bool shouldTranspose,
+ bool shouldTransposeKey,
+ bool shouldIgnorePercussion);
+ virtual ~MultiKeyInsertionCommand();
+
+ static QString getGlobalName(Key *key = 0) {
+ if (key) {
+ return i18n("Change all to &Key %1...").arg(strtoqstr(key->getName()));
+ } else {
+ return i18n("Add &Key Change...");
+ }
+ }
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/NormalizeRestsCommand.cpp b/src/commands/notation/NormalizeRestsCommand.cpp
new file mode 100644
index 0000000..9d96586
--- /dev/null
+++ b/src/commands/notation/NormalizeRestsCommand.cpp
@@ -0,0 +1,52 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "NormalizeRestsCommand.h"
+
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+NormalizeRestsCommand::NormalizeRestsCommand
+(EventSelection &selection) :
+ BasicCommand(getGlobalName(),
+ selection.getSegment(),
+ selection.getStartTime(),
+ selection.getEndTime())
+{
+ // nothing else
+}
+
+void NormalizeRestsCommand::modifySegment()
+{
+ getSegment().normalizeRests(getStartTime(), getEndTime());
+}
+
+}
diff --git a/src/commands/notation/NormalizeRestsCommand.h b/src/commands/notation/NormalizeRestsCommand.h
new file mode 100644
index 0000000..db57920
--- /dev/null
+++ b/src/commands/notation/NormalizeRestsCommand.h
@@ -0,0 +1,64 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUNORMALIZERESTSCOMMAND_H_
+#define _RG_ADJUSTMENUNORMALIZERESTSCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class EventSelection;
+
+
+class NormalizeRestsCommand : public BasicCommand
+{
+public:
+ NormalizeRestsCommand(Segment &s,
+ timeT startTime,
+ timeT endTime) :
+ BasicCommand(getGlobalName(), s, startTime, endTime) { }
+
+ NormalizeRestsCommand(EventSelection &selection);
+
+ static QString getGlobalName() { return i18n("&Normalize Rests"); }
+
+protected:
+ virtual void modifySegment();
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/NoteInsertionCommand.cpp b/src/commands/notation/NoteInsertionCommand.cpp
new file mode 100644
index 0000000..cadae55
--- /dev/null
+++ b/src/commands/notation/NoteInsertionCommand.cpp
@@ -0,0 +1,296 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "NoteInsertionCommand.h"
+
+#include <cmath>
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentMatrixHelper.h"
+#include "base/SegmentNotationHelper.h"
+#include "document/BasicCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include "gui/editors/notation/NoteStyleFactory.h"
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+NoteInsertionCommand::NoteInsertionCommand(Segment &segment, timeT time,
+ timeT endTime, Note note, int pitch,
+ Accidental accidental,
+ AutoBeamMode autoBeam,
+ MatrixMode matrixType,
+ GraceMode grace,
+ float targetSubordering,
+ NoteStyleName noteStyle) :
+ BasicCommand(i18n("Insert Note"), segment,
+ getModificationStartTime(segment, time),
+ (autoBeam ? segment.getBarEndForTime(endTime) : endTime)),
+ m_insertionTime(time),
+ m_note(note),
+ m_pitch(pitch),
+ m_accidental(accidental),
+ m_autoBeam(autoBeam == AutoBeamOn),
+ m_matrixType(matrixType == MatrixModeOn),
+ m_grace(grace),
+ m_targetSubordering(targetSubordering),
+ m_noteStyle(noteStyle),
+ m_lastInsertedEvent(0)
+{
+ // nothing
+}
+
+NoteInsertionCommand::~NoteInsertionCommand()
+{
+ // nothing
+}
+
+timeT
+NoteInsertionCommand::getModificationStartTime(Segment &segment,
+ timeT time)
+{
+ // We may be splitting a rest to insert this note, so we'll have
+ // to record the change from the start of that rest rather than
+ // just the start of the note
+
+ timeT barTime = segment.getBarStartForTime(time);
+ Segment::iterator i = segment.findNearestTime(time);
+
+ if (i != segment.end() &&
+ (*i)->getAbsoluteTime() < time &&
+ (*i)->getAbsoluteTime() + (*i)->getDuration() > time &&
+ (*i)->isa(Note::EventRestType)) {
+ return std::min(barTime, (*i)->getAbsoluteTime());
+ }
+
+ return barTime;
+}
+
+void
+NoteInsertionCommand::modifySegment()
+{
+ Segment &segment(getSegment());
+ SegmentNotationHelper helper(segment);
+ Segment::iterator i, j;
+
+ // insert via a model event, so as to apply the note style
+
+ // subordering is always negative for these insertions; round it down
+ int actualSubordering = lrintf(floorf(m_targetSubordering + 0.01));
+ if ((m_grace != GraceModeOff) && actualSubordering >= 0) {
+ actualSubordering = -1;
+ }
+
+ // this is true if the subordering is "more or less" an integer,
+ // as opposed to something like -0.5
+ bool suborderingExact = (actualSubordering !=
+ (lrintf(floorf(m_targetSubordering - 0.01))));
+
+ std::cerr << "actualSubordering = " << actualSubordering
+ << " suborderingExact = " << suborderingExact << std::endl;
+
+ Event *e;
+
+ if (m_grace == GraceModeOff) {
+
+ e = new Event
+ (Note::EventType,
+ m_insertionTime,
+ m_note.getDuration(),
+ 0,
+ m_insertionTime,
+ m_note.getDuration());
+
+ } else {
+
+ e = new Event
+ (Note::EventType,
+ m_insertionTime,
+ 0,
+ actualSubordering == 0 ? -1 : actualSubordering,
+ m_insertionTime,
+ m_note.getDuration());
+ }
+
+ e->set<Int>(PITCH, m_pitch);
+ e->set<Int>(VELOCITY, 100);
+
+ if (m_accidental != Accidentals::NoAccidental) {
+ e->set<String>(ACCIDENTAL, m_accidental);
+ }
+
+ if (m_noteStyle != NoteStyleFactory::DefaultStyle) {
+ e->set<String>(NotationProperties::NOTE_STYLE, m_noteStyle);
+ }
+
+ if (m_grace != GraceModeOff) {
+
+ if (!suborderingExact) {
+
+ // Adjust suborderings of any existing grace notes, if there
+ // is at least one with the same subordering and
+ // suborderingExact is not set
+
+ segment.getTimeSlice(m_insertionTime, i, j);
+ bool collision = false;
+ for (Segment::iterator k = i; k != j; ++k) {
+ if ((*k)->getSubOrdering() == actualSubordering) {
+ collision = true;
+ break;
+ }
+ }
+
+ if (collision) {
+ std::vector<Event *> toInsert, toErase;
+ for (Segment::iterator k = i; k != j; ++k) {
+ if ((*k)->isa(Note::EventType) &&
+ (*k)->getSubOrdering() <= actualSubordering) {
+ toErase.push_back(*k);
+ toInsert.push_back
+ (new Event(**k,
+ (*k)->getAbsoluteTime(),
+ (*k)->getDuration(),
+ (*k)->getSubOrdering() - 1,
+ (*k)->getNotationAbsoluteTime(),
+ (*k)->getNotationDuration()));
+ }
+ }
+ for (std::vector<Event *>::iterator k = toErase.begin();
+ k != toErase.end(); ++k) segment.eraseSingle(*k);
+ for (std::vector<Event *>::iterator k = toInsert.begin();
+ k != toInsert.end(); ++k) segment.insert(*k);
+ }
+ }
+
+ e->set<Bool>(IS_GRACE_NOTE, true);
+ i = segment.insert(e);
+
+ Segment::iterator k;
+ segment.getTimeSlice(m_insertionTime, j, k);
+ Segment::iterator bg0 = segment.end(), bg1 = segment.end();
+ while (j != k) {
+ std::cerr << "testing for truthiness: time " << (*j)->getAbsoluteTime() << ", subordering " << (*j)->getSubOrdering() << std::endl;
+ if ((*j)->isa(Note::EventType) &&
+ (*j)->getSubOrdering() < 0 &&
+ (*j)->has(IS_GRACE_NOTE) &&
+ (*j)->get<Bool>(IS_GRACE_NOTE)) {
+ std::cerr << "truthiful" << std::endl;
+ if (bg0 == segment.end()) bg0 = j;
+ bg1 = j;
+ }
+ ++j;
+ }
+
+ if (bg0 != segment.end() && bg1 != bg0) {
+ if (bg1 != segment.end()) ++bg1;
+ int count = 0;
+ int pso = 0;
+ for (Segment::iterator i = bg0; i != bg1; ++i) {
+ (*i)->unset(BEAMED_GROUP_ID);
+ (*i)->unset(BEAMED_GROUP_TYPE);
+ (*i)->unset(BEAMED_GROUP_TUPLED_COUNT);
+ (*i)->unset(BEAMED_GROUP_UNTUPLED_COUNT);
+ if ((*i)->getSubOrdering() != pso) {
+ ++count;
+ pso = (*i)->getSubOrdering();
+ }
+ }
+ if (m_grace == GraceAndTripletModesOn) {
+ helper.makeBeamedGroupExact(bg0, bg1, GROUP_TYPE_TUPLED);
+ if (count > 1) {
+ for (Segment::iterator i = bg0; i != bg1; ++i) {
+ (*i)->set<Int>(BEAMED_GROUP_TUPLED_COUNT, count-1);
+ (*i)->set<Int>(BEAMED_GROUP_UNTUPLED_COUNT, count);
+ }
+ }
+ } else {
+ helper.makeBeamedGroupExact(bg0, bg1, GROUP_TYPE_BEAMED);
+ }
+ }
+
+ } else {
+
+ // If we're attempting to insert at the same time and pitch as
+ // an existing note, then we remove the existing note first
+ // (so as to change its duration, if the durations differ)
+ segment.getTimeSlice(m_insertionTime, i, j);
+ while (i != j) {
+ if ((*i)->isa(Note::EventType)) {
+ long pitch;
+ if ((*i)->get<Int>(PITCH, pitch) && pitch == m_pitch) {
+ helper.deleteNote(*i);
+ break;
+ }
+ }
+ ++i;
+ }
+
+ if (m_matrixType) {
+ i = SegmentMatrixHelper(segment).insertNote(e);
+ } else {
+ i = helper.insertNote(e);
+ // e is just a model for SegmentNotationHelper::insertNote
+ delete e;
+ }
+ }
+
+ if (i != segment.end()) m_lastInsertedEvent = *i;
+
+ if (m_autoBeam) {
+
+ // We auto-beam the bar if it contains no beamed groups
+ // after the insertion point and if it contains no tupled
+ // groups at all.
+
+ timeT barStartTime = segment.getBarStartForTime(m_insertionTime);
+ timeT barEndTime = segment.getBarEndForTime(m_insertionTime);
+
+ for (Segment::iterator j = i;
+ j != segment.end() && (*j)->getAbsoluteTime() < barEndTime;
+ ++j) {
+ if ((*j)->has(BEAMED_GROUP_ID))
+ return ;
+ }
+
+ for (Segment::iterator j = i;
+ j != segment.end() && (*j)->getAbsoluteTime() >= barStartTime;
+ --j) {
+ if ((*j)->has(BEAMED_GROUP_TUPLET_BASE))
+ return ;
+ if (j == segment.begin())
+ break;
+ }
+
+ helper.autoBeam(m_insertionTime, m_insertionTime, GROUP_TYPE_BEAMED);
+ }
+}
+
+}
diff --git a/src/commands/notation/NoteInsertionCommand.h b/src/commands/notation/NoteInsertionCommand.h
new file mode 100644
index 0000000..9424f1c
--- /dev/null
+++ b/src/commands/notation/NoteInsertionCommand.h
@@ -0,0 +1,98 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTEINSERTIONCOMMAND_H_
+#define _RG_NOTEINSERTIONCOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "document/BasicCommand.h"
+#include "base/Event.h"
+#include "gui/editors/notation/NoteStyle.h"
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class NoteInsertionCommand : public BasicCommand
+{
+public:
+ enum AutoBeamMode {
+ AutoBeamOff,
+ AutoBeamOn
+ };
+
+ enum MatrixMode {
+ MatrixModeOff,
+ MatrixModeOn
+ };
+
+ enum GraceMode {
+ GraceModeOff,
+ GraceModeOn,
+ GraceAndTripletModesOn
+ };
+
+ NoteInsertionCommand(Segment &segment,
+ timeT time,
+ timeT endTime,
+ Note note,
+ int pitch,
+ Accidental accidental,
+ AutoBeamMode autoBeam,
+ MatrixMode matrixType,
+ GraceMode grace,
+ float targetSubordering,
+ NoteStyleName noteStyle);
+ virtual ~NoteInsertionCommand();
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ timeT getModificationStartTime(Segment &, timeT);
+
+ timeT m_insertionTime;
+ Note m_note;
+ int m_pitch;
+ Accidental m_accidental;
+ bool m_autoBeam;
+ bool m_matrixType;
+ GraceMode m_grace;
+ float m_targetSubordering;
+ NoteStyleName m_noteStyle;
+
+ Event *m_lastInsertedEvent;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/RemoveFingeringMarksCommand.cpp b/src/commands/notation/RemoveFingeringMarksCommand.cpp
new file mode 100644
index 0000000..2b66cba
--- /dev/null
+++ b/src/commands/notation/RemoveFingeringMarksCommand.cpp
@@ -0,0 +1,54 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RemoveFingeringMarksCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RemoveFingeringMarksCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ std::vector<Mark> marks = Marks::getMarks(**i);
+ for (std::vector<Mark>::iterator j = marks.begin();
+ j != marks.end(); ++j) {
+ if (Marks::isFingeringMark(*j)) {
+ Marks::removeMark(**i, *j);
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/RemoveFingeringMarksCommand.h b/src/commands/notation/RemoveFingeringMarksCommand.h
new file mode 100644
index 0000000..6e02bfc
--- /dev/null
+++ b/src/commands/notation/RemoveFingeringMarksCommand.h
@@ -0,0 +1,61 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUREMOVEFINGERINGMARKSCOMMAND_H_
+#define _RG_NOTESMENUREMOVEFINGERINGMARKSCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RemoveFingeringMarksCommand : public BasicSelectionCommand
+{
+public:
+ RemoveFingeringMarksCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Remove Fingerings"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/RemoveMarksCommand.cpp b/src/commands/notation/RemoveMarksCommand.cpp
new file mode 100644
index 0000000..29513c2
--- /dev/null
+++ b/src/commands/notation/RemoveMarksCommand.cpp
@@ -0,0 +1,58 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RemoveMarksCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+RemoveMarksCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ long n = 0;
+ (*i)->get
+ <Int>(MARK_COUNT, n);
+ (*i)->unset(MARK_COUNT);
+
+ for (int j = 0; j < n; ++j) {
+ (*i)->unset(getMarkPropertyName(j));
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/RemoveMarksCommand.h b/src/commands/notation/RemoveMarksCommand.h
new file mode 100644
index 0000000..d04a1c9
--- /dev/null
+++ b/src/commands/notation/RemoveMarksCommand.h
@@ -0,0 +1,61 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUREMOVEMARKSCOMMAND_H_
+#define _RG_NOTESMENUREMOVEMARKSCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RemoveMarksCommand : public BasicSelectionCommand
+{
+public:
+ RemoveMarksCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Remove All Marks"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/RemoveNotationQuantizeCommand.cpp b/src/commands/notation/RemoveNotationQuantizeCommand.cpp
new file mode 100644
index 0000000..9b500fc
--- /dev/null
+++ b/src/commands/notation/RemoveNotationQuantizeCommand.cpp
@@ -0,0 +1,69 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RemoveNotationQuantizeCommand.h"
+
+#include "base/Event.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RemoveNotationQuantizeCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ std::vector<Event *> toInsert;
+ std::vector<Event *> toErase;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ toInsert.push_back(new Event(**i,
+ (*i)->getAbsoluteTime(),
+ (*i)->getDuration(),
+ (*i)->getSubOrdering(),
+ (*i)->getAbsoluteTime(),
+ (*i)->getDuration()));
+
+ toErase.push_back(*i);
+ }
+
+ for (std::vector<Event *>::iterator i = toErase.begin(); i != toErase.end();
+ ++i) {
+ m_selection->getSegment().eraseSingle(*i);
+ }
+
+ for (std::vector<Event *>::iterator i = toInsert.begin(); i != toInsert.end();
+ ++i) {
+ m_selection->getSegment().insert(*i);
+ }
+}
+
+}
diff --git a/src/commands/notation/RemoveNotationQuantizeCommand.h b/src/commands/notation/RemoveNotationQuantizeCommand.h
new file mode 100644
index 0000000..bc61ff8
--- /dev/null
+++ b/src/commands/notation/RemoveNotationQuantizeCommand.h
@@ -0,0 +1,61 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUREMOVENOTATIONQUANTIZECOMMAND_H_
+#define _RG_ADJUSTMENUREMOVENOTATIONQUANTIZECOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RemoveNotationQuantizeCommand : public BasicSelectionCommand
+{
+public:
+ RemoveNotationQuantizeCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("Remo&ve Notation Quantization"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/ResetDisplacementsCommand.cpp b/src/commands/notation/ResetDisplacementsCommand.cpp
new file mode 100644
index 0000000..dff8549
--- /dev/null
+++ b/src/commands/notation/ResetDisplacementsCommand.cpp
@@ -0,0 +1,52 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ResetDisplacementsCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+ResetDisplacementsCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ (*i)->unset(DISPLACED_X);
+ (*i)->unset(DISPLACED_Y);
+ }
+}
+
+}
diff --git a/src/commands/notation/ResetDisplacementsCommand.h b/src/commands/notation/ResetDisplacementsCommand.h
new file mode 100644
index 0000000..b1d165b
--- /dev/null
+++ b/src/commands/notation/ResetDisplacementsCommand.h
@@ -0,0 +1,61 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RESETDISPLACEMENTSCOMMAND_H_
+#define _RG_RESETDISPLACEMENTSCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class ResetDisplacementsCommand : public BasicSelectionCommand
+{
+public:
+ ResetDisplacementsCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("Restore Positions"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/RespellCommand.cpp b/src/commands/notation/RespellCommand.cpp
new file mode 100644
index 0000000..c410707
--- /dev/null
+++ b/src/commands/notation/RespellCommand.cpp
@@ -0,0 +1,141 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RespellCommand.h"
+
+#include <klocale.h>
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+using namespace BaseProperties;
+using namespace Accidentals;
+
+QString
+RespellCommand::getGlobalName(Type type, Accidental accidental)
+{
+ switch (type) {
+
+ case Set: {
+ QString s(i18n("Respell with %1"));
+ //!!! should be in notationstrings:
+ if (accidental == DoubleSharp) {
+ s = s.arg(i18n("Do&uble Sharp"));
+ } else if (accidental == Sharp) {
+ s = s.arg(i18n("&Sharp"));
+ } else if (accidental == Flat) {
+ s = s.arg(i18n("&Flat"));
+ } else if (accidental == DoubleFlat) {
+ s = s.arg(i18n("Dou&ble Flat"));
+ } else if (accidental == Natural) {
+ s = s.arg(i18n("&Natural"));
+ } else {
+ s = s.arg(i18n("N&one"));
+ }
+ return s;
+ }
+
+ case Up:
+ return i18n("Respell Accidentals &Upward");
+
+ case Down:
+ return i18n("Respell Accidentals &Downward");
+
+ case Restore:
+ return i18n("&Restore Accidentals");
+ }
+
+ return i18n("Respell Accidentals");
+}
+
+void
+RespellCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+
+ if (m_type == Up || m_type == Down) {
+
+ Accidental acc = NoAccidental;
+ (*i)->get
+ <String>(ACCIDENTAL, acc);
+
+ if (m_type == Down) {
+ if (acc == DoubleFlat) {
+ acc = Flat;
+ } else if (acc == Flat || acc == NoAccidental) {
+ acc = Sharp;
+ } else if (acc == Sharp) {
+ acc = DoubleSharp;
+ }
+ } else {
+ if (acc == Flat) {
+ acc = DoubleFlat;
+ } else if (acc == Sharp || acc == NoAccidental) {
+ acc = Flat;
+ } else if (acc == DoubleSharp) {
+ acc = Sharp;
+ }
+ }
+
+ (*i)->set
+ <String>(ACCIDENTAL, acc);
+
+ } else if (m_type == Set) {
+
+ // trap respelling black key notes as natural; which is
+ // impossible, and makes rawPitchToDisplayPitch() do crazy
+ // things as a consequence (fixes #1349782)
+ // 1 = C#, 3 = D#, 6 = F#, 8 = G#, 10 = A#
+ long pitch;
+ (*i)->get
+ <Int>(PITCH, pitch);
+ pitch %= 12;
+ if ((pitch == 1 || pitch == 3 || pitch == 6 || pitch == 8 || pitch == 10 )
+ && m_accidental == Natural) {
+ // fail silently; is there anything to do here?
+ } else {
+ (*i)->set
+ <String>(ACCIDENTAL, m_accidental);
+ }
+
+ } else {
+
+ (*i)->unset(ACCIDENTAL);
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/RespellCommand.h b/src/commands/notation/RespellCommand.h
new file mode 100644
index 0000000..e2c414f
--- /dev/null
+++ b/src/commands/notation/RespellCommand.h
@@ -0,0 +1,72 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RESPELLCOMMAND_H_
+#define _RG_RESPELLCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RespellCommand : public BasicSelectionCommand
+{
+public:
+ enum Type {
+ Set,
+ Up,
+ Down,
+ Restore
+ };
+
+ RespellCommand(Type type, Accidental acc,
+ EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(type, acc), selection, true),
+ m_selection(&selection),
+ m_type(type),
+ m_accidental(acc) { }
+
+ static QString getGlobalName(Type type, Accidental acc);
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ Type m_type;
+ Accidental m_accidental;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/RestInsertionCommand.cpp b/src/commands/notation/RestInsertionCommand.cpp
new file mode 100644
index 0000000..8fff336
--- /dev/null
+++ b/src/commands/notation/RestInsertionCommand.cpp
@@ -0,0 +1,65 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RestInsertionCommand.h"
+
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "document/BasicCommand.h"
+#include "gui/editors/notation/NoteStyleFactory.h"
+#include "NoteInsertionCommand.h"
+
+
+namespace Rosegarden
+{
+
+RestInsertionCommand::RestInsertionCommand(Segment &segment, timeT time,
+ timeT endTime, Note note) :
+ NoteInsertionCommand(segment, time, endTime, note, 0,
+ Accidentals::NoAccidental,
+ AutoBeamOff, MatrixModeOff, GraceModeOff, 0,
+ NoteStyleFactory::DefaultStyle)
+{
+ setName("Insert Rest");
+}
+
+RestInsertionCommand::~RestInsertionCommand()
+{
+ // nothing
+}
+
+void
+RestInsertionCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+
+ Segment::iterator i = helper.insertRest(m_insertionTime, m_note);
+ if (i != helper.segment().end())
+ m_lastInsertedEvent = *i;
+}
+
+}
diff --git a/src/commands/notation/RestInsertionCommand.h b/src/commands/notation/RestInsertionCommand.h
new file mode 100644
index 0000000..dc3d991
--- /dev/null
+++ b/src/commands/notation/RestInsertionCommand.h
@@ -0,0 +1,58 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RESTINSERTIONCOMMAND_H_
+#define _RG_RESTINSERTIONCOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "NoteInsertionCommand.h"
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class RestInsertionCommand : public NoteInsertionCommand
+{
+public:
+ RestInsertionCommand(Segment &segment,
+ timeT time,
+ timeT endTime,
+ Note note);
+ virtual ~RestInsertionCommand();
+
+protected:
+ virtual void modifySegment();
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/RestoreSlursCommand.cpp b/src/commands/notation/RestoreSlursCommand.cpp
new file mode 100644
index 0000000..4cb2ec8
--- /dev/null
+++ b/src/commands/notation/RestoreSlursCommand.cpp
@@ -0,0 +1,58 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RestoreSlursCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RestoreSlursCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Indication::EventType)) {
+ std::string indicationType;
+ if ((*i)->get
+ <String>(Indication::IndicationTypePropertyName, indicationType)
+ && (indicationType == Indication::Slur ||
+ indicationType == Indication::PhrasingSlur)) {
+ (*i)->unset(NotationProperties::SLUR_ABOVE);
+ }
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/RestoreSlursCommand.h b/src/commands/notation/RestoreSlursCommand.h
new file mode 100644
index 0000000..687d016
--- /dev/null
+++ b/src/commands/notation/RestoreSlursCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENURESTORESLURSCOMMAND_H_
+#define _RG_ADJUSTMENURESTORESLURSCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RestoreSlursCommand : public BasicSelectionCommand
+{
+public:
+ RestoreSlursCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Restore Slur Positions"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/RestoreStemsCommand.cpp b/src/commands/notation/RestoreStemsCommand.cpp
new file mode 100644
index 0000000..99709f3
--- /dev/null
+++ b/src/commands/notation/RestoreStemsCommand.cpp
@@ -0,0 +1,52 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RestoreStemsCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RestoreStemsCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if ((*i)->isa(Note::EventType)) {
+ (*i)->unset(NotationProperties::STEM_UP);
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/RestoreStemsCommand.h b/src/commands/notation/RestoreStemsCommand.h
new file mode 100644
index 0000000..94dd0cf
--- /dev/null
+++ b/src/commands/notation/RestoreStemsCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENURESTORESTEMSCOMMAND_H_
+#define _RG_ADJUSTMENURESTORESTEMSCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RestoreStemsCommand : public BasicSelectionCommand
+{
+public:
+ RestoreStemsCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Restore Stems"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/RestoreTiesCommand.cpp b/src/commands/notation/RestoreTiesCommand.cpp
new file mode 100644
index 0000000..6402361
--- /dev/null
+++ b/src/commands/notation/RestoreTiesCommand.cpp
@@ -0,0 +1,51 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RestoreTiesCommand.h"
+
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include "gui/editors/notation/NotationProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RestoreTiesCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ (*i)->unset(BaseProperties::TIE_IS_ABOVE);
+ }
+}
+
+}
diff --git a/src/commands/notation/RestoreTiesCommand.h b/src/commands/notation/RestoreTiesCommand.h
new file mode 100644
index 0000000..d3ffef9
--- /dev/null
+++ b/src/commands/notation/RestoreTiesCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENURESTORETIESCOMMAND_H_
+#define _RG_ADJUSTMENURESTORETIESCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class RestoreTiesCommand : public BasicSelectionCommand
+{
+public:
+ RestoreTiesCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Restore Tie Positions"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/SetVisibilityCommand.cpp b/src/commands/notation/SetVisibilityCommand.cpp
new file mode 100644
index 0000000..c7f49f3
--- /dev/null
+++ b/src/commands/notation/SetVisibilityCommand.cpp
@@ -0,0 +1,57 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SetVisibilityCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+
+void
+SetVisibilityCommand::modifySegment()
+{
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ if (m_visible) {
+ (*i)->unset(INVISIBLE);
+ } else {
+ (*i)->set
+ <Bool>(INVISIBLE, true);
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/SetVisibilityCommand.h b/src/commands/notation/SetVisibilityCommand.h
new file mode 100644
index 0000000..6aef5ef
--- /dev/null
+++ b/src/commands/notation/SetVisibilityCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SETVISIBILITYCOMMAND_H_
+#define _RG_SETVISIBILITYCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class SetVisibilityCommand : public BasicSelectionCommand
+{
+public:
+ SetVisibilityCommand(EventSelection &selection, bool visible) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection),
+ m_visible(visible) { }
+
+ static QString getGlobalName() { return i18n("Set Visibility"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+ bool m_visible;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/SustainInsertionCommand.cpp b/src/commands/notation/SustainInsertionCommand.cpp
new file mode 100644
index 0000000..f3c3917
--- /dev/null
+++ b/src/commands/notation/SustainInsertionCommand.cpp
@@ -0,0 +1,66 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SustainInsertionCommand.h"
+
+#include "base/Event.h"
+#include "base/MidiTypes.h"
+#include "base/Segment.h"
+#include "document/BasicCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SustainInsertionCommand::SustainInsertionCommand(Segment &segment, timeT time,
+ bool down,
+ int controllerNumber) :
+ BasicCommand(getGlobalName(down), segment, time, time),
+ m_down(down),
+ m_controllerNumber(controllerNumber),
+ m_lastInsertedEvent(0)
+{
+ // nothing
+}
+
+SustainInsertionCommand::~SustainInsertionCommand()
+{
+ // nothing
+}
+
+void
+SustainInsertionCommand::modifySegment()
+{
+ Event *e = new Event(Controller::EventType, getStartTime(), 0,
+ Controller::EventSubOrdering);
+ e->set
+ <Int>(Controller::NUMBER, m_controllerNumber);
+ e->set
+ <Int>(Controller::VALUE, m_down ? 127 : 0);
+ m_lastInsertedEvent = *getSegment().insert(e);
+}
+
+}
diff --git a/src/commands/notation/SustainInsertionCommand.h b/src/commands/notation/SustainInsertionCommand.h
new file mode 100644
index 0000000..ddb93b4
--- /dev/null
+++ b/src/commands/notation/SustainInsertionCommand.h
@@ -0,0 +1,76 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SUSTAININSERTIONCOMMAND_H_
+#define _RG_SUSTAININSERTIONCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+class Pedal;
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class SustainInsertionCommand : public BasicCommand
+{
+public:
+ SustainInsertionCommand(Segment &segment,
+ timeT time,
+ bool down,
+ int controllerNumber);
+ virtual ~SustainInsertionCommand();
+
+ static QString getGlobalName(bool down) {
+ if (down) {
+ return i18n("Add Pedal &Press");
+ } else {
+ return i18n("Add Pedal &Release");
+ }
+ }
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ bool m_down;
+ int m_controllerNumber;
+ Event *m_lastInsertedEvent;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/TextChangeCommand.cpp b/src/commands/notation/TextChangeCommand.cpp
new file mode 100644
index 0000000..e909839
--- /dev/null
+++ b/src/commands/notation/TextChangeCommand.cpp
@@ -0,0 +1,62 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "TextChangeCommand.h"
+
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "document/BasicCommand.h"
+
+
+namespace Rosegarden
+{
+
+TextChangeCommand::TextChangeCommand(Segment &segment,
+ Event *event,
+ Text text) :
+ BasicCommand(i18n("Edit Text"), segment,
+ event->getAbsoluteTime(), event->getAbsoluteTime() + 1,
+ true), // bruteForceRedo
+ m_event(event),
+ m_text(text)
+{
+ // nothing
+}
+
+TextChangeCommand::~TextChangeCommand()
+{}
+
+void
+TextChangeCommand::modifySegment()
+{
+ m_event->set
+ <String>(Text::TextTypePropertyName, m_text.getTextType());
+ m_event->set
+ <String>(Text::TextPropertyName, m_text.getText());
+}
+
+}
diff --git a/src/commands/notation/TextChangeCommand.h b/src/commands/notation/TextChangeCommand.h
new file mode 100644
index 0000000..5dce48e
--- /dev/null
+++ b/src/commands/notation/TextChangeCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_TEXTCHANGECOMMAND_H_
+#define _RG_TEXTCHANGECOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "document/BasicCommand.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class TextChangeCommand : public BasicCommand
+{
+public:
+ TextChangeCommand(Segment &segment,
+ Event *event,
+ Text text);
+ virtual ~TextChangeCommand();
+
+protected:
+ virtual void modifySegment();
+ Event *m_event; // only used first time through
+ Text m_text;
+};
+
+/*
+ * Inserts a key change into a single segment, taking segment transpose into
+ * account (fixes #1520716) if desired.
+ */
+
+}
+
+#endif
diff --git a/src/commands/notation/TextInsertionCommand.cpp b/src/commands/notation/TextInsertionCommand.cpp
new file mode 100644
index 0000000..8ba94c9
--- /dev/null
+++ b/src/commands/notation/TextInsertionCommand.cpp
@@ -0,0 +1,63 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "TextInsertionCommand.h"
+
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "document/BasicCommand.h"
+
+
+namespace Rosegarden
+{
+
+TextInsertionCommand::TextInsertionCommand(Segment &segment, timeT time,
+ Text text) :
+ BasicCommand(i18n("Insert Text"), segment, time, time + 1),
+ m_text(text),
+ m_lastInsertedEvent(0)
+{
+ // nothing
+}
+
+TextInsertionCommand::~TextInsertionCommand()
+{
+ // nothing
+}
+
+void
+TextInsertionCommand::modifySegment()
+{
+ SegmentNotationHelper helper(getSegment());
+
+ Segment::iterator i = helper.insertText(getStartTime(), m_text);
+ if (i != helper.segment().end())
+ m_lastInsertedEvent = *i;
+}
+
+}
diff --git a/src/commands/notation/TextInsertionCommand.h b/src/commands/notation/TextInsertionCommand.h
new file mode 100644
index 0000000..34b574f
--- /dev/null
+++ b/src/commands/notation/TextInsertionCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_TEXTINSERTIONCOMMAND_H_
+#define _RG_TEXTINSERTIONCOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "document/BasicCommand.h"
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Event;
+
+
+class TextInsertionCommand : public BasicCommand
+{
+public:
+ TextInsertionCommand(Segment &segment,
+ timeT time,
+ Text text);
+ virtual ~TextInsertionCommand();
+
+ Event *getLastInsertedEvent() { return m_lastInsertedEvent; }
+
+protected:
+ virtual void modifySegment();
+
+ Text m_text;
+ Event *m_lastInsertedEvent;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/notation/TieNotesCommand.cpp b/src/commands/notation/TieNotesCommand.cpp
new file mode 100644
index 0000000..18b8188
--- /dev/null
+++ b/src/commands/notation/TieNotesCommand.cpp
@@ -0,0 +1,72 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "TieNotesCommand.h"
+
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+TieNotesCommand::modifySegment()
+{
+ Segment &segment(getSegment());
+ SegmentNotationHelper helper(segment);
+
+ //!!! move part of this to SegmentNotationHelper?
+
+ for (EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ // bool tiedForward;
+ // if ((*i)->get<Bool>(TIED_FORWARD, tiedForward) && tiedForward) {
+ // continue;
+ // }
+
+ Segment::iterator si = segment.findSingle(*i);
+ Segment::iterator sj;
+ while ((sj = helper.getNextAdjacentNote(si, true, false)) !=
+ segment.end()) {
+ if (!m_selection->contains(*sj))
+ break;
+ (*si)->set<Bool>(TIED_FORWARD, true);
+ (*si)->unset(TIE_IS_ABOVE);
+ (*sj)->set<Bool>(TIED_BACKWARD, true);
+ si = sj;
+ }
+ }
+}
+
+}
diff --git a/src/commands/notation/TieNotesCommand.h b/src/commands/notation/TieNotesCommand.h
new file mode 100644
index 0000000..2f1874f
--- /dev/null
+++ b/src/commands/notation/TieNotesCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_NOTESMENUTIENOTESCOMMAND_H_
+#define _RG_NOTESMENUTIENOTESCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class TieNotesCommand : public BasicSelectionCommand
+{
+public:
+ TieNotesCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Tie"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/TupletCommand.cpp b/src/commands/notation/TupletCommand.cpp
new file mode 100644
index 0000000..b46fff5
--- /dev/null
+++ b/src/commands/notation/TupletCommand.cpp
@@ -0,0 +1,91 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "TupletCommand.h"
+
+#include "base/Event.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include "document/BasicCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+TupletCommand::TupletCommand(Segment &segment,
+ timeT startTime,
+ timeT unit,
+ int untupled, int tupled,
+ bool hasTimingAlready) :
+ BasicCommand(getGlobalName((untupled == 3) && (tupled == 2)),
+ segment, startTime, startTime + (unit * untupled)),
+ m_unit(unit),
+ m_untupled(untupled),
+ m_tupled(tupled),
+ m_hasTimingAlready(hasTimingAlready)
+{
+ // nothing else
+}
+
+void
+TupletCommand::modifySegment()
+{
+ if (m_hasTimingAlready) {
+
+ int groupId = getSegment().getNextId();
+
+ for (Segment::iterator i = getSegment().findTime(getStartTime());
+ getSegment().isBeforeEndMarker(i); ++i) {
+
+ if ((*i)->getNotationAbsoluteTime() >=
+ getStartTime() + (m_unit * m_tupled))
+ break;
+
+ Event *e = *i;
+
+ e->set
+ <Int>(BEAMED_GROUP_ID, groupId);
+ e->set
+ <String>(BEAMED_GROUP_TYPE, GROUP_TYPE_TUPLED);
+
+ e->set
+ <Int>(BEAMED_GROUP_TUPLET_BASE, m_unit);
+ e->set
+ <Int>(BEAMED_GROUP_TUPLED_COUNT, m_tupled);
+ e->set
+ <Int>(BEAMED_GROUP_UNTUPLED_COUNT, m_untupled);
+ }
+
+ } else {
+ SegmentNotationHelper helper(getSegment());
+ helper.makeTupletGroup(getStartTime(), m_untupled, m_tupled, m_unit);
+ }
+}
+
+}
diff --git a/src/commands/notation/TupletCommand.h b/src/commands/notation/TupletCommand.h
new file mode 100644
index 0000000..b08a204
--- /dev/null
+++ b/src/commands/notation/TupletCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUTUPLETCOMMAND_H_
+#define _RG_ADJUSTMENUTUPLETCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class TupletCommand : public BasicCommand
+{
+public:
+ TupletCommand(Segment &segment,
+ timeT startTime,
+ timeT unit,
+ int untupled = 3, int tupled = 2,
+ bool groupHasTimingAlready = false);
+
+ static QString getGlobalName(bool simple = true) {
+ if (simple) return i18n("&Triplet");
+ else return i18n("Tu&plet...");
+ }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ timeT m_unit;
+ int m_untupled;
+ int m_tupled;
+ bool m_hasTimingAlready;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/UnGraceCommand.cpp b/src/commands/notation/UnGraceCommand.cpp
new file mode 100644
index 0000000..7eb0343
--- /dev/null
+++ b/src/commands/notation/UnGraceCommand.cpp
@@ -0,0 +1,42 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "UnGraceCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+UnGraceCommand::modifySegment()
+{
+ //!!!
+}
+
+}
diff --git a/src/commands/notation/UnGraceCommand.h b/src/commands/notation/UnGraceCommand.h
new file mode 100644
index 0000000..cdaf244
--- /dev/null
+++ b/src/commands/notation/UnGraceCommand.h
@@ -0,0 +1,58 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUUNGRACECOMMAND_H_
+#define _RG_ADJUSTMENUUNGRACECOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class UnGraceCommand : public BasicSelectionCommand
+{
+public:
+ UnGraceCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection) { }
+
+ static QString getGlobalName() { return i18n("Ung&race"); }
+
+protected:
+ virtual void modifySegment();
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/UnTupletCommand.cpp b/src/commands/notation/UnTupletCommand.cpp
new file mode 100644
index 0000000..0a4b85e
--- /dev/null
+++ b/src/commands/notation/UnTupletCommand.cpp
@@ -0,0 +1,54 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "UnTupletCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include "base/BaseProperties.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+UnTupletCommand::modifySegment()
+{
+ for (EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ (*i)->unset(BEAMED_GROUP_ID);
+ (*i)->unset(BEAMED_GROUP_TYPE);
+ (*i)->unset(BEAMED_GROUP_TUPLET_BASE);
+ (*i)->unset(BEAMED_GROUP_TUPLED_COUNT);
+ (*i)->unset(BEAMED_GROUP_UNTUPLED_COUNT);
+ }
+}
+
+}
diff --git a/src/commands/notation/UnTupletCommand.h b/src/commands/notation/UnTupletCommand.h
new file mode 100644
index 0000000..76aabe4
--- /dev/null
+++ b/src/commands/notation/UnTupletCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUUNTUPLETCOMMAND_H_
+#define _RG_ADJUSTMENUUNTUPLETCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class UnTupletCommand : public BasicSelectionCommand
+{
+public:
+ UnTupletCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() {
+ return i18n("&Untuplet");
+ }
+
+protected:
+ virtual void modifySegment();
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/notation/UntieNotesCommand.cpp b/src/commands/notation/UntieNotesCommand.cpp
new file mode 100644
index 0000000..e32d605
--- /dev/null
+++ b/src/commands/notation/UntieNotesCommand.cpp
@@ -0,0 +1,52 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "UntieNotesCommand.h"
+
+#include "base/Selection.h"
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include "base/BaseProperties.h"
+
+
+namespace Rosegarden
+{
+
+using namespace BaseProperties;
+
+void
+UntieNotesCommand::modifySegment()
+{
+ for (EventSelection::eventcontainer::iterator i =
+ m_selection->getSegmentEvents().begin();
+ i != m_selection->getSegmentEvents().end(); ++i) {
+
+ (*i)->unset(TIED_FORWARD);
+ (*i)->unset(TIE_IS_ABOVE);
+ (*i)->unset(TIED_BACKWARD);
+ }
+}
+
+}
diff --git a/src/commands/notation/UntieNotesCommand.h b/src/commands/notation/UntieNotesCommand.h
new file mode 100644
index 0000000..3f57413
--- /dev/null
+++ b/src/commands/notation/UntieNotesCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADJUSTMENUUNTIENOTESCOMMAND_H_
+#define _RG_ADJUSTMENUUNTIENOTESCOMMAND_H_
+
+#include "document/BasicSelectionCommand.h"
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class EventSelection;
+
+
+class UntieNotesCommand : public BasicSelectionCommand
+{
+public:
+ UntieNotesCommand(EventSelection &selection) :
+ BasicSelectionCommand(getGlobalName(), selection, true),
+ m_selection(&selection) { }
+
+ static QString getGlobalName() { return i18n("&Untie"); }
+
+protected:
+ virtual void modifySegment();
+
+private:
+ EventSelection *m_selection;// only used on 1st execute (cf bruteForceRedo)
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AddTempoChangeCommand.cpp b/src/commands/segment/AddTempoChangeCommand.cpp
new file mode 100644
index 0000000..6665215
--- /dev/null
+++ b/src/commands/segment/AddTempoChangeCommand.cpp
@@ -0,0 +1,66 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddTempoChangeCommand.h"
+
+#include "base/Composition.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+AddTempoChangeCommand::~AddTempoChangeCommand()
+{
+ // nothing here either
+}
+
+void
+AddTempoChangeCommand::execute()
+{
+ int oldIndex = m_composition->getTempoChangeNumberAt(m_time);
+
+ if (oldIndex >= 0) {
+ std::pair<timeT, tempoT> data =
+ m_composition->getTempoChange(oldIndex);
+
+ if (data.first == m_time)
+ m_oldTempo = data.second;
+ }
+
+ m_tempoChangeIndex = m_composition->addTempoAtTime(m_time, m_tempo, m_target);
+}
+
+void
+AddTempoChangeCommand::unexecute()
+{
+ m_composition->removeTempoChange(m_tempoChangeIndex);
+
+ if (m_oldTempo != 0) {
+ m_composition->addTempoAtTime(m_time, m_oldTempo);
+ }
+}
+
+}
diff --git a/src/commands/segment/AddTempoChangeCommand.h b/src/commands/segment/AddTempoChangeCommand.h
new file mode 100644
index 0000000..07036dd
--- /dev/null
+++ b/src/commands/segment/AddTempoChangeCommand.h
@@ -0,0 +1,76 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADDTEMPOCHANGECOMMAND_H_
+#define _RG_ADDTEMPOCHANGECOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include "base/Composition.h" // for tempoT
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class AddTempoChangeCommand : public KNamedCommand
+{
+public:
+ AddTempoChangeCommand(Composition *composition,
+ timeT time,
+ tempoT tempo,
+ tempoT target = -1):
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_time(time),
+ m_tempo(tempo),
+ m_target(target),
+ m_oldTempo(0),
+ m_tempoChangeIndex(0) {}
+
+ virtual ~AddTempoChangeCommand();
+
+ static QString getGlobalName() { return i18n("Add Te&mpo Change..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ timeT m_time;
+ tempoT m_tempo;
+ tempoT m_target;
+ tempoT m_oldTempo;
+ int m_tempoChangeIndex;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AddTimeSignatureAndNormalizeCommand.cpp b/src/commands/segment/AddTimeSignatureAndNormalizeCommand.cpp
new file mode 100644
index 0000000..45b391b
--- /dev/null
+++ b/src/commands/segment/AddTimeSignatureAndNormalizeCommand.cpp
@@ -0,0 +1,78 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddTimeSignatureAndNormalizeCommand.h"
+
+#include "AddTimeSignatureCommand.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "commands/notation/MakeRegionViableCommand.h"
+
+
+namespace Rosegarden
+{
+
+AddTimeSignatureAndNormalizeCommand::AddTimeSignatureAndNormalizeCommand
+(Composition *composition, timeT time, TimeSignature timeSig) :
+ KMacroCommand(AddTimeSignatureCommand::getGlobalName())
+{
+ addCommand(new AddTimeSignatureCommand(composition, time, timeSig));
+
+ // only up to the next time signature
+ timeT nextTimeSigTime(composition->getDuration());
+
+ int index = composition->getTimeSignatureNumberAt(time);
+ if (composition->getTimeSignatureCount() > index + 1) {
+ nextTimeSigTime = composition->getTimeSignatureChange(index + 1).first;
+ }
+
+ for (Composition::iterator i = composition->begin();
+ i != composition->end(); ++i) {
+
+ if ((*i)->getType() != Segment::Internal) continue;
+
+ timeT startTime = (*i)->getStartTime();
+ timeT endTime = (*i)->getEndTime();
+
+ if (startTime >= nextTimeSigTime || endTime <= time)
+ continue;
+
+ // "Make Notes Viable" splits and ties notes at barlines, and
+ // also does a rest normalize. It's what we normally want
+ // when adding a time signature.
+
+ addCommand(new MakeRegionViableCommand
+ (**i,
+ std::max(startTime, time),
+ std::min(endTime, nextTimeSigTime)));
+ }
+}
+
+AddTimeSignatureAndNormalizeCommand::~AddTimeSignatureAndNormalizeCommand()
+{
+ // well, nothing really
+}
+
+}
diff --git a/src/commands/segment/AddTimeSignatureAndNormalizeCommand.h b/src/commands/segment/AddTimeSignatureAndNormalizeCommand.h
new file mode 100644
index 0000000..f22faa4
--- /dev/null
+++ b/src/commands/segment/AddTimeSignatureAndNormalizeCommand.h
@@ -0,0 +1,53 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADDTIMESIGNATUREANDNORMALIZECOMMAND_H_
+#define _RG_ADDTIMESIGNATUREANDNORMALIZECOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include "base/Event.h"
+#include <kcommand.h>
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class AddTimeSignatureAndNormalizeCommand : public KMacroCommand
+{
+public:
+ AddTimeSignatureAndNormalizeCommand(Composition *composition,
+ timeT time,
+ TimeSignature timeSig);
+ virtual ~AddTimeSignatureAndNormalizeCommand();
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AddTimeSignatureCommand.cpp b/src/commands/segment/AddTimeSignatureCommand.cpp
new file mode 100644
index 0000000..88f2d07
--- /dev/null
+++ b/src/commands/segment/AddTimeSignatureCommand.cpp
@@ -0,0 +1,78 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddTimeSignatureCommand.h"
+
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+AddTimeSignatureCommand::AddTimeSignatureCommand(Composition *composition,
+ timeT time,
+ TimeSignature timeSig) :
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_time(time),
+ m_timeSignature(timeSig),
+ m_oldTimeSignature(0)
+{
+ // nothing else
+}
+
+AddTimeSignatureCommand::~AddTimeSignatureCommand()
+{
+ if (m_oldTimeSignature)
+ delete m_oldTimeSignature;
+}
+
+void
+AddTimeSignatureCommand::execute()
+{
+ int oldIndex = m_composition->getTimeSignatureNumberAt(m_time);
+ if (oldIndex >= 0) {
+ std::pair<timeT, TimeSignature> data =
+ m_composition->getTimeSignatureChange(oldIndex);
+ if (data.first == m_time) {
+ m_oldTimeSignature = new TimeSignature(data.second);
+ }
+ }
+
+ m_timeSigIndex = m_composition->addTimeSignature(m_time, m_timeSignature);
+}
+
+void
+AddTimeSignatureCommand::unexecute()
+{
+ m_composition->removeTimeSignature(m_timeSigIndex);
+ if (m_oldTimeSignature) {
+ m_composition->addTimeSignature(m_time, *m_oldTimeSignature);
+ }
+}
+
+}
diff --git a/src/commands/segment/AddTimeSignatureCommand.h b/src/commands/segment/AddTimeSignatureCommand.h
new file mode 100644
index 0000000..fbc875d
--- /dev/null
+++ b/src/commands/segment/AddTimeSignatureCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADDTIMESIGNATURECOMMAND_H_
+#define _RG_ADDTIMESIGNATURECOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class AddTimeSignatureCommand : public KNamedCommand
+{
+public:
+ AddTimeSignatureCommand(Composition *composition,
+ timeT time,
+ TimeSignature timeSig);
+ virtual ~AddTimeSignatureCommand();
+
+ static QString getGlobalName() { return i18n("Add Time Si&gnature Change..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ timeT m_time;
+ TimeSignature m_timeSignature;
+
+ TimeSignature *m_oldTimeSignature; // for undo
+ int m_timeSigIndex; // for undo
+};
+
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AddTracksCommand.cpp b/src/commands/segment/AddTracksCommand.cpp
new file mode 100644
index 0000000..1f09227
--- /dev/null
+++ b/src/commands/segment/AddTracksCommand.cpp
@@ -0,0 +1,137 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddTracksCommand.h"
+
+#include "misc/Debug.h"
+#include "base/Composition.h"
+#include "base/MidiProgram.h"
+#include "base/Track.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+AddTracksCommand::AddTracksCommand(Composition *composition,
+ unsigned int nbTracks,
+ InstrumentId id,
+ int position):
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_nbNewTracks(nbTracks),
+ m_instrumentId(id),
+ m_position(position),
+ m_detached(false)
+
+{
+}
+
+AddTracksCommand::~AddTracksCommand()
+{
+ if (m_detached) {
+ for (unsigned int i = 0; i < m_newTracks.size(); ++i)
+ delete m_newTracks[i];
+ }
+}
+
+void AddTracksCommand::execute()
+{
+ // Re-attach tracks
+ //
+ if (m_detached) {
+
+ for (unsigned int i = 0; i < m_newTracks.size(); i++) {
+ m_composition->addTrack(m_newTracks[i]);
+ }
+
+ for (TrackPositionMap::iterator i = m_oldPositions.begin();
+ i != m_oldPositions.end(); ++i) {
+
+ int newPosition = i->second + m_nbNewTracks;
+ Track *track = m_composition->getTrackById(i->first);
+ if (track) track->setPosition(newPosition);
+ }
+
+ return;
+ }
+
+ int highPosition = 0;
+
+ for (Composition::trackiterator it = m_composition->getTracks().begin();
+ it != m_composition->getTracks().end(); ++it) {
+
+ int pos = it->second->getPosition();
+
+ if (pos > highPosition) {
+ highPosition = pos;
+ }
+ }
+
+ if (m_position == -1) m_position = highPosition + 1;
+ if (m_position < 0) m_position = 0;
+ if (m_position > highPosition + 1) m_position = highPosition + 1;
+
+ for (Composition::trackiterator it = m_composition->getTracks().begin();
+ it != m_composition->getTracks().end(); ++it) {
+
+ int pos = it->second->getPosition();
+
+ if (pos >= m_position) {
+ m_oldPositions[it->first] = pos;
+ it->second->setPosition(pos + m_nbNewTracks);
+ }
+ }
+
+ for (unsigned int i = 0; i < m_nbNewTracks; ++i) {
+
+ TrackId trackId = m_composition->getNewTrackId();
+ Track *track = new Track(trackId);
+
+ track->setPosition(m_position + i);
+ track->setInstrument(m_instrumentId);
+
+ m_composition->addTrack(track);
+ m_newTracks.push_back(track);
+ }
+}
+
+void AddTracksCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_newTracks.size(); i++) {
+ m_composition->detachTrack(m_newTracks[i]);
+ }
+
+ for (TrackPositionMap::iterator i = m_oldPositions.begin();
+ i != m_oldPositions.end(); ++i) {
+
+ Track *track = m_composition->getTrackById(i->first);
+ if (track) track->setPosition(i->second);
+ }
+
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/AddTracksCommand.h b/src/commands/segment/AddTracksCommand.h
new file mode 100644
index 0000000..d3e09ca
--- /dev/null
+++ b/src/commands/segment/AddTracksCommand.h
@@ -0,0 +1,77 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADDTRACKSCOMMAND_H_
+#define _RG_ADDTRACKSCOMMAND_H_
+
+#include "base/MidiProgram.h"
+#include "base/Composition.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <map>
+#include <klocale.h>
+
+
+
+namespace Rosegarden
+{
+
+class Track;
+class Composition;
+
+
+class AddTracksCommand : public KNamedCommand
+{
+public:
+ AddTracksCommand(Composition *composition,
+ unsigned int nbTracks,
+ InstrumentId id,
+ int position); // -1 -> at end
+ virtual ~AddTracksCommand();
+
+ static QString getGlobalName() { return i18n("Add Tracks..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ unsigned int m_nbNewTracks;
+ InstrumentId m_instrumentId;
+ int m_position;
+
+ typedef std::map<TrackId, int> TrackPositionMap;
+
+ std::vector<Track *> m_newTracks;
+ TrackPositionMap m_oldPositions;
+
+ bool m_detached;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AddTriggerSegmentCommand.cpp b/src/commands/segment/AddTriggerSegmentCommand.cpp
new file mode 100644
index 0000000..12d406e
--- /dev/null
+++ b/src/commands/segment/AddTriggerSegmentCommand.cpp
@@ -0,0 +1,90 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddTriggerSegmentCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include "base/TriggerSegment.h"
+#include "document/RosegardenGUIDoc.h"
+
+
+namespace Rosegarden
+{
+
+AddTriggerSegmentCommand::AddTriggerSegmentCommand(RosegardenGUIDoc *doc,
+ timeT duration,
+ int basePitch,
+ int baseVelocity) :
+ KNamedCommand(i18n("Add Triggered Segment")),
+ m_composition(&doc->getComposition()),
+ m_duration(duration),
+ m_basePitch(basePitch),
+ m_baseVelocity(baseVelocity),
+ m_id(0),
+ m_segment(0),
+ m_detached(false)
+{
+ // nothing else
+}
+
+AddTriggerSegmentCommand::~AddTriggerSegmentCommand()
+{
+ if (m_detached)
+ delete m_segment;
+}
+
+TriggerSegmentId
+AddTriggerSegmentCommand::getId() const
+{
+ return m_id;
+}
+
+void
+AddTriggerSegmentCommand::execute()
+{
+ if (m_segment) {
+ m_composition->addTriggerSegment(m_segment, m_id, m_basePitch, m_baseVelocity);
+ } else {
+ m_segment = new Segment();
+ m_segment->setEndMarkerTime(m_duration);
+ TriggerSegmentRec *rec = m_composition->addTriggerSegment
+ (m_segment, m_basePitch, m_baseVelocity);
+ if (rec)
+ m_id = rec->getId();
+ }
+ m_detached = false;
+}
+
+void
+AddTriggerSegmentCommand::unexecute()
+{
+ if (m_segment)
+ m_composition->detachTriggerSegment(m_id);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/AddTriggerSegmentCommand.h b/src/commands/segment/AddTriggerSegmentCommand.h
new file mode 100644
index 0000000..46d23cb
--- /dev/null
+++ b/src/commands/segment/AddTriggerSegmentCommand.h
@@ -0,0 +1,72 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADDTRIGGERSEGMENTCOMMAND_H_
+#define _RG_ADDTRIGGERSEGMENTCOMMAND_H_
+
+#include "base/TriggerSegment.h"
+#include <kcommand.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class RosegardenGUIDoc;
+class Composition;
+
+
+class AddTriggerSegmentCommand : public KNamedCommand
+{
+public:
+ AddTriggerSegmentCommand(RosegardenGUIDoc *doc,
+ timeT duration, // start time always 0
+ int basePitch = -1,
+ int baseVelocity = -1);
+ virtual ~AddTriggerSegmentCommand();
+
+ TriggerSegmentId getId() const; // after invocation
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ timeT m_duration;
+ int m_basePitch;
+ int m_baseVelocity;
+ TriggerSegmentId m_id;
+ Segment *m_segment;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AudioSegmentAutoSplitCommand.cpp b/src/commands/segment/AudioSegmentAutoSplitCommand.cpp
new file mode 100644
index 0000000..d474b64
--- /dev/null
+++ b/src/commands/segment/AudioSegmentAutoSplitCommand.cpp
@@ -0,0 +1,191 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AudioSegmentAutoSplitCommand.h"
+
+#include "base/Event.h"
+#include "misc/Debug.h"
+#include "misc/Strings.h"
+#include "base/Composition.h"
+#include "base/RealTime.h"
+#include "base/Segment.h"
+#include "document/RosegardenGUIDoc.h"
+#include "sound/AudioFileManager.h"
+#include "sound/PeakFileManager.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+struct AutoSplitPoint
+{
+ timeT time;
+ timeT lastSoundTime;
+ Clef clef;
+ Rosegarden::Key key;
+ AutoSplitPoint(timeT t, timeT lst, Clef c, Rosegarden::Key k) :
+ time(t), lastSoundTime(lst), clef(c), key(k) { }
+};
+
+AudioSegmentAutoSplitCommand::AudioSegmentAutoSplitCommand(
+ RosegardenGUIDoc *doc,
+ Segment *segment,
+ int threshold) :
+ KNamedCommand(getGlobalName()),
+ m_segment(segment),
+ m_composition(segment->getComposition()),
+ m_audioFileManager(&(doc->getAudioFileManager())),
+ m_detached(false),
+ m_threshold(threshold)
+{}
+
+AudioSegmentAutoSplitCommand::~AudioSegmentAutoSplitCommand()
+{
+ if (m_detached) {
+ delete m_segment;
+ } else {
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i) {
+ delete m_newSegments[i];
+ }
+ }
+}
+
+void
+AudioSegmentAutoSplitCommand::execute()
+{
+ if (m_newSegments.size() == 0) {
+
+ std::vector<AutoSplitPoint> splitPoints;
+
+ if (m_segment->getType() != Segment::Audio)
+ return ;
+
+ // Auto split the audio file - we ask for a minimum
+ // result file size of 0.2secs - that's probably fair
+ // enough.
+ //
+ std::vector<SplitPointPair> rtSplitPoints;
+
+ try {
+ rtSplitPoints =
+ m_audioFileManager->
+ getSplitPoints(m_segment->getAudioFileId(),
+ m_segment->getAudioStartTime(),
+ m_segment->getAudioEndTime(),
+ m_threshold,
+ RealTime(0, 200000000));
+ } catch (AudioFileManager::BadAudioPathException e) {
+ std::cerr << "ERROR: AudioSegmentAutoSplitCommand: Bad audio path: " << e.getMessage() << std::endl;
+ } catch (PeakFileManager::BadPeakFileException e) {
+ std::cerr << "ERROR: AudioSegmentAutoSplitCommand: Bad peak file: " << e.getMessage() << std::endl;
+ }
+
+ std::vector<SplitPointPair>::iterator it;
+ timeT absStartTime, absEndTime;
+
+ char splitNumber[10];
+ int splitCount = 0;
+
+ timeT origStartTime = m_segment->getStartTime();
+ RealTime audioStart = m_segment->getAudioStartTime();
+ RealTime origStartRT = m_composition->getElapsedRealTime(origStartTime);
+
+ for (it = rtSplitPoints.begin(); it != rtSplitPoints.end(); it++) {
+ // The start time for the segment is the original
+ // segment's start time, plus whatever it->first translates
+ // into as an offset from the original segment's start
+ // time
+
+ RG_DEBUG << "AudioSegmentAutoSplitCommand::execute: range " << it->first << " -> " << it->second << endl;
+
+ absStartTime = m_composition->getElapsedTimeForRealTime
+ (origStartRT - audioStart + it->first);
+
+ absEndTime = m_composition->getElapsedTimeForRealTime
+ (origStartRT - audioStart + it->second);
+
+ // absStartTime = m_segment->getStartTime() +
+ // m_composition->getElapsedTimeForRealTime(it->first - audioStart);
+
+ // absEndTime = m_segment->getStartTime() +
+ // m_composition->getElapsedTimeForRealTime(it->second - audioStart);
+
+ Segment *newSegment = new Segment(*m_segment);
+
+ newSegment->setStartTime(absStartTime);
+ newSegment->setAudioFileId(m_segment->getAudioFileId());
+ newSegment->setAudioStartTime(it->first);
+ newSegment->setAudioEndTime(it->second);
+ newSegment->setEndMarkerTime(absEndTime);
+
+ // label
+ sprintf(splitNumber, "%d", splitCount++);
+ newSegment->
+ setLabel(qstrtostr(i18n("%1 (autosplit %2)").arg
+ (strtoqstr(m_segment->getLabel())).arg
+ (splitNumber)));
+
+ newSegment->setColourIndex(m_segment->getColourIndex());
+
+ RG_DEBUG << "AudioSegmentAutoSplitCommand::execute "
+ << "abs start = " << absStartTime
+ << ", abs end = " << absEndTime
+ << ", seg start = " << newSegment->getStartTime()
+ << ", seg end = " << newSegment->getEndMarkerTime()
+ << ", audio start = " << newSegment->getAudioStartTime()
+ << ", audio end = " << newSegment->getAudioEndTime()
+ << endl;
+
+ m_newSegments.push_back(newSegment);
+ }
+ }
+
+ RG_DEBUG << "AudioSegmentAutoSplitCommand::execute: have " << m_newSegments.size() << " new segments" << endl;
+
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i) {
+ m_composition->addSegment(m_newSegments[i]);
+ }
+
+ if (m_newSegments.size() > 0) {
+ m_composition->detachSegment(m_segment);
+ }
+
+ m_detached = true;
+}
+
+void
+AudioSegmentAutoSplitCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i) {
+ m_composition->detachSegment(m_newSegments[i]);
+ }
+ if (m_newSegments.size() > 0) { // otherwise it was never detached
+ m_composition->addSegment(m_segment);
+ }
+ m_detached = false;
+}
+
+}
diff --git a/src/commands/segment/AudioSegmentAutoSplitCommand.h b/src/commands/segment/AudioSegmentAutoSplitCommand.h
new file mode 100644
index 0000000..a1c4b48
--- /dev/null
+++ b/src/commands/segment/AudioSegmentAutoSplitCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_AUDIOSEGMENTAUTOSPLITCOMMAND_H_
+#define _RG_AUDIOSEGMENTAUTOSPLITCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class RosegardenGUIDoc;
+class Composition;
+class AudioFileManager;
+
+
+class AudioSegmentAutoSplitCommand : public KNamedCommand
+{
+public:
+ AudioSegmentAutoSplitCommand(RosegardenGUIDoc *doc,
+ Segment *segment,
+ int threshold);
+ virtual ~AudioSegmentAutoSplitCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName() { return i18n("&Split on Silence"); }
+
+private:
+ Segment *m_segment;
+ Composition *m_composition;
+ AudioFileManager *m_audioFileManager;
+ std::vector<Segment *> m_newSegments;
+ bool m_detached;
+ int m_threshold;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AudioSegmentDistributeCommand.cpp b/src/commands/segment/AudioSegmentDistributeCommand.cpp
new file mode 100644
index 0000000..9bdfb97
--- /dev/null
+++ b/src/commands/segment/AudioSegmentDistributeCommand.cpp
@@ -0,0 +1,156 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AudioSegmentDistributeCommand.h"
+
+#include "base/Event.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/RealTime.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "sound/AudioFile.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+AudioSegmentDistributeCommand::AudioSegmentDistributeCommand(
+ Composition *comp,
+ SegmentSelection &inputSelection,
+ Segment *audioSegment):
+ KNamedCommand(getGlobalName()),
+ m_composition(comp),
+ m_selection(inputSelection),
+ m_audioFile(0),
+ m_audioSegment(audioSegment),
+ m_executed(false)
+{}
+
+AudioSegmentDistributeCommand::AudioSegmentDistributeCommand(
+ Composition *comp,
+ SegmentSelection &inputSelection,
+ AudioFile *audioFile):
+ KNamedCommand(getGlobalName()),
+ m_composition(comp),
+ m_selection(inputSelection),
+ m_audioFile(audioFile),
+ m_audioSegment(0),
+ m_executed(false)
+{}
+
+AudioSegmentDistributeCommand::~AudioSegmentDistributeCommand()
+{
+ if (m_executed) {
+ for (SegmentSelection::iterator i = m_selection.begin();
+ i != m_selection.end(); ++i) {
+ delete *i;
+ }
+ } else {
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i)
+ delete m_newSegments[i];
+ }
+}
+
+void
+AudioSegmentDistributeCommand::execute()
+{
+ // Store the insert times in a local vector
+ //
+ std::vector<timeT> insertTimes;
+
+ bool addNew = m_newSegments.size() == 0 ? true : false;
+
+ for (SegmentSelection::iterator i = m_selection.begin();
+ i != m_selection.end(); ++i) {
+ // For MIDI (Internal) Segments only of course
+ //
+ if ((*i)->getType() == Segment::Internal) {
+ if (addNew) {
+ for (Segment::iterator it = (*i)->begin();
+ it != (*i)->end(); ++it) {
+ if ((*it)->isa(Note::EventType)) {
+ Segment *segment =
+ new Segment(
+ Segment::Audio,
+ (*it)->getAbsoluteTime());
+ segment->setTrack((*i)->getTrack());
+
+ // If we've constructed against an AudioFile
+ //
+ if (m_audioFile) {
+ segment->setAudioFileId(m_audioFile->getId());
+ segment->setAudioStartTime(
+ RealTime::zeroTime);
+ segment->setAudioEndTime(
+ m_audioFile->getLength());
+ } else // or an audio Segment
+ {
+ segment->setAudioFileId(
+ m_audioSegment->getAudioFileId());
+ segment->setAudioStartTime(
+ m_audioSegment->getAudioStartTime());
+ segment->setAudioEndTime(
+ m_audioSegment->getAudioEndTime());
+ }
+
+ m_composition->addSegment(segment);
+ m_newSegments.push_back(segment);
+ }
+ }
+ }
+
+ // Detach original Segment
+ //
+ m_composition->detachSegment(*i);
+ }
+
+ }
+
+ if (!addNew && m_newSegments.size()) {
+ // Reattach new segments
+ //
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i)
+ m_composition->addSegment(m_newSegments[i]);
+ }
+
+ m_executed = true;
+}
+
+void
+AudioSegmentDistributeCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i)
+ m_composition->detachSegment(m_newSegments[i]);
+
+ for (SegmentSelection::iterator it = m_selection.begin();
+ it != m_selection.end(); ++it)
+ m_composition->addSegment(*it);
+
+ m_executed = false;
+}
+
+}
diff --git a/src/commands/segment/AudioSegmentDistributeCommand.h b/src/commands/segment/AudioSegmentDistributeCommand.h
new file mode 100644
index 0000000..d325daf
--- /dev/null
+++ b/src/commands/segment/AudioSegmentDistributeCommand.h
@@ -0,0 +1,86 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_AUDIOSEGMENTDISTRIBUTECOMMAND_H_
+#define _RG_AUDIOSEGMENTDISTRIBUTECOMMAND_H_
+
+#include "base/Selection.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+class AudioFile;
+
+
+/**
+ * AudioSegmentDistributeCommand - Distribute an Audio Segment triggered
+ * against the MIDI Note ons in a SegmentSelection.
+ *
+ * (I think this is actually unused --cc)
+ */
+class AudioSegmentDistributeCommand : public KNamedCommand
+{
+public:
+ AudioSegmentDistributeCommand(Composition *comp,
+ SegmentSelection &inputSelection,
+ Segment *audioSegment);
+
+ AudioSegmentDistributeCommand(Composition *comp,
+ SegmentSelection &inputSelection,
+ AudioFile *audioFile);
+
+ virtual ~AudioSegmentDistributeCommand();
+
+ static QString getGlobalName()
+ { return i18n("Distribute Audio Segments over MIDI"); }
+
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ SegmentSelection m_selection;
+ AudioFile *m_audioFile;
+ Segment *m_audioSegment;
+ std::vector<Segment*> m_newSegments;
+ bool m_executed;
+
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AudioSegmentInsertCommand.cpp b/src/commands/segment/AudioSegmentInsertCommand.cpp
new file mode 100644
index 0000000..b5167f7
--- /dev/null
+++ b/src/commands/segment/AudioSegmentInsertCommand.cpp
@@ -0,0 +1,136 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AudioSegmentInsertCommand.h"
+
+#include <klocale.h>
+#include "misc/Debug.h"
+#include "misc/Strings.h"
+#include "base/Composition.h"
+#include "base/RealTime.h"
+#include "base/Segment.h"
+#include "base/Studio.h"
+#include "base/Track.h"
+#include "document/RosegardenGUIDoc.h"
+#include "gui/general/GUIPalette.h"
+#include "sound/AudioFile.h"
+#include "sound/AudioFileManager.h"
+
+
+namespace Rosegarden
+{
+
+AudioSegmentInsertCommand::AudioSegmentInsertCommand(RosegardenGUIDoc *doc,
+ TrackId track,
+ timeT startTime,
+ AudioFileId audioFileId,
+ const RealTime &audioStartTime,
+ const RealTime &audioEndTime):
+ KNamedCommand(i18n("Create Segment")),
+ m_composition(&(doc->getComposition())),
+ m_audioFileManager(&(doc->getAudioFileManager())),
+ m_segment(0),
+ m_track(track),
+ m_startTime(startTime),
+ m_audioFileId(audioFileId),
+ m_audioStartTime(audioStartTime),
+ m_audioEndTime(audioEndTime),
+ m_detached(false)
+{}
+
+AudioSegmentInsertCommand::~AudioSegmentInsertCommand()
+{
+ if (m_detached) {
+ delete m_segment;
+ }
+}
+
+void
+AudioSegmentInsertCommand::execute()
+{
+ if (!m_segment) {
+ // Create and insert Segment
+ //
+ m_segment = new Segment(Segment::Audio);
+ m_segment->setTrack(m_track);
+ m_segment->setStartTime(m_startTime);
+ m_segment->setAudioStartTime(m_audioStartTime);
+ m_segment->setAudioEndTime(m_audioEndTime);
+ m_segment->setAudioFileId(m_audioFileId);
+
+ // Set color for audio segment (DMM)
+ //
+ m_segment->setColourIndex(GUIPalette::AudioDefaultIndex);
+
+ // Calculate end time
+ //
+ RealTime startTime =
+ m_composition->getElapsedRealTime(m_startTime);
+
+ RealTime endTime =
+ startTime + m_audioEndTime - m_audioStartTime;
+
+ timeT endTimeT = m_composition->getElapsedTimeForRealTime(endTime);
+
+ RG_DEBUG << "AudioSegmentInsertCommand::execute : start timeT "
+ << m_startTime << ", startTime " << startTime << ", audioStartTime " << m_audioStartTime << ", audioEndTime " << m_audioEndTime << ", endTime " << endTime << ", end timeT " << endTimeT << endl;
+
+ m_segment->setEndTime(endTimeT);
+
+ if (endTimeT > m_composition->getEndMarker()) {
+ m_composition->setEndMarker(m_composition->getBarEndForTime(endTimeT));
+ }
+
+ // Label by audio file name
+ //
+ std::string label = "";
+
+ AudioFile *aF =
+ m_audioFileManager->getAudioFile(m_audioFileId);
+
+ if (aF)
+ label = qstrtostr(i18n("%1 (inserted)").arg
+ (strtoqstr(aF->getName())));
+ else
+ label = qstrtostr(i18n("unknown audio file"));
+
+ m_segment->setLabel(label);
+
+ m_composition->addSegment(m_segment);
+ } else {
+ m_composition->addSegment(m_segment);
+ }
+
+ m_detached = false;
+}
+
+void
+AudioSegmentInsertCommand::unexecute()
+{
+ m_composition->detachSegment(m_segment);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/AudioSegmentInsertCommand.h b/src/commands/segment/AudioSegmentInsertCommand.h
new file mode 100644
index 0000000..3510833
--- /dev/null
+++ b/src/commands/segment/AudioSegmentInsertCommand.h
@@ -0,0 +1,77 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_AUDIOSEGMENTINSERTCOMMAND_H_
+#define _RG_AUDIOSEGMENTINSERTCOMMAND_H_
+
+#include "base/RealTime.h"
+#include "base/Track.h"
+#include "sound/AudioFile.h"
+#include <kcommand.h>
+#include "base/Event.h"
+
+
+namespace Rosegarden
+{
+
+class Studio;
+class Segment;
+class RosegardenGUIDoc;
+class Composition;
+class AudioFileManager;
+
+
+class AudioSegmentInsertCommand : public KNamedCommand
+{
+public:
+ AudioSegmentInsertCommand(RosegardenGUIDoc *doc,
+ TrackId track,
+ timeT startTime,
+ AudioFileId audioFileId,
+ const RealTime &audioStartTime,
+ const RealTime &audioEndTime);
+ virtual ~AudioSegmentInsertCommand();
+
+ Segment *getNewSegment() { return m_segment; }
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ AudioFileManager *m_audioFileManager;
+ Segment *m_segment;
+ int m_track;
+ timeT m_startTime;
+ AudioFileId m_audioFileId;
+ RealTime m_audioStartTime;
+ RealTime m_audioEndTime;
+ bool m_detached;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AudioSegmentRescaleCommand.cpp b/src/commands/segment/AudioSegmentRescaleCommand.cpp
new file mode 100644
index 0000000..1386783
--- /dev/null
+++ b/src/commands/segment/AudioSegmentRescaleCommand.cpp
@@ -0,0 +1,210 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AudioSegmentRescaleCommand.h"
+
+#include "misc/Strings.h"
+#include "base/Event.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "document/RosegardenGUIDoc.h"
+#include "sound/AudioFileTimeStretcher.h"
+#include "sound/AudioFileManager.h"
+#include "gui/widgets/ProgressDialog.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+AudioSegmentRescaleCommand::AudioSegmentRescaleCommand(RosegardenGUIDoc *doc,
+ Segment *s,
+ float ratio) :
+ KNamedCommand(getGlobalName()),
+ m_afm(&doc->getAudioFileManager()),
+ m_stretcher(new AudioFileTimeStretcher(m_afm)),
+ m_segment(s),
+ m_newSegment(0),
+ m_fid(-1),
+ m_timesGiven(false),
+ m_startTime(0),
+ m_endMarkerTime(0),
+ m_ratio(ratio),
+ m_detached(false)
+{
+ // nothing
+}
+
+AudioSegmentRescaleCommand::AudioSegmentRescaleCommand(RosegardenGUIDoc *doc,
+ Segment *s,
+ float ratio,
+ timeT st,
+ timeT emt) :
+ KNamedCommand(getGlobalName()),
+ m_afm(&doc->getAudioFileManager()),
+ m_stretcher(new AudioFileTimeStretcher(m_afm)),
+ m_segment(s),
+ m_newSegment(0),
+ m_fid(-1),
+ m_timesGiven(true),
+ m_startTime(st),
+ m_endMarkerTime(emt),
+ m_ratio(ratio),
+ m_detached(false)
+{
+ // nothing
+}
+
+AudioSegmentRescaleCommand::~AudioSegmentRescaleCommand()
+{
+ delete m_stretcher;
+
+ if (m_detached) {
+ delete m_segment;
+ } else {
+ delete m_newSegment;
+ }
+}
+
+void
+AudioSegmentRescaleCommand::connectProgressDialog(ProgressDialog *dlg)
+{
+ QObject::connect(m_stretcher, SIGNAL(setProgress(int)),
+ dlg->progressBar(), SLOT(setValue(int)));
+ QObject::connect(dlg, SIGNAL(cancelClicked()),
+ m_stretcher, SLOT(slotStopTimestretch()));
+}
+
+void
+AudioSegmentRescaleCommand::disconnectProgressDialog(ProgressDialog *dlg)
+{
+ QObject::disconnect(m_stretcher, SIGNAL(setProgress(int)),
+ dlg->progressBar(), SLOT(setValue(int)));
+ QObject::disconnect(dlg, SIGNAL(cancelClicked()),
+ m_stretcher, SLOT(slotStopTimestretch()));
+}
+
+void
+AudioSegmentRescaleCommand::execute()
+{
+ timeT startTime = m_segment->getStartTime();
+
+ if (m_segment->getType() != Segment::Audio) {
+ return;
+ }
+
+ bool failed = false;
+
+ if (!m_newSegment) {
+
+ m_newSegment = new Segment(*m_segment);
+
+ QString oldLabel = strtoqstr(m_segment->getLabel());
+ if (!oldLabel.endsWith(i18n("(rescaled)"))) {
+ m_newSegment->setLabel(qstrtostr(i18n("%1 (rescaled)").arg
+ (oldLabel)));
+ }
+
+ AudioFileId sourceFileId = m_segment->getAudioFileId();
+ float absoluteRatio = m_ratio;
+
+ std::cerr << "AudioSegmentRescaleCommand: segment file id " << sourceFileId << ", given ratio " << m_ratio << std::endl;
+
+ if (m_segment->getStretchRatio() != 1.f &&
+ m_segment->getStretchRatio() != 0.f) {
+ sourceFileId = m_segment->getUnstretchedFileId();
+ absoluteRatio *= m_segment->getStretchRatio();
+ std::cerr << "AudioSegmentRescaleCommand: unstretched file id " << sourceFileId << ", prev ratio " << m_segment->getStretchRatio() << ", resulting ratio " << absoluteRatio << std::endl;
+ }
+
+ if (!m_timesGiven) {
+ m_endMarkerTime = m_segment->getStartTime() +
+ (m_segment->getEndMarkerTime() - m_segment->getStartTime()) * m_ratio;
+ }
+
+ try {
+ m_fid = m_stretcher->getStretchedAudioFile(sourceFileId,
+ absoluteRatio);
+ m_newSegment->setAudioFileId(m_fid);
+ m_newSegment->setUnstretchedFileId(sourceFileId);
+ m_newSegment->setStretchRatio(absoluteRatio);
+ m_newSegment->setAudioStartTime(m_segment->getAudioStartTime() *
+ m_ratio);
+ if (m_timesGiven) {
+ m_newSegment->setStartTime(m_startTime);
+ m_newSegment->setAudioEndTime(m_segment->getAudioEndTime() *
+ m_ratio);
+ m_newSegment->setEndMarkerTime(m_endMarkerTime);
+ } else {
+ m_newSegment->setEndMarkerTime(m_endMarkerTime);
+ m_newSegment->setAudioEndTime(m_segment->getAudioEndTime() *
+ m_ratio);
+ }
+ } catch (SoundFile::BadSoundFileException e) {
+ std::cerr << "AudioSegmentRescaleCommand: ERROR: BadSoundFileException: "
+ << e.getMessage() << std::endl;
+ delete m_newSegment;
+ m_newSegment = 0;
+ m_fid = -1;
+ failed = true;
+ } catch (AudioFileManager::BadAudioPathException e) {
+ std::cerr << "AudioSegmentRescaleCommand: ERROR: BadAudioPathException: "
+ << e.getMessage() << std::endl;
+ delete m_newSegment;
+ m_newSegment = 0;
+ m_fid = -1;
+ failed = true;
+ } catch (AudioFileTimeStretcher::CancelledException e) {
+ std::cerr << "AudioSegmentRescaleCommand: ERROR: Rescale cancelled" << std::endl;
+ delete m_newSegment;
+ m_newSegment = 0;
+ m_fid = -1;
+ failed = true;
+ }
+ }
+
+ if (failed) return;
+
+ m_segment->getComposition()->addSegment(m_newSegment);
+ m_segment->getComposition()->detachSegment(m_segment);
+
+// m_newSegment->setEndMarkerTime
+// (startTime + rescale(m_segment->getEndMarkerTime() - startTime));
+
+ m_detached = true;
+}
+
+void
+AudioSegmentRescaleCommand::unexecute()
+{
+ if (m_newSegment) {
+ m_newSegment->getComposition()->addSegment(m_segment);
+ m_newSegment->getComposition()->detachSegment(m_newSegment);
+ m_detached = false;
+ }
+}
+
+}
diff --git a/src/commands/segment/AudioSegmentRescaleCommand.h b/src/commands/segment/AudioSegmentRescaleCommand.h
new file mode 100644
index 0000000..a4edb13
--- /dev/null
+++ b/src/commands/segment/AudioSegmentRescaleCommand.h
@@ -0,0 +1,81 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_AUDIOSEGMENTRESCALECOMMAND_H_
+#define _RG_AUDIOSEGMENTRESCALECOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+namespace Rosegarden
+{
+
+class Segment;
+class AudioFileManager;
+class AudioFileTimeStretcher;
+class RosegardenGUIDoc;
+class ProgressDialog;
+
+class AudioSegmentRescaleCommand : public KNamedCommand
+{
+public:
+ AudioSegmentRescaleCommand(RosegardenGUIDoc *doc,
+ Segment *segment, float ratio);
+ AudioSegmentRescaleCommand(RosegardenGUIDoc *doc,
+ Segment *segment, float ratio,
+ timeT newStartTime,
+ timeT newEndMarkerTime);
+ virtual ~AudioSegmentRescaleCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ AudioFileTimeStretcher *getStretcher() { return m_stretcher; }
+ int getNewAudioFileId() const { return m_fid; }
+
+ void connectProgressDialog(ProgressDialog *dlg);
+ void disconnectProgressDialog(ProgressDialog *dlg);
+
+ static QString getGlobalName() { return i18n("Stretch or S&quash..."); }
+
+private:
+ AudioFileManager *m_afm;
+ AudioFileTimeStretcher *m_stretcher;
+ Segment *m_segment;
+ Segment *m_newSegment;
+ bool m_timesGiven;
+ timeT m_startTime;
+ timeT m_endMarkerTime;
+ int m_fid;
+ float m_ratio;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AudioSegmentResizeFromStartCommand.cpp b/src/commands/segment/AudioSegmentResizeFromStartCommand.cpp
new file mode 100644
index 0000000..5045500
--- /dev/null
+++ b/src/commands/segment/AudioSegmentResizeFromStartCommand.cpp
@@ -0,0 +1,87 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AudioSegmentResizeFromStartCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/RealTime.h"
+#include "base/Segment.h"
+
+
+namespace Rosegarden
+{
+
+AudioSegmentResizeFromStartCommand::AudioSegmentResizeFromStartCommand(Segment *segment,
+ timeT newStartTime) :
+ KNamedCommand(i18n("Resize Segment")),
+ m_segment(segment),
+ m_newSegment(0),
+ m_detached(false),
+ m_oldStartTime(segment->getStartTime()),
+ m_newStartTime(newStartTime)
+{}
+
+AudioSegmentResizeFromStartCommand::~AudioSegmentResizeFromStartCommand()
+{
+ if (!m_detached)
+ delete m_segment;
+ else
+ delete m_newSegment;
+}
+
+void
+AudioSegmentResizeFromStartCommand::execute()
+{
+ Composition *c = m_segment->getComposition();
+
+ if (!m_newSegment) {
+ RealTime oldRT = c->getElapsedRealTime(m_oldStartTime);
+ RealTime newRT = c->getElapsedRealTime(m_newStartTime);
+
+ m_newSegment = new Segment(*m_segment);
+ m_newSegment->setStartTime(m_newStartTime);
+ m_newSegment->setAudioStartTime(m_segment->getAudioStartTime() -
+ (oldRT - newRT));
+ }
+
+ c->addSegment(m_newSegment);
+ m_newSegment->setEndMarkerTime(m_segment->getEndMarkerTime());
+ c->detachSegment(m_segment);
+
+ m_detached = false;
+}
+
+void
+AudioSegmentResizeFromStartCommand::unexecute()
+{
+ Composition *c = m_newSegment->getComposition();
+ c->addSegment(m_segment);
+ c->detachSegment(m_newSegment);
+
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/AudioSegmentResizeFromStartCommand.h b/src/commands/segment/AudioSegmentResizeFromStartCommand.h
new file mode 100644
index 0000000..734a6e0
--- /dev/null
+++ b/src/commands/segment/AudioSegmentResizeFromStartCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_AUDIOSEGMENTRESIZEFROMSTARTCOMMAND_H_
+#define _RG_AUDIOSEGMENTRESIZEFROMSTARTCOMMAND_H_
+
+#include <kcommand.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+/**
+ * As above, but for audio segments.
+ */
+class AudioSegmentResizeFromStartCommand : public KNamedCommand
+{
+public:
+ AudioSegmentResizeFromStartCommand(Segment *segment,
+ timeT newStartTime);
+ virtual ~AudioSegmentResizeFromStartCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Segment *m_segment;
+ Segment *m_newSegment;
+ bool m_detached;
+ timeT m_oldStartTime;
+ timeT m_newStartTime;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/AudioSegmentSplitCommand.cpp b/src/commands/segment/AudioSegmentSplitCommand.cpp
new file mode 100644
index 0000000..f0c462e
--- /dev/null
+++ b/src/commands/segment/AudioSegmentSplitCommand.cpp
@@ -0,0 +1,155 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AudioSegmentSplitCommand.h"
+
+#include <klocale.h>
+#include "misc/Debug.h"
+#include "misc/Strings.h"
+#include "base/RealTime.h"
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+AudioSegmentSplitCommand::AudioSegmentSplitCommand(Segment *segment,
+ timeT splitTime) :
+ KNamedCommand(i18n("Split Audio Segment")),
+ m_segment(segment),
+ m_newSegment(0),
+ m_splitTime(splitTime),
+ m_previousEndMarkerTime(0),
+ m_detached(false)
+{}
+
+AudioSegmentSplitCommand::~AudioSegmentSplitCommand()
+{
+ if (m_detached) {
+ delete m_newSegment;
+ }
+ delete m_previousEndMarkerTime;
+}
+
+void
+AudioSegmentSplitCommand::execute()
+{
+ if (!m_newSegment) {
+
+ m_newSegment = new Segment(Segment::Audio);
+
+ // Basics
+ //
+ m_newSegment->setAudioFileId(m_segment->getAudioFileId());
+ m_newSegment->setTrack(m_segment->getTrack());
+
+ // Get the RealTime split time
+ //
+ RealTime splitDiff =
+ m_segment->getComposition()->getRealTimeDifference(
+ m_segment->getStartTime(), m_splitTime);
+
+ // Set audio start and end
+ //
+ m_newSegment->setAudioStartTime
+ (m_segment->getAudioStartTime() + splitDiff);
+ m_newSegment->setAudioEndTime(m_segment->getAudioEndTime());
+
+ // Insert into composition before setting end time
+ //
+ m_segment->getComposition()->addSegment(m_newSegment);
+
+ // Set start and end times
+ //
+ m_newSegment->setStartTime(m_splitTime);
+ m_newSegment->setEndTime(m_segment->getEndTime());
+
+ // Set original end time
+ //
+ // m_previousEndAudioTime = m_segment->getAudioEndTime();
+ // m_segment->setAudioEndTime(m_newSegment->getAudioStartTime());
+
+ RG_DEBUG << "AudioSegmentSplitCommand::execute: Set end audio of left segment to " << m_newSegment->getAudioStartTime() << endl;
+
+
+ // Set labels
+ //
+ m_segmentLabel = m_segment->getLabel();
+ QString newLabel = strtoqstr(m_segmentLabel);
+ if (!newLabel.endsWith(i18n(" (split)"))) {
+ newLabel = i18n("%1 (split)").arg(newLabel);
+ }
+ m_segment->setLabel(qstrtostr(newLabel));
+ m_newSegment->setLabel(m_segment->getLabel());
+
+ // Set color
+ //
+ m_newSegment->setColourIndex(m_segment->getColourIndex());
+ }
+
+ // Resize left hand Segment
+ //
+ const timeT *emt = m_segment->getRawEndMarkerTime();
+ if (emt) {
+ m_previousEndMarkerTime = new timeT(*emt);
+ } else {
+ m_previousEndMarkerTime = 0;
+ }
+
+ RG_DEBUG << "AudioSegmentSplitCommand::execute: Setting end marker of left segment to " << m_splitTime << endl;
+
+ m_segment->setEndMarkerTime(m_splitTime);
+
+ if (!m_newSegment->getComposition()) {
+ m_segment->getComposition()->addSegment(m_newSegment);
+ }
+
+ m_detached = false;
+
+}
+
+void
+AudioSegmentSplitCommand::unexecute()
+{
+ if (m_previousEndMarkerTime) {
+ RG_DEBUG << "AudioSegmentSplitCommand::unexecute: Restoring end marker of left segment to " << *m_previousEndMarkerTime << endl;
+
+ m_segment->setEndMarkerTime(*m_previousEndMarkerTime);
+ delete m_previousEndMarkerTime;
+ m_previousEndMarkerTime = 0;
+ } else {
+ m_segment->clearEndMarker();
+ }
+
+ m_segment->setLabel(m_segmentLabel);
+ // RG_DEBUG << "AudioSegmentSplitCommand::unexecute: Setting audio end time of left segment to " << m_previousEndAudioTime << endl;
+ // m_segment->setAudioEndTime(m_previousEndAudioTime);
+ m_segment->getComposition()->detachSegment(m_newSegment);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/AudioSegmentSplitCommand.h b/src/commands/segment/AudioSegmentSplitCommand.h
new file mode 100644
index 0000000..ce7c59c
--- /dev/null
+++ b/src/commands/segment/AudioSegmentSplitCommand.h
@@ -0,0 +1,65 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_AUDIOSEGMENTSPLITCOMMAND_H_
+#define _RG_AUDIOSEGMENTSPLITCOMMAND_H_
+
+#include <string>
+#include <kcommand.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class AudioSegmentSplitCommand : public KNamedCommand
+{
+public:
+ AudioSegmentSplitCommand(Segment *segment,
+ timeT splitTime);
+ virtual ~AudioSegmentSplitCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Segment *m_segment;
+ Segment *m_newSegment;
+ timeT m_splitTime;
+ timeT *m_previousEndMarkerTime;
+ bool m_detached;
+ std::string m_segmentLabel;
+// RealTime m_previousEndAudioTime;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/ChangeCompositionLengthCommand.cpp b/src/commands/segment/ChangeCompositionLengthCommand.cpp
new file mode 100644
index 0000000..bdeb7a5
--- /dev/null
+++ b/src/commands/segment/ChangeCompositionLengthCommand.cpp
@@ -0,0 +1,64 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ChangeCompositionLengthCommand.h"
+
+#include "base/Composition.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+ChangeCompositionLengthCommand::ChangeCompositionLengthCommand(
+ Composition *composition,
+ timeT startTime,
+ timeT endTime):
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_startTime(startTime),
+ m_endTime(endTime),
+ m_oldStartTime(m_composition->getStartMarker()),
+ m_oldEndTime(m_composition->getEndMarker())
+{}
+
+ChangeCompositionLengthCommand::~ChangeCompositionLengthCommand()
+{}
+
+void
+ChangeCompositionLengthCommand::execute()
+{
+ m_composition->setStartMarker(m_startTime);
+ m_composition->setEndMarker(m_endTime);
+}
+
+void
+ChangeCompositionLengthCommand::unexecute()
+{
+ m_composition->setStartMarker(m_oldStartTime);
+ m_composition->setEndMarker(m_oldEndTime);
+}
+
+}
diff --git a/src/commands/segment/ChangeCompositionLengthCommand.h b/src/commands/segment/ChangeCompositionLengthCommand.h
new file mode 100644
index 0000000..9e0db9b
--- /dev/null
+++ b/src/commands/segment/ChangeCompositionLengthCommand.h
@@ -0,0 +1,70 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CHANGECOMPOSITIONLENGTHCOMMAND_H_
+#define _RG_CHANGECOMPOSITIONLENGTHCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+class Change;
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class ChangeCompositionLengthCommand : public KNamedCommand
+{
+public:
+ ChangeCompositionLengthCommand(Composition *composition,
+ timeT startTime,
+ timeT endTime);
+ virtual ~ChangeCompositionLengthCommand();
+
+ static QString getGlobalName()
+ { return i18n("Change &Composition Start and End..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ timeT m_startTime;
+ timeT m_endTime;
+ timeT m_oldStartTime;
+ timeT m_oldEndTime;
+
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/CreateTempoMapFromSegmentCommand.cpp b/src/commands/segment/CreateTempoMapFromSegmentCommand.cpp
new file mode 100644
index 0000000..e548875
--- /dev/null
+++ b/src/commands/segment/CreateTempoMapFromSegmentCommand.cpp
@@ -0,0 +1,166 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "CreateTempoMapFromSegmentCommand.h"
+
+#include <klocale.h>
+#include "misc/Debug.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/RealTime.h"
+#include "base/Segment.h"
+
+
+namespace Rosegarden
+{
+
+CreateTempoMapFromSegmentCommand::CreateTempoMapFromSegmentCommand(Segment *groove) :
+ KNamedCommand(i18n("Set Tempos from Beat Segment")),
+ m_composition(groove->getComposition())
+{
+ initialise(groove);
+}
+
+CreateTempoMapFromSegmentCommand::~CreateTempoMapFromSegmentCommand()
+{
+ // nothing
+}
+
+void
+CreateTempoMapFromSegmentCommand::execute()
+{
+ for (TempoMap::iterator i = m_oldTempi.begin(); i != m_oldTempi.end(); ++i) {
+ int n = m_composition->getTempoChangeNumberAt(i->first);
+ if (n < m_composition->getTempoChangeCount()) {
+ m_composition->removeTempoChange(n);
+ }
+ }
+
+ for (TempoMap::iterator i = m_newTempi.begin(); i != m_newTempi.end(); ++i) {
+ m_composition->addTempoAtTime(i->first, i->second);
+ }
+}
+
+void
+CreateTempoMapFromSegmentCommand::unexecute()
+{
+ for (TempoMap::iterator i = m_newTempi.begin(); i != m_newTempi.end(); ++i) {
+ int n = m_composition->getTempoChangeNumberAt(i->first);
+ if (n < m_composition->getTempoChangeCount()) {
+ m_composition->removeTempoChange(n);
+ }
+ }
+
+ for (TempoMap::iterator i = m_oldTempi.begin(); i != m_oldTempi.end(); ++i) {
+ m_composition->addTempoAtTime(i->first, i->second);
+ }
+}
+
+void
+CreateTempoMapFromSegmentCommand::initialise(Segment *s)
+{
+ m_oldTempi.clear();
+ m_newTempi.clear();
+
+ //!!! need an additional option: per-chord, per-beat, per-bar.
+ // Let's work per-beat for the moment. Even for this, we should
+ // probably use TimeSignature.getDivisions()
+
+ std::vector<timeT> beatTimeTs;
+ std::vector<RealTime> beatRealTimes;
+
+ int startBar = m_composition->getBarNumber(s->getStartTime());
+ int barNo = startBar;
+ int beat = 0;
+
+ for (Segment::iterator i = s->begin(); s->isBeforeEndMarker(i); ++i) {
+ if ((*i)->isa(Note::EventType)) {
+
+ bool isNew;
+ TimeSignature sig =
+ m_composition->getTimeSignatureInBar(barNo, isNew);
+
+ beatTimeTs.push_back(m_composition->getBarStart(barNo) +
+ beat * sig.getBeatDuration());
+
+ if (++beat >= sig.getBeatsPerBar()) {
+ ++barNo;
+ beat = 0;
+ }
+
+ beatRealTimes.push_back(s->getComposition()->getElapsedRealTime
+ ((*i)->getAbsoluteTime()));
+ }
+ }
+
+ if (beatTimeTs.size() < 2)
+ return ;
+
+ tempoT prevTempo = 0;
+
+ // set up m_oldTempi and prevTempo
+
+ for (int i = m_composition->getTempoChangeNumberAt(*beatTimeTs.begin() - 1) + 1;
+ i <= m_composition->getTempoChangeNumberAt(*beatTimeTs.end() - 1); ++i) {
+
+ std::pair<timeT, tempoT> tempoChange =
+ m_composition->getTempoChange(i);
+ m_oldTempi[tempoChange.first] = tempoChange.second;
+ if (prevTempo == 0)
+ prevTempo = tempoChange.second;
+ }
+
+ RG_DEBUG << "starting tempo: " << prevTempo << endl;
+
+ timeT quarter = Note(Note::Crotchet).getDuration();
+
+ for (int beat = 1; beat < beatTimeTs.size(); ++beat) {
+
+ timeT beatTime = beatTimeTs[beat] - beatTimeTs[beat - 1];
+ RealTime beatRealTime = beatRealTimes[beat] - beatRealTimes[beat - 1];
+
+ // Calculate tempo to nearest qpm.
+ // This is 60 / {quarter note duration in seconds}
+ // = 60 / ( {beat in seconds} * {quarter in ticks} / { beat in ticks} )
+ // = ( 60 * {beat in ticks} ) / ( {beat in seconds} * {quarter in ticks} )
+ // Precision is deliberately limited to qpm to avoid silly values.
+
+ double beatSec = double(beatRealTime.sec) +
+ double(beatRealTime.usec() / 1000000.0);
+ double qpm = (60.0 * beatTime) / (beatSec * quarter);
+ tempoT tempo = Composition::getTempoForQpm(int(qpm + 0.001));
+
+ RG_DEBUG << "prev beat: " << beatTimeTs[beat] << ", prev beat real time " << beatRealTimes[beat] << endl;
+ RG_DEBUG << "time " << beatTime << ", rt " << beatRealTime << ", beatSec " << beatSec << ", tempo " << tempo << endl;
+
+ if (tempo != prevTempo) {
+ m_newTempi[beatTimeTs[beat - 1]] = tempo;
+ prevTempo = tempo;
+ }
+ }
+
+}
+
+}
diff --git a/src/commands/segment/CreateTempoMapFromSegmentCommand.h b/src/commands/segment/CreateTempoMapFromSegmentCommand.h
new file mode 100644
index 0000000..f6ea4d5
--- /dev/null
+++ b/src/commands/segment/CreateTempoMapFromSegmentCommand.h
@@ -0,0 +1,69 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CREATETEMPOMAPFROMSEGMENTCOMMAND_H_
+#define _RG_CREATETEMPOMAPFROMSEGMENTCOMMAND_H_
+
+#include <map>
+#include <kcommand.h>
+#include "base/Event.h"
+#include "base/Composition.h" // for tempoT
+
+
+
+
+namespace Rosegarden
+{
+
+
+/**
+ * CreateTempoMapFromSegment applies timings found in a reference
+ * segment to the composition as a whole via the tempo map.
+ */
+
+class CreateTempoMapFromSegmentCommand : public KNamedCommand
+{
+public:
+ CreateTempoMapFromSegmentCommand(Segment *grooveSegment);
+ virtual ~CreateTempoMapFromSegmentCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ void initialise(Segment *s);
+
+ Composition *m_composition;
+
+ typedef std::map<timeT, tempoT> TempoMap;
+ TempoMap m_oldTempi;
+ TempoMap m_newTempi;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/CutRangeCommand.cpp b/src/commands/segment/CutRangeCommand.cpp
new file mode 100644
index 0000000..df91398
--- /dev/null
+++ b/src/commands/segment/CutRangeCommand.cpp
@@ -0,0 +1,47 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "CutRangeCommand.h"
+
+#include <klocale.h>
+#include "base/Clipboard.h"
+#include "base/Composition.h"
+#include "commands/edit/CopyCommand.h"
+#include "DeleteRangeCommand.h"
+
+
+namespace Rosegarden
+{
+
+CutRangeCommand::CutRangeCommand(Composition *composition,
+ timeT t0, timeT t1,
+ Clipboard *clipboard) :
+ KMacroCommand(i18n("Cut Range"))
+{
+ addCommand(new CopyCommand(composition, t0, t1, clipboard));
+ addCommand(new DeleteRangeCommand(composition, t0, t1));
+}
+
+}
diff --git a/src/commands/segment/CutRangeCommand.h b/src/commands/segment/CutRangeCommand.h
new file mode 100644
index 0000000..f2b3402
--- /dev/null
+++ b/src/commands/segment/CutRangeCommand.h
@@ -0,0 +1,53 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CUTRANGECOMMAND_H_
+#define _RG_CUTRANGECOMMAND_H_
+
+#include "base/Event.h"
+#include <kcommand.h>
+
+
+namespace Rosegarden
+{
+
+class Composition;
+class Clipboard;
+
+
+class CutRangeCommand : public KMacroCommand
+{
+public:
+ CutRangeCommand(Composition *composition,
+ timeT begin,
+ timeT end,
+ Clipboard *clipboard);
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/DeleteRangeCommand.cpp b/src/commands/segment/DeleteRangeCommand.cpp
new file mode 100644
index 0000000..05ec79f
--- /dev/null
+++ b/src/commands/segment/DeleteRangeCommand.cpp
@@ -0,0 +1,127 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "DeleteRangeCommand.h"
+
+#include "AudioSegmentSplitCommand.h"
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include "EraseSegmentsStartingInRangeCommand.h"
+#include "OpenOrCloseRangeCommand.h"
+#include "SegmentJoinCommand.h"
+#include "SegmentSplitCommand.h"
+
+
+namespace Rosegarden
+{
+
+DeleteRangeCommand::DeleteRangeCommand(Composition *composition,
+ timeT t0, timeT t1) :
+ KMacroCommand(i18n("Delete Range"))
+{
+ // First add commands to split the segments up. Make a note of
+ // segments that will need rejoining with their neighbours
+ // afterwards.
+
+ std::vector<Segment *> rejoins;
+
+ for (int e = 0; e < 2; ++e) {
+
+ // Split all segments at the range end first, then the range
+ // begin afterwards. This is because the split commands create
+ // new segments for the right part and leave the left parts in
+ // the original segments, so that we can use the same segment
+ // pointer to do the left split as we did for the right
+
+ timeT t = t1;
+ if (e == 1)
+ t = t0;
+
+ for (Composition::iterator i = composition->begin();
+ i != composition->end(); ++i) {
+
+ if ((*i)->getStartTime() >= t || (*i)->getEndMarkerTime() <= t) {
+ continue;
+ }
+
+ if ((*i)->getType() == Segment::Audio) {
+ addCommand(new AudioSegmentSplitCommand(*i, t));
+ } else {
+ addCommand(new SegmentSplitCommand(*i, t));
+
+ if (t == t0 && (*i)->getEndMarkerTime() > t1) {
+ rejoins.push_back(*i);
+ }
+ }
+ }
+ }
+
+ // Then commands to do the rest of the work
+
+ addCommand(new EraseSegmentsStartingInRangeCommand(composition, t0, t1));
+
+ addCommand(new OpenOrCloseRangeCommand(composition, t0, t1, false));
+
+ for (std::vector<Segment *>::iterator i = rejoins.begin();
+ i != rejoins.end(); ++i) {
+ addCommand(new RejoinCommand(composition, *i,
+ (*i)->getEndMarkerTime() + t0 - t1));
+ }
+}
+
+DeleteRangeCommand::~DeleteRangeCommand()
+{}
+
+void
+DeleteRangeCommand::RejoinCommand::execute()
+{
+ if (m_joinCommand) {
+ m_joinCommand->execute();
+ return ;
+ }
+
+ //!!! Need to remove the "(split)" names from the segment bits
+
+ for (Composition::iterator i = m_composition->begin();
+ i != m_composition->end(); ++i) {
+ if ((*i) == m_segment)
+ continue;
+ if ((*i)->getTrack() != m_segment->getTrack())
+ continue;
+ if ((*i)->getEndMarkerTime() != m_endMarkerTime)
+ continue;
+ if ((*i)->getStartTime() <= m_segment->getStartTime())
+ continue;
+ SegmentSelection selection;
+ selection.insert(m_segment);
+ selection.insert(*i);
+ m_joinCommand = new SegmentJoinCommand(selection);
+ m_joinCommand->execute();
+ break;
+ }
+}
+
+}
diff --git a/src/commands/segment/DeleteRangeCommand.h b/src/commands/segment/DeleteRangeCommand.h
new file mode 100644
index 0000000..6b198ea
--- /dev/null
+++ b/src/commands/segment/DeleteRangeCommand.h
@@ -0,0 +1,84 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_DELETERANGECOMMAND_H_
+#define _RG_DELETERANGECOMMAND_H_
+
+#include <kcommand.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+#include "SegmentJoinCommand.h"
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+class DeleteRangeCommand : public KMacroCommand
+{
+public:
+ DeleteRangeCommand(Composition *composition,
+ timeT begin,
+ timeT end);
+ virtual ~DeleteRangeCommand();
+
+private:
+ class RejoinCommand : public KNamedCommand
+ {
+ public:
+ // This command rejoins s on to a subsequent segment on the same
+ // track that ends at endMarkerTime (presumably the original end
+ // marker time of s, with the range duration subtracted).
+
+ RejoinCommand(Composition *c,
+ Segment *s,
+ timeT endMarkerTime) :
+ KNamedCommand(i18n("Rejoin Command")),
+ m_composition(c), m_segment(s), m_endMarkerTime(endMarkerTime),
+ m_joinCommand(0) { }
+
+ ~RejoinCommand() { delete m_joinCommand; }
+
+ void execute();
+ void unexecute() { if (m_joinCommand) m_joinCommand->unexecute(); }
+
+ private:
+ Composition *m_composition;
+ Segment *m_segment;
+ timeT m_endMarkerTime;
+
+ SegmentJoinCommand *m_joinCommand;
+ };
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/DeleteTracksCommand.cpp b/src/commands/segment/DeleteTracksCommand.cpp
new file mode 100644
index 0000000..bad2be0
--- /dev/null
+++ b/src/commands/segment/DeleteTracksCommand.cpp
@@ -0,0 +1,161 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "DeleteTracksCommand.h"
+
+#include "misc/Debug.h"
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+DeleteTracksCommand::DeleteTracksCommand(Composition *composition,
+ std::vector<TrackId> tracks):
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_tracks(tracks),
+ m_detached(false)
+{}
+
+DeleteTracksCommand::~DeleteTracksCommand()
+{
+ if (m_detached) {
+ for (unsigned int i = 0; i < m_oldTracks.size(); ++i)
+ delete m_oldTracks[i];
+
+ for (unsigned int i = 0; i < m_oldSegments.size(); ++i)
+ delete m_oldSegments[i];
+
+ m_oldTracks.clear();
+ m_oldSegments.clear();
+ }
+}
+
+void DeleteTracksCommand::execute()
+{
+ Track *track = 0;
+ const Composition::segmentcontainer &segments =
+ m_composition->getSegments();
+
+ //cout << "DeleteTracksCommand::execute()" << endl;
+
+ m_oldSegments.clear();
+ m_oldTracks.clear();
+
+ // Remap positions and track numbers
+ //
+
+ Composition::trackiterator tit;
+ Composition::trackcontainer
+ &tracks = m_composition->getTracks();
+
+ for (unsigned int i = 0; i < m_tracks.size(); ++i) {
+ // detach segments and store tracks somewhere
+ track = m_composition->getTrackById(m_tracks[i]);
+
+ if (track) {
+ // detach all segments for that track
+ //
+ for (Composition::segmentcontainer::const_iterator
+ it = segments.begin();
+ it != segments.end(); ++it) {
+ if ((*it)->getTrack() == m_tracks[i]) {
+ m_oldSegments.push_back(*it);
+ m_composition->detachSegment(*it);
+ }
+ }
+
+ // store old tracks
+ m_oldTracks.push_back(track);
+ if (m_composition->detachTrack(track) == false) {
+ RG_DEBUG << "DeleteTracksCommand::execute - can't detach track" << endl;
+ }
+ }
+ }
+
+ std::vector<Track*>::iterator otIt;
+ for (otIt = m_oldTracks.begin(); otIt != m_oldTracks.end(); ++otIt) {
+ for (tit = tracks.begin(); tit != tracks.end(); ++tit) {
+ if ((*tit).second->getPosition() > (*otIt)->getPosition()) {
+ // If the track we've removed was after the current
+ // track then decrement the track position.
+ //
+ int newPosition = (*tit).second->getPosition() - 1;
+
+ (*tit).second->setPosition(newPosition);
+
+ }
+ }
+ }
+
+ m_detached = true;
+}
+
+void DeleteTracksCommand::unexecute()
+{
+ // Add the tracks and the segments back in
+ //
+
+ // Remap positions and track numbers
+ //
+ Composition::trackcontainer
+ &tracks = m_composition->getTracks();
+ Composition::trackiterator tit;
+
+ std::vector<Track*>::iterator otIt;
+ for (otIt = m_oldTracks.begin(); otIt != m_oldTracks.end(); ++otIt) {
+ // From the back we shuffle out the tracks to allow the new
+ // (old) track some space to come back in.
+ //
+ tit = tracks.end();
+ while (true) {
+ --tit;
+
+ if ((*tit).second->getPosition() >= (*otIt)->getPosition()) {
+ // If the track we're adding has position after the
+ // current track then increment position.
+ //
+ int newPosition = (*tit).second->getPosition() + 1;
+
+ (*tit).second->setPosition(newPosition);
+ }
+
+ if (tit == tracks.begin())
+ break;
+ }
+
+ m_composition->addTrack(*otIt);
+ }
+
+ for (unsigned int i = 0; i < m_oldSegments.size(); ++i)
+ m_composition->addSegment(m_oldSegments[i]);
+
+ m_detached = false;
+}
+
+}
diff --git a/src/commands/segment/DeleteTracksCommand.h b/src/commands/segment/DeleteTracksCommand.h
new file mode 100644
index 0000000..d1d2332
--- /dev/null
+++ b/src/commands/segment/DeleteTracksCommand.h
@@ -0,0 +1,68 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_DELETETRACKSCOMMAND_H_
+#define _RG_DELETETRACKSCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+#include "base/Track.h"
+
+
+namespace Rosegarden
+{
+
+class Track;
+class Segment;
+class Composition;
+
+
+class DeleteTracksCommand : public KNamedCommand
+{
+public:
+ DeleteTracksCommand(Composition *composition,
+ std::vector<TrackId> tracks);
+ virtual ~DeleteTracksCommand();
+
+ static QString getGlobalName() { return i18n("Delete Tracks..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ std::vector<TrackId> m_tracks;
+
+ std::vector<Track*> m_oldTracks;
+ std::vector<Segment*> m_oldSegments;
+ bool m_detached;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/DeleteTriggerSegmentCommand.cpp b/src/commands/segment/DeleteTriggerSegmentCommand.cpp
new file mode 100644
index 0000000..3ddb4af
--- /dev/null
+++ b/src/commands/segment/DeleteTriggerSegmentCommand.cpp
@@ -0,0 +1,78 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "DeleteTriggerSegmentCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include "base/TriggerSegment.h"
+#include "document/RosegardenGUIDoc.h"
+
+
+namespace Rosegarden
+{
+
+DeleteTriggerSegmentCommand::DeleteTriggerSegmentCommand(RosegardenGUIDoc *doc,
+ TriggerSegmentId id) :
+ KNamedCommand(i18n("Delete Triggered Segment")),
+ m_composition(&doc->getComposition()),
+ m_id(id),
+ m_segment(0),
+ m_basePitch( -1),
+ m_baseVelocity( -1),
+ m_detached(true)
+{
+ // nothing else
+}
+
+DeleteTriggerSegmentCommand::~DeleteTriggerSegmentCommand()
+{
+ if (m_detached)
+ delete m_segment;
+}
+
+void
+DeleteTriggerSegmentCommand::execute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ m_segment = rec->getSegment();
+ m_basePitch = rec->getBasePitch();
+ m_baseVelocity = rec->getBaseVelocity();
+ m_composition->detachTriggerSegment(m_id);
+ m_detached = true;
+}
+
+void
+DeleteTriggerSegmentCommand::unexecute()
+{
+ if (m_segment)
+ m_composition->addTriggerSegment(m_segment, m_id, m_basePitch, m_baseVelocity);
+ m_detached = false;
+}
+
+}
diff --git a/src/commands/segment/DeleteTriggerSegmentCommand.h b/src/commands/segment/DeleteTriggerSegmentCommand.h
new file mode 100644
index 0000000..30986f7
--- /dev/null
+++ b/src/commands/segment/DeleteTriggerSegmentCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_DELETETRIGGERSEGMENTCOMMAND_H_
+#define _RG_DELETETRIGGERSEGMENTCOMMAND_H_
+
+#include "base/TriggerSegment.h"
+#include <kcommand.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class RosegardenGUIDoc;
+class Composition;
+
+
+class DeleteTriggerSegmentCommand : public KNamedCommand
+{
+public:
+ DeleteTriggerSegmentCommand(RosegardenGUIDoc *doc,
+ TriggerSegmentId);
+ virtual ~DeleteTriggerSegmentCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ TriggerSegmentId m_id;
+ Segment *m_segment;
+ int m_basePitch;
+ int m_baseVelocity;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/EraseSegmentsStartingInRangeCommand.cpp b/src/commands/segment/EraseSegmentsStartingInRangeCommand.cpp
new file mode 100644
index 0000000..35f7f10
--- /dev/null
+++ b/src/commands/segment/EraseSegmentsStartingInRangeCommand.cpp
@@ -0,0 +1,99 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "EraseSegmentsStartingInRangeCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/Segment.h"
+
+
+namespace Rosegarden
+{
+
+EraseSegmentsStartingInRangeCommand::EraseSegmentsStartingInRangeCommand(
+ Composition *composition,
+ timeT t0, timeT t1) :
+ KNamedCommand(i18n("Delete Range")),
+ m_composition(composition),
+ m_beginTime(t0),
+ m_endTime(t1),
+ m_detached(false)
+{}
+
+EraseSegmentsStartingInRangeCommand::~EraseSegmentsStartingInRangeCommand()
+{
+ if (m_detached) {
+ for (std::vector<Segment *>::iterator i = m_detaching.begin();
+ i != m_detaching.end(); ++i) {
+ delete *i;
+ }
+ }
+}
+
+void
+EraseSegmentsStartingInRangeCommand::execute()
+{
+ if (m_detaching.empty()) {
+
+ for (Composition::iterator i = m_composition->begin();
+ i != m_composition->end(); ++i) {
+
+ if ((*i)->getStartTime() >= m_beginTime &&
+ (*i)->getStartTime() < m_endTime) {
+ m_detaching.push_back(*i);
+ }
+ }
+ }
+
+ for (std::vector<Segment *>::iterator i = m_detaching.begin();
+ i != m_detaching.end(); ++i) {
+ m_composition->detachSegment(*i);
+ }
+
+ m_detached = true;
+}
+
+void
+EraseSegmentsStartingInRangeCommand::unexecute()
+{
+ for (std::vector<Segment *>::iterator i = m_detaching.begin();
+ i != m_detaching.end(); ++i) {
+
+ m_composition->addSegment(*i);
+
+ //!!! see horrible code in SegmentEraseCommand::unexecute()
+ // to restore the audio file ID association in audio file mgr
+ // when an audio segment is restored. Why is this necessary?
+ // What is the agency that removed the audio file association
+ // in the first place, and why? Need to investigate that
+ // before heedlessly duplicating the same horrors here.
+
+ }
+
+ m_detached = false;
+}
+
+}
diff --git a/src/commands/segment/EraseSegmentsStartingInRangeCommand.h b/src/commands/segment/EraseSegmentsStartingInRangeCommand.h
new file mode 100644
index 0000000..70b6978
--- /dev/null
+++ b/src/commands/segment/EraseSegmentsStartingInRangeCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ERASESEGMENTSSTARTINGINRANGECOMMAND_H_
+#define _RG_ERASESEGMENTSSTARTINGINRANGECOMMAND_H_
+
+#include <kcommand.h>
+#include <vector>
+#include "base/Event.h"
+#include "gui/application/RosegardenDCOP.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+class EraseSegmentsStartingInRangeCommand : public KNamedCommand
+{
+public:
+ EraseSegmentsStartingInRangeCommand(Composition *composition,
+ timeT begin,
+ timeT end);
+ virtual ~EraseSegmentsStartingInRangeCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ timeT m_beginTime;
+ timeT m_endTime;
+
+ bool m_detached;
+ std::vector<Segment *> m_detaching;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/InsertRangeCommand.cpp b/src/commands/segment/InsertRangeCommand.cpp
new file mode 100644
index 0000000..73dc5fd
--- /dev/null
+++ b/src/commands/segment/InsertRangeCommand.cpp
@@ -0,0 +1,63 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "InsertRangeCommand.h"
+
+#include <klocale.h>
+#include "AudioSegmentSplitCommand.h"
+#include "base/Clipboard.h"
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include "OpenOrCloseRangeCommand.h"
+#include "SegmentSplitCommand.h"
+
+
+namespace Rosegarden
+{
+
+InsertRangeCommand::InsertRangeCommand(Composition *composition,
+ timeT t0, timeT duration) :
+ KMacroCommand(i18n("Insert Range"))
+{
+ // Need to split segments before opening, at t0
+
+ for (Composition::iterator i = composition->begin();
+ i != composition->end(); ++i) {
+
+ if ((*i)->getStartTime() >= t0 || (*i)->getEndMarkerTime() <= t0) {
+ continue;
+ }
+
+ if ((*i)->getType() == Segment::Audio) {
+ addCommand(new AudioSegmentSplitCommand(*i, t0));
+ } else {
+ addCommand(new SegmentSplitCommand(*i, t0));
+ }
+ }
+
+ addCommand(new OpenOrCloseRangeCommand(composition, t0, t0 + duration, true));
+}
+
+}
diff --git a/src/commands/segment/InsertRangeCommand.h b/src/commands/segment/InsertRangeCommand.h
new file mode 100644
index 0000000..e3960c8
--- /dev/null
+++ b/src/commands/segment/InsertRangeCommand.h
@@ -0,0 +1,47 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_INSERTRANGECOMMAND_H_
+#define _RG_INSERTRANGECOMMAND_H_
+
+#include "base/Event.h"
+#include <kcommand.h>
+
+namespace Rosegarden
+{
+
+class Composition;
+
+class InsertRangeCommand : public KMacroCommand
+{
+public:
+ InsertRangeCommand(Composition *composition,
+ timeT startTime, timeT duration);
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/ModifyDefaultTempoCommand.cpp b/src/commands/segment/ModifyDefaultTempoCommand.cpp
new file mode 100644
index 0000000..88360a4
--- /dev/null
+++ b/src/commands/segment/ModifyDefaultTempoCommand.cpp
@@ -0,0 +1,48 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ModifyDefaultTempoCommand.h"
+
+#include "base/Composition.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+ModifyDefaultTempoCommand::execute()
+{
+ m_oldTempo = m_composition->getCompositionDefaultTempo();
+ m_composition->setCompositionDefaultTempo(m_tempo);
+}
+
+void
+ModifyDefaultTempoCommand::unexecute()
+{
+ m_composition->setCompositionDefaultTempo(m_oldTempo);
+}
+
+}
diff --git a/src/commands/segment/ModifyDefaultTempoCommand.h b/src/commands/segment/ModifyDefaultTempoCommand.h
new file mode 100644
index 0000000..50f736d
--- /dev/null
+++ b/src/commands/segment/ModifyDefaultTempoCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MODIFYDEFAULTTEMPOCOMMAND_H_
+#define _RG_MODIFYDEFAULTTEMPOCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+#include "base/Composition.h" // for tempoT
+
+
+
+namespace Rosegarden
+{
+
+
+class ModifyDefaultTempoCommand : public KNamedCommand
+{
+public:
+ ModifyDefaultTempoCommand(Composition *composition,
+ tempoT tempo):
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_tempo(tempo) {}
+
+ virtual ~ModifyDefaultTempoCommand() {}
+
+ static QString getGlobalName() { return i18n("Modify &Default Tempo..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ tempoT m_tempo;
+ tempoT m_oldTempo;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/MoveTracksCommand.cpp b/src/commands/segment/MoveTracksCommand.cpp
new file mode 100644
index 0000000..49c089b
--- /dev/null
+++ b/src/commands/segment/MoveTracksCommand.cpp
@@ -0,0 +1,76 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "MoveTracksCommand.h"
+
+#include "base/Composition.h"
+#include "base/Track.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+MoveTracksCommand::MoveTracksCommand(Composition *composition,
+ TrackId srcTrack,
+ TrackId destTrack):
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_srcTrack(srcTrack),
+ m_destTrack(destTrack)
+{}
+
+MoveTracksCommand::~MoveTracksCommand()
+{}
+
+void
+MoveTracksCommand::execute()
+{
+ Track *srcTrack = m_composition->getTrackById(m_srcTrack);
+ Track *destTrack = m_composition->getTrackById(m_destTrack);
+
+ int srcPosition = srcTrack->getPosition();
+
+ srcTrack->setPosition(destTrack->getPosition());
+ destTrack->setPosition(srcPosition);
+
+ m_composition->updateRefreshStatuses();
+}
+
+void
+MoveTracksCommand::unexecute()
+{
+ Track *srcTrack = m_composition->getTrackById(m_srcTrack);
+ Track *destTrack = m_composition->getTrackById(m_destTrack);
+
+ int srcPosition = srcTrack->getPosition();
+
+ srcTrack->setPosition(destTrack->getPosition());
+ destTrack->setPosition(srcPosition);
+
+ m_composition->updateRefreshStatuses();
+}
+
+}
diff --git a/src/commands/segment/MoveTracksCommand.h b/src/commands/segment/MoveTracksCommand.h
new file mode 100644
index 0000000..e35af5e
--- /dev/null
+++ b/src/commands/segment/MoveTracksCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MOVETRACKSCOMMAND_H_
+#define _RG_MOVETRACKSCOMMAND_H_
+
+#include "base/Track.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class MoveTracksCommand : public KNamedCommand
+{
+public:
+ MoveTracksCommand(Composition *composition,
+ TrackId srcTrack,
+ TrackId destTrack);
+ virtual ~MoveTracksCommand();
+
+ static QString getGlobalName() { return i18n("Move Tracks..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+
+ TrackId m_srcTrack;
+ TrackId m_destTrack;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/OpenOrCloseRangeCommand.cpp b/src/commands/segment/OpenOrCloseRangeCommand.cpp
new file mode 100644
index 0000000..ad1db2c
--- /dev/null
+++ b/src/commands/segment/OpenOrCloseRangeCommand.cpp
@@ -0,0 +1,181 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "OpenOrCloseRangeCommand.h"
+
+#include <klocale.h>
+#include "misc/Debug.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+
+
+namespace Rosegarden
+{
+
+OpenOrCloseRangeCommand::OpenOrCloseRangeCommand(Composition *composition,
+ timeT rangeBegin,
+ timeT rangeEnd,
+ bool open) :
+ KNamedCommand(i18n("Open or Close Range")),
+ m_composition(composition),
+ m_beginTime(rangeBegin),
+ m_endTime(rangeEnd),
+ m_prepared(false),
+ m_opening(open)
+{}
+
+OpenOrCloseRangeCommand::~OpenOrCloseRangeCommand()
+{}
+
+void
+OpenOrCloseRangeCommand::execute()
+{
+ timeT offset = m_endTime - m_beginTime;
+ if (!m_opening)
+ offset = -offset;
+
+ if (m_opening) {
+ if (offset + m_composition->getDuration() >
+ m_composition->getEndMarker()) {
+ m_composition->setEndMarker
+ (m_composition->getBarEndForTime
+ (m_composition->getDuration() + offset));
+ }
+ }
+
+ if (!m_prepared) {
+
+ timeT movingFrom = m_beginTime;
+ if (!m_opening)
+ movingFrom = m_endTime;
+
+ for (Composition::iterator i = m_composition->begin();
+ i != m_composition->end(); ++i) {
+
+ if ((*i)->getStartTime() >= movingFrom) {
+ m_moving.push_back(*i);
+ }
+ }
+
+ m_timesigsPre = TimeSignatureSelection
+ (*m_composition, movingFrom,
+ m_composition->getEndMarker(),
+ false);
+
+ m_temposPre = TempoSelection
+ (*m_composition, movingFrom,
+ m_composition->getEndMarker(),
+ false);
+
+ for (TimeSignatureSelection::timesigcontainer::const_iterator i =
+ m_timesigsPre.begin(); i != m_timesigsPre.end(); ++i) {
+
+ timeT t = i->first;
+ TimeSignature sig = i->second;
+ m_timesigsPost.addTimeSignature(t + offset, sig);
+ }
+
+ for (TempoSelection::tempocontainer::const_iterator i =
+ m_temposPre.begin(); i != m_temposPre.end(); ++i) {
+
+ timeT t = i->first;
+ TempoSelection::tempochange change = i->second;
+ m_temposPost.addTempo(t + offset, change.first, change.second);
+ }
+
+ m_prepared = true;
+ }
+
+ for (std::vector<Segment *>::iterator i = m_moving.begin();
+ i != m_moving.end(); ++i) {
+ // RG_DEBUG << "Moving segment on track " << (*i)->getTrack() << " from " << (*i)->getStartTime() << " to " << ((*i)->getStartTime() + offset) << " (current end time is " << (*i)->getEndTime() << ", end marker is " << (*i)->getEndMarkerTime() << ")" << endl;
+ (*i)->setStartTime((*i)->getStartTime() + offset);
+ }
+
+ for (TimeSignatureSelection::timesigcontainer::const_iterator i =
+ m_timesigsPre.begin(); i != m_timesigsPre.end(); ++i) {
+ int n = m_composition->getTimeSignatureNumberAt(i->first);
+ if (n >= 0)
+ m_composition->removeTimeSignature(n);
+ }
+
+ for (TimeSignatureSelection::timesigcontainer::const_iterator i =
+ m_timesigsPost.begin(); i != m_timesigsPost.end(); ++i) {
+ m_composition->addTimeSignature(i->first, i->second);
+ }
+
+ for (TempoSelection::tempocontainer::const_iterator i =
+ m_temposPre.begin(); i != m_temposPre.end(); ++i) {
+ int n = m_composition->getTempoChangeNumberAt(i->first);
+ if (n >= 0)
+ m_composition->removeTempoChange(n);
+ }
+
+ for (TempoSelection::tempocontainer::const_iterator i =
+ m_temposPost.begin(); i != m_temposPost.end(); ++i) {
+ m_composition->addTempoAtTime(i->first, i->second.first, i->second.second);
+ }
+}
+
+void
+OpenOrCloseRangeCommand::unexecute()
+{
+ timeT offset = m_beginTime - m_endTime;
+ if (!m_opening)
+ offset = -offset;
+
+ for (std::vector<Segment *>::iterator i = m_moving.begin();
+ i != m_moving.end(); ++i) {
+ (*i)->setStartTime((*i)->getStartTime() + offset);
+ }
+
+ for (TimeSignatureSelection::timesigcontainer::const_iterator i =
+ m_timesigsPost.begin(); i != m_timesigsPost.end(); ++i) {
+ int n = m_composition->getTimeSignatureNumberAt(i->first);
+ if (n >= 0)
+ m_composition->removeTimeSignature(n);
+ }
+
+ for (TimeSignatureSelection::timesigcontainer::const_iterator i =
+ m_timesigsPre.begin(); i != m_timesigsPre.end(); ++i) {
+ m_composition->addTimeSignature(i->first, i->second);
+ }
+
+ for (TempoSelection::tempocontainer::const_iterator i =
+ m_temposPost.begin(); i != m_temposPost.end(); ++i) {
+ int n = m_composition->getTempoChangeNumberAt(i->first);
+ if (n >= 0)
+ m_composition->removeTempoChange(n);
+ }
+
+ for (TempoSelection::tempocontainer::const_iterator i =
+ m_temposPre.begin(); i != m_temposPre.end(); ++i) {
+ m_composition->addTempoAtTime(i->first, i->second.first, i->second.second);
+ }
+}
+
+}
diff --git a/src/commands/segment/OpenOrCloseRangeCommand.h b/src/commands/segment/OpenOrCloseRangeCommand.h
new file mode 100644
index 0000000..6cb0f16
--- /dev/null
+++ b/src/commands/segment/OpenOrCloseRangeCommand.h
@@ -0,0 +1,84 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_OPENORCLOSERANGECOMMAND_H_
+#define _RG_OPENORCLOSERANGECOMMAND_H_
+
+#include "base/Selection.h"
+#include <kcommand.h>
+#include <vector>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+/**
+ * Pull all segments, time sigs, tempos etc starting after the end of
+ * a given range back by the duration of that range, so as to fill in
+ * the (presumably empty) range itself.
+ *
+ * This does not actually split any segments etc, it just moves them.
+ */
+class OpenOrCloseRangeCommand : public KNamedCommand
+{
+public:
+ OpenOrCloseRangeCommand(Composition *composition,
+ timeT rangeBegin,
+ timeT rangeEnd,
+ bool open);
+ virtual ~OpenOrCloseRangeCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ timeT m_beginTime;
+ timeT m_endTime;
+
+ bool m_prepared;
+ bool m_opening;
+
+ std::vector<Segment *> m_moving;
+
+ TimeSignatureSelection m_timesigsPre;
+ TimeSignatureSelection m_timesigsPost;
+
+ TempoSelection m_temposPre;
+ TempoSelection m_temposPost;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/PasteConductorDataCommand.cpp b/src/commands/segment/PasteConductorDataCommand.cpp
new file mode 100644
index 0000000..6db082f
--- /dev/null
+++ b/src/commands/segment/PasteConductorDataCommand.cpp
@@ -0,0 +1,128 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "PasteConductorDataCommand.h"
+
+#include <klocale.h>
+#include "base/Clipboard.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Selection.h"
+
+
+namespace Rosegarden
+{
+
+PasteConductorDataCommand::PasteConductorDataCommand(Composition *composition,
+ Clipboard *clipboard,
+ timeT t) :
+ KNamedCommand(i18n("Paste Tempos and Time Signatures")),
+ m_composition(composition),
+ m_clipboard(new Clipboard(*clipboard)),
+ m_t0(t)
+{}
+
+PasteConductorDataCommand::~PasteConductorDataCommand()
+{
+ delete m_clipboard;
+}
+
+void
+PasteConductorDataCommand::execute()
+{
+ //!!! current implementation of execute and unexecute require
+ // that the target area of the composition be empty of tempo and
+ // timesig data before the command is executed
+
+ if (m_clipboard->hasTimeSignatureSelection()) {
+
+ for (TimeSignatureSelection::timesigcontainer::const_iterator i =
+ m_clipboard->getTimeSignatureSelection().begin();
+ i != m_clipboard->getTimeSignatureSelection().end(); ++i) {
+
+ timeT t = i->first;
+ t = t - m_clipboard->getBaseTime() + m_t0;
+ TimeSignature sig = i->second;
+
+ if (i == m_clipboard->getTimeSignatureSelection().begin() &&
+ m_composition->getTimeSignatureAt(t) == sig)
+ continue;
+
+ m_composition->addTimeSignature(t, sig);
+ }
+ }
+
+ if (m_clipboard->hasTempoSelection()) {
+
+ for (TempoSelection::tempocontainer::const_iterator i =
+ m_clipboard->getTempoSelection().begin();
+ i != m_clipboard->getTempoSelection().end(); ++i) {
+
+ timeT t = i->first;
+ t = t - m_clipboard->getBaseTime() + m_t0;
+ tempoT tempo = i->second.first;
+ tempoT targetTempo = i->second.second;
+
+ if (i == m_clipboard->getTempoSelection().begin() &&
+ targetTempo < 0 &&
+ m_composition->getTempoAtTime(t) == tempo)
+ continue;
+
+ m_composition->addTempoAtTime(t, tempo, targetTempo);
+ }
+ }
+}
+
+void
+PasteConductorDataCommand::unexecute()
+{
+ //!!! see note above
+
+ for (TimeSignatureSelection::timesigcontainer::const_iterator i =
+ m_clipboard->getTimeSignatureSelection().begin();
+ i != m_clipboard->getTimeSignatureSelection().end(); ++i) {
+
+ timeT t = i->first;
+ int n = m_composition->getTimeSignatureNumberAt(t);
+
+ if (n >= 0 && m_composition->getTimeSignatureChange(n).first == t) {
+ m_composition->removeTimeSignature(n);
+ }
+ }
+
+ for (TempoSelection::tempocontainer::const_iterator i =
+ m_clipboard->getTempoSelection().begin();
+ i != m_clipboard->getTempoSelection().end(); ++i) {
+
+ timeT t = i->first;
+ int n = m_composition->getTempoChangeNumberAt(t);
+
+ if (n >= 0 && m_composition->getTempoChange(n).first == t) {
+ m_composition->removeTempoChange(n);
+ }
+ }
+}
+
+}
diff --git a/src/commands/segment/PasteConductorDataCommand.h b/src/commands/segment/PasteConductorDataCommand.h
new file mode 100644
index 0000000..15b6e54
--- /dev/null
+++ b/src/commands/segment/PasteConductorDataCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_PASTECONDUCTORDATACOMMAND_H_
+#define _RG_PASTECONDUCTORDATACOMMAND_H_
+
+#include <kcommand.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+class Clipboard;
+
+
+/**
+ * Paste time signature and tempo data from the given clipboard into
+ * the given composition starting at the given time.
+ */
+class PasteConductorDataCommand : public KNamedCommand
+{
+public:
+ PasteConductorDataCommand(Composition *composition,
+ Clipboard *clipboard,
+ timeT t);
+ virtual ~PasteConductorDataCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ Clipboard *m_clipboard;
+ timeT m_t0;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/PasteRangeCommand.cpp b/src/commands/segment/PasteRangeCommand.cpp
new file mode 100644
index 0000000..c2f9a0e
--- /dev/null
+++ b/src/commands/segment/PasteRangeCommand.cpp
@@ -0,0 +1,97 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "PasteRangeCommand.h"
+
+#include <klocale.h>
+#include "AudioSegmentSplitCommand.h"
+#include "base/Clipboard.h"
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include "commands/edit/PasteSegmentsCommand.h"
+#include "OpenOrCloseRangeCommand.h"
+#include "PasteConductorDataCommand.h"
+#include "SegmentSplitCommand.h"
+
+
+namespace Rosegarden
+{
+
+PasteRangeCommand::PasteRangeCommand(Composition *composition,
+ Clipboard *clipboard,
+ timeT t0) :
+ KMacroCommand(i18n("Paste Range"))
+{
+ timeT clipBeginTime = clipboard->getBaseTime();
+
+ timeT t1 = t0;
+
+ if (clipboard->hasNominalRange()) {
+
+ clipboard->getNominalRange(clipBeginTime, t1);
+ t1 = t0 + (t1 - clipBeginTime);
+
+ } else {
+
+ timeT duration = 0;
+
+ for (Clipboard::iterator i = clipboard->begin();
+ i != clipboard->end(); ++i) {
+ timeT durationHere = (*i)->getEndMarkerTime() - clipBeginTime;
+ if (i == clipboard->begin() || durationHere > duration) {
+ duration = durationHere;
+ }
+ }
+
+ if (duration <= 0)
+ return ;
+ t1 = t0 + duration;
+ }
+
+ // Need to split segments before opening, at t0
+
+ for (Composition::iterator i = composition->begin();
+ i != composition->end(); ++i) {
+
+ if ((*i)->getStartTime() >= t0 || (*i)->getEndMarkerTime() <= t0) {
+ continue;
+ }
+
+ if ((*i)->getType() == Segment::Audio) {
+ addCommand(new AudioSegmentSplitCommand(*i, t0));
+ } else {
+ addCommand(new SegmentSplitCommand(*i, t0));
+ }
+ }
+
+ addCommand(new OpenOrCloseRangeCommand(composition, t0, t1, true));
+ addCommand(new PasteSegmentsCommand
+ (composition, clipboard, t0,
+ composition->getTrackByPosition(0)->getId(),
+ true));
+ addCommand(new PasteConductorDataCommand(composition, clipboard, t0));
+}
+
+}
diff --git a/src/commands/segment/PasteRangeCommand.h b/src/commands/segment/PasteRangeCommand.h
new file mode 100644
index 0000000..f64da24
--- /dev/null
+++ b/src/commands/segment/PasteRangeCommand.h
@@ -0,0 +1,52 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_PASTERANGECOMMAND_H_
+#define _RG_PASTERANGECOMMAND_H_
+
+#include "base/Event.h"
+#include <kcommand.h>
+
+
+namespace Rosegarden
+{
+
+class Composition;
+class Clipboard;
+
+
+class PasteRangeCommand : public KMacroCommand
+{
+public:
+ PasteRangeCommand(Composition *composition,
+ Clipboard *clipboard,
+ timeT pasteTime);
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/PasteToTriggerSegmentCommand.cpp b/src/commands/segment/PasteToTriggerSegmentCommand.cpp
new file mode 100644
index 0000000..0447c40
--- /dev/null
+++ b/src/commands/segment/PasteToTriggerSegmentCommand.cpp
@@ -0,0 +1,129 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "PasteToTriggerSegmentCommand.h"
+
+#include "base/Event.h"
+#include <klocale.h>
+#include "misc/Strings.h"
+#include "base/Clipboard.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/TriggerSegment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+PasteToTriggerSegmentCommand::PasteToTriggerSegmentCommand(Composition *composition,
+ Clipboard *clipboard,
+ QString label,
+ int basePitch,
+ int baseVelocity) :
+ KNamedCommand(i18n("Paste as New Triggered Segment")),
+ m_composition(composition),
+ m_clipboard(new Clipboard(*clipboard)),
+ m_label(label),
+ m_basePitch(basePitch),
+ m_baseVelocity(baseVelocity),
+ m_segment(0),
+ m_detached(false)
+{
+ // nothing else
+}
+
+PasteToTriggerSegmentCommand::~PasteToTriggerSegmentCommand()
+{
+ if (m_detached)
+ delete m_segment;
+ delete m_clipboard;
+}
+
+void
+PasteToTriggerSegmentCommand::execute()
+{
+ if (m_segment) {
+
+ m_composition->addTriggerSegment(m_segment, m_id, m_basePitch, m_baseVelocity);
+
+ } else {
+
+ if (m_clipboard->isEmpty())
+ return ;
+
+ m_segment = new Segment();
+
+ timeT earliestStartTime = 0;
+ timeT latestEndTime = 0;
+
+ for (Clipboard::iterator i = m_clipboard->begin();
+ i != m_clipboard->end(); ++i) {
+
+ if (i == m_clipboard->begin() ||
+ (*i)->getStartTime() < earliestStartTime) {
+ earliestStartTime = (*i)->getStartTime();
+ }
+
+ if ((*i)->getEndMarkerTime() > latestEndTime)
+ latestEndTime = (*i)->getEndMarkerTime();
+ }
+
+ for (Clipboard::iterator i = m_clipboard->begin();
+ i != m_clipboard->end(); ++i) {
+
+ for (Segment::iterator si = (*i)->begin();
+ (*i)->isBeforeEndMarker(si); ++si) {
+ if (!(*si)->isa(Note::EventRestType)) {
+ m_segment->insert
+ (new Event(**si,
+ (*si)->getAbsoluteTime() - earliestStartTime));
+ }
+ }
+ }
+
+ m_segment->setLabel(qstrtostr(m_label));
+
+ TriggerSegmentRec *rec =
+ m_composition->addTriggerSegment(m_segment, m_basePitch, m_baseVelocity);
+ if (rec)
+ m_id = rec->getId();
+ }
+
+ m_composition->getTriggerSegmentRec(m_id)->updateReferences();
+
+ m_detached = false;
+}
+
+void
+PasteToTriggerSegmentCommand::unexecute()
+{
+ if (m_segment)
+ m_composition->detachTriggerSegment(m_id);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/PasteToTriggerSegmentCommand.h b/src/commands/segment/PasteToTriggerSegmentCommand.h
new file mode 100644
index 0000000..32f95e7
--- /dev/null
+++ b/src/commands/segment/PasteToTriggerSegmentCommand.h
@@ -0,0 +1,73 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_PASTETOTRIGGERSEGMENTCOMMAND_H_
+#define _RG_PASTETOTRIGGERSEGMENTCOMMAND_H_
+
+#include "base/TriggerSegment.h"
+#include <kcommand.h>
+#include <qstring.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+class Clipboard;
+
+
+class PasteToTriggerSegmentCommand : public KNamedCommand
+{
+public:
+ /// If basePitch is -1, the first pitch in the selection will be used
+ PasteToTriggerSegmentCommand(Composition *composition,
+ Clipboard *clipboard,
+ QString label,
+ int basePitch = -1,
+ int baseVelocity = -1);
+ virtual ~PasteToTriggerSegmentCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ Clipboard *m_clipboard;
+ QString m_label;
+ int m_basePitch;
+ int m_baseVelocity;
+ Segment *m_segment;
+ TriggerSegmentId m_id;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/RemoveTempoChangeCommand.cpp b/src/commands/segment/RemoveTempoChangeCommand.cpp
new file mode 100644
index 0000000..11a89ad
--- /dev/null
+++ b/src/commands/segment/RemoveTempoChangeCommand.cpp
@@ -0,0 +1,59 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RemoveTempoChangeCommand.h"
+
+#include "base/Composition.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RemoveTempoChangeCommand::execute()
+{
+ if (m_tempoChangeIndex >= 0) {
+ std::pair<timeT, tempoT> data =
+ m_composition->getTempoChange(m_tempoChangeIndex);
+
+ // store
+ m_oldTime = data.first;
+ m_oldTempo = data.second;
+ }
+
+ // do we need to (re)store the index number?
+ //
+ m_composition->removeTempoChange(m_tempoChangeIndex);
+
+}
+
+void
+RemoveTempoChangeCommand::unexecute()
+{
+ m_composition->addTempoAtTime(m_oldTime, m_oldTempo);
+}
+
+}
diff --git a/src/commands/segment/RemoveTempoChangeCommand.h b/src/commands/segment/RemoveTempoChangeCommand.h
new file mode 100644
index 0000000..1900a8b
--- /dev/null
+++ b/src/commands/segment/RemoveTempoChangeCommand.h
@@ -0,0 +1,75 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_REMOVETEMPOCHANGECOMMAND_H_
+#define _RG_REMOVETEMPOCHANGECOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include "base/Composition.h" // for tempoT
+#include <klocale.h>
+
+
+class Remove;
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class RemoveTempoChangeCommand : public KNamedCommand
+{
+public:
+ RemoveTempoChangeCommand(Composition *composition,
+ int index):
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_tempoChangeIndex(index),
+ m_oldTime(0),
+ m_oldTempo(0){}
+
+ virtual ~RemoveTempoChangeCommand() {}
+
+ static QString getGlobalName() { return i18n("Remove &Tempo Change..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ int m_tempoChangeIndex;
+ timeT m_oldTime;
+ tempoT m_oldTempo;
+};
+
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/RemoveTimeSignatureCommand.cpp b/src/commands/segment/RemoveTimeSignatureCommand.cpp
new file mode 100644
index 0000000..c6b59b1
--- /dev/null
+++ b/src/commands/segment/RemoveTimeSignatureCommand.cpp
@@ -0,0 +1,60 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RemoveTimeSignatureCommand.h"
+
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RemoveTimeSignatureCommand::execute()
+{
+ if (m_timeSigIndex >= 0) {
+ std::pair<timeT, TimeSignature> data =
+ m_composition->getTimeSignatureChange(m_timeSigIndex);
+
+ // store
+ m_oldTime = data.first;
+ m_oldTimeSignature = data.second;
+ }
+
+ // do we need to (re)store the index number?
+ //
+ m_composition->removeTimeSignature(m_timeSigIndex);
+
+}
+
+void
+RemoveTimeSignatureCommand::unexecute()
+{
+ m_composition->addTimeSignature(m_oldTime, m_oldTimeSignature);
+}
+
+}
diff --git a/src/commands/segment/RemoveTimeSignatureCommand.h b/src/commands/segment/RemoveTimeSignatureCommand.h
new file mode 100644
index 0000000..d29d666
--- /dev/null
+++ b/src/commands/segment/RemoveTimeSignatureCommand.h
@@ -0,0 +1,74 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_REMOVETIMESIGNATURECOMMAND_H_
+#define _RG_REMOVETIMESIGNATURECOMMAND_H_
+
+#include "base/NotationTypes.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+class Remove;
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class RemoveTimeSignatureCommand : public KNamedCommand
+{
+public:
+ RemoveTimeSignatureCommand(Composition *composition,
+ int index):
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_timeSigIndex(index),
+ m_oldTime(0),
+ m_oldTimeSignature() { }
+
+ virtual ~RemoveTimeSignatureCommand() {}
+
+ static QString getGlobalName() { return i18n("Remove &Time Signature Change..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ int m_timeSigIndex;
+ timeT m_oldTime;
+ TimeSignature m_oldTimeSignature;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/RenameTrackCommand.cpp b/src/commands/segment/RenameTrackCommand.cpp
new file mode 100644
index 0000000..62d1d7e
--- /dev/null
+++ b/src/commands/segment/RenameTrackCommand.cpp
@@ -0,0 +1,75 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RenameTrackCommand.h"
+
+#include "misc/Debug.h"
+#include "base/Composition.h"
+#include "base/Track.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+RenameTrackCommand::RenameTrackCommand(Composition *composition,
+ TrackId trackId,
+ std::string name) :
+ KNamedCommand(getGlobalName()),
+ m_composition(composition),
+ m_track(trackId),
+ m_newName(name)
+{
+ Track *track = composition->getTrackById(m_track);
+ if (!track) {
+ RG_DEBUG << "Hey! No Track in RenameTrackCommand (track id " << track
+ << ")!" << endl;
+ return ;
+ }
+ m_oldName = track->getLabel();
+}
+
+RenameTrackCommand::~RenameTrackCommand()
+{}
+
+void
+RenameTrackCommand::execute()
+{
+ Track *track = m_composition->getTrackById(m_track);
+ if (!track)
+ return ;
+ track->setLabel(m_newName);
+}
+
+void
+RenameTrackCommand::unexecute()
+{
+ Track *track = m_composition->getTrackById(m_track);
+ if (!track)
+ return ;
+ track->setLabel(m_oldName);
+}
+
+}
diff --git a/src/commands/segment/RenameTrackCommand.h b/src/commands/segment/RenameTrackCommand.h
new file mode 100644
index 0000000..8e63a88
--- /dev/null
+++ b/src/commands/segment/RenameTrackCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RENAMETRACKCOMMAND_H_
+#define _RG_RENAMETRACKCOMMAND_H_
+
+#include "base/Track.h"
+#include <string>
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class RenameTrackCommand : public KNamedCommand
+{
+public:
+ RenameTrackCommand(Composition *composition,
+ TrackId track,
+ std::string name);
+ virtual ~RenameTrackCommand();
+
+ static QString getGlobalName() { return i18n("Rename Track"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ TrackId m_track;
+ std::string m_oldName;
+ std::string m_newName;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentAutoSplitCommand.cpp b/src/commands/segment/SegmentAutoSplitCommand.cpp
new file mode 100644
index 0000000..fbd6daa
--- /dev/null
+++ b/src/commands/segment/SegmentAutoSplitCommand.cpp
@@ -0,0 +1,205 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentAutoSplitCommand.h"
+
+#include "base/Event.h"
+#include "misc/Debug.h"
+#include "misc/Strings.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+struct AutoSplitPoint
+{
+ timeT time;
+ timeT lastSoundTime;
+ Clef clef;
+ Rosegarden::Key key;
+ AutoSplitPoint(timeT t, timeT lst, Clef c, Rosegarden::Key k) :
+ time(t), lastSoundTime(lst), clef(c), key(k) { }
+};
+
+SegmentAutoSplitCommand::SegmentAutoSplitCommand(Segment *segment) :
+ KNamedCommand(getGlobalName()),
+ m_segment(segment),
+ m_composition(segment->getComposition()),
+ m_detached(false)
+{}
+
+SegmentAutoSplitCommand::~SegmentAutoSplitCommand()
+{
+ if (m_detached) {
+ delete m_segment;
+ } else {
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i) {
+ delete m_newSegments[i];
+ }
+ }
+}
+
+void
+SegmentAutoSplitCommand::execute()
+{
+ if (m_newSegments.size() == 0) {
+
+ std::vector<AutoSplitPoint> splitPoints;
+
+ Clef clef;
+ Key key;
+ timeT segmentStart = m_segment->getStartTime();
+ timeT lastSoundTime = segmentStart;
+ timeT lastSplitTime = segmentStart - 1;
+
+ for (Segment::iterator i = m_segment->begin();
+ m_segment->isBeforeEndMarker(i); ++i) {
+
+ timeT myTime = (*i)->getAbsoluteTime();
+ int barNo = m_composition->getBarNumber(myTime);
+
+ if ((*i)->isa(Clef::EventType)) {
+ clef = Clef(**i);
+ } else if ((*i)->isa(Key::EventType)) {
+ key = Key(**i);
+ }
+
+ if (myTime <= lastSplitTime)
+ continue;
+
+ bool newTimeSig = false;
+ TimeSignature tsig =
+ m_composition->getTimeSignatureInBar(barNo, newTimeSig);
+
+ if (newTimeSig) {
+
+ // If there's a new time sig in this bar and we haven't
+ // already made a split in this bar, make one
+
+ if (splitPoints.size() == 0 ||
+ m_composition->getBarNumber
+ (splitPoints[splitPoints.size() - 1].time) < barNo) {
+
+ splitPoints.push_back(AutoSplitPoint(myTime, lastSoundTime,
+ clef, key));
+ lastSoundTime = lastSplitTime = myTime;
+ }
+
+ } else if ((*i)->isa(Note::EventRestType)) {
+
+ // Otherwise never start a subsegment on a rest
+
+ continue;
+
+ } else {
+
+ // When we meet a non-rest event, start a new split
+ // if an entire bar has passed since the last one
+
+ int lastSoundBarNo = m_composition->getBarNumber(lastSoundTime);
+
+ if (lastSoundBarNo < barNo - 1 ||
+ (lastSoundBarNo == barNo - 1 &&
+ m_composition->getBarStartForTime(lastSoundTime) ==
+ lastSoundTime &&
+ lastSoundTime > segmentStart)) {
+
+ splitPoints.push_back
+ (AutoSplitPoint
+ (m_composition->getBarStartForTime(myTime), lastSoundTime,
+ clef, key));
+ lastSplitTime = myTime;
+ }
+ }
+
+ lastSoundTime = std::max(lastSoundTime, myTime + (*i)->getDuration());
+ }
+
+ for (unsigned int split = 0; split <= splitPoints.size(); ++split) {
+
+ Segment *newSegment = new Segment();
+ newSegment->setTrack(m_segment->getTrack());
+ newSegment->setLabel(qstrtostr(i18n("%1 (part)").arg
+ (strtoqstr(m_segment->getLabel()))));
+ newSegment->setColourIndex(m_segment->getColourIndex());
+
+ timeT startTime = segmentStart;
+ if (split > 0) {
+
+ RG_DEBUG << "Auto-split point " << split - 1 << ": time "
+ << splitPoints[split - 1].time << ", lastSoundTime "
+ << splitPoints[split - 1].lastSoundTime << endl;
+
+ startTime = splitPoints[split - 1].time;
+ newSegment->insert(splitPoints[split - 1].clef.getAsEvent(startTime));
+ newSegment->insert(splitPoints[split - 1].key.getAsEvent(startTime));
+ }
+
+ Segment::iterator i = m_segment->findTime(startTime);
+
+ // A segment has to contain at least one note to be a worthy
+ // candidate for adding back into the composition
+ bool haveNotes = false;
+
+ while (m_segment->isBeforeEndMarker(i)) {
+ timeT t = (*i)->getAbsoluteTime();
+ if (split < splitPoints.size() &&
+ t >= splitPoints[split].lastSoundTime)
+ break;
+ if ((*i)->isa(Note::EventType))
+ haveNotes = true;
+ newSegment->insert(new Event(**i));
+ ++i;
+ }
+
+ if (haveNotes)
+ m_newSegments.push_back(newSegment);
+ else
+ delete newSegment;
+ }
+ }
+
+ m_composition->detachSegment(m_segment);
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i) {
+ m_composition->addSegment(m_newSegments[i]);
+ }
+ m_detached = true;
+}
+
+void
+SegmentAutoSplitCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_newSegments.size(); ++i) {
+ m_composition->detachSegment(m_newSegments[i]);
+ }
+ m_composition->addSegment(m_segment);
+ m_detached = false;
+}
+
+}
diff --git a/src/commands/segment/SegmentAutoSplitCommand.h b/src/commands/segment/SegmentAutoSplitCommand.h
new file mode 100644
index 0000000..a7e54c7
--- /dev/null
+++ b/src/commands/segment/SegmentAutoSplitCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTAUTOSPLITCOMMAND_H_
+#define _RG_SEGMENTAUTOSPLITCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+class SegmentAutoSplitCommand : public KNamedCommand
+{
+public:
+ SegmentAutoSplitCommand(Segment *segment);
+ virtual ~SegmentAutoSplitCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName() { return i18n("&Split on Silence"); }
+
+private:
+ Segment *m_segment;
+ Composition *m_composition;
+ std::vector<Segment *> m_newSegments;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentChangePlayableRangeCommand.cpp b/src/commands/segment/SegmentChangePlayableRangeCommand.cpp
new file mode 100644
index 0000000..b4d5d3a
--- /dev/null
+++ b/src/commands/segment/SegmentChangePlayableRangeCommand.cpp
@@ -0,0 +1,77 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2007
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentChangePlayableRangeCommand.h"
+
+#include "base/Segment.h"
+#include "gui/editors/notation/NotationStrings.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentChangePlayableRangeCommand::SegmentChangePlayableRangeCommand(int low, int high, Segment *segment) :
+ KNamedCommand(getGlobalName(low, high)),
+ m_lowestPlayableNote(low),
+ m_highestPlayableNote(high),
+ m_segment(segment)
+{
+ // nothing
+}
+
+SegmentChangePlayableRangeCommand::~SegmentChangePlayableRangeCommand()
+{
+ // nothing
+}
+
+void
+SegmentChangePlayableRangeCommand::execute()
+{
+ m_oldLowestPlayableNote = m_segment->getLowestPlayable();
+ m_oldHighestPlayableNote = m_segment->getHighestPlayable();
+ m_segment->setLowestPlayable(m_lowestPlayableNote);
+ m_segment->setHighestPlayable(m_highestPlayableNote);
+}
+
+void
+SegmentChangePlayableRangeCommand::unexecute()
+{
+ m_segment->setLowestPlayable(m_oldLowestPlayableNote);
+ m_segment->setHighestPlayable(m_oldHighestPlayableNote);
+}
+
+QString
+SegmentChangePlayableRangeCommand::getGlobalName(int low, int high)
+{
+ bool unit = false; // fake code to allow trunk/ to compile!
+ if (!unit) {
+ return "Undo change playable range";
+ } else {
+ return QString("Change playable range to %1-%2").arg(low, high);
+ }
+}
+
+}
diff --git a/src/commands/segment/SegmentChangePlayableRangeCommand.h b/src/commands/segment/SegmentChangePlayableRangeCommand.h
new file mode 100644
index 0000000..d78aa5c
--- /dev/null
+++ b/src/commands/segment/SegmentChangePlayableRangeCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2007
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTCHANGEPLAYABLERANGECOMMAND_H_
+#define _RG_SEGMENTCHANGEPLAYABLERANGECOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class SegmentChangePlayableRangeCommand : public KNamedCommand
+{
+public:
+ /// Set transpose on segments.
+ SegmentChangePlayableRangeCommand(int /*low*/, int /*high*/, Segment *segment);
+ virtual ~SegmentChangePlayableRangeCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName(int, int);
+
+private:
+ Segment *m_segment;
+ int m_oldLowestPlayableNote;
+ int m_oldHighestPlayableNote;
+ int m_lowestPlayableNote;
+ int m_highestPlayableNote;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentChangeQuantizationCommand.cpp b/src/commands/segment/SegmentChangeQuantizationCommand.cpp
new file mode 100644
index 0000000..22d09f4
--- /dev/null
+++ b/src/commands/segment/SegmentChangeQuantizationCommand.cpp
@@ -0,0 +1,115 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentChangeQuantizationCommand.h"
+
+#include "base/Segment.h"
+#include "base/BasicQuantizer.h"
+#include "gui/editors/notation/NotationStrings.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentChangeQuantizationCommand::SegmentChangeQuantizationCommand(timeT unit) :
+ KNamedCommand(getGlobalName(unit)),
+ m_unit(unit)
+{
+ // nothing
+}
+
+SegmentChangeQuantizationCommand::~SegmentChangeQuantizationCommand()
+{
+ // nothing
+}
+
+void
+SegmentChangeQuantizationCommand::execute()
+{
+ for (unsigned int i = 0; i < m_records.size(); ++i) {
+
+ SegmentRec &rec = m_records[i];
+
+ if (m_unit) {
+
+ rec.oldUnit = rec.segment->getQuantizer()->getUnit();
+ rec.segment->setQuantizeLevel(m_unit);
+
+ rec.wasQuantized = rec.segment->hasQuantization();
+ rec.segment->setQuantization(true);
+
+ } else {
+
+ rec.wasQuantized = rec.segment->hasQuantization();
+ rec.segment->setQuantization(false);
+ }
+ }
+}
+
+void
+SegmentChangeQuantizationCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_records.size(); ++i) {
+
+ SegmentRec &rec = m_records[i];
+
+ if (m_unit) {
+
+ if (!rec.wasQuantized)
+ rec.segment->setQuantization(false);
+ rec.segment->setQuantizeLevel(rec.oldUnit);
+
+ } else {
+
+ if (rec.wasQuantized)
+ rec.segment->setQuantization(true);
+ }
+ }
+}
+
+void
+SegmentChangeQuantizationCommand::addSegment(Segment *s)
+{
+ SegmentRec rec;
+ rec.segment = s;
+ rec.oldUnit = 0; // shouldn't matter what we initialise this to
+ rec.wasQuantized = false; // shouldn't matter what we initialise this to
+ m_records.push_back(rec);
+}
+
+QString
+SegmentChangeQuantizationCommand::getGlobalName(timeT unit)
+{
+ if (!unit) {
+ return "Unquantize";
+ } else {
+ timeT error = 0;
+ QString label = NotationStrings::makeNoteMenuLabel(unit, true, error);
+ return QString("Quantize to %1").arg(label);
+ }
+}
+
+}
diff --git a/src/commands/segment/SegmentChangeQuantizationCommand.h b/src/commands/segment/SegmentChangeQuantizationCommand.h
new file mode 100644
index 0000000..e5d7a36
--- /dev/null
+++ b/src/commands/segment/SegmentChangeQuantizationCommand.h
@@ -0,0 +1,73 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTCHANGEQUANTIZATIONCOMMAND_H_
+#define _RG_SEGMENTCHANGEQUANTIZATIONCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class SegmentChangeQuantizationCommand : public KNamedCommand
+{
+public:
+ /// Set quantization on segments. If unit is zero, switch quantization off
+ SegmentChangeQuantizationCommand(timeT);
+ virtual ~SegmentChangeQuantizationCommand();
+
+ void addSegment(Segment *s);
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName(timeT);
+
+private:
+ struct SegmentRec {
+ Segment *segment;
+ timeT oldUnit;
+ bool wasQuantized;
+ };
+ typedef std::vector<SegmentRec> SegmentRecSet;
+ SegmentRecSet m_records;
+
+ timeT m_unit;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentChangeTransposeCommand.cpp b/src/commands/segment/SegmentChangeTransposeCommand.cpp
new file mode 100644
index 0000000..452c2d7
--- /dev/null
+++ b/src/commands/segment/SegmentChangeTransposeCommand.cpp
@@ -0,0 +1,72 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentChangeTransposeCommand.h"
+
+#include "base/Segment.h"
+#include "gui/editors/notation/NotationStrings.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentChangeTransposeCommand::SegmentChangeTransposeCommand(int unit, Segment *segment) :
+ KNamedCommand(getGlobalName(unit)),
+ m_unit(unit),
+ m_segment(segment)
+{
+ // nothing
+}
+
+SegmentChangeTransposeCommand::~SegmentChangeTransposeCommand()
+{
+ // nothing
+}
+
+void
+SegmentChangeTransposeCommand::execute()
+{
+ m_oldUnit = m_segment->getTranspose();
+ m_segment->setTranspose(m_unit);
+}
+
+void
+SegmentChangeTransposeCommand::unexecute()
+{
+ m_segment->setTranspose(m_oldUnit);
+}
+
+QString
+SegmentChangeTransposeCommand::getGlobalName(int unit)
+{
+ if (!unit) {
+ return "Undo change transposition";
+ } else {
+ return QString("Change transposition to %1").arg(unit);
+ }
+}
+
+}
diff --git a/src/commands/segment/SegmentChangeTransposeCommand.h b/src/commands/segment/SegmentChangeTransposeCommand.h
new file mode 100644
index 0000000..64bd75a
--- /dev/null
+++ b/src/commands/segment/SegmentChangeTransposeCommand.h
@@ -0,0 +1,65 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTCHANGETRANSPOSECOMMAND_H_
+#define _RG_SEGMENTCHANGETRANSPOSECOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class SegmentChangeTransposeCommand : public KNamedCommand
+{
+public:
+ /// Set transpose on segments.
+ SegmentChangeTransposeCommand(int, Segment *segment);
+ virtual ~SegmentChangeTransposeCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName(int);
+
+private:
+ Segment *m_segment;
+ int m_oldUnit;
+ int m_unit;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentColourCommand.cpp b/src/commands/segment/SegmentColourCommand.cpp
new file mode 100644
index 0000000..7dffc8f
--- /dev/null
+++ b/src/commands/segment/SegmentColourCommand.cpp
@@ -0,0 +1,65 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentColourCommand.h"
+
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentColourCommand::SegmentColourCommand(
+ SegmentSelection &segments,
+ const unsigned int index):
+ KNamedCommand(i18n("Change Segment Color")),
+ m_newColourIndex(index)
+{
+ for (SegmentSelection::iterator i = segments.begin(); i != segments.end(); ++i)
+ m_segments.push_back(*i);
+}
+
+SegmentColourCommand::~SegmentColourCommand()
+{}
+
+void
+SegmentColourCommand::execute()
+{
+ for (unsigned int i = 0; i < m_segments.size(); ++i) {
+ m_oldColourIndexes.push_back(m_segments[i]->getColourIndex());
+ m_segments[i]->setColourIndex(m_newColourIndex);
+ }
+}
+
+void
+SegmentColourCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_segments.size(); ++i)
+ m_segments[i]->setColourIndex(m_oldColourIndexes[i]);
+}
+
+}
diff --git a/src/commands/segment/SegmentColourCommand.h b/src/commands/segment/SegmentColourCommand.h
new file mode 100644
index 0000000..79b7d3d
--- /dev/null
+++ b/src/commands/segment/SegmentColourCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTCOLOURCOMMAND_H_
+#define _RG_SEGMENTCOLOURCOMMAND_H_
+
+#include "base/Segment.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class SegmentSelection;
+
+
+class SegmentColourCommand : public KNamedCommand
+{
+public:
+ SegmentColourCommand(SegmentSelection &segments,
+ const unsigned int index);
+ virtual ~SegmentColourCommand();
+
+ static QString getGlobalName()
+ { return i18n("Change Segment Color..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+protected:
+
+ std::vector<Segment*> m_segments;
+ std::vector<unsigned int> m_oldColourIndexes;
+ unsigned int m_newColourIndex;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentColourMapCommand.cpp b/src/commands/segment/SegmentColourMapCommand.cpp
new file mode 100644
index 0000000..0e09d4b
--- /dev/null
+++ b/src/commands/segment/SegmentColourMapCommand.cpp
@@ -0,0 +1,64 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentColourMapCommand.h"
+
+#include "base/ColourMap.h"
+#include "base/Segment.h"
+#include "document/RosegardenGUIDoc.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentColourMapCommand::SegmentColourMapCommand(
+ RosegardenGUIDoc *doc,
+ const ColourMap &map):
+ KNamedCommand(i18n("Change Segment Color Map")),
+ m_doc(doc),
+ m_oldMap(m_doc->getComposition().getSegmentColourMap()),
+ m_newMap(map)
+{
+}
+
+SegmentColourMapCommand::~SegmentColourMapCommand()
+{}
+
+void
+SegmentColourMapCommand::execute()
+{
+ m_doc->getComposition().setSegmentColourMap(m_newMap);
+ m_doc->slotDocColoursChanged();
+}
+
+void
+SegmentColourMapCommand::unexecute()
+{
+ m_doc->getComposition().setSegmentColourMap(m_oldMap);
+ m_doc->slotDocColoursChanged();
+}
+
+}
diff --git a/src/commands/segment/SegmentColourMapCommand.h b/src/commands/segment/SegmentColourMapCommand.h
new file mode 100644
index 0000000..257cdce
--- /dev/null
+++ b/src/commands/segment/SegmentColourMapCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTCOLOURMAPCOMMAND_H_
+#define _RG_SEGMENTCOLOURMAPCOMMAND_H_
+
+#include "base/ColourMap.h"
+#include "base/Segment.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class RosegardenGUIDoc;
+
+
+class SegmentColourMapCommand : public KNamedCommand
+{
+public:
+ SegmentColourMapCommand( RosegardenGUIDoc* doc,
+ const ColourMap& map);
+ virtual ~SegmentColourMapCommand();
+
+ static QString getGlobalName()
+ { return i18n("Change Segment Color Map..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+protected:
+ RosegardenGUIDoc * m_doc;
+ ColourMap m_oldMap;
+ ColourMap m_newMap;
+};
+
+
+// Trigger Segment commands. These are the commands that create
+// and manage the triggered segments themselves. See editcommands.h
+// for SetTriggerCommand and ClearTriggersCommand which manipulate
+// the events that do the triggering.
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentCommand.cpp b/src/commands/segment/SegmentCommand.cpp
new file mode 100644
index 0000000..68ff846
--- /dev/null
+++ b/src/commands/segment/SegmentCommand.cpp
@@ -0,0 +1,42 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentCommand.h"
+
+#include "base/Segment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentCommand::SegmentCommand(QString name, const std::vector<Segment*>& segments)
+ : KNamedCommand(name)
+{
+ m_segments.resize(segments.size());
+ std::copy(segments.begin(), segments.end(), m_segments.begin());
+}
+
+}
diff --git a/src/commands/segment/SegmentCommand.h b/src/commands/segment/SegmentCommand.h
new file mode 100644
index 0000000..da28a04
--- /dev/null
+++ b/src/commands/segment/SegmentCommand.h
@@ -0,0 +1,59 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTCOMMAND_H_
+#define _RG_SEGMENTCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+/**
+ * Base class for commands from the SegmentParameterBox
+ */
+class SegmentCommand : public KNamedCommand
+{
+public:
+ SegmentCommand(QString name, const std::vector<Segment*>&);
+
+ typedef std::vector<Segment*> segmentlist;
+
+protected:
+ segmentlist m_segments;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentCommandRepeat.cpp b/src/commands/segment/SegmentCommandRepeat.cpp
new file mode 100644
index 0000000..4b707cb
--- /dev/null
+++ b/src/commands/segment/SegmentCommandRepeat.cpp
@@ -0,0 +1,59 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentCommandRepeat.h"
+
+#include <klocale.h>
+#include "base/Segment.h"
+#include "SegmentCommand.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentCommandRepeat::SegmentCommandRepeat(const std::vector<Segment*>& segments,
+ bool repeat)
+ : SegmentCommand(i18n("Repeat Segments"), segments),
+ m_repeatState(repeat)
+{}
+
+void SegmentCommandRepeat::execute()
+{
+ segmentlist::iterator it;
+
+ for (it = m_segments.begin(); it != m_segments.end(); it++)
+ (*it)->setRepeating(m_repeatState);
+}
+
+void SegmentCommandRepeat::unexecute()
+{
+ segmentlist::iterator it;
+
+ for (it = m_segments.begin(); it != m_segments.end(); it++)
+ (*it)->setRepeating(!m_repeatState);
+}
+
+}
diff --git a/src/commands/segment/SegmentCommandRepeat.h b/src/commands/segment/SegmentCommandRepeat.h
new file mode 100644
index 0000000..0234070
--- /dev/null
+++ b/src/commands/segment/SegmentCommandRepeat.h
@@ -0,0 +1,81 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTCOMMANDREPEAT_H_
+#define _RG_SEGMENTCOMMANDREPEAT_H_
+
+#include "SegmentCommand.h"
+#include <vector>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+/**
+ * Repeat segment command from the SegmentParameterBox
+ */
+class SegmentCommandRepeat : public SegmentCommand
+{
+public:
+ SegmentCommandRepeat(const std::vector<Segment*>&,
+ bool repeat);
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ bool m_repeatState;
+};
+
+// Disabled until we find a better solution
+//
+// As it is, command creation happens on every change of the text
+// value of the combo box
+//
+//
+// class SegmentCommandChangeTransposeValue : public SegmentCommand
+// {
+// public:
+// SegmentCommandChangeTransposeValue(const std::vector<Segment*>&,
+// int transposeValue);
+
+// virtual void execute();
+// virtual void unexecute();
+
+// protected:
+// int m_transposeValue;
+// std::vector<int> m_savedValues;
+// };
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentEraseCommand.cpp b/src/commands/segment/SegmentEraseCommand.cpp
new file mode 100644
index 0000000..b15788f
--- /dev/null
+++ b/src/commands/segment/SegmentEraseCommand.cpp
@@ -0,0 +1,108 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentEraseCommand.h"
+
+#include <klocale.h>
+#include "misc/Debug.h"
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include "sound/AudioFile.h"
+#include "sound/AudioFileManager.h"
+
+
+namespace Rosegarden
+{
+
+SegmentEraseCommand::SegmentEraseCommand(Segment *segment) :
+ KNamedCommand(i18n("Erase Segment")),
+ m_composition(segment->getComposition()),
+ m_segment(segment),
+ m_mgr(0),
+ m_audioFileName(""),
+ m_detached(false)
+{
+ // nothing else
+}
+
+SegmentEraseCommand::SegmentEraseCommand(Segment *segment,
+ AudioFileManager *mgr) :
+ KNamedCommand(i18n("Erase Segment")),
+ m_composition(segment->getComposition()),
+ m_segment(segment),
+ m_mgr(mgr),
+ m_detached(false)
+{
+ // If this is an audio segment, we want to make a note of
+ // its associated file name in case we need to undo and restore
+ // the file.
+ if (m_segment->getType() == Segment::Audio) {
+ unsigned int id = m_segment->getAudioFileId();
+ AudioFile *file = mgr->getAudioFile(id);
+ if (file)
+ m_audioFileName = file->getFilename();
+ }
+}
+
+SegmentEraseCommand::~SegmentEraseCommand()
+{
+ // This is the only place in this command that the Segment can
+ // safely be deleted, and then only if it is not in the
+ // Composition (i.e. if we executed more recently than we
+ // unexecuted). Can't safely call through the m_segment pointer
+ // here; someone else might have got to it first
+
+ if (m_detached) {
+ delete m_segment;
+ }
+}
+
+void
+SegmentEraseCommand::execute()
+{
+ m_composition->detachSegment(m_segment);
+ m_detached = true;
+}
+
+void
+SegmentEraseCommand::unexecute()
+{
+ m_composition->addSegment(m_segment);
+ m_detached = false;
+
+ if (m_segment->getType() == Segment::Audio &&
+ m_audioFileName != "" &&
+ m_mgr) {
+ int id = m_mgr->fileExists(m_audioFileName);
+
+ RG_DEBUG << "SegmentEraseCommand::unexecute: file is " << m_audioFileName << endl;
+
+ if (id == -1)
+ id = (int)m_mgr->addFile(m_audioFileName);
+ m_segment->setAudioFileId(id);
+ }
+}
+
+}
diff --git a/src/commands/segment/SegmentEraseCommand.h b/src/commands/segment/SegmentEraseCommand.h
new file mode 100644
index 0000000..493cd14
--- /dev/null
+++ b/src/commands/segment/SegmentEraseCommand.h
@@ -0,0 +1,70 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTERASECOMMAND_H_
+#define _RG_SEGMENTERASECOMMAND_H_
+
+#include <string>
+#include <kcommand.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+class AudioFileManager;
+
+
+////////////////////////////////////////////////////////////
+
+class SegmentEraseCommand : public KNamedCommand
+{
+public:
+ /// for removing segment normally
+ SegmentEraseCommand(Segment *segment);
+
+ /// for removing audio segment when removing an audio file
+ SegmentEraseCommand(Segment *segment,
+ AudioFileManager *mgr);
+ virtual ~SegmentEraseCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ Segment *m_segment;
+ AudioFileManager *m_mgr;
+ std::string m_audioFileName;
+ bool m_detached;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentInsertCommand.cpp b/src/commands/segment/SegmentInsertCommand.cpp
new file mode 100644
index 0000000..f10ef45
--- /dev/null
+++ b/src/commands/segment/SegmentInsertCommand.cpp
@@ -0,0 +1,124 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentInsertCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include "base/Studio.h"
+#include "base/Track.h"
+#include "document/RosegardenGUIDoc.h"
+
+
+namespace Rosegarden
+{
+
+SegmentInsertCommand::SegmentInsertCommand(RosegardenGUIDoc *doc,
+ TrackId track,
+ timeT startTime,
+ timeT endTime):
+ KNamedCommand(i18n("Create Segment")),
+ m_composition(&(doc->getComposition())),
+ m_studio(&(doc->getStudio())),
+ m_segment(0),
+ m_track(track),
+ m_startTime(startTime),
+ m_endTime(endTime),
+ m_detached(false)
+{}
+
+SegmentInsertCommand::SegmentInsertCommand(Composition *composition,
+ Segment *segment,
+ TrackId track):
+ KNamedCommand(i18n("Create Segment")),
+ m_composition(composition),
+ m_studio(0),
+ m_segment(segment),
+ m_track(track),
+ m_startTime(0),
+ m_endTime(0),
+ m_detached(false)
+{}
+
+SegmentInsertCommand::~SegmentInsertCommand()
+{
+ if (m_detached) {
+ delete m_segment;
+ }
+}
+
+Segment *
+SegmentInsertCommand::getSegment() const
+{
+ return m_segment;
+}
+
+void
+SegmentInsertCommand::execute()
+{
+ if (!m_segment) {
+ // Create and insert Segment
+ //
+ m_segment = new Segment();
+ m_segment->setTrack(m_track);
+ m_segment->setStartTime(m_startTime);
+ m_composition->addSegment(m_segment);
+ m_segment->setEndTime(m_endTime);
+
+ // Do our best to label the Segment with whatever is currently
+ // showing against it.
+ //
+ Track *track = m_composition->getTrackById(m_track);
+ std::string label;
+
+ if (track) {
+ // try to get a reasonable Segment name by Instrument
+ //
+ label = m_studio->getSegmentName(track->getInstrument());
+
+ // if not use the track label
+ //
+ if (label == "")
+ label = track->getLabel();
+
+ m_segment->setLabel(label);
+ }
+ } else {
+ m_segment->setTrack(m_track);
+ m_composition->addSegment(m_segment);
+ }
+
+ m_detached = false;
+}
+
+void
+SegmentInsertCommand::unexecute()
+{
+ m_composition->detachSegment(m_segment);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/SegmentInsertCommand.h b/src/commands/segment/SegmentInsertCommand.h
new file mode 100644
index 0000000..932919a
--- /dev/null
+++ b/src/commands/segment/SegmentInsertCommand.h
@@ -0,0 +1,76 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTINSERTCOMMAND_H_
+#define _RG_SEGMENTINSERTCOMMAND_H_
+
+#include "base/Track.h"
+#include <kcommand.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Studio;
+class Segment;
+class RosegardenGUIDoc;
+class Composition;
+
+
+class SegmentInsertCommand : public KNamedCommand
+{
+public:
+ SegmentInsertCommand(RosegardenGUIDoc *doc,
+ TrackId track,
+ timeT startTime,
+ timeT endTime);
+ SegmentInsertCommand(Composition *composition,
+ Segment *segment,
+ TrackId track);
+ virtual ~SegmentInsertCommand();
+
+ Segment *getSegment() const; // after invocation
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ Studio *m_studio;
+ Segment *m_segment;
+ int m_track;
+ timeT m_startTime;
+ timeT m_endTime;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentJoinCommand.cpp b/src/commands/segment/SegmentJoinCommand.cpp
new file mode 100644
index 0000000..27b1bb8
--- /dev/null
+++ b/src/commands/segment/SegmentJoinCommand.cpp
@@ -0,0 +1,175 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentJoinCommand.h"
+
+#include "base/Composition.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentJoinCommand::SegmentJoinCommand(SegmentSelection &
+ segments) :
+ KNamedCommand(getGlobalName()),
+ m_newSegment(0),
+ m_detached(false) // true if the old segments are detached, not the new
+{
+ for (SegmentSelection::iterator i = segments.begin();
+ i != segments.end(); ++i)
+ {
+ m_oldSegments.push_back(*i);
+ }
+ assert(m_oldSegments.size() > 0);
+}
+
+SegmentJoinCommand::~SegmentJoinCommand()
+{
+ if (m_detached) {
+ for (unsigned int i = 0; i < m_oldSegments.size(); ++i) {
+ delete m_oldSegments[i];
+ }
+ } else {
+ delete m_newSegment;
+ }
+}
+
+void
+SegmentJoinCommand::execute()
+{
+ Composition *composition = m_oldSegments[0]->getComposition();
+ if (!composition) {
+ std::cerr
+ << "SegmentJoinCommand::execute: ERROR: old segments are not in composition!"
+ << std::endl;
+ return ;
+ }
+
+ // we normalize rests in any overlapping areas
+ timeT overlapStart = 0, overlapEnd = 0;
+ bool haveOverlap = false;
+
+ if (!m_newSegment) {
+
+ m_newSegment = new Segment(*m_oldSegments[0]);
+
+ // that duplicated segment 0; now do the rest
+
+ for (unsigned int i = 1; i < m_oldSegments.size(); ++i) {
+
+ Segment *s = m_oldSegments[i];
+
+ timeT start = s->getStartTime(), end = s->getEndMarkerTime();
+
+ timeT os = 0, oe = 0;
+ bool haveOverlapHere = false;
+
+ if (start < m_newSegment->getEndMarkerTime() &&
+ end > m_newSegment->getStartTime()) {
+ haveOverlapHere = true;
+ os = std::max(start, m_newSegment->getStartTime());
+ oe = std::min(end, m_newSegment->getEndMarkerTime());
+ std::cerr << "overlap here, os = " << os << ", oe = " << oe << std::endl;
+ }
+
+ if (haveOverlapHere) {
+ if (haveOverlap) {
+ overlapStart = std::min(overlapStart, os);
+ overlapEnd = std::max(overlapEnd, oe);
+ } else {
+ overlapStart = os;
+ overlapEnd = oe;
+ haveOverlap = true;
+ }
+ }
+
+ if (start > m_newSegment->getEndMarkerTime()) {
+ m_newSegment->setEndMarkerTime(start);
+ }
+
+ for (Segment::iterator si = s->begin();
+ s->isBeforeEndMarker(si); ++si) {
+
+ // weed out duplicate clefs and keys
+
+ if ((*si)->isa(Clef::EventType)) {
+ try {
+ Clef newClef(**si);
+ if (m_newSegment->getClefAtTime
+ ((*si)->getAbsoluteTime() + 1) == newClef) {
+ continue;
+ }
+ } catch (...) { }
+ }
+
+ if ((*si)->isa(Key::EventType)) {
+ try {
+ Key newKey(**si);
+ if (m_newSegment->getKeyAtTime
+ ((*si)->getAbsoluteTime() + 1) == newKey) {
+ continue;
+ }
+ } catch (...) { }
+ }
+
+ m_newSegment->insert(new Event(**si));
+ }
+
+ if (end > m_newSegment->getEndMarkerTime()) {
+ m_newSegment->setEndMarkerTime(end);
+ }
+ }
+ }
+
+ composition->addSegment(m_newSegment);
+
+ if (haveOverlap) {
+ m_newSegment->normalizeRests(overlapStart, overlapEnd);
+ }
+
+ for (unsigned int i = 0; i < m_oldSegments.size(); ++i) {
+ composition->detachSegment(m_oldSegments[i]);
+ }
+
+ m_detached = true;
+}
+
+void
+SegmentJoinCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_oldSegments.size(); ++i) {
+ m_newSegment->getComposition()->addSegment(m_oldSegments[i]);
+ }
+
+ m_newSegment->getComposition()->detachSegment(m_newSegment);
+ m_detached = false;
+}
+
+}
diff --git a/src/commands/segment/SegmentJoinCommand.h b/src/commands/segment/SegmentJoinCommand.h
new file mode 100644
index 0000000..97c7924
--- /dev/null
+++ b/src/commands/segment/SegmentJoinCommand.h
@@ -0,0 +1,65 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTJOINCOMMAND_H_
+#define _RG_SEGMENTJOINCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class SegmentSelection;
+class Segment;
+
+
+class SegmentJoinCommand : public KNamedCommand
+{
+public:
+ SegmentJoinCommand(SegmentSelection &segments);
+ virtual ~SegmentJoinCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName() { return i18n("&Join"); }
+
+private:
+ std::vector<Segment *> m_oldSegments;
+ Segment *m_newSegment;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentLabelCommand.cpp b/src/commands/segment/SegmentLabelCommand.cpp
new file mode 100644
index 0000000..8bc0ff4
--- /dev/null
+++ b/src/commands/segment/SegmentLabelCommand.cpp
@@ -0,0 +1,73 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentLabelCommand.h"
+
+#include "misc/Strings.h"
+#include "base/Segment.h"
+#include "base/Selection.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentLabelCommand::SegmentLabelCommand(
+ SegmentSelection &segments,
+ const QString &label):
+ KNamedCommand(i18n("Label Segments")),
+ m_newLabel(label)
+{
+ for (SegmentSelection::iterator i = segments.begin();
+ i != segments.end(); ++i)
+ m_segments.push_back(*i);
+}
+
+SegmentLabelCommand::~SegmentLabelCommand()
+{}
+
+void
+SegmentLabelCommand::execute()
+{
+ bool addLabels = false;
+ if (m_labels.size() == 0)
+ addLabels = true;
+
+ for (unsigned int i = 0; i < m_segments.size(); ++i) {
+ if (addLabels)
+ m_labels.push_back(strtoqstr(m_segments[i]->getLabel()));
+
+ m_segments[i]->setLabel(qstrtostr(m_newLabel));
+ }
+}
+
+void
+SegmentLabelCommand::unexecute()
+{
+ for (unsigned int i = 0; i < m_segments.size(); ++i)
+ m_segments[i]->setLabel(qstrtostr(m_labels[i]));
+}
+
+}
diff --git a/src/commands/segment/SegmentLabelCommand.h b/src/commands/segment/SegmentLabelCommand.h
new file mode 100644
index 0000000..1c55f3b
--- /dev/null
+++ b/src/commands/segment/SegmentLabelCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTLABELCOMMAND_H_
+#define _RG_SEGMENTLABELCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class SegmentSelection;
+class Segment;
+
+
+class SegmentLabelCommand : public KNamedCommand
+{
+public:
+ SegmentLabelCommand(SegmentSelection &segments,
+ const QString &label);
+ virtual ~SegmentLabelCommand();
+
+ static QString getGlobalName()
+ { return i18n("Re&label..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+protected:
+
+ std::vector<Segment*> m_segments;
+ std::vector<QString> m_labels;
+ QString m_newLabel;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentQuickCopyCommand.cpp b/src/commands/segment/SegmentQuickCopyCommand.cpp
new file mode 100644
index 0000000..1ce432c
--- /dev/null
+++ b/src/commands/segment/SegmentQuickCopyCommand.cpp
@@ -0,0 +1,71 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentQuickCopyCommand.h"
+
+#include "misc/Strings.h"
+#include "base/Composition.h"
+#include "base/Segment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentQuickCopyCommand::SegmentQuickCopyCommand(Segment *segment):
+ KNamedCommand(getGlobalName()),
+ m_composition(segment->getComposition()),
+ m_segmentToCopy(segment),
+ m_segment(0),
+ m_detached(false)
+{}
+
+SegmentQuickCopyCommand::~SegmentQuickCopyCommand()
+{
+ if (m_detached) {
+ delete m_segment;
+ }
+}
+
+void
+SegmentQuickCopyCommand::execute()
+{
+ if (!m_segment) {
+ m_segment = new Segment(*m_segmentToCopy);
+ m_segment->setLabel(qstrtostr(i18n("%1 (copied)").arg
+ (strtoqstr(m_segment->getLabel()))));
+ }
+ m_composition->addSegment(m_segment);
+ m_detached = false;
+}
+
+void
+SegmentQuickCopyCommand::unexecute()
+{
+ m_composition->detachSegment(m_segment);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/SegmentQuickCopyCommand.h b/src/commands/segment/SegmentQuickCopyCommand.h
new file mode 100644
index 0000000..638b16a
--- /dev/null
+++ b/src/commands/segment/SegmentQuickCopyCommand.h
@@ -0,0 +1,68 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTQUICKCOPYCOMMAND_H_
+#define _RG_SEGMENTQUICKCOPYCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+class SegmentQuickCopyCommand : public KNamedCommand
+{
+public:
+ SegmentQuickCopyCommand(Segment *segment);
+ virtual ~SegmentQuickCopyCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ // return pointer to new copy
+ Segment* getCopy() { return m_segment; }
+
+ static QString getGlobalName() { return i18n("Quick-Copy Segment"); }
+
+private:
+ Composition *m_composition;
+ Segment *m_segmentToCopy;
+ Segment *m_segment;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentReconfigureCommand.cpp b/src/commands/segment/SegmentReconfigureCommand.cpp
new file mode 100644
index 0000000..ec9d1bd
--- /dev/null
+++ b/src/commands/segment/SegmentReconfigureCommand.cpp
@@ -0,0 +1,114 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentReconfigureCommand.h"
+
+#include "base/Segment.h"
+#include "base/Track.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentReconfigureCommand::SegmentReconfigureCommand(QString name) :
+ KNamedCommand(name)
+{}
+
+SegmentReconfigureCommand::~SegmentReconfigureCommand()
+{}
+
+void
+SegmentReconfigureCommand::addSegment(Segment *segment,
+ timeT startTime,
+ timeT endMarkerTime,
+ TrackId track)
+{
+ SegmentRec record;
+ record.segment = segment;
+ record.startTime = startTime;
+ record.endMarkerTime = endMarkerTime;
+ record.track = track;
+ m_records.push_back(record);
+}
+
+void
+SegmentReconfigureCommand::addSegments(const SegmentRecSet &records)
+{
+ for (SegmentRecSet::const_iterator i = records.begin(); i != records.end(); ++i) {
+ m_records.push_back(*i);
+ }
+}
+
+void
+SegmentReconfigureCommand::execute()
+{
+ swap();
+}
+
+void
+SegmentReconfigureCommand::unexecute()
+{
+ swap();
+}
+
+void
+SegmentReconfigureCommand::swap()
+{
+ for (SegmentRecSet::iterator i = m_records.begin();
+ i != m_records.end(); ++i) {
+
+ // set the segment's values from the record, but set the
+ // previous values back in to the record for use in the
+ // next iteration of the execute/unexecute cycle.
+
+ // #1083496: look up both of the "old" values before we set
+ // anything, as setting the start time is likely to change the
+ // end marker time.
+
+ timeT prevStartTime = i->segment->getStartTime();
+ timeT prevEndMarkerTime = i->segment->getEndMarkerTime();
+
+ if (i->segment->getStartTime() != i->startTime) {
+ i->segment->setStartTime(i->startTime);
+ }
+
+ if (i->segment->getEndMarkerTime() != i->endMarkerTime) {
+ i->segment->setEndMarkerTime(i->endMarkerTime);
+ }
+
+ i->startTime = prevStartTime;
+ i->endMarkerTime = prevEndMarkerTime;
+
+ TrackId currentTrack = i->segment->getTrack();
+
+ if (currentTrack != i->track) {
+ i->segment->setTrack(i->track);
+ i->track = currentTrack;
+ }
+ }
+}
+
+}
diff --git a/src/commands/segment/SegmentReconfigureCommand.h b/src/commands/segment/SegmentReconfigureCommand.h
new file mode 100644
index 0000000..be82e47
--- /dev/null
+++ b/src/commands/segment/SegmentReconfigureCommand.h
@@ -0,0 +1,81 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTRECONFIGURECOMMAND_H_
+#define _RG_SEGMENTRECONFIGURECOMMAND_H_
+
+#include "base/Track.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+/**
+ * SegmentReconfigureCommand is a general-purpose command for
+ * moving, resizing or changing the track of one or more segments
+ */
+class SegmentReconfigureCommand : public KNamedCommand
+{
+public:
+ SegmentReconfigureCommand(QString name);
+ virtual ~SegmentReconfigureCommand();
+
+ struct SegmentRec {
+ Segment *segment;
+ timeT startTime;
+ timeT endMarkerTime;
+ TrackId track;
+ };
+ typedef std::vector<SegmentRec> SegmentRecSet;
+
+ void addSegment(Segment *segment,
+ timeT startTime,
+ timeT endMarkerTime,
+ TrackId track);
+
+ void addSegments(const SegmentRecSet &records);
+
+ void execute();
+ void unexecute();
+
+private:
+ SegmentRecSet m_records;
+ void swap();
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentRecordCommand.cpp b/src/commands/segment/SegmentRecordCommand.cpp
new file mode 100644
index 0000000..f457f32
--- /dev/null
+++ b/src/commands/segment/SegmentRecordCommand.cpp
@@ -0,0 +1,67 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentRecordCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/Segment.h"
+
+
+namespace Rosegarden
+{
+
+SegmentRecordCommand::SegmentRecordCommand(Segment *s) :
+ KNamedCommand(i18n("Record")),
+ m_composition(s->getComposition()),
+ m_segment(s),
+ m_detached(false)
+{}
+
+SegmentRecordCommand::~SegmentRecordCommand()
+{
+ if (m_detached) {
+ delete m_segment;
+ }
+}
+
+void
+SegmentRecordCommand::execute()
+{
+ if (!m_segment->getComposition()) {
+ m_composition->addSegment(m_segment);
+ }
+
+ m_detached = false;
+}
+
+void
+SegmentRecordCommand::unexecute()
+{
+ m_composition->detachSegment(m_segment);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/SegmentRecordCommand.h b/src/commands/segment/SegmentRecordCommand.h
new file mode 100644
index 0000000..c3f4ffe
--- /dev/null
+++ b/src/commands/segment/SegmentRecordCommand.h
@@ -0,0 +1,67 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTRECORDCOMMAND_H_
+#define _RG_SEGMENTRECORDCOMMAND_H_
+
+#include <kcommand.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+/**
+ * SegmentRecordCommand pretends to insert a Segment that is actually
+ * already in the Composition (the currently-being-recorded one). It's
+ * used at the end of recording, to ensure that GUI updates happen
+ * correctly, and it provides the ability to undo recording. (The
+ * unexecute does remove the segment, it doesn't just pretend to.)
+ */
+class SegmentRecordCommand : public KNamedCommand
+{
+public:
+ SegmentRecordCommand(Segment *segment);
+ virtual ~SegmentRecordCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ Segment *m_segment;
+ bool m_detached;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentRepeatToCopyCommand.cpp b/src/commands/segment/SegmentRepeatToCopyCommand.cpp
new file mode 100644
index 0000000..a0e0e43
--- /dev/null
+++ b/src/commands/segment/SegmentRepeatToCopyCommand.cpp
@@ -0,0 +1,106 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentRepeatToCopyCommand.h"
+
+#include "base/Event.h"
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/Segment.h"
+
+
+namespace Rosegarden
+{
+
+SegmentRepeatToCopyCommand::SegmentRepeatToCopyCommand(
+ Segment *segment):
+ KNamedCommand(i18n("Turn Repeats into Copies")),
+ m_composition(segment->getComposition()),
+ m_segment(segment),
+ m_detached(false)
+{}
+
+SegmentRepeatToCopyCommand::~SegmentRepeatToCopyCommand()
+{
+ if (m_detached) {
+ std::vector<Segment*>::iterator it =
+ m_newSegments.begin();
+
+ for (; it != m_newSegments.end(); it++)
+ delete (*it);
+ }
+}
+
+void
+SegmentRepeatToCopyCommand::execute()
+{
+ if (m_newSegments.size() == 0) {
+ timeT newStartTime = m_segment->getEndMarkerTime();
+ timeT newDuration =
+ m_segment->getEndMarkerTime() - m_segment->getStartTime();
+ Segment *newSegment;
+ timeT repeatEndTime = m_segment->getRepeatEndTime();
+
+ while (newStartTime + newDuration < repeatEndTime) {
+ // Create new segment, transpose and turn off repeat
+ //
+ newSegment = new Segment(*m_segment);
+ newSegment->setStartTime(newStartTime);
+ newSegment->setRepeating(false);
+
+ // Insert and store
+ m_composition->addSegment(newSegment);
+ m_newSegments.push_back(newSegment);
+
+ // Move onto next
+ newStartTime += newDuration;
+ }
+
+ // fill remaining partial segment
+ } else {
+ std::vector<Segment*>::iterator it =
+ m_newSegments.begin();
+
+ for (; it != m_newSegments.end(); it++)
+ m_composition->addSegment(*it);
+ }
+ m_segment->setRepeating(false);
+ m_detached = false;
+}
+
+void
+SegmentRepeatToCopyCommand::unexecute()
+{
+ std::vector<Segment*>::iterator it =
+ m_newSegments.begin();
+
+ for (; it != m_newSegments.end(); it++)
+ m_composition->detachSegment(*it);
+
+ m_detached = true;
+ m_segment->setRepeating(true);
+}
+
+}
diff --git a/src/commands/segment/SegmentRepeatToCopyCommand.h b/src/commands/segment/SegmentRepeatToCopyCommand.h
new file mode 100644
index 0000000..d0cc565
--- /dev/null
+++ b/src/commands/segment/SegmentRepeatToCopyCommand.h
@@ -0,0 +1,62 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTREPEATTOCOPYCOMMAND_H_
+#define _RG_SEGMENTREPEATTOCOPYCOMMAND_H_
+
+#include <kcommand.h>
+#include <vector>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+class SegmentRepeatToCopyCommand : public KNamedCommand
+{
+public:
+ SegmentRepeatToCopyCommand(Segment *segment);
+ virtual ~SegmentRepeatToCopyCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+
+ Composition *m_composition;
+ Segment *m_segment;
+ std::vector<Segment*> m_newSegments;
+ bool m_detached;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentRescaleCommand.cpp b/src/commands/segment/SegmentRescaleCommand.cpp
new file mode 100644
index 0000000..d7a7c80
--- /dev/null
+++ b/src/commands/segment/SegmentRescaleCommand.cpp
@@ -0,0 +1,148 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentRescaleCommand.h"
+
+#include "misc/Strings.h"
+#include "base/Event.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentRescaleCommand::SegmentRescaleCommand(Segment *s,
+ int multiplier,
+ int divisor) :
+ KNamedCommand(getGlobalName()),
+ m_segment(s),
+ m_newSegment(0),
+ m_startTimeGiven(false),
+ m_startTime(s->getStartTime()),
+ m_multiplier(multiplier),
+ m_divisor(divisor),
+ m_detached(false)
+{
+ // nothing
+}
+
+SegmentRescaleCommand::SegmentRescaleCommand(Segment *s,
+ int multiplier,
+ int divisor,
+ timeT st) :
+ KNamedCommand(getGlobalName()),
+ m_segment(s),
+ m_newSegment(0),
+ m_startTimeGiven(true),
+ m_startTime(st),
+ m_multiplier(multiplier),
+ m_divisor(divisor),
+ m_detached(false)
+{
+ // nothing
+}
+
+SegmentRescaleCommand::~SegmentRescaleCommand()
+{
+ if (m_detached) {
+ delete m_segment;
+ } else {
+ delete m_newSegment;
+ }
+}
+
+timeT
+SegmentRescaleCommand::rescale(timeT t)
+{
+ // avoid overflows by using doubles
+ double d = t;
+ d *= m_multiplier;
+ d /= m_divisor;
+ d += 0.5;
+ return (timeT)d;
+}
+
+void
+SegmentRescaleCommand::execute()
+{
+ timeT startTime = m_segment->getStartTime();
+
+ if (m_startTimeGiven) startTime = m_startTime;
+
+ if (!m_newSegment) {
+
+ m_newSegment = new Segment();
+ m_newSegment->setTrack(m_segment->getTrack());
+ QString oldLabel = strtoqstr(m_segment->getLabel());
+ if (oldLabel.endsWith(i18n("(rescaled)"))) {
+ m_newSegment->setLabel(m_segment->getLabel());
+ } else {
+ m_newSegment->setLabel(qstrtostr(i18n("%1 (rescaled)").arg
+ (oldLabel)));
+ }
+ m_newSegment->setColourIndex(m_segment->getColourIndex());
+
+ for (Segment::iterator i = m_segment->begin();
+ m_segment->isBeforeEndMarker(i); ++i) {
+
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+
+ timeT dt = (*i)->getAbsoluteTime() - startTime;
+ timeT duration = (*i)->getDuration();
+
+ //!!! use doubles for this calculation where necessary
+
+ m_newSegment->insert
+ (new Event(**i,
+ startTime + rescale(dt),
+ rescale(duration)));
+ }
+ }
+
+ m_segment->getComposition()->addSegment(m_newSegment);
+ m_segment->getComposition()->detachSegment(m_segment);
+ m_newSegment->normalizeRests(m_newSegment->getStartTime(),
+ m_newSegment->getEndTime());
+
+ m_newSegment->setEndMarkerTime
+ (startTime + rescale(m_segment->getEndMarkerTime() -
+ m_segment->getStartTime()));
+
+ m_detached = true;
+}
+
+void
+SegmentRescaleCommand::unexecute()
+{
+ m_newSegment->getComposition()->addSegment(m_segment);
+ m_newSegment->getComposition()->detachSegment(m_newSegment);
+ m_detached = false;
+}
+
+}
diff --git a/src/commands/segment/SegmentRescaleCommand.h b/src/commands/segment/SegmentRescaleCommand.h
new file mode 100644
index 0000000..7a34727
--- /dev/null
+++ b/src/commands/segment/SegmentRescaleCommand.h
@@ -0,0 +1,76 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTRESCALECOMMAND_H_
+#define _RG_SEGMENTRESCALECOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include "base/Event.h"
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class SegmentRescaleCommand : public KNamedCommand
+{
+public:
+ SegmentRescaleCommand(Segment *segment,
+ int multiplier,
+ int divisor);
+ SegmentRescaleCommand(Segment *segment,
+ int multiplier,
+ int divisor,
+ timeT newStartTime);
+ virtual ~SegmentRescaleCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName() { return i18n("Stretch or S&quash..."); }
+
+private:
+ Segment *m_segment;
+ Segment *m_newSegment;
+ bool m_startTimeGiven;
+ timeT m_startTime;
+ int m_multiplier;
+ int m_divisor;
+ bool m_detached;
+
+ timeT rescale(timeT);
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentResizeFromStartCommand.cpp b/src/commands/segment/SegmentResizeFromStartCommand.cpp
new file mode 100644
index 0000000..a4157bb
--- /dev/null
+++ b/src/commands/segment/SegmentResizeFromStartCommand.cpp
@@ -0,0 +1,85 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentResizeFromStartCommand.h"
+
+#include <klocale.h>
+#include "base/Event.h"
+#include "base/Segment.h"
+#include "document/BasicCommand.h"
+
+
+namespace Rosegarden
+{
+
+SegmentResizeFromStartCommand::SegmentResizeFromStartCommand(Segment *s,
+ timeT time) :
+ BasicCommand(i18n("Resize Segment"), *s,
+ std::min(time, s->getStartTime()),
+ std::max(time, s->getStartTime())),
+ m_segment(s),
+ m_oldStartTime(s->getStartTime()),
+ m_newStartTime(time)
+{
+ // nothing else
+}
+
+SegmentResizeFromStartCommand::~SegmentResizeFromStartCommand()
+{
+ // nothing
+}
+
+void
+SegmentResizeFromStartCommand::modifySegment()
+{
+ if (m_newStartTime < m_oldStartTime) {
+ m_segment->fillWithRests(m_newStartTime, m_oldStartTime);
+ } else {
+
+ for (Segment::iterator i = m_segment->begin();
+ m_segment->isBeforeEndMarker(i); ) {
+
+ Segment::iterator j = i;
+ ++j;
+
+ if ((*i)->getAbsoluteTime() >= m_newStartTime)
+ break;
+
+ if ((*i)->getAbsoluteTime() + (*i)->getDuration() <= m_newStartTime) {
+ m_segment->erase(i);
+ } else {
+ Event *e = new Event
+ (**i, m_newStartTime,
+ (*i)->getAbsoluteTime() + (*i)->getDuration() - m_newStartTime);
+ m_segment->erase(i);
+ m_segment->insert(e);
+ }
+
+ i = j;
+ }
+ }
+}
+
+}
diff --git a/src/commands/segment/SegmentResizeFromStartCommand.h b/src/commands/segment/SegmentResizeFromStartCommand.h
new file mode 100644
index 0000000..8f0dc89
--- /dev/null
+++ b/src/commands/segment/SegmentResizeFromStartCommand.h
@@ -0,0 +1,69 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTRESIZEFROMSTARTCOMMAND_H_
+#define _RG_SEGMENTRESIZEFROMSTARTCOMMAND_H_
+
+#include "document/BasicCommand.h"
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+/**
+ * SegmentResizeFromStartCommand moves the start time of a segment
+ * leaving the events in it at the same absolute times as before, so
+ * padding with rests or deleting events as appropriate. (Distinct
+ * from Segment::setStartTime, as used by SegmentReconfigureCommand,
+ * which moves all the events in the segment.)
+ * Not for use on audio segments (see AudioSegmentResizeFromStartCommand).
+ */
+class SegmentResizeFromStartCommand : public BasicCommand
+{
+public:
+ SegmentResizeFromStartCommand(Segment *segment,
+ timeT newStartTime);
+ virtual ~SegmentResizeFromStartCommand();
+
+protected:
+ virtual void modifySegment();
+
+private:
+ Segment *m_segment;
+ timeT m_oldStartTime;
+ timeT m_newStartTime;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentSingleRepeatToCopyCommand.cpp b/src/commands/segment/SegmentSingleRepeatToCopyCommand.cpp
new file mode 100644
index 0000000..c9b92fb
--- /dev/null
+++ b/src/commands/segment/SegmentSingleRepeatToCopyCommand.cpp
@@ -0,0 +1,73 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentSingleRepeatToCopyCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/Segment.h"
+
+
+namespace Rosegarden
+{
+
+SegmentSingleRepeatToCopyCommand::SegmentSingleRepeatToCopyCommand(
+ Segment *segment,
+ timeT time):
+ KNamedCommand(i18n("Turn Single Repeat into Copy")),
+ m_composition(segment->getComposition()),
+ m_segment(segment),
+ m_newSegment(0),
+ m_time(time),
+ m_detached(false)
+{}
+
+SegmentSingleRepeatToCopyCommand::~SegmentSingleRepeatToCopyCommand()
+{
+ if (m_detached)
+ delete m_newSegment;
+}
+
+void
+SegmentSingleRepeatToCopyCommand::execute()
+{
+ if (!m_newSegment) {
+ m_newSegment = new Segment(*m_segment);
+ m_newSegment->setStartTime(m_time);
+ m_newSegment->setRepeating(true);
+ }
+
+ m_composition->addSegment(m_newSegment);
+ m_detached = false;
+}
+
+void
+SegmentSingleRepeatToCopyCommand::unexecute()
+{
+ m_composition->detachSegment(m_newSegment);
+ m_detached = true;
+}
+
+}
diff --git a/src/commands/segment/SegmentSingleRepeatToCopyCommand.h b/src/commands/segment/SegmentSingleRepeatToCopyCommand.h
new file mode 100644
index 0000000..0c4984e
--- /dev/null
+++ b/src/commands/segment/SegmentSingleRepeatToCopyCommand.h
@@ -0,0 +1,65 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTSINGLEREPEATTOCOPYCOMMAND_H_
+#define _RG_SEGMENTSINGLEREPEATTOCOPYCOMMAND_H_
+
+#include <kcommand.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+class SegmentSingleRepeatToCopyCommand : public KNamedCommand
+{
+public:
+ SegmentSingleRepeatToCopyCommand(Segment *segment,
+ timeT time);
+ virtual ~SegmentSingleRepeatToCopyCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ Segment *getNewSegment() const { return m_newSegment; }
+
+private:
+ Composition *m_composition;
+ Segment *m_segment;
+ Segment *m_newSegment;
+ timeT m_time;
+ bool m_detached;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentSplitByPitchCommand.cpp b/src/commands/segment/SegmentSplitByPitchCommand.cpp
new file mode 100644
index 0000000..2000a35
--- /dev/null
+++ b/src/commands/segment/SegmentSplitByPitchCommand.cpp
@@ -0,0 +1,280 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentSplitByPitchCommand.h"
+
+#include "base/BaseProperties.h"
+#include "base/Sets.h"
+#include "misc/Strings.h"
+#include "base/Composition.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/NotationQuantizer.h"
+#include "base/Segment.h"
+#include "base/SegmentNotationHelper.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentSplitByPitchCommand::SegmentSplitByPitchCommand(Segment *segment,
+ int p, bool r, bool d,
+ ClefHandling c) :
+ KNamedCommand(i18n("Split by Pitch")),
+ m_composition(segment->getComposition()),
+ m_segment(segment),
+ m_newSegmentA(0),
+ m_newSegmentB(0),
+ m_splitPitch(p),
+ m_ranging(r),
+ m_dupNonNoteEvents(d),
+ m_clefHandling(c),
+ m_executed(false)
+{}
+
+SegmentSplitByPitchCommand::~SegmentSplitByPitchCommand()
+{
+ if (m_executed) {
+ delete m_segment;
+ } else {
+ delete m_newSegmentA;
+ delete m_newSegmentB;
+ }
+}
+
+void
+SegmentSplitByPitchCommand::execute()
+{
+ if (!m_newSegmentA) {
+
+ m_newSegmentA = new Segment;
+ m_newSegmentB = new Segment;
+
+ m_newSegmentA->setTrack(m_segment->getTrack());
+ m_newSegmentA->setStartTime(m_segment->getStartTime());
+
+ m_newSegmentB->setTrack(m_segment->getTrack());
+ m_newSegmentB->setStartTime(m_segment->getStartTime());
+
+ int splitPitch(m_splitPitch);
+
+ for (Segment::iterator i = m_segment->begin();
+ m_segment->isBeforeEndMarker(i); ++i) {
+
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+ if ((*i)->isa(Clef::EventType) &&
+ m_clefHandling != LeaveClefs)
+ continue;
+
+ if ((*i)->isa(Note::EventType)) {
+
+ if (m_ranging) {
+ splitPitch = getSplitPitchAt(i, splitPitch);
+ }
+
+ if ((*i)->has(BaseProperties::PITCH) &&
+ (*i)->get
+ <Int>(BaseProperties::PITCH) <
+ splitPitch) {
+ if (m_newSegmentB->empty()) {
+ m_newSegmentB->fillWithRests((*i)->getAbsoluteTime());
+ }
+ m_newSegmentB->insert(new Event(**i));
+ }
+ else {
+ if (m_newSegmentA->empty()) {
+ m_newSegmentA->fillWithRests((*i)->getAbsoluteTime());
+ }
+ m_newSegmentA->insert(new Event(**i));
+ }
+
+ } else {
+
+ m_newSegmentA->insert(new Event(**i));
+
+ if (m_dupNonNoteEvents) {
+ m_newSegmentB->insert(new Event(**i));
+ }
+ }
+ }
+
+ //!!! m_newSegmentA->fillWithRests(m_segment->getEndMarkerTime());
+ // m_newSegmentB->fillWithRests(m_segment->getEndMarkerTime());
+ m_newSegmentA->normalizeRests(m_segment->getStartTime(),
+ m_segment->getEndMarkerTime());
+ m_newSegmentB->normalizeRests(m_segment->getStartTime(),
+ m_segment->getEndMarkerTime());
+ }
+
+ m_composition->addSegment(m_newSegmentA);
+ m_composition->addSegment(m_newSegmentB);
+
+ SegmentNotationHelper helperA(*m_newSegmentA);
+ SegmentNotationHelper helperB(*m_newSegmentB);
+
+ if (m_clefHandling == RecalculateClefs) {
+
+ m_newSegmentA->insert
+ (helperA.guessClef(m_newSegmentA->begin(),
+ m_newSegmentA->end()).getAsEvent
+ (m_newSegmentA->getStartTime()));
+
+ m_newSegmentB->insert
+ (helperB.guessClef(m_newSegmentB->begin(),
+ m_newSegmentB->end()).getAsEvent
+ (m_newSegmentB->getStartTime()));
+
+ } else if (m_clefHandling == UseTrebleAndBassClefs) {
+
+ m_newSegmentA->insert
+ (Clef(Clef::Treble).getAsEvent
+ (m_newSegmentA->getStartTime()));
+
+ m_newSegmentB->insert
+ (Clef(Clef::Bass).getAsEvent
+ (m_newSegmentB->getStartTime()));
+ }
+
+ //!!! m_composition->getNotationQuantizer()->quantize(m_newSegmentA);
+ // m_composition->getNotationQuantizer()->quantize(m_newSegmentB);
+ helperA.autoBeam(m_newSegmentA->begin(), m_newSegmentA->end(),
+ BaseProperties::GROUP_TYPE_BEAMED);
+ helperB.autoBeam(m_newSegmentB->begin(), m_newSegmentB->end(),
+ BaseProperties::GROUP_TYPE_BEAMED);
+
+ std::string label = m_segment->getLabel();
+ m_newSegmentA->setLabel(qstrtostr(i18n("%1 (upper)").arg
+ (strtoqstr(label))));
+ m_newSegmentB->setLabel(qstrtostr(i18n("%1 (lower)").arg
+ (strtoqstr(label))));
+ m_newSegmentA->setColourIndex(m_segment->getColourIndex());
+ m_newSegmentB->setColourIndex(m_segment->getColourIndex());
+
+ m_composition->detachSegment(m_segment);
+ m_executed = true;
+}
+
+void
+SegmentSplitByPitchCommand::unexecute()
+{
+ m_composition->addSegment(m_segment);
+ m_composition->detachSegment(m_newSegmentA);
+ m_composition->detachSegment(m_newSegmentB);
+ m_executed = false;
+}
+
+int
+SegmentSplitByPitchCommand::getSplitPitchAt(Segment::iterator i,
+ int lastSplitPitch)
+{
+ typedef std::set<int>::iterator PitchItr;
+ std::set<int> pitches;
+
+ // when this algorithm appears to be working ok, we should be
+ // able to make it much quicker
+
+ const Quantizer *quantizer
+ (m_segment->getComposition()->getNotationQuantizer());
+
+ int myHighest, myLowest;
+ int prevHighest = 0, prevLowest = 0;
+ bool havePrev = false;
+
+ Chord c0(*m_segment, i, quantizer);
+ std::vector<int> c0p(c0.getPitches());
+ pitches.insert<std::vector<int>::iterator>(c0p.begin(), c0p.end());
+
+ myLowest = c0p[0];
+ myHighest = c0p[c0p.size() - 1];
+
+ Segment::iterator j(c0.getPreviousNote());
+ if (j != m_segment->end()) {
+
+ havePrev = true;
+
+ Chord c1(*m_segment, j, quantizer);
+ std::vector<int> c1p(c1.getPitches());
+ pitches.insert<std::vector<int>::iterator>(c1p.begin(), c1p.end());
+
+ prevLowest = c1p[0];
+ prevHighest = c1p[c1p.size() - 1];
+ }
+
+ if (pitches.size() < 2)
+ return lastSplitPitch;
+
+ PitchItr pi = pitches.begin();
+ int lowest(*pi);
+
+ pi = pitches.end();
+ --pi;
+ int highest(*pi);
+
+ if ((pitches.size() == 2 || highest - lowest <= 18) &&
+ myHighest > lastSplitPitch &&
+ myLowest < lastSplitPitch &&
+ prevHighest > lastSplitPitch &&
+ prevLowest < lastSplitPitch) {
+
+ if (havePrev) {
+ if ((myLowest > prevLowest && myHighest > prevHighest) ||
+ (myLowest < prevLowest && myHighest < prevHighest)) {
+ int avgDiff = ((myLowest - prevLowest) +
+ (myHighest - prevHighest)) / 2;
+ if (avgDiff < -5)
+ avgDiff = -5;
+ if (avgDiff > 5)
+ avgDiff = 5;
+ return lastSplitPitch + avgDiff;
+ }
+ }
+
+ return lastSplitPitch;
+ }
+
+ int middle = (highest - lowest) / 2 + lowest;
+
+ while (lastSplitPitch > middle && lastSplitPitch > m_splitPitch - 12) {
+ if (lastSplitPitch - lowest < 12)
+ return lastSplitPitch;
+ if (lastSplitPitch <= m_splitPitch - 12)
+ return lastSplitPitch;
+ --lastSplitPitch;
+ }
+
+ while (lastSplitPitch < middle && lastSplitPitch < m_splitPitch + 12) {
+ if (highest - lastSplitPitch < 12)
+ return lastSplitPitch;
+ if (lastSplitPitch >= m_splitPitch + 12)
+ return lastSplitPitch;
+ ++lastSplitPitch;
+ }
+
+ return lastSplitPitch;
+}
+
+}
diff --git a/src/commands/segment/SegmentSplitByPitchCommand.h b/src/commands/segment/SegmentSplitByPitchCommand.h
new file mode 100644
index 0000000..e536be6
--- /dev/null
+++ b/src/commands/segment/SegmentSplitByPitchCommand.h
@@ -0,0 +1,83 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTSPLITBYPITCHCOMMAND_H_
+#define _RG_SEGMENTSPLITBYPITCHCOMMAND_H_
+
+#include "base/Segment.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+#include "gui/general/ClefIndex.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class SegmentSplitByPitchCommand : public KNamedCommand
+{
+public:
+ enum ClefHandling {
+ LeaveClefs,
+ RecalculateClefs,
+ UseTrebleAndBassClefs
+ };
+
+ SegmentSplitByPitchCommand(Segment *segment,
+ int splitPitch,
+ bool ranging,
+ bool duplicateNonNoteEvents,
+ ClefHandling clefHandling);
+ virtual ~SegmentSplitByPitchCommand();
+
+ static QString getGlobalName()
+ { return i18n("Split by &Pitch..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ int getSplitPitchAt(Segment::iterator i, int lastSplitPitch);
+
+ Composition *m_composition;
+ Segment *m_segment;
+ Segment *m_newSegmentA;
+ Segment *m_newSegmentB;
+ int m_splitPitch;
+ bool m_ranging;
+ bool m_dupNonNoteEvents;
+ ClefHandling m_clefHandling;
+ bool m_executed;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentSplitByRecordingSrcCommand.cpp b/src/commands/segment/SegmentSplitByRecordingSrcCommand.cpp
new file mode 100644
index 0000000..fbb3c1b
--- /dev/null
+++ b/src/commands/segment/SegmentSplitByRecordingSrcCommand.cpp
@@ -0,0 +1,153 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentSplitByRecordingSrcCommand.h"
+
+#include "base/BaseProperties.h"
+#include "misc/Strings.h"
+#include "base/Composition.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentSplitByRecordingSrcCommand::SegmentSplitByRecordingSrcCommand (
+ Segment *segment, int channel, int device ) :
+ KNamedCommand(i18n("Split by Recording Source")),
+ m_composition(segment->getComposition()),
+ m_segment(segment),
+ m_newSegmentA(0),
+ m_channel(channel),
+ m_device(device),
+ m_executed(false)
+{}
+
+void
+SegmentSplitByRecordingSrcCommand::execute()
+{
+ if (!m_newSegmentA) {
+
+ m_newSegmentA = new Segment;
+ m_newSegmentB = new Segment;
+
+ m_newSegmentA->setTrack(m_segment->getTrack());
+ m_newSegmentA->setStartTime(m_segment->getStartTime());
+
+ m_newSegmentB->setTrack(m_segment->getTrack());
+ m_newSegmentB->setStartTime(m_segment->getStartTime());
+
+ bool selectedC = false;
+ bool selectedD = false;
+
+ for (Segment::iterator i = m_segment->begin();
+ m_segment->isBeforeEndMarker(i); ++i) {
+
+ if ((*i)->isa(Note::EventRestType))
+ continue;
+
+ if ( (*i)->isa(Clef::EventType) ||
+ (*i)->isa(Key::EventType) ) {
+
+ m_newSegmentA->insert(new Event(**i));
+ m_newSegmentB->insert(new Event(**i));
+ continue;
+ }
+
+ selectedC = false;
+ selectedD = false;
+
+ if ((*i)->has(BaseProperties::RECORDED_CHANNEL)) {
+ selectedC = true;
+ if (m_channel > -1)
+ selectedC = ( m_channel ==
+ (*i)->get
+ <Int>(BaseProperties::RECORDED_CHANNEL) );
+ }
+
+ if ((*i)->has(BaseProperties::RECORDED_PORT)) {
+ selectedD = true;
+ if (m_device > -1)
+ selectedD = ( m_device ==
+ (*i)->get
+ <Int>(BaseProperties::RECORDED_PORT) );
+ }
+
+ if (selectedC & selectedD) {
+ if (m_newSegmentB->empty()) {
+ m_newSegmentB->fillWithRests((*i)->getAbsoluteTime());
+ }
+ m_newSegmentB->insert(new Event(**i));
+ } else {
+ if (m_newSegmentA->empty()) {
+ m_newSegmentA->fillWithRests((*i)->getAbsoluteTime());
+ }
+ m_newSegmentA->insert(new Event(**i));
+ }
+ }
+
+ m_newSegmentA->normalizeRests(m_segment->getStartTime(),
+ m_segment->getEndMarkerTime());
+ m_newSegmentB->normalizeRests(m_segment->getStartTime(),
+ m_segment->getEndMarkerTime());
+
+ std::string label = m_segment->getLabel();
+ m_newSegmentA->setLabel(qstrtostr(i18n("%1 (split)").arg
+ (strtoqstr(label))));
+ m_newSegmentB->setLabel(qstrtostr(i18n("%1 (split)").arg
+ (strtoqstr(label))));
+ m_newSegmentA->setColourIndex(m_segment->getColourIndex());
+ m_newSegmentB->setColourIndex(m_segment->getColourIndex());
+ }
+
+ m_composition->addSegment(m_newSegmentA);
+ m_composition->addSegment(m_newSegmentB);
+ m_composition->detachSegment(m_segment);
+ m_executed = true;
+}
+
+void
+SegmentSplitByRecordingSrcCommand::unexecute()
+{
+ m_composition->addSegment(m_segment);
+ m_composition->detachSegment(m_newSegmentA);
+ m_composition->detachSegment(m_newSegmentB);
+ m_executed = false;
+}
+
+SegmentSplitByRecordingSrcCommand::~SegmentSplitByRecordingSrcCommand()
+{
+ if (m_executed) {
+ delete m_segment;
+ } else {
+ delete m_newSegmentA;
+ delete m_newSegmentB;
+ }
+}
+
+}
diff --git a/src/commands/segment/SegmentSplitByRecordingSrcCommand.h b/src/commands/segment/SegmentSplitByRecordingSrcCommand.h
new file mode 100644
index 0000000..3b087ab
--- /dev/null
+++ b/src/commands/segment/SegmentSplitByRecordingSrcCommand.h
@@ -0,0 +1,70 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTSPLITBYRECORDINGSRCCOMMAND_H_
+#define _RG_SEGMENTSPLITBYRECORDINGSRCCOMMAND_H_
+
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+#include "gui/application/RosegardenDCOP.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+class Composition;
+
+
+class SegmentSplitByRecordingSrcCommand : public KNamedCommand
+{
+public:
+ SegmentSplitByRecordingSrcCommand(Segment *segment,
+ int channel, int device);
+ virtual ~SegmentSplitByRecordingSrcCommand();
+
+ static QString getGlobalName()
+ { return i18n("Split by &Recording Source..."); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Composition *m_composition;
+ Segment *m_segment;
+ Segment *m_newSegmentA;
+ Segment *m_newSegmentB;
+ int m_channel;
+ int m_device;
+ bool m_executed;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentSplitCommand.cpp b/src/commands/segment/SegmentSplitCommand.cpp
new file mode 100644
index 0000000..450ad3e
--- /dev/null
+++ b/src/commands/segment/SegmentSplitCommand.cpp
@@ -0,0 +1,185 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentSplitCommand.h"
+
+#include <klocale.h>
+#include "misc/Strings.h"
+#include "base/Event.h"
+#include "base/Composition.h"
+#include "base/NotationTypes.h"
+#include "base/Segment.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+SegmentSplitCommand::SegmentSplitCommand(Segment *segment,
+ timeT splitTime) :
+ KNamedCommand(i18n("Split Segment")),
+ m_segment(segment),
+ m_newSegmentA(0),
+ m_newSegmentB(0),
+ m_splitTime(splitTime),
+ m_previousEndMarkerTime(0),
+ m_detached(true)
+{}
+
+SegmentSplitCommand::~SegmentSplitCommand()
+{
+ if (m_detached) {
+ delete m_newSegmentA;
+ delete m_newSegmentB;
+ }
+ delete m_previousEndMarkerTime;
+}
+
+void
+SegmentSplitCommand::execute()
+{
+ if (m_newSegmentA) {
+
+ m_segment->getComposition()->addSegment(m_newSegmentA);
+ m_segment->getComposition()->addSegment(m_newSegmentB);
+
+ m_segment->getComposition()->detachSegment(m_segment);
+
+ m_detached = false; // i.e. new segments are not detached
+ return;
+ }
+
+ m_newSegmentA = new Segment(*m_segment);
+ m_newSegmentB = new Segment();
+
+ m_newSegmentB->setTrack(m_segment->getTrack());
+ m_newSegmentB->setStartTime(m_splitTime);
+
+ m_segment->getComposition()->addSegment(m_newSegmentA);
+ m_segment->getComposition()->addSegment(m_newSegmentB);
+
+ Event *clefEvent = 0;
+ Event *keyEvent = 0;
+
+ // Copy the last occurrence of clef and key
+ // from the left hand side of the split (nb. timesig events
+ // don't appear in segments, only in composition)
+ //
+ Segment::iterator it = m_segment->findTime(m_splitTime);
+
+ while (it != m_segment->begin()) {
+
+ --it;
+
+ if (!clefEvent && (*it)->isa(Clef::EventType)) {
+ clefEvent = new Event(**it, m_splitTime);
+ }
+
+ if (!keyEvent && (*it)->isa(Key::EventType)) {
+ keyEvent = new Event(**it, m_splitTime);
+ }
+
+ if (clefEvent && keyEvent)
+ break;
+ }
+
+ // Insert relevant meta info if we've found some
+ //
+ if (clefEvent)
+ m_newSegmentB->insert(clefEvent);
+
+ if (keyEvent)
+ m_newSegmentB->insert(keyEvent);
+
+ // Copy through the Events
+ //
+ it = m_segment->findTime(m_splitTime);
+
+ if (it != m_segment->end() && (*it)->getAbsoluteTime() > m_splitTime) {
+ m_newSegmentB->fillWithRests((*it)->getAbsoluteTime());
+ }
+
+ while (it != m_segment->end()) {
+ m_newSegmentB->insert(new Event(**it));
+ ++it;
+ }
+ m_newSegmentB->setEndTime(m_segment->getEndTime());
+ m_newSegmentB->setEndMarkerTime(m_segment->getEndMarkerTime());
+
+ // Set labels
+ //
+ m_segmentLabel = m_segment->getLabel();
+ QString newLabel = strtoqstr(m_segmentLabel);
+ if (!newLabel.endsWith(i18n(" (split)"))) {
+ newLabel = i18n("%1 (split)").arg(newLabel);
+ }
+ m_newSegmentA->setLabel(newLabel);
+ m_newSegmentB->setLabel(newLabel);
+
+ m_newSegmentB->setColourIndex(m_segment->getColourIndex());
+ m_newSegmentB->setTranspose(m_segment->getTranspose());
+ m_newSegmentB->setDelay(m_segment->getDelay());
+
+ // Resize left hand Segment
+ //
+ std::vector<Event *> toErase, toInsert;
+ for (Segment::iterator i = m_newSegmentA->findTime(m_splitTime);
+ i != m_newSegmentA->end(); ++i) {
+ if ((*i)->getAbsoluteTime() >= m_splitTime) break;
+ if ((*i)->getAbsoluteTime() + (*i)->getDuration() > m_splitTime) {
+ Event *e = new Event(**i, (*i)->getAbsoluteTime(),
+ m_splitTime - (*i)->getAbsoluteTime());
+ toErase.push_back(*i);
+ toInsert.push_back(e);
+ }
+ }
+
+ for (int i = 0; i < toErase.size(); ++i) {
+ m_newSegmentA->eraseSingle(toErase[i]);
+ delete toErase[i];
+ }
+ for (int i = 0; i < toInsert.size(); ++i) {
+ m_newSegmentA->insert(toInsert[i]);
+ }
+
+ m_newSegmentA->setEndTime(m_splitTime);
+
+ m_segment->getComposition()->detachSegment(m_segment);
+
+ m_detached = false; // i.e. new segments are not detached
+}
+
+void
+SegmentSplitCommand::unexecute()
+{
+ m_newSegmentA->getComposition()->addSegment(m_segment);
+
+ m_segment->getComposition()->detachSegment(m_newSegmentA);
+ m_segment->getComposition()->detachSegment(m_newSegmentB);
+
+ m_detached = true; // i.e. new segments are not detached
+}
+
+}
diff --git a/src/commands/segment/SegmentSplitCommand.h b/src/commands/segment/SegmentSplitCommand.h
new file mode 100644
index 0000000..8b59b76
--- /dev/null
+++ b/src/commands/segment/SegmentSplitCommand.h
@@ -0,0 +1,65 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTSPLITCOMMAND_H_
+#define _RG_SEGMENTSPLITCOMMAND_H_
+
+#include <string>
+#include <kcommand.h>
+#include "base/Event.h"
+
+
+
+
+namespace Rosegarden
+{
+
+class Segment;
+
+
+class SegmentSplitCommand : public KNamedCommand
+{
+public:
+ SegmentSplitCommand(Segment *segment,
+ timeT splitTime);
+ virtual ~SegmentSplitCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Segment *m_segment;
+ Segment *m_newSegmentA;
+ Segment *m_newSegmentB;
+ timeT m_splitTime;
+ timeT *m_previousEndMarkerTime;
+ bool m_detached;
+ std::string m_segmentLabel;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentSyncClefCommand.cpp b/src/commands/segment/SegmentSyncClefCommand.cpp
new file mode 100644
index 0000000..5e3560b
--- /dev/null
+++ b/src/commands/segment/SegmentSyncClefCommand.cpp
@@ -0,0 +1,67 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentSyncClefCommand.h"
+
+#include "base/Selection.h"
+#include "commands/notation/ClefInsertionCommand.h"
+
+namespace Rosegarden
+{
+SegmentSyncClefCommand::SegmentSyncClefCommand(Segment &segment, const Clef& clef) :
+ KMacroCommand(i18n("Sync segment clef"))
+{
+ processSegment(segment, clef);
+}
+
+void
+SegmentSyncClefCommand::processSegment(Segment &segment, const Clef& clef)
+{
+ KMacroCommand * macroCommand = this;
+
+ // TODO delete it somewhere.
+ EventSelection * wholeSegment = new EventSelection(segment, segment.getStartTime(), segment.getEndMarkerTime());
+
+ EventSelection::eventcontainer::iterator i;
+
+ for (i = wholeSegment->getSegmentEvents().begin();
+ i != wholeSegment->getSegmentEvents().end(); ++i) {
+ if ((*i)->isa(Rosegarden::Clef::EventType)) {
+ macroCommand->addCommand
+ (new ClefInsertionCommand
+ (segment,
+ (*i)->getAbsoluteTime(),
+ clef, false, false));
+ }
+ }
+
+}
+
+
+SegmentSyncClefCommand::~SegmentSyncClefCommand()
+{}
+
+
+}
diff --git a/src/commands/segment/SegmentSyncClefCommand.h b/src/commands/segment/SegmentSyncClefCommand.h
new file mode 100644
index 0000000..01b97fd
--- /dev/null
+++ b/src/commands/segment/SegmentSyncClefCommand.h
@@ -0,0 +1,55 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTSYNCCLEFCOMMAND_H_
+#define _RG_SEGMENTSYNCCLEFCOMMAND_H_
+
+#include <kcommand.h>
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "document/MultiViewCommandHistory.h"
+#include <klocale.h>
+
+namespace Rosegarden
+{
+
+class Segment;
+class SegmentSelection;
+
+
+class SegmentSyncClefCommand : public KMacroCommand
+{
+public:
+ SegmentSyncClefCommand(Segment &segment, const Clef& clef);
+
+ virtual ~SegmentSyncClefCommand();
+
+protected:
+ void processSegment(Segment &segment, const Clef& clef);
+};
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentSyncCommand.cpp b/src/commands/segment/SegmentSyncCommand.cpp
new file mode 100644
index 0000000..d5e9734
--- /dev/null
+++ b/src/commands/segment/SegmentSyncCommand.cpp
@@ -0,0 +1,103 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2007
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentSyncCommand.h"
+
+#include "base/Selection.h"
+#include "commands/notation/KeyInsertionCommand.h"
+#include "commands/edit/TransposeCommand.h"
+#include "commands/segment/SegmentChangeTransposeCommand.h"
+#include "commands/segment/SegmentTransposeCommand.h"
+#include "commands/segment/SegmentSyncClefCommand.h"
+
+namespace Rosegarden
+{
+SegmentSyncCommand::SegmentSyncCommand(Segment &segment, int newTranspose, int lowRange, int highRange, const Clef& clef) :
+ KMacroCommand(i18n("Sync segment parameters"))
+{
+ processSegment(segment, newTranspose, lowRange, highRange, clef);
+}
+
+SegmentSyncCommand::SegmentSyncCommand(SegmentSelection selection, int newTranspose, int lowRange, int highRange, const Clef& clef) :
+ KMacroCommand(i18n("Sync segment parameters"))
+{
+ for (SegmentSelection::iterator i = selection.begin();
+ i != selection.end(); ++i)
+ {
+ Segment &segment = **i;
+ processSegment(segment, newTranspose, lowRange, highRange, clef);
+ }
+}
+
+SegmentSyncCommand::SegmentSyncCommand(std::vector<Segment *> segments, int newTranspose, int lowRange, int highRange, const Clef& clef) :
+ KMacroCommand(i18n("Sync segment parameters"))
+{
+ for (int i = 0; i < segments.size(); i++) {
+ processSegment(*(segments[i]), newTranspose, lowRange, highRange, clef);
+ }
+}
+
+SegmentSyncCommand::SegmentSyncCommand(Composition::segmentcontainer& segments, TrackId selectedTrack, int newTranspose, int lowRange, int highRange, const Clef& clef) :
+ KMacroCommand(i18n("Sync segment parameters"))
+{
+ for (Composition::segmentcontainer::const_iterator si = segments.begin();
+ si != segments.end(); ++si) {
+ if ((*si)->getTrack() == selectedTrack) {
+ processSegment(**si, newTranspose, lowRange, highRange, clef);
+ }
+ }
+}
+
+void
+SegmentSyncCommand::processSegment(Segment &segment, int newTranspose, int lowRange, int highRange, const Clef& clef)
+{
+ KMacroCommand * macroCommand = this;
+
+ // if the new desired setting for 'transpose' is higher, we need to
+ // transpose the notes upwards to compensate:
+ int semitones = segment.getTranspose() - newTranspose;
+
+ // Say the old transpose was -2 and the new is 0, this corresponds to
+ // Bb and C. The height of the old transpose is 1 below the height of the new.
+ int oldHeight = Pitch(segment.getTranspose()).getHeightOnStaff(Clef::Treble, Key("C major"));
+ int newHeight = Pitch(newTranspose).getHeightOnStaff(Clef::Treble, Key("C major"));
+ int steps = oldHeight - newHeight;
+
+ SegmentTransposeCommand* command = new SegmentTransposeCommand(segment, true, steps, semitones, true);
+ macroCommand->addCommand(command);
+
+ // TODO do this in an undoable fashion:
+ segment.setLowestPlayable(lowRange);
+ segment.setHighestPlayable(highRange);
+
+ macroCommand->addCommand(new SegmentSyncClefCommand(segment, clef));
+}
+
+
+SegmentSyncCommand::~SegmentSyncCommand()
+{}
+
+
+}
diff --git a/src/commands/segment/SegmentSyncCommand.h b/src/commands/segment/SegmentSyncCommand.h
new file mode 100644
index 0000000..0d8e189
--- /dev/null
+++ b/src/commands/segment/SegmentSyncCommand.h
@@ -0,0 +1,66 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2007
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTSYNCCOMMAND_H_
+#define _RG_SEGMENTSYNCCOMMAND_H_
+
+#include <kcommand.h>
+#include "base/Composition.h"
+#include "base/Event.h"
+#include "base/NotationTypes.h"
+#include "document/MultiViewCommandHistory.h"
+#include <klocale.h>
+
+namespace Rosegarden
+{
+
+class Segment;
+class SegmentSelection;
+
+
+class SegmentSyncCommand : public KMacroCommand
+{
+public:
+ SegmentSyncCommand(Segment &segment,
+ int newTranspose, int lowRange, int highRange, const Clef& clef);
+
+ SegmentSyncCommand(SegmentSelection selection,
+ int newTranspose, int lowRange, int highRange, const Clef& clef);
+
+ SegmentSyncCommand(std::vector<Segment *> segments,
+ int newTranspose, int lowRange, int highRange, const Clef& clef);
+
+ SegmentSyncCommand(Composition::segmentcontainer& segments, TrackId track,
+ int newTranspose, int lowRange, int highRange, const Clef& clef);
+
+ virtual ~SegmentSyncCommand();
+
+protected:
+ void processSegment(Segment &segment, int newTranspose, int lowRange, int highRange, const Clef& clef);
+};
+
+}
+
+#endif
diff --git a/src/commands/segment/SegmentTransposeCommand.cpp b/src/commands/segment/SegmentTransposeCommand.cpp
new file mode 100644
index 0000000..d3e4221
--- /dev/null
+++ b/src/commands/segment/SegmentTransposeCommand.cpp
@@ -0,0 +1,123 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SegmentTransposeCommand.h"
+
+#include "base/Selection.h"
+#include "commands/notation/KeyInsertionCommand.h"
+#include "commands/edit/TransposeCommand.h"
+#include "commands/segment/SegmentChangeTransposeCommand.h"
+
+namespace Rosegarden
+{
+SegmentTransposeCommand::SegmentTransposeCommand(Segment &segment, bool changeKey, int steps, int semitones, bool transposeSegmentBack) :
+ KMacroCommand(i18n("Change segment transposition"))
+{
+ processSegment(segment, changeKey, steps, semitones, transposeSegmentBack);
+}
+
+SegmentTransposeCommand::SegmentTransposeCommand(SegmentSelection selection, bool changeKey, int steps, int semitones, bool transposeSegmentBack) :
+ KMacroCommand(i18n("Change segment transposition"))
+{
+ //SegmentSelection selection(m_view->getSelection());
+ for (SegmentSelection::iterator i = selection.begin();
+ i != selection.end(); ++i)
+ {
+ Segment &segment = **i;
+ processSegment(segment, changeKey, steps, semitones, transposeSegmentBack);
+ }
+}
+
+void
+SegmentTransposeCommand::processSegment(Segment &segment, bool changeKey, int steps, int semitones, bool transposeSegmentBack)
+{
+ KMacroCommand * macroCommand = this;
+
+ // TODO delete it somewhere.
+ EventSelection * wholeSegment = new EventSelection(segment, segment.getStartTime(), segment.getEndMarkerTime());
+ macroCommand->addCommand(new TransposeCommand
+ (semitones, steps, *wholeSegment));
+
+ // Key insertion can do transposition, but a C4 to D becomes a D4, while
+ // a C4 to G becomes a G3. Because we let the user specify an explicit number
+ // of octaves to move the notes up/down, we add the keys without transposing
+ // and handle the transposition seperately:
+ if (changeKey)
+ {
+ Rosegarden::Key initialKey = segment.getKeyAtTime(segment.getStartTime());
+ Rosegarden::Key newInitialKey = initialKey.transpose(semitones, steps);
+
+ EventSelection::eventcontainer::iterator i;
+ //std::list<KeyInsertionCommand*> commands;
+
+ for (i = wholeSegment->getSegmentEvents().begin();
+ i != wholeSegment->getSegmentEvents().end(); ++i) {
+ // transpose key
+ if ((*i)->isa(Rosegarden::Key::EventType)) {
+ Rosegarden::Key trKey = (Rosegarden::Key (**i)).transpose(semitones, steps);
+ //commands.push_front
+ macroCommand->addCommand
+ (new KeyInsertionCommand
+ (segment,
+ (*i)->getAbsoluteTime(),
+ trKey,
+ false,
+ false,
+ false,
+ true));
+ }
+ }
+ std::list<KeyInsertionCommand*>::iterator ci;
+ //for (ci=commands.begin(); ci!=commands.end(); ci++)
+ //{
+ // commandHistory->addCommand(*ci);
+ //}
+
+ KeyInsertionCommand *firstKeyCommand = new KeyInsertionCommand
+ (segment,
+ segment.getStartTime(),
+ newInitialKey,
+ false,
+ false,
+ false,
+ true);
+ //commandHistory->addCommand(firstKeyCommand);
+ macroCommand->addCommand(firstKeyCommand);
+ }
+
+ if (transposeSegmentBack)
+ {
+ // Transpose segment in opposite direction
+ int newTranspose = segment.getTranspose() - semitones;
+ macroCommand->addCommand(new SegmentChangeTransposeCommand(newTranspose, &segment));
+ }
+}
+
+
+SegmentTransposeCommand::~SegmentTransposeCommand()
+{}
+
+
+}
diff --git a/src/commands/segment/SegmentTransposeCommand.h b/src/commands/segment/SegmentTransposeCommand.h
new file mode 100644
index 0000000..74af8d4
--- /dev/null
+++ b/src/commands/segment/SegmentTransposeCommand.h
@@ -0,0 +1,64 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SEGMENTTRANSPOSECOMMAND_H_
+#define _RG_SEGMENTTRANSPOSECOMMAND_H_
+
+#include <kcommand.h>
+#include "base/Event.h"
+#include "document/MultiViewCommandHistory.h"
+#include <klocale.h>
+
+namespace Rosegarden
+{
+
+class Segment;
+class SegmentSelection;
+
+
+class SegmentTransposeCommand : public KMacroCommand
+{
+public:
+ SegmentTransposeCommand(Segment &segment,
+ bool changeKey, int steps, int semitones, bool transposeSegmentBack);
+
+ SegmentTransposeCommand(SegmentSelection selection,
+ bool changeKey, int steps, int semitones, bool transposeSegmentBack);
+
+ virtual ~SegmentTransposeCommand();
+
+ static QString getGlobalName(int semitones = 0, int step = 0) {
+ switch (semitones) {
+ default: return i18n("Transpose by &Interval...");
+ }
+ }
+
+protected:
+ void processSegment(Segment &segment, bool changeKey, int steps, int semitones, bool transposeSegmentBack);
+};
+
+}
+
+#endif
diff --git a/src/commands/segment/SetTriggerSegmentBasePitchCommand.cpp b/src/commands/segment/SetTriggerSegmentBasePitchCommand.cpp
new file mode 100644
index 0000000..9bb1bc3
--- /dev/null
+++ b/src/commands/segment/SetTriggerSegmentBasePitchCommand.cpp
@@ -0,0 +1,74 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SetTriggerSegmentBasePitchCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/TriggerSegment.h"
+
+
+namespace Rosegarden
+{
+
+SetTriggerSegmentBasePitchCommand::SetTriggerSegmentBasePitchCommand(Composition *composition,
+ TriggerSegmentId id,
+ int newPitch) :
+ KNamedCommand(i18n("Set Base Pitch")),
+ m_composition(composition),
+ m_id(id),
+ m_newPitch(newPitch),
+ m_oldPitch( -1)
+{
+ // nothing
+}
+
+SetTriggerSegmentBasePitchCommand::~SetTriggerSegmentBasePitchCommand()
+{
+ // nothing
+}
+
+void
+SetTriggerSegmentBasePitchCommand::execute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ if (m_oldPitch == -1) {
+ m_oldPitch = rec->getBasePitch();
+ }
+ rec->setBasePitch(m_newPitch);
+}
+
+void
+SetTriggerSegmentBasePitchCommand::unexecute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ rec->setBasePitch(m_oldPitch);
+}
+
+}
diff --git a/src/commands/segment/SetTriggerSegmentBasePitchCommand.h b/src/commands/segment/SetTriggerSegmentBasePitchCommand.h
new file mode 100644
index 0000000..0d79c7c
--- /dev/null
+++ b/src/commands/segment/SetTriggerSegmentBasePitchCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SETTRIGGERSEGMENTBASEPITCHCOMMAND_H_
+#define _RG_SETTRIGGERSEGMENTBASEPITCHCOMMAND_H_
+
+#include "base/TriggerSegment.h"
+#include <kcommand.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class SetTriggerSegmentBasePitchCommand : public KNamedCommand
+{
+public:
+ SetTriggerSegmentBasePitchCommand(Composition *composition,
+ TriggerSegmentId id,
+ int newPitch);
+ virtual ~SetTriggerSegmentBasePitchCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ TriggerSegmentId m_id;
+ int m_newPitch;
+ int m_oldPitch;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SetTriggerSegmentBaseVelocityCommand.cpp b/src/commands/segment/SetTriggerSegmentBaseVelocityCommand.cpp
new file mode 100644
index 0000000..f1bba10
--- /dev/null
+++ b/src/commands/segment/SetTriggerSegmentBaseVelocityCommand.cpp
@@ -0,0 +1,74 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SetTriggerSegmentBaseVelocityCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/TriggerSegment.h"
+
+
+namespace Rosegarden
+{
+
+SetTriggerSegmentBaseVelocityCommand::SetTriggerSegmentBaseVelocityCommand(Composition *composition,
+ TriggerSegmentId id,
+ int newVelocity) :
+ KNamedCommand(i18n("Set Base Velocity")),
+ m_composition(composition),
+ m_id(id),
+ m_newVelocity(newVelocity),
+ m_oldVelocity( -1)
+{
+ // nothing
+}
+
+SetTriggerSegmentBaseVelocityCommand::~SetTriggerSegmentBaseVelocityCommand()
+{
+ // nothing
+}
+
+void
+SetTriggerSegmentBaseVelocityCommand::execute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ if (m_oldVelocity == -1) {
+ m_oldVelocity = rec->getBaseVelocity();
+ }
+ rec->setBaseVelocity(m_newVelocity);
+}
+
+void
+SetTriggerSegmentBaseVelocityCommand::unexecute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ rec->setBaseVelocity(m_oldVelocity);
+}
+
+}
diff --git a/src/commands/segment/SetTriggerSegmentBaseVelocityCommand.h b/src/commands/segment/SetTriggerSegmentBaseVelocityCommand.h
new file mode 100644
index 0000000..26875ec
--- /dev/null
+++ b/src/commands/segment/SetTriggerSegmentBaseVelocityCommand.h
@@ -0,0 +1,63 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SETTRIGGERSEGMENTBASEVELOCITYCOMMAND_H_
+#define _RG_SETTRIGGERSEGMENTBASEVELOCITYCOMMAND_H_
+
+#include "base/TriggerSegment.h"
+#include <kcommand.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class SetTriggerSegmentBaseVelocityCommand : public KNamedCommand
+{
+public:
+ SetTriggerSegmentBaseVelocityCommand(Composition *composition,
+ TriggerSegmentId id,
+ int newVelocity);
+ virtual ~SetTriggerSegmentBaseVelocityCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ TriggerSegmentId m_id;
+ int m_newVelocity;
+ int m_oldVelocity;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SetTriggerSegmentDefaultRetuneCommand.cpp b/src/commands/segment/SetTriggerSegmentDefaultRetuneCommand.cpp
new file mode 100644
index 0000000..35ae878
--- /dev/null
+++ b/src/commands/segment/SetTriggerSegmentDefaultRetuneCommand.cpp
@@ -0,0 +1,75 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SetTriggerSegmentDefaultRetuneCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/TriggerSegment.h"
+
+
+namespace Rosegarden
+{
+
+SetTriggerSegmentDefaultRetuneCommand::SetTriggerSegmentDefaultRetuneCommand(Composition *composition,
+ TriggerSegmentId id,
+ bool newDefaultRetune) :
+ KNamedCommand(i18n("Set Default Retune")),
+ m_composition(composition),
+ m_id(id),
+ m_newDefaultRetune(newDefaultRetune),
+ m_oldDefaultRetune(false),
+ m_haveOldDefaultRetune(false)
+{
+ // nothing
+}
+
+SetTriggerSegmentDefaultRetuneCommand::~SetTriggerSegmentDefaultRetuneCommand()
+{
+ // nothing
+}
+
+void
+SetTriggerSegmentDefaultRetuneCommand::execute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ if (!m_haveOldDefaultRetune) {
+ m_oldDefaultRetune = rec->getDefaultRetune();
+ }
+ rec->setDefaultRetune(m_newDefaultRetune);
+}
+
+void
+SetTriggerSegmentDefaultRetuneCommand::unexecute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ rec->setDefaultRetune(m_oldDefaultRetune);
+}
+
+}
diff --git a/src/commands/segment/SetTriggerSegmentDefaultRetuneCommand.h b/src/commands/segment/SetTriggerSegmentDefaultRetuneCommand.h
new file mode 100644
index 0000000..4563594
--- /dev/null
+++ b/src/commands/segment/SetTriggerSegmentDefaultRetuneCommand.h
@@ -0,0 +1,64 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SETTRIGGERSEGMENTDEFAULTRETUNECOMMAND_H_
+#define _RG_SETTRIGGERSEGMENTDEFAULTRETUNECOMMAND_H_
+
+#include "base/TriggerSegment.h"
+#include <kcommand.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class SetTriggerSegmentDefaultRetuneCommand : public KNamedCommand
+{
+public:
+ SetTriggerSegmentDefaultRetuneCommand(Composition *composition,
+ TriggerSegmentId id,
+ bool newDefaultRetune);
+ virtual ~SetTriggerSegmentDefaultRetuneCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ TriggerSegmentId m_id;
+ bool m_newDefaultRetune;
+ bool m_oldDefaultRetune;
+ bool m_haveOldDefaultRetune;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/segment/SetTriggerSegmentDefaultTimeAdjustCommand.cpp b/src/commands/segment/SetTriggerSegmentDefaultTimeAdjustCommand.cpp
new file mode 100644
index 0000000..deb49a1
--- /dev/null
+++ b/src/commands/segment/SetTriggerSegmentDefaultTimeAdjustCommand.cpp
@@ -0,0 +1,74 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "SetTriggerSegmentDefaultTimeAdjustCommand.h"
+
+#include <klocale.h>
+#include "base/Composition.h"
+#include "base/TriggerSegment.h"
+
+
+namespace Rosegarden
+{
+
+SetTriggerSegmentDefaultTimeAdjustCommand::SetTriggerSegmentDefaultTimeAdjustCommand(Composition *composition,
+ TriggerSegmentId id,
+ std::string newDefaultTimeAdjust) :
+ KNamedCommand(i18n("Set Default Time Adjust")),
+ m_composition(composition),
+ m_id(id),
+ m_newDefaultTimeAdjust(newDefaultTimeAdjust),
+ m_oldDefaultTimeAdjust("")
+{
+ // nothing
+}
+
+SetTriggerSegmentDefaultTimeAdjustCommand::~SetTriggerSegmentDefaultTimeAdjustCommand()
+{
+ // nothing
+}
+
+void
+SetTriggerSegmentDefaultTimeAdjustCommand::execute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ if (m_oldDefaultTimeAdjust == "") {
+ m_oldDefaultTimeAdjust = rec->getDefaultTimeAdjust();
+ }
+ rec->setDefaultTimeAdjust(m_newDefaultTimeAdjust);
+}
+
+void
+SetTriggerSegmentDefaultTimeAdjustCommand::unexecute()
+{
+ TriggerSegmentRec *rec = m_composition->getTriggerSegmentRec(m_id);
+ if (!rec)
+ return ;
+ rec->setDefaultTimeAdjust(m_oldDefaultTimeAdjust);
+}
+
+}
diff --git a/src/commands/segment/SetTriggerSegmentDefaultTimeAdjustCommand.h b/src/commands/segment/SetTriggerSegmentDefaultTimeAdjustCommand.h
new file mode 100644
index 0000000..7d31b26
--- /dev/null
+++ b/src/commands/segment/SetTriggerSegmentDefaultTimeAdjustCommand.h
@@ -0,0 +1,64 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_SETTRIGGERSEGMENTDEFAULTTIMEADJUSTCOMMAND_H_
+#define _RG_SETTRIGGERSEGMENTDEFAULTTIMEADJUSTCOMMAND_H_
+
+#include "base/TriggerSegment.h"
+#include <string>
+#include <kcommand.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Composition;
+
+
+class SetTriggerSegmentDefaultTimeAdjustCommand : public KNamedCommand
+{
+public:
+ SetTriggerSegmentDefaultTimeAdjustCommand(Composition *composition,
+ TriggerSegmentId id,
+ std::string newDefaultTimeAdjust);
+ virtual ~SetTriggerSegmentDefaultTimeAdjustCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ TriggerSegmentId m_id;
+ std::string m_newDefaultTimeAdjust;
+ std::string m_oldDefaultTimeAdjust;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/studio/AddControlParameterCommand.cpp b/src/commands/studio/AddControlParameterCommand.cpp
new file mode 100644
index 0000000..35ac62a
--- /dev/null
+++ b/src/commands/studio/AddControlParameterCommand.cpp
@@ -0,0 +1,75 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "AddControlParameterCommand.h"
+
+#include "base/ControlParameter.h"
+#include "base/Device.h"
+#include "base/MidiDevice.h"
+#include "base/Studio.h"
+#include <qstring.h>
+#include <iostream>
+
+
+namespace Rosegarden
+{
+
+AddControlParameterCommand::~AddControlParameterCommand()
+{}
+
+void
+AddControlParameterCommand::execute()
+{
+ MidiDevice *md = dynamic_cast<MidiDevice *>
+ (m_studio->getDevice(m_device));
+ if (!md) {
+ std::cerr << "WARNING: AddControlParameterCommand::execute: device "
+ << m_device << " is not a MidiDevice in current studio"
+ << std::endl;
+ return ;
+ }
+
+ md->addControlParameter(m_control);
+
+ // store id of the new control
+ m_id = md->getControlParameters().size() - 1;
+}
+
+void
+AddControlParameterCommand::unexecute()
+{
+ MidiDevice *md = dynamic_cast<MidiDevice *>
+ (m_studio->getDevice(m_device));
+ if (!md) {
+ std::cerr << "WARNING: AddControlParameterCommand::unexecute: device "
+ << m_device << " is not a MidiDevice in current studio"
+ << std::endl;
+ return ;
+ }
+
+ md->removeControlParameter(m_id);
+}
+
+}
diff --git a/src/commands/studio/AddControlParameterCommand.h b/src/commands/studio/AddControlParameterCommand.h
new file mode 100644
index 0000000..fa614ac
--- /dev/null
+++ b/src/commands/studio/AddControlParameterCommand.h
@@ -0,0 +1,75 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ADDCONTROLPARAMETERCOMMAND_H_
+#define _RG_ADDCONTROLPARAMETERCOMMAND_H_
+
+#include "base/ControlParameter.h"
+#include "base/Device.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Studio;
+
+
+class AddControlParameterCommand : public KNamedCommand
+{
+public:
+ AddControlParameterCommand(Studio *studio,
+ DeviceId device,
+ ControlParameter control):
+ KNamedCommand(getGlobalName()),
+ m_studio(studio),
+ m_device(device),
+ m_control(control),
+ m_id(0) { }
+
+ ~AddControlParameterCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName() { return i18n("&Add Control Parameter"); }
+
+protected:
+ Studio *m_studio;
+ DeviceId m_device;
+ ControlParameter m_control;
+ int m_id;
+
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/studio/CreateOrDeleteDeviceCommand.cpp b/src/commands/studio/CreateOrDeleteDeviceCommand.cpp
new file mode 100644
index 0000000..48dc6c1
--- /dev/null
+++ b/src/commands/studio/CreateOrDeleteDeviceCommand.cpp
@@ -0,0 +1,161 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "CreateOrDeleteDeviceCommand.h"
+
+#include "misc/Debug.h"
+#include "misc/Strings.h"
+#include "base/Device.h"
+#include "base/MidiDevice.h"
+#include "base/Studio.h"
+#include <qcstring.h>
+#include <qdatastream.h>
+#include <qstring.h>
+#include "gui/application/RosegardenApplication.h"
+
+
+namespace Rosegarden
+{
+
+CreateOrDeleteDeviceCommand::CreateOrDeleteDeviceCommand(Studio *studio,
+ DeviceId id) :
+ KNamedCommand(getGlobalName(true)),
+ m_studio(studio),
+ m_deviceId(id),
+ m_deviceCreated(true)
+{
+ Device *device = m_studio->getDevice(m_deviceId);
+
+ if (device) {
+ m_name = device->getName();
+ m_type = device->getType();
+ m_direction = MidiDevice::Play;
+ MidiDevice *md =
+ dynamic_cast<MidiDevice *>(device);
+ if (md)
+ m_direction = md->getDirection();
+ m_connection = device->getConnection();
+ } else {
+ RG_DEBUG << "CreateOrDeleteDeviceCommand: No such device as "
+ << m_deviceId << endl;
+ }
+}
+
+void
+CreateOrDeleteDeviceCommand::execute()
+{
+ if (!m_deviceCreated) {
+
+ // Create
+
+ // don't want to do this again on undo even if it fails -- only on redo
+ m_deviceCreated = true;
+
+
+ QByteArray data;
+ QByteArray replyData;
+ QCString replyType;
+ QDataStream arg(data, IO_WriteOnly);
+
+ arg << (int)m_type;
+ arg << (unsigned int)m_direction;
+
+ if (!rgapp->sequencerCall("addDevice(int, unsigned int)",
+ replyType, replyData, data)) {
+ SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
+ << "failure in sequencer addDevice" << endl;
+ return ;
+ }
+
+ QDataStream reply(replyData, IO_ReadOnly);
+ reply >> m_deviceId;
+
+ if (m_deviceId == Device::NO_DEVICE) {
+ SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
+ << "sequencer addDevice failed" << endl;
+ return ;
+ }
+
+ SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
+ << " added device " << m_deviceId << endl;
+
+ arg.device()->reset();
+ arg << (unsigned int)m_deviceId;
+ arg << strtoqstr(m_connection);
+
+ if (!rgapp->sequencerCall("setConnection(unsigned int, QString)",
+ replyType, replyData, data)) {
+ SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
+ << "failure in sequencer setConnection" << endl;
+ return ;
+ }
+
+ SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
+ << " reconnected device " << m_deviceId
+ << " to " << m_connection << endl;
+
+ // Add the device to the Studio now, so that we can name it --
+ // otherwise the name will be lost
+ m_studio->addDevice(m_name, m_deviceId, m_type);
+ Device *device = m_studio->getDevice(m_deviceId);
+ if (device) {
+ MidiDevice *md = dynamic_cast<MidiDevice *>
+ (device);
+ if (md)
+ md->setDirection(m_direction);
+ }
+
+ } else {
+
+ // Delete
+
+ QByteArray data;
+ QByteArray replyData;
+ QCString replyType;
+ QDataStream arg(data, IO_WriteOnly);
+
+ if (m_deviceId == Device::NO_DEVICE)
+ return ;
+
+ arg << (int)m_deviceId;
+
+ if (!rgapp->sequencerCall("removeDevice(unsigned int)",
+ replyType, replyData, data)) {
+ SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
+ << "failure in sequencer addDevice" << endl;
+ return ;
+ }
+
+ SEQMAN_DEBUG << "CreateDeviceCommand::unexecute - "
+ << " removed device " << m_deviceId << endl;
+
+ m_studio->removeDevice(m_deviceId);
+
+ m_deviceId = Device::NO_DEVICE;
+ m_deviceCreated = false;
+ }
+}
+
+}
diff --git a/src/commands/studio/CreateOrDeleteDeviceCommand.h b/src/commands/studio/CreateOrDeleteDeviceCommand.h
new file mode 100644
index 0000000..2fe69a3
--- /dev/null
+++ b/src/commands/studio/CreateOrDeleteDeviceCommand.h
@@ -0,0 +1,88 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_CREATEORDELETEDEVICECOMMAND_H_
+#define _RG_CREATEORDELETEDEVICECOMMAND_H_
+
+#include "base/Device.h"
+#include "base/MidiDevice.h"
+#include <string>
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Studio;
+
+
+class CreateOrDeleteDeviceCommand : public KNamedCommand
+{
+public:
+ // Creation constructor
+ CreateOrDeleteDeviceCommand(Studio *studio,
+ std::string name,
+ Device::DeviceType type,
+ MidiDevice::DeviceDirection direction,
+ std::string connection) :
+ KNamedCommand(getGlobalName(false)),
+ m_studio(studio),
+ m_name(name),
+ m_type(type),
+ m_direction(direction),
+ m_connection(connection),
+ m_deviceId(Device::NO_DEVICE),
+ m_deviceCreated(false) { }
+
+ // Deletion constructor
+ CreateOrDeleteDeviceCommand(Studio *studio,
+ DeviceId deviceId);
+
+ static QString getGlobalName(bool deletion) {
+ return (deletion ? i18n("Delete Device") : i18n("Create Device"));
+ }
+
+ virtual void execute();
+ virtual void unexecute() { execute(); }
+
+protected:
+ Studio *m_studio;
+ std::string m_name;
+ Device::DeviceType m_type;
+ MidiDevice::DeviceDirection m_direction;
+ std::string m_connection;
+ DeviceId m_deviceId;
+ bool m_deviceCreated;
+};
+
+
+
+}
+
+#endif
diff --git a/src/commands/studio/ModifyControlParameterCommand.cpp b/src/commands/studio/ModifyControlParameterCommand.cpp
new file mode 100644
index 0000000..5c8c1a2
--- /dev/null
+++ b/src/commands/studio/ModifyControlParameterCommand.cpp
@@ -0,0 +1,75 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ModifyControlParameterCommand.h"
+
+#include "base/ControlParameter.h"
+#include "base/Device.h"
+#include "base/MidiDevice.h"
+#include "base/Studio.h"
+#include <qstring.h>
+#include <iostream>
+
+
+namespace Rosegarden
+{
+
+ModifyControlParameterCommand::~ModifyControlParameterCommand()
+{}
+
+void
+ModifyControlParameterCommand::execute()
+{
+ MidiDevice *md = dynamic_cast<MidiDevice *>
+ (m_studio->getDevice(m_device));
+ if (!md) {
+ std::cerr << "WARNING: ModifyControlParameterCommand::execute: device "
+ << m_device << " is not a MidiDevice in current studio"
+ << std::endl;
+ return ;
+ }
+
+ ControlParameter *param = md->getControlParameter(m_id);
+ if (param)
+ m_originalControl = *param;
+ md->modifyControlParameter(m_control, m_id);
+}
+
+void
+ModifyControlParameterCommand::unexecute()
+{
+ MidiDevice *md = dynamic_cast<MidiDevice *>
+ (m_studio->getDevice(m_device));
+ if (!md) {
+ std::cerr << "WARNING: ModifyControlParameterCommand::execute: device "
+ << m_device << " is not a MidiDevice in current studio"
+ << std::endl;
+ return ;
+ }
+
+ md->modifyControlParameter(m_originalControl, m_id);
+}
+
+}
diff --git a/src/commands/studio/ModifyControlParameterCommand.h b/src/commands/studio/ModifyControlParameterCommand.h
new file mode 100644
index 0000000..cd705d6
--- /dev/null
+++ b/src/commands/studio/ModifyControlParameterCommand.h
@@ -0,0 +1,74 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MODIFYCONTROLPARAMETERCOMMAND_H_
+#define _RG_MODIFYCONTROLPARAMETERCOMMAND_H_
+
+#include "base/ControlParameter.h"
+#include "base/Device.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Studio;
+
+
+class ModifyControlParameterCommand : public KNamedCommand
+{
+public:
+ ModifyControlParameterCommand(Studio *studio,
+ DeviceId device,
+ ControlParameter control,
+ int id):
+ KNamedCommand(getGlobalName()),
+ m_studio(studio),
+ m_device(device),
+ m_control(control),
+ m_id(id) { }
+ ~ModifyControlParameterCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName() { return i18n("&Modify Control Parameter"); }
+
+protected:
+ Studio *m_studio;
+ DeviceId m_device;
+ ControlParameter m_control;
+ int m_id;
+ ControlParameter m_originalControl;
+
+};
+
+}
+
+#endif
diff --git a/src/commands/studio/ModifyDeviceCommand.cpp b/src/commands/studio/ModifyDeviceCommand.cpp
new file mode 100644
index 0000000..d3323ac
--- /dev/null
+++ b/src/commands/studio/ModifyDeviceCommand.cpp
@@ -0,0 +1,198 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ModifyDeviceCommand.h"
+
+#include "base/Device.h"
+#include "base/MidiDevice.h"
+#include "base/Studio.h"
+#include <qstring.h>
+#include <iostream>
+
+
+namespace Rosegarden
+{
+
+ModifyDeviceCommand::ModifyDeviceCommand(
+ Studio *studio,
+ DeviceId device,
+ const std::string &name,
+ const std::string &librarianName,
+ const std::string &librarianEmail):
+ KNamedCommand(getGlobalName()),
+ m_studio(studio),
+ m_device(device),
+ m_name(name),
+ m_librarianName(librarianName),
+ m_librarianEmail(librarianEmail),
+ m_overwrite(true),
+ m_rename(true),
+ m_changeVariation(false),
+ m_changeBanks(false),
+ m_changePrograms(false),
+ m_changeControls(false),
+ m_changeKeyMappings(false),
+ m_clearBankAndProgramList(false)
+{}
+
+void ModifyDeviceCommand::setVariation(MidiDevice::VariationType variationType)
+{
+ m_variationType = variationType;
+ m_changeVariation = true;
+}
+
+void ModifyDeviceCommand::setBankList(const BankList &bankList)
+{
+ m_bankList = bankList;
+ m_changeBanks = true;
+}
+
+void ModifyDeviceCommand::setProgramList(const ProgramList &programList)
+{
+ m_programList = programList;
+ m_changePrograms = true;
+}
+
+void ModifyDeviceCommand::setControlList(const ControlList &controlList)
+{
+ m_controlList = controlList;
+ m_changeControls = true;
+}
+
+void ModifyDeviceCommand::setKeyMappingList(const KeyMappingList &keyMappingList)
+{
+ m_keyMappingList = keyMappingList;
+ m_changeKeyMappings = true;
+}
+
+void
+ModifyDeviceCommand::execute()
+{
+ Device *device = m_studio->getDevice(m_device);
+ MidiDevice *midiDevice =
+ dynamic_cast<MidiDevice *>(device);
+
+ if (device) {
+ if (!midiDevice) {
+ std::cerr << "ERROR: ModifyDeviceCommand::execute: device "
+ << m_device << " is not a MIDI device" << std::endl;
+ return ;
+ }
+ } else {
+ std::cerr
+ << "ERROR: ModifyDeviceCommand::execute: no such device as "
+ << m_device << std::endl;
+ return ;
+ }
+
+ m_oldName = midiDevice->getName();
+ m_oldBankList = midiDevice->getBanks();
+ m_oldProgramList = midiDevice->getPrograms();
+ m_oldControlList = midiDevice->getControlParameters();
+ m_oldKeyMappingList = midiDevice->getKeyMappings();
+ m_oldLibrarianName = midiDevice->getLibrarianName();
+ m_oldLibrarianEmail = midiDevice->getLibrarianEmail();
+ m_oldVariationType = midiDevice->getVariationType();
+
+ if (m_changeVariation)
+ midiDevice->setVariationType(m_variationType);
+
+ if (m_overwrite) {
+ if (m_clearBankAndProgramList) {
+ midiDevice->clearBankList();
+ midiDevice->clearProgramList();
+ } else {
+ if (m_changeBanks)
+ midiDevice->replaceBankList(m_bankList);
+ if (m_changePrograms)
+ midiDevice->replaceProgramList(m_programList);
+ }
+
+ if (m_changeKeyMappings) {
+ midiDevice->replaceKeyMappingList(m_keyMappingList);
+ }
+
+ if (m_rename)
+ midiDevice->setName(m_name);
+ midiDevice->setLibrarian(m_librarianName, m_librarianEmail);
+ } else {
+ if (m_clearBankAndProgramList) {
+ midiDevice->clearBankList();
+ midiDevice->clearProgramList();
+ } else {
+ if (m_changeBanks)
+ midiDevice->mergeBankList(m_bankList);
+ if (m_changePrograms)
+ midiDevice->mergeProgramList(m_programList);
+ }
+
+ if (m_changeKeyMappings) {
+ midiDevice->mergeKeyMappingList(m_keyMappingList);
+ }
+
+ if (m_rename) {
+ std::string mergeName = midiDevice->getName() +
+ std::string("/") + m_name;
+ midiDevice->setName(mergeName);
+ }
+ }
+
+ //!!! merge option?
+ if (m_changeControls)
+ midiDevice->replaceControlParameters(m_controlList);
+}
+
+void
+ModifyDeviceCommand::unexecute()
+{
+ Device *device = m_studio->getDevice(m_device);
+ MidiDevice *midiDevice =
+ dynamic_cast<MidiDevice *>(device);
+
+ if (device) {
+ if (!midiDevice) {
+ std::cerr << "ERROR: ModifyDeviceCommand::unexecute: device "
+ << m_device << " is not a MIDI device" << std::endl;
+ return ;
+ }
+ } else {
+ std::cerr
+ << "ERROR: ModifyDeviceCommand::unexecute: no such device as "
+ << m_device << std::endl;
+ return ;
+ }
+
+ if (m_rename)
+ midiDevice->setName(m_oldName);
+ midiDevice->replaceBankList(m_oldBankList);
+ midiDevice->replaceProgramList(m_oldProgramList);
+ midiDevice->replaceControlParameters(m_oldControlList);
+ midiDevice->replaceKeyMappingList(m_oldKeyMappingList);
+ midiDevice->setLibrarian(m_oldLibrarianName, m_oldLibrarianEmail);
+ if (m_changeVariation)
+ midiDevice->setVariationType(m_oldVariationType);
+}
+
+}
diff --git a/src/commands/studio/ModifyDeviceCommand.h b/src/commands/studio/ModifyDeviceCommand.h
new file mode 100644
index 0000000..f8f820e
--- /dev/null
+++ b/src/commands/studio/ModifyDeviceCommand.h
@@ -0,0 +1,109 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MODIFYDEVICECOMMAND_H_
+#define _RG_MODIFYDEVICECOMMAND_H_
+
+#include "base/Device.h"
+#include "base/MidiDevice.h"
+#include <string>
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+class Modify;
+
+
+namespace Rosegarden
+{
+
+class Studio;
+
+
+class ModifyDeviceCommand : public KNamedCommand
+{
+public:
+ // Any of the arguments passed by pointer may be null (except for
+ // the Studio) -- in which case they will not be changed in the device.
+ ModifyDeviceCommand(Studio *studio,
+ DeviceId device,
+ const std::string &name,
+ const std::string &librarianName,
+ const std::string &librarianEmail);
+
+ void setVariation (MidiDevice::VariationType variationType);
+ void setBankList (const BankList &bankList);
+ void setProgramList(const ProgramList &programList);
+ void setControlList(const ControlList &controlList);
+ void setKeyMappingList(const KeyMappingList &keyMappingList);
+ void setOverwrite (bool overwrite) { m_overwrite = overwrite; }
+ void setRename (bool rename) { m_rename = rename; }
+
+ /// supersedes setBankList() and setProgramList()
+ void clearBankAndProgramList() { m_clearBankAndProgramList = true; }
+
+ static QString getGlobalName() { return i18n("Modify &MIDI Bank"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+
+ Studio *m_studio;
+ int m_device;
+ std::string m_name;
+ std::string m_librarianName;
+ std::string m_librarianEmail;
+ MidiDevice::VariationType m_variationType;
+ BankList m_bankList;
+ ProgramList m_programList;
+ ControlList m_controlList;
+ KeyMappingList m_keyMappingList;
+
+ std::string m_oldName;
+ std::string m_oldLibrarianName;
+ std::string m_oldLibrarianEmail;
+ MidiDevice::VariationType m_oldVariationType;
+ BankList m_oldBankList;
+ ProgramList m_oldProgramList;
+ ControlList m_oldControlList;
+ KeyMappingList m_oldKeyMappingList;
+
+ bool m_overwrite;
+ bool m_rename;
+ bool m_changeVariation;
+ bool m_changeBanks;
+ bool m_changePrograms;
+ bool m_changeControls;
+ bool m_changeKeyMappings;
+ bool m_clearBankAndProgramList;
+
+};
+
+
+}
+
+#endif
diff --git a/src/commands/studio/ModifyDeviceMappingCommand.cpp b/src/commands/studio/ModifyDeviceMappingCommand.cpp
new file mode 100644
index 0000000..6f02d8d
--- /dev/null
+++ b/src/commands/studio/ModifyDeviceMappingCommand.cpp
@@ -0,0 +1,147 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ModifyDeviceMappingCommand.h"
+
+#include "misc/Debug.h"
+#include "base/Composition.h"
+#include "base/Device.h"
+#include "base/Instrument.h"
+#include "base/MidiProgram.h"
+#include "base/Studio.h"
+#include "base/Track.h"
+#include "document/RosegardenGUIDoc.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+ModifyDeviceMappingCommand::ModifyDeviceMappingCommand(
+ RosegardenGUIDoc *doc,
+ DeviceId fromDevice,
+ DeviceId toDevice):
+ KNamedCommand(getGlobalName()),
+ m_composition(&doc->getComposition()),
+ m_studio(&doc->getStudio()),
+ m_fromDevice(fromDevice),
+ m_toDevice(toDevice)
+{}
+
+void
+ModifyDeviceMappingCommand::execute()
+{
+ Composition::trackcontainer &tracks =
+ m_composition->getTracks();
+ Composition::trackcontainer::iterator it = tracks.begin();
+ Instrument *instr = 0;
+ int index = 0;
+
+ for (; it != tracks.end(); it++) {
+ instr = m_studio->getInstrumentById(it->second->getInstrument());
+ if (!instr || !instr->getDevice())
+ continue;
+
+ if (instr->getDevice()->getId() == m_fromDevice) {
+ // if source and target are MIDI
+ if (m_studio->getDevice(m_fromDevice)->getType() ==
+ Device::Midi &&
+ m_studio->getDevice(m_toDevice)->getType() ==
+ Device::Midi) {
+ // Try to match channels on the target device
+ //
+ MidiByte channel = instr->getMidiChannel();
+
+ InstrumentList destList = m_studio->
+ getDevice(m_toDevice)->getPresentationInstruments();
+
+ InstrumentList::iterator dIt = destList.begin();
+
+ for (; dIt != destList.end(); dIt++) {
+ if ((*dIt)->getMidiChannel() == channel) {
+ break;
+ }
+ }
+
+ // Failure to match anything and there's no Instruments
+ // at all in the destination. Skip to next source Instrument.
+ //
+ if (dIt == destList.end() || destList.size() == 0)
+ continue;
+
+
+ RG_DEBUG << " Track " << it->first
+ << ", setting Instrument to "
+ << (*dIt)->getId() << endl;
+
+ // store "to" and "from" values
+ //
+ m_mapping.push_back(
+ std::pair < TrackId,
+ InstrumentId >
+ (it->first,
+ instr->getId()));
+
+ it->second->setInstrument((*dIt)->getId());
+ } else // audio is involved in the mapping - use indexes
+ {
+ // assign by index numbers
+ InstrumentList destList = m_studio->
+ getDevice(m_toDevice)->getPresentationInstruments();
+
+ // skip if we can't match
+ //
+ if (index > (int)(destList.size() - 1))
+ continue;
+
+ m_mapping.push_back(
+ std::pair < TrackId,
+ InstrumentId >
+ (it->first,
+ instr->getId()));
+
+ it->second->setInstrument(destList[index]->getId());
+ }
+
+ index++;
+ }
+ }
+
+}
+
+void
+ModifyDeviceMappingCommand::unexecute()
+{
+ std::vector<std::pair<TrackId, InstrumentId> >
+ ::iterator it = m_mapping.begin();
+ Track *track = 0;
+
+ for (; it != m_mapping.end(); it++) {
+ track = m_composition->getTrackById(it->first);
+ track->setInstrument(it->second);
+ }
+}
+
+}
diff --git a/src/commands/studio/ModifyDeviceMappingCommand.h b/src/commands/studio/ModifyDeviceMappingCommand.h
new file mode 100644
index 0000000..150275d
--- /dev/null
+++ b/src/commands/studio/ModifyDeviceMappingCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MODIFYDEVICEMAPPINGCOMMAND_H_
+#define _RG_MODIFYDEVICEMAPPINGCOMMAND_H_
+
+#include "base/Device.h"
+#include "base/Track.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+class Modify;
+
+
+namespace Rosegarden
+{
+
+class Studio;
+class RosegardenGUIDoc;
+class Composition;
+
+
+class ModifyDeviceMappingCommand : public KNamedCommand
+{
+public:
+ ModifyDeviceMappingCommand(RosegardenGUIDoc *doc,
+ DeviceId fromDevice,
+ DeviceId toDevice);
+
+ static QString getGlobalName() { return i18n("Modify &Device Mapping"); }
+
+ virtual void execute();
+ virtual void unexecute();
+protected:
+ Composition *m_composition;
+ Studio *m_studio;
+ DeviceId m_fromDevice;
+ DeviceId m_toDevice;
+
+ std::vector<std::pair<TrackId, InstrumentId> > m_mapping;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/studio/ModifyInstrumentMappingCommand.cpp b/src/commands/studio/ModifyInstrumentMappingCommand.cpp
new file mode 100644
index 0000000..e6369b6
--- /dev/null
+++ b/src/commands/studio/ModifyInstrumentMappingCommand.cpp
@@ -0,0 +1,78 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ModifyInstrumentMappingCommand.h"
+
+#include "base/Composition.h"
+#include "base/MidiProgram.h"
+#include "base/Studio.h"
+#include "base/Track.h"
+#include "document/RosegardenGUIDoc.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+ModifyInstrumentMappingCommand::ModifyInstrumentMappingCommand(
+ RosegardenGUIDoc *doc,
+ InstrumentId fromInstrument,
+ InstrumentId toInstrument):
+ KNamedCommand(getGlobalName()),
+ m_composition(&doc->getComposition()),
+ m_studio(&doc->getStudio()),
+ m_fromInstrument(fromInstrument),
+ m_toInstrument(toInstrument)
+{}
+
+void
+ModifyInstrumentMappingCommand::execute()
+{
+ Composition::trackcontainer &tracks =
+ m_composition->getTracks();
+ Composition::trackcontainer::iterator it = tracks.begin();
+
+ for (; it != tracks.end(); it++) {
+ if (it->second->getInstrument() == m_fromInstrument) {
+ m_mapping.push_back(it->first);
+ it->second->setInstrument(m_toInstrument);
+ }
+ }
+
+}
+
+void
+ModifyInstrumentMappingCommand::unexecute()
+{
+ std::vector<TrackId>::iterator it = m_mapping.begin();
+ Track *track = 0;
+
+ for (; it != m_mapping.end(); it++) {
+ track = m_composition->getTrackById(*it);
+ track->setInstrument(m_fromInstrument);
+ }
+}
+
+}
diff --git a/src/commands/studio/ModifyInstrumentMappingCommand.h b/src/commands/studio/ModifyInstrumentMappingCommand.h
new file mode 100644
index 0000000..224459b
--- /dev/null
+++ b/src/commands/studio/ModifyInstrumentMappingCommand.h
@@ -0,0 +1,76 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_MODIFYINSTRUMENTMAPPINGCOMMAND_H_
+#define _RG_MODIFYINSTRUMENTMAPPINGCOMMAND_H_
+
+#include "base/MidiProgram.h"
+#include "base/Track.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <vector>
+#include <klocale.h>
+
+
+class Modify;
+
+
+namespace Rosegarden
+{
+
+class Studio;
+class RosegardenGUIDoc;
+class Composition;
+
+
+class ModifyInstrumentMappingCommand : public KNamedCommand
+{
+public:
+ ModifyInstrumentMappingCommand(RosegardenGUIDoc *doc,
+ InstrumentId fromInstrument,
+ InstrumentId toInstrument);
+
+ static QString getGlobalName() { return i18n("Modify &Instrument Mapping"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Composition *m_composition;
+ Studio *m_studio;
+ InstrumentId m_fromInstrument;
+ InstrumentId m_toInstrument;
+
+ std::vector<TrackId> m_mapping;
+
+};
+
+
+// because ModifyDeviceCommand is overkill for this
+
+
+}
+
+#endif
diff --git a/src/commands/studio/ReconnectDeviceCommand.cpp b/src/commands/studio/ReconnectDeviceCommand.cpp
new file mode 100644
index 0000000..6d40ede
--- /dev/null
+++ b/src/commands/studio/ReconnectDeviceCommand.cpp
@@ -0,0 +1,98 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "ReconnectDeviceCommand.h"
+
+#include "misc/Strings.h"
+#include "misc/Debug.h"
+#include "base/Device.h"
+#include "base/Studio.h"
+#include <qcstring.h>
+#include <qdatastream.h>
+#include <qstring.h>
+#include "gui/application/RosegardenApplication.h"
+
+
+namespace Rosegarden
+{
+
+void
+ReconnectDeviceCommand::execute()
+{
+ Device *device = m_studio->getDevice(m_deviceId);
+
+ if (device) {
+ m_oldConnection = device->getConnection();
+
+ QByteArray data;
+ QByteArray replyData;
+ QCString replyType;
+ QDataStream arg(data, IO_WriteOnly);
+
+ arg << (unsigned int)m_deviceId;
+ arg << strtoqstr(m_newConnection);
+
+ if (!rgapp->sequencerCall("setConnection(unsigned int, QString)",
+ replyType, replyData, data)) {
+ SEQMAN_DEBUG << "ReconnectDeviceCommand::execute - "
+ << "failure in sequencer setConnection" << endl;
+ return ;
+ }
+
+ SEQMAN_DEBUG << "ReconnectDeviceCommand::execute - "
+ << " reconnected device " << m_deviceId
+ << " to " << m_newConnection << endl;
+ }
+}
+
+void
+ReconnectDeviceCommand::unexecute()
+{
+ Device *device = m_studio->getDevice(m_deviceId);
+
+ if (device) {
+
+ QByteArray data;
+ QByteArray replyData;
+ QCString replyType;
+ QDataStream arg(data, IO_WriteOnly);
+
+ arg << (unsigned int)m_deviceId;
+ arg << strtoqstr(m_oldConnection);
+
+ if (!rgapp->sequencerCall("setConnection(unsigned int, QString)",
+ replyType, replyData, data)) {
+ SEQMAN_DEBUG << "ReconnectDeviceCommand::unexecute - "
+ << "failure in sequencer setConnection" << endl;
+ return ;
+ }
+
+ SEQMAN_DEBUG << "ReconnectDeviceCommand::unexecute - "
+ << " reconnected device " << m_deviceId
+ << " to " << m_oldConnection << endl;
+ }
+}
+
+}
diff --git a/src/commands/studio/ReconnectDeviceCommand.h b/src/commands/studio/ReconnectDeviceCommand.h
new file mode 100644
index 0000000..910bdbf
--- /dev/null
+++ b/src/commands/studio/ReconnectDeviceCommand.h
@@ -0,0 +1,70 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RECONNECTDEVICECOMMAND_H_
+#define _RG_RECONNECTDEVICECOMMAND_H_
+
+#include "base/Device.h"
+#include <string>
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Studio;
+
+
+class ReconnectDeviceCommand : public KNamedCommand
+{
+public:
+ ReconnectDeviceCommand(Studio *studio,
+ DeviceId deviceId,
+ std::string newConnection) :
+ KNamedCommand(getGlobalName()),
+ m_studio(studio),
+ m_deviceId(deviceId),
+ m_newConnection(newConnection) { }
+
+ static QString getGlobalName() { return i18n("Reconnect Device"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Studio *m_studio;
+ DeviceId m_deviceId;
+ std::string m_newConnection;
+ std::string m_oldConnection;
+};
+
+
+}
+
+#endif
diff --git a/src/commands/studio/RemoveControlParameterCommand.cpp b/src/commands/studio/RemoveControlParameterCommand.cpp
new file mode 100644
index 0000000..5f596b5
--- /dev/null
+++ b/src/commands/studio/RemoveControlParameterCommand.cpp
@@ -0,0 +1,75 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RemoveControlParameterCommand.h"
+
+#include "base/ControlParameter.h"
+#include "base/Device.h"
+#include "base/MidiDevice.h"
+#include "base/Studio.h"
+#include <qstring.h>
+#include <iostream>
+
+
+namespace Rosegarden
+{
+
+RemoveControlParameterCommand::~RemoveControlParameterCommand()
+{}
+
+void
+RemoveControlParameterCommand::execute()
+{
+ MidiDevice *md = dynamic_cast<MidiDevice *>
+ (m_studio->getDevice(m_device));
+ if (!md) {
+ std::cerr << "WARNING: RemoveControlParameterCommand::execute: device "
+ << m_device << " is not a MidiDevice in current studio"
+ << std::endl;
+ return ;
+ }
+
+ ControlParameter *param = md->getControlParameter(m_id);
+ if (param)
+ m_oldControl = *param;
+ md->removeControlParameter(m_id);
+}
+
+void
+RemoveControlParameterCommand::unexecute()
+{
+ MidiDevice *md = dynamic_cast<MidiDevice *>
+ (m_studio->getDevice(m_device));
+ if (!md) {
+ std::cerr << "WARNING: RemoveControlParameterCommand::execute: device "
+ << m_device << " is not a MidiDevice in current studio"
+ << std::endl;
+ return ;
+ }
+
+ md->addControlParameter(m_oldControl, m_id);
+}
+
+}
diff --git a/src/commands/studio/RemoveControlParameterCommand.h b/src/commands/studio/RemoveControlParameterCommand.h
new file mode 100644
index 0000000..3143739
--- /dev/null
+++ b/src/commands/studio/RemoveControlParameterCommand.h
@@ -0,0 +1,73 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_REMOVECONTROLPARAMETERCOMMAND_H_
+#define _RG_REMOVECONTROLPARAMETERCOMMAND_H_
+
+#include "base/ControlParameter.h"
+#include "base/Device.h"
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Studio;
+
+
+class RemoveControlParameterCommand : public KNamedCommand
+{
+public:
+ RemoveControlParameterCommand(Studio *studio,
+ DeviceId device,
+ int id):
+ KNamedCommand(getGlobalName()),
+ m_studio(studio),
+ m_device(device),
+ m_id(id) { }
+
+ ~RemoveControlParameterCommand();
+
+ virtual void execute();
+ virtual void unexecute();
+
+ static QString getGlobalName() { return i18n("&Remove Control Parameter"); }
+
+protected:
+ Studio *m_studio;
+ DeviceId m_device;
+ int m_id;
+ ControlParameter m_oldControl;
+
+};
+
+
+}
+
+#endif
diff --git a/src/commands/studio/RenameDeviceCommand.cpp b/src/commands/studio/RenameDeviceCommand.cpp
new file mode 100644
index 0000000..1d6c382
--- /dev/null
+++ b/src/commands/studio/RenameDeviceCommand.cpp
@@ -0,0 +1,52 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+
+#include "RenameDeviceCommand.h"
+
+#include "base/Device.h"
+#include "base/Studio.h"
+#include <qstring.h>
+
+
+namespace Rosegarden
+{
+
+void
+RenameDeviceCommand::execute()
+{
+ Device *device = m_studio->getDevice(m_deviceId);
+ if (m_oldName == "")
+ m_oldName = device->getName();
+ device->setName(m_name);
+}
+
+void
+RenameDeviceCommand::unexecute()
+{
+ Device *device = m_studio->getDevice(m_deviceId);
+ device->setName(m_oldName);
+}
+
+}
diff --git a/src/commands/studio/RenameDeviceCommand.h b/src/commands/studio/RenameDeviceCommand.h
new file mode 100644
index 0000000..d767bca
--- /dev/null
+++ b/src/commands/studio/RenameDeviceCommand.h
@@ -0,0 +1,71 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <[email protected]>,
+ Chris Cannam <[email protected]>,
+ Richard Bown <[email protected]>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_RENAMEDEVICECOMMAND_H_
+#define _RG_RENAMEDEVICECOMMAND_H_
+
+#include "base/Device.h"
+#include <string>
+#include <kcommand.h>
+#include <qstring.h>
+#include <klocale.h>
+
+
+
+
+namespace Rosegarden
+{
+
+class Studio;
+
+
+class RenameDeviceCommand : public KNamedCommand
+{
+public:
+ RenameDeviceCommand(Studio *studio,
+ DeviceId deviceId,
+ std::string name) :
+ KNamedCommand(getGlobalName()),
+ m_studio(studio),
+ m_deviceId(deviceId),
+ m_name(name) { }
+
+ static QString getGlobalName() { return i18n("Rename Device"); }
+
+ virtual void execute();
+ virtual void unexecute();
+
+protected:
+ Studio *m_studio;
+ DeviceId m_deviceId;
+ std::string m_name;
+ std::string m_oldName;
+};
+
+
+
+}
+
+#endif