summaryrefslogtreecommitdiffstats
path: root/src/commands/notation
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/notation')
-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
94 files changed, 7396 insertions, 0 deletions
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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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 <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; 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