summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2013-08-19 22:10:22 +0200
committerFlorian Jung <flo@windfisch.org>2013-08-19 22:10:22 +0200
commit013294f58a6433671da3b34775de5a3a7ea91464 (patch)
tree7a1135f74c798f78c802c8c4e4ca4f9b0c293baa /muse2
parent67c0ed979d4dd05c1d51b688c2fb02ebc681afd1 (diff)
some const-correctness. Part interface overhaul.
various fixes.
Diffstat (limited to 'muse2')
-rw-r--r--muse2/muse/arranger/pcanvas.cpp6
-rw-r--r--muse2/muse/event.cpp2
-rw-r--r--muse2/muse/event.h3
-rw-r--r--muse2/muse/eventbase.h2
-rw-r--r--muse2/muse/eventlist.cpp13
-rw-r--r--muse2/muse/exportmidi.cpp2
-rw-r--r--muse2/muse/functions.cpp269
-rw-r--r--muse2/muse/functions.h74
-rw-r--r--muse2/muse/helper.cpp6
-rw-r--r--muse2/muse/helper.h2
-rw-r--r--muse2/muse/importmidi.cpp14
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp6
-rw-r--r--muse2/muse/midiedit/prcanvas.cpp6
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp12
-rw-r--r--muse2/muse/midiedit/scoreedit.h2
-rw-r--r--muse2/muse/midievent.cpp2
-rw-r--r--muse2/muse/midievent.h2
-rw-r--r--muse2/muse/miditransform.cpp46
-rw-r--r--muse2/muse/miditransform.h4
-rw-r--r--muse2/muse/part.cpp151
-rw-r--r--muse2/muse/part.h41
-rw-r--r--muse2/muse/song.cpp21
-rw-r--r--muse2/muse/steprec.cpp10
-rw-r--r--muse2/muse/structure.cpp12
-rw-r--r--muse2/muse/track.cpp4
-rw-r--r--muse2/muse/track.h1
-rw-r--r--muse2/muse/undo.cpp18
-rw-r--r--muse2/muse/undo.h22
-rw-r--r--muse2/muse/waveedit/wavecanvas.cpp8
-rw-r--r--muse2/muse/waveevent.cpp4
-rw-r--r--muse2/muse/waveevent.h2
-rw-r--r--muse2/muse/wavetrack.cpp4
32 files changed, 341 insertions, 430 deletions
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp
index 860a33ac..91c0df5e 100644
--- a/muse2/muse/arranger/pcanvas.cpp
+++ b/muse2/muse/arranger/pcanvas.cpp
@@ -2321,7 +2321,7 @@ void PartCanvas::copy_in_range(MusECore::PartList* pl_)
MusECore::Part* p1;
MusECore::Part* p2;
- track->splitPart(part, lpos, p1, p2);
+ part->splitPart(lpos, p1, p2);
part=p2;
}
@@ -2331,7 +2331,7 @@ void PartCanvas::copy_in_range(MusECore::PartList* pl_)
MusECore::Part* p1;
MusECore::Part* p2;
- track->splitPart(part, rpos, p1, p2);
+ part->splitPart(rpos, p1, p2);
part=p1;
}
@@ -2427,7 +2427,7 @@ MusECore::Undo PartCanvas::pasteAt(const QString& pt, MusECore::Track* track, un
if (tag == "part") {
// Read the part.
MusECore::Part* p = 0;
- p = Part::readFromXml(xml, track, clone, toTrack);
+ p = MusECore::Part::readFromXml(xml, track, clone, toTrack);
// If it could not be created...
if(!p)
diff --git a/muse2/muse/event.cpp b/muse2/muse/event.cpp
index 73611448..065a49cf 100644
--- a/muse2/muse/event.cpp
+++ b/muse2/muse/event.cpp
@@ -203,7 +203,7 @@ void Event::read(Xml& xml)
void Event::write(int a, Xml& xml, const Pos& o, bool forceWavePaths) const { ev->write(a, xml, o, forceWavePaths); }
void Event::dump(int n) const { ev->dump(n); }
-Event Event::mid(unsigned a, unsigned b) { return Event(ev->mid(a, b)); }
+Event Event::mid(unsigned a, unsigned b) const { return Event(ev->mid(a, b)); }
bool Event::isNote() const { return ev->isNote(); }
bool Event::isNoteOff() const { return ev->isNoteOff(); }
diff --git a/muse2/muse/event.h b/muse2/muse/event.h
index 78ac7f93..ed1ddb87 100644
--- a/muse2/muse/event.h
+++ b/muse2/muse/event.h
@@ -74,7 +74,7 @@ class Event {
void write(int a, Xml& xml, const Pos& offset, bool ForceWavePaths = false) const;
void dump(int n = 0) const;
Event clone() const;
- Event mid(unsigned a, unsigned b);
+ Event mid(unsigned a, unsigned b) const;
bool isNote() const;
bool isNoteOff() const;
@@ -135,6 +135,7 @@ class EventList : public EL {
void deselect();
public:
+ ciEvent find(const Event&) const;
iEvent find(const Event&);
iEvent add(Event& event);
void move(Event& event, unsigned tick);
diff --git a/muse2/muse/eventbase.h b/muse2/muse/eventbase.h
index 9e7b2df8..adf7da97 100644
--- a/muse2/muse/eventbase.h
+++ b/muse2/muse/eventbase.h
@@ -60,7 +60,7 @@ class EventBase : public PosLen {
virtual void read(Xml&) = 0;
virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const = 0;
virtual void dump(int n = 0) const;
- virtual EventBase* mid(unsigned, unsigned) = 0;
+ virtual EventBase* mid(unsigned, unsigned) const = 0;
friend class Event;
virtual bool isNote() const { return false; }
diff --git a/muse2/muse/eventlist.cpp b/muse2/muse/eventlist.cpp
index 50ba2652..f499fd2d 100644
--- a/muse2/muse/eventlist.cpp
+++ b/muse2/muse/eventlist.cpp
@@ -129,11 +129,22 @@ void EventList::move(Event& event, unsigned tick)
//---------------------------------------------------------
iEvent EventList::find(const Event& event)
+{
+ std::pair<iEvent,iEvent> range = equal_range(event.type() == Wave ? event.frame() : event.tick());
+
+ for (iEvent i = range.first; i != range.second; ++i) {
+ if (i->second == event)
+ return i;
+ }
+ return end();
+}
+
+ciEvent EventList::find(const Event& event) const
{
EventRange range = equal_range(event.type() == Wave ? event.frame() : event.tick());
- for (iEvent i = range.first; i != range.second; ++i) {
+ for (ciEvent i = range.first; i != range.second; ++i) {
if (i->second == event)
return i;
}
diff --git a/muse2/muse/exportmidi.cpp b/muse2/muse/exportmidi.cpp
index aa9b83cc..34ac8983 100644
--- a/muse2/muse/exportmidi.cpp
+++ b/muse2/muse/exportmidi.cpp
@@ -490,7 +490,7 @@ void MusE::exportMidi()
{
MusECore::EventList* el = instr->midiInit();
if(!el->empty())
- MusECore::addEventList(el, l, NULL, NULL, port, channel); // No track or part passed for init sequences
+ MusECore::addEventList(*el, l, NULL, NULL, port, channel); // No track or part passed for init sequences
}
//--------------------------
diff --git a/muse2/muse/functions.cpp b/muse2/muse/functions.cpp
index 8b978843..c2941a72 100644
--- a/muse2/muse/functions.cpp
+++ b/muse2/muse/functions.cpp
@@ -71,9 +71,9 @@ bool read_eventlist_and_part(Xml& xml, EventList* el, int* part_id);
-set<Part*> partlist_to_set(PartList* pl)
+set<const Part*> partlist_to_set(PartList* pl)
{
- set<Part*> result;
+ set<const Part*> result;
for (PartList::iterator it=pl->begin(); it!=pl->end(); it++)
result.insert(it->second);
@@ -81,16 +81,16 @@ set<Part*> partlist_to_set(PartList* pl)
return result;
}
-set<Part*> part_to_set(Part* p)
+set<const Part*> part_to_set(const Part* p)
{
- set<Part*> result;
+ set<const Part*> result;
result.insert(p);
return result;
}
-set<Part*> get_all_parts()
+set<const Part*> get_all_parts()
{
- set<Part*> result;
+ set<const Part*> result;
TrackList* tracks=MusEGlobal::song->tracks();
for (TrackList::const_iterator t_it=tracks->begin(); t_it!=tracks->end(); t_it++)
@@ -103,9 +103,9 @@ set<Part*> get_all_parts()
return result;
}
-set<Part*> get_all_selected_parts()
+set<const Part*> get_all_selected_parts()
{
- set<Part*> result;
+ set<const Part*> result;
TrackList* tracks=MusEGlobal::song->tracks();
for (TrackList::const_iterator t_it=tracks->begin(); t_it!=tracks->end(); t_it++)
@@ -137,14 +137,14 @@ bool is_relevant(const Event& event, const Part* part, int range)
}
-map<Event*, Part*> get_events(const set<Part*>& parts, int range)
+map<const Event*, const Part*> get_events(const set<const Part*>& parts, int range)
{
- map<Event*, Part*> events;
+ map<const Event*, const Part*> events;
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
for (ciEvent event=(*part)->events().begin(); event!=(*part)->events().end(); event++)
if (is_relevant(event->second, *part, range))
- events.insert(pair<Event*, Part*>(&event->second, *part));
+ events.insert(pair<const Event*, const Part*>(&event->second, *part));
return events;
}
@@ -152,7 +152,7 @@ map<Event*, Part*> get_events(const set<Part*>& parts, int range)
-bool modify_notelen(const set<Part*>& parts)
+bool modify_notelen(const set<const Part*>& parts)
{
if (!MusEGui::gatetime_dialog->exec())
return false;
@@ -162,7 +162,7 @@ bool modify_notelen(const set<Part*>& parts)
return true;
}
-bool modify_velocity(const set<Part*>& parts)
+bool modify_velocity(const set<const Part*>& parts)
{
if (!MusEGui::velocity_dialog->exec())
return false;
@@ -172,7 +172,7 @@ bool modify_velocity(const set<Part*>& parts)
return true;
}
-bool quantize_notes(const set<Part*>& parts)
+bool quantize_notes(const set<const Part*>& parts)
{
if (!MusEGui::quantize_dialog->exec())
return false;
@@ -185,7 +185,7 @@ bool quantize_notes(const set<Part*>& parts)
return true;
}
-bool erase_notes(const set<Part*>& parts)
+bool erase_notes(const set<const Part*>& parts)
{
if (!MusEGui::erase_dialog->exec())
return false;
@@ -196,7 +196,7 @@ bool erase_notes(const set<Part*>& parts)
return true;
}
-bool delete_overlaps(const set<Part*>& parts)
+bool delete_overlaps(const set<const Part*>& parts)
{
if (!MusEGui::del_overlaps_dialog->exec())
return false;
@@ -206,7 +206,7 @@ bool delete_overlaps(const set<Part*>& parts)
return true;
}
-bool set_notelen(const set<Part*>& parts)
+bool set_notelen(const set<const Part*>& parts)
{
if (!MusEGui::set_notelen_dialog->exec())
return false;
@@ -216,7 +216,7 @@ bool set_notelen(const set<Part*>& parts)
return true;
}
-bool move_notes(const set<Part*>& parts)
+bool move_notes(const set<const Part*>& parts)
{
if (!MusEGui::move_notes_dialog->exec())
return false;
@@ -226,7 +226,7 @@ bool move_notes(const set<Part*>& parts)
return true;
}
-bool transpose_notes(const set<Part*>& parts)
+bool transpose_notes(const set<const Part*>& parts)
{
if (!MusEGui::transpose_dialog->exec())
return false;
@@ -236,7 +236,7 @@ bool transpose_notes(const set<Part*>& parts)
return true;
}
-bool crescendo(const set<Part*>& parts)
+bool crescendo(const set<const Part*>& parts)
{
if (MusEGlobal::song->rpos() <= MusEGlobal::song->lpos())
{
@@ -252,7 +252,7 @@ bool crescendo(const set<Part*>& parts)
return true;
}
-bool legato(const set<Part*>& parts)
+bool legato(const set<const Part*>& parts)
{
if (!MusEGui::legato_dialog->exec())
return false;
@@ -269,7 +269,7 @@ bool modify_notelen()
if (!MusEGui::gatetime_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::gatetime_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -285,7 +285,7 @@ bool modify_velocity()
if (!MusEGui::velocity_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::velocity_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -301,7 +301,7 @@ bool quantize_notes()
if (!MusEGui::quantize_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::quantize_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -320,7 +320,7 @@ bool erase_notes()
if (!MusEGui::erase_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::erase_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -337,7 +337,7 @@ bool delete_overlaps()
if (!MusEGui::del_overlaps_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::del_overlaps_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -353,7 +353,7 @@ bool set_notelen()
if (!MusEGui::set_notelen_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::set_notelen_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -369,7 +369,7 @@ bool move_notes()
if (!MusEGui::move_notes_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::move_notes_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -385,7 +385,7 @@ bool transpose_notes()
if (!MusEGui::transpose_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::transpose_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -407,7 +407,7 @@ bool crescendo()
if (!MusEGui::crescendo_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::crescendo_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -423,7 +423,7 @@ bool legato()
if (!MusEGui::legato_dialog->exec())
return false;
- set<Part*> parts;
+ set<const Part*> parts;
if (MusEGui::legato_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
parts=get_all_selected_parts();
else
@@ -439,17 +439,17 @@ bool legato()
-bool modify_velocity(const set<Part*>& parts, int range, int rate, int offset)
+bool modify_velocity(const set<const Part*>& parts, int range, int rate, int offset)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
if ( (!events.empty()) && ((rate!=100) || (offset!=0)) )
{
- for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ for (map<const Event*, const Part*>::iterator it=events.begin(); it!=events.end(); it++)
{
- Event& event=*(it->first);
- Part* part=it->second;
+ const Event& event=*(it->first);
+ const Part* part=it->second;
int velo = event.velo();
@@ -475,17 +475,17 @@ bool modify_velocity(const set<Part*>& parts, int range, int rate, int offset)
return false;
}
-bool modify_off_velocity(const set<Part*>& parts, int range, int rate, int offset)
+bool modify_off_velocity(const set<const Part*>& parts, int range, int rate, int offset)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
if ( (!events.empty()) && ((rate!=100) || (offset!=0)) )
{
- for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ for (map<const Event*, const Part*>::iterator it=events.begin(); it!=events.end(); it++)
{
- Event& event=*(it->first);
- Part* part=it->second;
+ const Event& event=*(it->first);
+ const Part* part=it->second;
int velo = event.veloOff();
@@ -511,18 +511,18 @@ bool modify_off_velocity(const set<Part*>& parts, int range, int rate, int offse
return false;
}
-bool modify_notelen(const set<Part*>& parts, int range, int rate, int offset)
+bool modify_notelen(const set<const Part*>& parts, int range, int rate, int offset)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
- map<Part*, int> partlen;
+ map<const Part*, int> partlen;
if ( (!events.empty()) && ((rate!=100) || (offset!=0)) )
{
- for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ for (map<const Event*, const Part*>::iterator it=events.begin(); it!=events.end(); it++)
{
- Event& event=*(it->first);
- Part* part=it->second;
+ const Event& event=*(it->first);
+ const Part* part=it->second;
unsigned int len = event.lenTick(); //prevent compiler warning: comparison singed/unsigned
@@ -543,7 +543,7 @@ bool modify_notelen(const set<Part*>& parts, int range, int rate, int offset)
}
}
- for (map<Part*, int>::iterator it=partlen.begin(); it!=partlen.end(); it++)
+ for (map<const Part*, int>::iterator it=partlen.begin(); it!=partlen.end(); it++)
schedule_resize_all_same_len_clone_parts(it->first, it->second, operations);
return MusEGlobal::song->applyOperationGroup(operations);
@@ -552,7 +552,7 @@ bool modify_notelen(const set<Part*>& parts, int range, int rate, int offset)
return false;
}
-bool set_notelen(const set<Part*>& parts, int range, int len)
+bool set_notelen(const set<const Part*>& parts, int range, int len)
{
return modify_notelen(parts, range, 0, len);
}
@@ -579,17 +579,17 @@ unsigned quantize_tick(unsigned tick, unsigned raster, int swing)
return tick_dest1;
}
-bool quantize_notes(const set<Part*>& parts, int range, int raster, bool quant_len, int strength, int swing, int threshold)
+bool quantize_notes(const set<const Part*>& parts, int range, int raster, bool quant_len, int strength, int swing, int threshold)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
if (!events.empty())
{
- for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ for (map<const Event*, const Part*>::iterator it=events.begin(); it!=events.end(); it++)
{
- Event& event=*(it->first);
- Part* part=it->second;
+ const Event& event=*(it->first);
+ const Part* part=it->second;
unsigned begin_tick = event.tick() + part->tick();
int begin_diff = quantize_tick(begin_tick, raster, swing) - begin_tick;
@@ -625,17 +625,17 @@ bool quantize_notes(const set<Part*>& parts, int range, int raster, bool quant_l
return false;
}
-bool erase_notes(const set<Part*>& parts, int range, int velo_threshold, bool velo_thres_used, int len_threshold, bool len_thres_used)
+bool erase_notes(const set<const Part*>& parts, int range, int velo_threshold, bool velo_thres_used, int len_threshold, bool len_thres_used)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
if (!events.empty())
{
- for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ for (map<const Event*, const Part*>::iterator it=events.begin(); it!=events.end(); it++)
{
- Event& event=*(it->first);
- Part* part=it->second;
+ const Event& event=*(it->first);
+ const Part* part=it->second;
if ( (!velo_thres_used && !len_thres_used) ||
(velo_thres_used && event.velo() < velo_threshold) ||
@@ -649,17 +649,17 @@ bool erase_notes(const set<Part*>& parts, int range, int velo_threshold, bool ve
return false;
}
-bool transpose_notes(const set<Part*>& parts, int range, signed int halftonesteps)
+bool transpose_notes(const set<const Part*>& parts, int range, signed int halftonesteps)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
if ( (!events.empty()) && (halftonesteps!=0) )
{
- for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ for (map<const Event*, const Part*>::iterator it=events.begin(); it!=events.end(); it++)
{
- Event& event=*(it->first);
- Part* part=it->second;
+ const Event& event=*(it->first);
+ const Part* part=it->second;
Event newEvent = event.clone();
int pitch = event.pitch()+halftonesteps;
@@ -675,9 +675,9 @@ bool transpose_notes(const set<Part*>& parts, int range, signed int halftonestep
return false;
}
-bool crescendo(const set<Part*>& parts, int range, int start_val, int end_val, bool absolute)
+bool crescendo(const set<const Part*>& parts, int range, int start_val, int end_val, bool absolute)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
int from=MusEGlobal::song->lpos();
@@ -685,10 +685,10 @@ bool crescendo(const set<Part*>& parts, int range, int start_val, int end_val, b
if ( (!events.empty()) && (to>from) )
{
- for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ for (map<const Event*, const Part*>::iterator it=events.begin(); it!=events.end(); it++)
{
- Event& event=*(it->first);
- Part* part=it->second;
+ const Event& event=*(it->first);
+ const Part* part=it->second;
unsigned tick = event.tick() + part->tick();
float curr_val= (float)start_val + (float)(end_val-start_val) * (tick-from) / (to-from);
@@ -713,18 +713,18 @@ bool crescendo(const set<Part*>& parts, int range, int start_val, int end_val, b
return false;
}
-bool move_notes(const set<Part*>& parts, int range, signed int ticks)
+bool move_notes(const set<const Part*>& parts, int range, signed int ticks)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
- map<Part*, int> partlen;
+ map<const Part*, int> partlen;
if ( (!events.empty()) && (ticks!=0) )
{
- for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ for (map<const Event*, const Part*>::iterator it=events.begin(); it!=events.end(); it++)
{
- Event& event=*(it->first);
- Part* part=it->second;
+ const Event& event=*(it->first);
+ const Part* part=it->second;
bool del=false;
Event newEvent = event.clone();
@@ -752,7 +752,7 @@ bool move_notes(const set<Part*>& parts, int range, signed int ticks)
operations.push_back(UndoOp(UndoOp::DeleteEvent, event, part, false, false));
}
- for (map<Part*, int>::iterator it=partlen.begin(); it!=partlen.end(); it++)
+ for (map<const Part*, int>::iterator it=partlen.begin(); it!=partlen.end(); it++)
schedule_resize_all_same_len_clone_parts(it->first, it->second, operations);
return MusEGlobal::song->applyOperationGroup(operations);
@@ -762,27 +762,27 @@ bool move_notes(const set<Part*>& parts, int range, signed int ticks)
}
-bool delete_overlaps(const set<Part*>& parts, int range)
+bool delete_overlaps(const set<const Part*>& parts, int range)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
- set<Event*> deleted_events;
+ set<const Event*> deleted_events;
if (!events.empty())
{
- for (map<Event*, Part*>::iterator it1=events.begin(); it1!=events.end(); it1++)
+ for (map<const Event*, const Part*>::iterator it1=events.begin(); it1!=events.end(); it1++)
{
- Event& event1=*(it1->first);
- Part* part1=it1->second;
+ const Event& event1=*(it1->first);
+ const Part* part1=it1->second;
// we may NOT optimize by letting it2 start at (it1 +1); this optimisation
// is only allowed when events was sorted by time. it is, however, sorted
// randomly by pointer.
- for (map<Event*, Part*>::iterator it2=events.begin(); it2!=events.end(); it2++)
+ for (map<const Event*, const Part*>::iterator it2=events.begin(); it2!=events.end(); it2++)
{
- Event& event2=*(it2->first);
- Part* part2=it2->second;
+ const Event& event2=*(it2->first);
+ const Part* part2=it2->second;
if ( (part1->isCloneOf(part2)) && // part1 and part2 are the same or are duplicates
(&event1 != &event2) && // and event1 and event2 aren't the same
@@ -817,28 +817,28 @@ bool delete_overlaps(const set<Part*>& parts, int range)
return false;
}
-bool legato(const set<Part*>& parts, int range, int min_len, bool dont_shorten)
+bool legato(const set<const Part*>& parts, int range, int min_len, bool dont_shorten)
{
- map<Event*, Part*> events = get_events(parts, range);
+ map<const Event*, const Part*> events = get_events(parts, range);
Undo operations;
if (min_len<=0) min_len=1;
if (!events.empty())
{
- for (map<Event*, Part*>::iterator it1=events.begin(); it1!=events.end(); it1++)
+ for (map<const Event*, const Part*>::iterator it1=events.begin(); it1!=events.end(); it1++)
{
- Event& event1=*(it1->first);
- Part* part1=it1->second;
+ const Event& event1=*(it1->first);
+ const Part* part1=it1->second;
unsigned len=INT_MAX;
// we may NOT optimize by letting it2 start at (it1 +1); this optimisation
// is only allowed when events was sorted by time. it is, however, sorted
// randomly by pointer.
- for (map<Event*, Part*>::iterator it2=events.begin(); it2!=events.end(); it2++)
+ for (map<const Event*, const Part*>::iterator it2=events.begin(); it2!=events.end(); it2++)
{
- Event& event2=*(it2->first);
- Part* part2=it2->second;
+ const Event& event2=*(it2->first);
+ const Part* part2=it2->second;
bool relevant = (event2.tick() >= event1.tick() + min_len);
if (dont_shorten)
@@ -869,7 +869,7 @@ bool legato(const set<Part*>& parts, int range, int min_len, bool dont_shorten)
-void copy_notes(const set<Part*>& parts, int range)
+void copy_notes(const set<const Part*>& parts, int range)
{
QMimeData* drag = selected_events_to_mime(parts,range);
@@ -951,11 +951,11 @@ void paste_notes(int max_distance, bool always_new_part, bool never_new_part, Pa
}
// if nothing is selected/relevant, this function returns NULL
-QMimeData* selected_events_to_mime(const set<Part*>& parts, int range)
+QMimeData* selected_events_to_mime(const set<const Part*>& parts, int range)
{
unsigned start_tick = INT_MAX; //will be the tick of the first event or INT_MAX if no events are there
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
for (ciEvent ev=(*part)->events().begin(); ev!=(*part)->events().end(); ev++)
if (is_relevant(ev->second, *part, range))
if (ev->second.tick() < start_tick)
@@ -978,7 +978,7 @@ QMimeData* selected_events_to_mime(const set<Part*>& parts, int range)
Xml xml(tmp);
int level = 0;
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
{
xml.tag(level++, "eventlist part_id=\"%d\"", (*part)->sn());
for (ciEvent ev=(*part)->events().begin(); ev!=(*part)->events().end(); ev++)
@@ -993,7 +993,7 @@ QMimeData* selected_events_to_mime(const set<Part*>& parts, int range)
}
// if nothing is selected/relevant, this function returns NULL
-QMimeData* parts_to_mime(const set<Part*>& parts)
+QMimeData* parts_to_mime(const set<const Part*>& parts)
{
//---------------------------------------------------
@@ -1012,7 +1012,7 @@ QMimeData* parts_to_mime(const set<Part*>& parts)
bool midi=false;
bool wave=false;
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
{
if ((*part)->track()->type() == MusECore::Track::MIDI)
midi=true;
@@ -1226,58 +1226,58 @@ void paste_at(const QString& pt, int pos, int max_distance, bool always_new_part
MusEGlobal::song->update(SC_SELECTION);
}
-void select_all(const std::set<Part*>& parts)
+void select_all(const set<const Part*>& parts)
{
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
for (ciEvent ev_it=(*part)->events().begin(); ev_it!=(*part)->events().end(); ev_it++)
{
- Event& event=ev_it->second;
+ const Event& event=ev_it->second;
event.setSelected(true);
}
MusEGlobal::song->update(SC_SELECTION);
}
-void select_none(const std::set<Part*>& parts)
+void select_none(const set<const Part*>& parts)
{
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
for (ciEvent ev_it=(*part)->events().begin(); ev_it!=(*part)->events().end(); ev_it++)
{
- Event& event=ev_it->second;
+ const Event& event=ev_it->second;
event.setSelected(false);
}
MusEGlobal::song->update(SC_SELECTION);
}
-void select_invert(const std::set<Part*>& parts)
+void select_invert(const set<const Part*>& parts)
{
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
for (ciEvent ev_it=(*part)->events().begin(); ev_it!=(*part)->events().end(); ev_it++)
{
- Event& event=ev_it->second;
+ const Event& event=ev_it->second;
event.setSelected(!event.selected());
}
MusEGlobal::song->update(SC_SELECTION);
}
-void select_in_loop(const std::set<Part*>& parts)
+void select_in_loop(const set<const Part*>& parts)
{
select_none(parts);
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
for (ciEvent ev_it=(*part)->events().begin(); ev_it!=(*part)->events().end(); ev_it++)
{
- Event& event=ev_it->second;
+ const Event& event=ev_it->second;
event.setSelected((event.tick()>=MusEGlobal::song->lpos() && event.endTick()<=MusEGlobal::song->rpos()));
}
MusEGlobal::song->update(SC_SELECTION);
}
-void select_not_in_loop(const std::set<Part*>& parts)
+void select_not_in_loop(const set<const Part*>& parts)
{
select_none(parts);
- for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
- for (diEvent ev_it=(*part)->events().begin(); ev_it!=(*part)->events().end(); ev_it++)
+ for (set<const Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (ciEvent ev_it=(*part)->events().begin(); ev_it!=(*part)->events().end(); ev_it++)
{
- Event& event=ev_it->second;
+ const Event& event=ev_it->second;
event.setSelected(!(event.tick()>=MusEGlobal::song->lpos() && event.endTick()<=MusEGlobal::song->rpos()));
}
MusEGlobal::song->update(SC_SELECTION);
@@ -1314,7 +1314,7 @@ void shrink_parts(int raster)
}
-void schedule_resize_all_same_len_clone_parts(Part* part, unsigned new_len, Undo& operations)
+void schedule_resize_all_same_len_clone_parts(const Part* part, unsigned new_len, Undo& operations)
{
QSet<const Part*> already_done;
@@ -1325,7 +1325,7 @@ void schedule_resize_all_same_len_clone_parts(Part* part, unsigned new_len, Undo
unsigned old_len= part->type() == Pos::FRAMES ? part->lenFrame() : part->lenTick();
if (old_len!=new_len)
{
- Part* part_it=part;
+ const Part* part_it=part;
do
{
if (part->type() == Pos::FRAMES)
@@ -1376,7 +1376,7 @@ void expand_parts(int raster)
void clean_parts()
{
Undo operations;
- set<Part*> already_processed;
+ set<const Part*> already_processed;
TrackList* tracks = MusEGlobal::song->tracks();
for (iTrack track = tracks->begin(); track != tracks->end(); track++)
@@ -1388,7 +1388,7 @@ void clean_parts()
// multiple clones)
unsigned len=0;
- Part* part_it=part->second;
+ const Part* part_it=part->second;
do
{
if (part_it->lenTick() > len)
@@ -1418,31 +1418,31 @@ void clean_parts()
bool merge_selected_parts()
{
- set<Part*> temp = get_all_selected_parts();
+ set<const Part*> temp = get_all_selected_parts();
return merge_parts(temp);
}
-bool merge_parts(const set<Part*>& parts)
+bool merge_parts(const set<const Part*>& parts)
{
- set<Track*> tracks;
- for (set<Part*>::iterator it=parts.begin(); it!=parts.end(); it++)
+ set<const Track*> tracks;
+ for (set<const Part*>::iterator it=parts.begin(); it!=parts.end(); it++)
tracks.insert( (*it)->track() );
Undo operations;
// process tracks separately
- for (set<Track*>::iterator t_it=tracks.begin(); t_it!=tracks.end(); t_it++)
+ for (set<const Track*>::iterator t_it=tracks.begin(); t_it!=tracks.end(); t_it++)
{
- Track* track=*t_it;
+ const Track* track=*t_it;
unsigned begin=INT_MAX, end=0;
- Part* first_part=NULL;
+ const Part* first_part=NULL;
// find begin of the first and end of the last part
- for (set<Part*>::iterator it=parts.begin(); it!=parts.end(); it++)
+ for (set<const Part*>::iterator it=parts.begin(); it!=parts.end(); it++)
if ((*it)->track()==track)
{
- Part* p=*it;
+ const Part* p=*it;
if (p->tick() < begin)
{
begin=p->tick();
@@ -1465,21 +1465,20 @@ bool merge_parts(const set<Part*>& parts)
new_part->setLenTick(end-begin);
// copy all events from the source parts into the new part
- EventList& new_el = new_part->events();
- for (set<Part*>::iterator p_it=parts.begin(); p_it!=parts.end(); p_it++)
+ for (set<const Part*>::iterator p_it=parts.begin(); p_it!=parts.end(); p_it++)
if ((*p_it)->track()==track)
{
- EventList* old_el= (*p_it)->events();
- for (iEvent ev_it=old_el->begin(); ev_it!=old_el->end(); ev_it++)
+ const EventList& old_el= (*p_it)->events();
+ for (ciEvent ev_it=old_el.begin(); ev_it!=old_el.end(); ev_it++)
{
- Event new_event=ev_it->second;
+ Event new_event=ev_it->second.clone();
new_event.setTick( new_event.tick() + (*p_it)->tick() - new_part->tick() );
new_part->nonconst_events().add(new_event);
}
}
// delete all the source parts
- for (set<Part*>::iterator it=parts.begin(); it!=parts.end(); it++)
+ for (set<const Part*>::iterator it=parts.begin(); it!=parts.end(); it++)
if ((*it)->track()==track)
operations.push_back( UndoOp(UndoOp::DeletePart, *it) );
// and add the new one
diff --git a/muse2/muse/functions.h b/muse2/muse/functions.h
index 31c91fe4..b746470c 100644
--- a/muse2/muse/functions.h
+++ b/muse2/muse/functions.h
@@ -39,36 +39,36 @@ class QMimeData;
namespace MusECore {
class Undo;
-std::set<Part*> partlist_to_set(PartList* pl);
-std::set<Part*> part_to_set(Part* p);
-std::map<Event*, Part*> get_events(const std::set<Part*>& parts, int range);
+std::set<const Part*> partlist_to_set(PartList* pl);
+std::set<const Part*> part_to_set(Part* p);
+std::map<const Event*, const Part*> get_events(const std::set<const Part*>& parts, int range);
//these functions simply do their job, non-interactively
-bool modify_velocity(const std::set<Part*>& parts, int range, int rate, int offset=0);
-bool modify_off_velocity(const std::set<Part*>& parts, int range, int rate, int offset=0);
-bool modify_notelen(const std::set<Part*>& parts, int range, int rate, int offset=0);
-bool quantize_notes(const std::set<Part*>& parts, int range, int raster, bool len=false, int strength=100, int swing=0, int threshold=0);
-bool erase_notes(const std::set<Part*>& parts, int range, int velo_threshold=0, bool velo_thres_used=false, int len_threshold=0, bool len_thres_used=false);
-bool delete_overlaps(const std::set<Part*>& parts, int range);
-bool set_notelen(const std::set<Part*>& parts, int range, int len);
-bool move_notes(const std::set<Part*>& parts, int range, signed int ticks);
-bool transpose_notes(const std::set<Part*>& parts, int range, signed int halftonesteps);
-bool crescendo(const std::set<Part*>& parts, int range, int start_val, int end_val, bool absolute);
-bool legato(const std::set<Part*>& parts, int range, int min_len=1, bool dont_shorten=false);
+bool modify_velocity(const std::set<const Part*>& parts, int range, int rate, int offset=0);
+bool modify_off_velocity(const std::set<const Part*>& parts, int range, int rate, int offset=0);
+bool modify_notelen(const std::set<const Part*>& parts, int range, int rate, int offset=0);
+bool quantize_notes(const std::set<const Part*>& parts, int range, int raster, bool len=false, int strength=100, int swing=0, int threshold=0);
+bool erase_notes(const std::set<const Part*>& parts, int range, int velo_threshold=0, bool velo_thres_used=false, int len_threshold=0, bool len_thres_used=false);
+bool delete_overlaps(const std::set<const Part*>& parts, int range);
+bool set_notelen(const std::set<const Part*>& parts, int range, int len);
+bool move_notes(const std::set<const Part*>& parts, int range, signed int ticks);
+bool transpose_notes(const std::set<const Part*>& parts, int range, signed int halftonesteps);
+bool crescendo(const std::set<const Part*>& parts, int range, int start_val, int end_val, bool absolute);
+bool legato(const std::set<const Part*>& parts, int range, int min_len=1, bool dont_shorten=false);
//the below functions automatically open the dialog
//they return true if you click "ok" and false if "abort"
-bool modify_velocity(const std::set<Part*>& parts);
-bool modify_notelen(const std::set<Part*>& parts);
-bool quantize_notes(const std::set<Part*>& parts);
-bool set_notelen(const std::set<Part*>& parts);
-bool move_notes(const std::set<Part*>& parts);
-bool transpose_notes(const std::set<Part*>& parts);
-bool crescendo(const std::set<Part*>& parts);
-bool erase_notes(const std::set<Part*>& parts);
-bool delete_overlaps(const std::set<Part*>& parts);
-bool legato(const std::set<Part*>& parts);
+bool modify_velocity(const std::set<const Part*>& parts);
+bool modify_notelen(const std::set<const Part*>& parts);
+bool quantize_notes(const std::set<const Part*>& parts);
+bool set_notelen(const std::set<const Part*>& parts);
+bool move_notes(const std::set<const Part*>& parts);
+bool transpose_notes(const std::set<const Part*>& parts);
+bool crescendo(const std::set<const Part*>& parts);
+bool erase_notes(const std::set<const Part*>& parts);
+bool delete_overlaps(const std::set<const Part*>& parts);
+bool legato(const std::set<const Part*>& parts);
//the below functions operate on selected parts
bool modify_velocity();
@@ -84,29 +84,29 @@ bool legato();
//functions for copy'n'paste
-void copy_notes(const std::set<Part*>& parts, int range);
-bool paste_notes(Part* paste_into_part=NULL); // shows a dialog
-void paste_notes(int max_distance=3072, bool always_new_part=false, bool never_new_part=false, Part* paste_into_part=NULL, int amount=1, int raster=3072);
-QMimeData* selected_events_to_mime(const std::set<Part*>& parts, int range);
-QMimeData* parts_to_mime(const std::set<Part*>& parts);
+void copy_notes(const std::set<const Part*>& parts, int range);
+bool paste_notes(const Part* paste_into_part=NULL); // shows a dialog
+void paste_notes(int max_distance=3072, bool always_new_part=false, bool never_new_part=false, const Part* paste_into_part=NULL, int amount=1, int raster=3072);
+QMimeData* selected_events_to_mime(const std::set<const Part*>& parts, int range);
+QMimeData* parts_to_mime(const std::set<const Part*>& parts);
-void paste_at(const QString& pt, int pos, int max_distance=3072, bool always_new_part=false, bool never_new_part=false, Part* paste_into_part=NULL, int amount=1, int raster=3072);
+void paste_at(const QString& pt, int pos, int max_distance=3072, bool always_new_part=false, bool never_new_part=false, const Part* paste_into_part=NULL, int amount=1, int raster=3072);
//functions for selections
-void select_all(const std::set<Part*>& parts);
-void select_none(const std::set<Part*>& parts);
-void select_invert(const std::set<Part*>& parts);
-void select_in_loop(const std::set<Part*>& parts);
-void select_not_in_loop(const std::set<Part*>& parts);
+void select_all(const std::set<const Part*>& parts);
+void select_none(const std::set<const Part*>& parts);
+void select_invert(const std::set<const Part*>& parts);
+void select_in_loop(const std::set<const Part*>& parts);
+void select_not_in_loop(const std::set<const Part*>& parts);
//functions for parts
void shrink_parts(int raster=-1); //negative values mean "config.division"
void expand_parts(int raster=-1);
-void schedule_resize_all_same_len_clone_parts(Part* part, unsigned new_len, Undo& operations);
+void schedule_resize_all_same_len_clone_parts(const Part* part, unsigned new_len, Undo& operations);
void clean_parts();
bool merge_selected_parts();
-bool merge_parts(const std::set<Part*>& parts);
+bool merge_parts(const std::set<const Part*>& parts);
// internal
QMimeData* file_to_mimedata(FILE *datafile, QString mimeType);
diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp
index e71be282..75cbce9f 100644
--- a/muse2/muse/helper.cpp
+++ b/muse2/muse/helper.cpp
@@ -108,7 +108,7 @@ Part* partFromSerialNumber(int serial)
return NULL;
}
-bool any_event_selected(const set<Part*>& parts, bool in_range)
+bool any_event_selected(const set<const Part*>& parts, bool in_range)
{
return !get_events(parts, in_range ? 3 : 1).empty();
}
@@ -942,8 +942,8 @@ int populateMidiCtrlMenu(PopupMenu* menu, MusECore::PartList* part_list, MusECor
bool used = false;
for (MusECore::iPart ip = part_list->begin(); ip != part_list->end(); ++ip) {
const MusECore::EventList& el = ip->second->events();
- for (MusECore::iEvent ie = el.begin(); ie != el.end(); ++ie) {
- MusECore::Event e = ie->second;
+ for (MusECore::ciEvent ie = el.begin(); ie != el.end(); ++ie) {
+ const MusECore::Event& e = ie->second;
if(e.type() != MusECore::Controller)
continue;
int ctl_num = e.dataA();
diff --git a/muse2/muse/helper.h b/muse2/muse/helper.h
index 33b2e9a0..b5763a4e 100644
--- a/muse2/muse/helper.h
+++ b/muse2/muse/helper.h
@@ -43,7 +43,7 @@ class PartList;
QString pitch2string(int v);
Part* partFromSerialNumber(int serial);
-bool any_event_selected(const std::set<Part*>&, bool in_range=false);
+bool any_event_selected(const std::set<const Part*>&, bool in_range=false);
bool drummaps_almost_equal(const DrumMap* one, const DrumMap* two, int drummap_size=128);
diff --git a/muse2/muse/importmidi.cpp b/muse2/muse/importmidi.cpp
index 7cd69095..b0affa24 100644
--- a/muse2/muse/importmidi.cpp
+++ b/muse2/muse/importmidi.cpp
@@ -379,7 +379,7 @@ bool MusE::importMidi(const QString name, bool merge)
void MusE::processTrack(MusECore::MidiTrack* track)
{
- const MusECore::EventList& tevents = track->events;
+ MusECore::EventList& tevents = track->events;
if (tevents.empty())
return;
@@ -394,8 +394,8 @@ void MusE::processTrack(MusECore::MidiTrack* track)
MusECore::PartList* pl = track->parts();
int lastTick = 0;
- for (MusECore::iEvent i = tevents.begin(); i != tevents.end(); ++i) {
- MusECore::Event event = i->second;
+ for (MusECore::ciEvent i = tevents.begin(); i != tevents.end(); ++i) {
+ const MusECore::Event& event = i->second;
int epos = event.tick() + event.lenTick();
if (epos > lastTick)
lastTick = epos;
@@ -440,8 +440,8 @@ void MusE::processTrack(MusECore::MidiTrack* track)
st = x1; // begin new part
//HACK:
//lastOff:
- for (MusECore::iEvent i = i1; i != i2; ++i) {
- MusECore::Event event = i->second;
+ for (MusECore::ciEvent i = i1; i != i2; ++i) {
+ const MusECore::Event& event = i->second;
if (event.type() == MusECore::Note) {
int off = event.tick() + event.lenTick();
if (off > lastOff)
@@ -481,7 +481,7 @@ void MusE::processTrack(MusECore::MidiTrack* track)
int startTick = part->tick();
for (MusECore::iEvent i = r1; i != r2; ++i) {
- MusECore::Event ev = i->second;
+ MusECore::Event& ev = i->second;
int ntick = ev.tick() - startTick;
ev.setTick(ntick);
part->nonconst_events().add(ev);
@@ -615,7 +615,7 @@ void MusE::importPartToTrack(QString& filename, unsigned tick, MusECore::Track*
if (tag == "part") {
// Read the part.
MusECore::Part* p = 0;
- p = Part::readFromXml(xml, track);
+ p = MusECore::Part::readFromXml(xml, track);
// If it could not be created...
if(!p)
{
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index e3dac210..893694c3 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -1211,7 +1211,7 @@ void DrumCanvas::resizeEvent(QResizeEvent* ev)
void DrumCanvas::modifySelected(NoteInfo::ValType type, int val, bool delta_mode)
{
- QList< QPair<MusECore::EventList*,MusECore::Event> > already_done;
+ QList< QPair<int,MusECore::Event> > already_done;
MusEGlobal::audio->msgIdle(true);
MusEGlobal::song->startUndo();
for (iCItem i = items.begin(); i != items.end(); ++i) {
@@ -1224,7 +1224,7 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int val, bool delta_mode
MusECore::MidiPart* part = (MusECore::MidiPart*)(e->part());
- if (already_done.contains(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event)))
+ if (already_done.contains(QPair<int,MusECore::Event>(part->clonemaster_sn(), event)))
continue;
MusECore::Event newEvent = event.clone();
@@ -1306,7 +1306,7 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int val, bool delta_mode
// Indicate do not do port controller values and clone parts.
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false));
- already_done.append(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event));
+ already_done.append(QPair<int,MusECore::Event>(part->clonemaster_sn(), event));
}
MusEGlobal::song->endUndo(SC_EVENT_MODIFIED);
MusEGlobal::audio->msgIdle(false);
diff --git a/muse2/muse/midiedit/prcanvas.cpp b/muse2/muse/midiedit/prcanvas.cpp
index a46b5a5c..5be4c090 100644
--- a/muse2/muse/midiedit/prcanvas.cpp
+++ b/muse2/muse/midiedit/prcanvas.cpp
@@ -986,7 +986,7 @@ void PianoCanvas::curPartChanged()
void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int val, bool delta_mode)
{
- QList< QPair<MusECore::EventList*,MusECore::Event> > already_done;
+ QList< QPair<int,MusECore::Event> > already_done;
MusEGlobal::audio->msgIdle(true);
MusEGlobal::song->startUndo();
for (MusEGui::iCItem i = items.begin(); i != items.end(); ++i) {
@@ -999,7 +999,7 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int val, bool
MusECore::MidiPart* part = (MusECore::MidiPart*)(e->part());
- if (already_done.contains(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event)))
+ if (already_done.contains(QPair<int,MusECore::Event>(part->clonemaster_sn(), event)))
continue;
MusECore::Event newEvent = event.clone();
@@ -1069,7 +1069,7 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int val, bool
// Indicate do not do port controller values and clone parts.
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false));
- already_done.append(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event));
+ already_done.append(QPair<int,MusECore::Event>(part->clonemaster_sn(), event));
}
MusEGlobal::song->endUndo(SC_EVENT_MODIFIED);
MusEGlobal::audio->msgIdle(false);
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 54ff0c2f..1b8daefc 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -653,7 +653,7 @@ void ScoreEdit::song_changed(MusECore::SongChangedFlags_t flags)
if (flags & (SC_SELECTION | SC_EVENT_MODIFIED | SC_EVENT_REMOVED))
{
- map<MusECore::Event*, MusECore::Part*> selection=get_events(score_canvas->get_all_parts(),1);
+ map<const MusECore::Event*, const MusECore::Part*> selection=get_events(score_canvas->get_all_parts(),1);
if (selection.empty())
{
apply_velo_to_label->setText(tr("Apply to new notes:"));
@@ -664,7 +664,7 @@ void ScoreEdit::song_changed(MusECore::SongChangedFlags_t flags)
int velo=-1;
int velo_off=-1;
- for (map<MusECore::Event*, MusECore::Part*>::iterator it=selection.begin(); it!=selection.end(); it++)
+ for (map<const MusECore::Event*, const MusECore::Part*>::iterator it=selection.begin(); it!=selection.end(); it++)
if (it->first->type()==MusECore::Note)
{
if (velo==-1) velo=it->first->velo();
@@ -1520,9 +1520,9 @@ void ScoreCanvas::move_staff_below(list<staff_t>::iterator dest, list<staff_t>::
move_staff_above(dest, src);
}
-set<MusECore::Part*> ScoreCanvas::get_all_parts()
+set<const MusECore::Part*> ScoreCanvas::get_all_parts()
{
- set<MusECore::Part*> result;
+ set<const MusECore::Part*> result;
for (list<staff_t>::iterator it=staves.begin(); it!=staves.end(); it++)
result.insert(it->parts.begin(), it->parts.end());
@@ -4504,9 +4504,9 @@ void ScoreCanvas::set_velo_off(int velo)
void ScoreCanvas::deselect_all()
{
- set<MusECore::Part*> all_parts=get_all_parts();
+ set<const MusECore::Part*> all_parts=get_all_parts();
- for (set<MusECore::Part*>::iterator part=all_parts.begin(); part!=all_parts.end(); part++)
+ for (set<const MusECore::Part*>::iterator part=all_parts.begin(); part!=all_parts.end(); part++)
for (MusECore::ciEvent event=(*part)->events().begin(); event!=(*part)->events().end(); event++)
event->second.setSelected(false);
diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h
index cc7acbd5..2175e1d1 100644
--- a/muse2/muse/midiedit/scoreedit.h
+++ b/muse2/muse/midiedit/scoreedit.h
@@ -860,7 +860,7 @@ class ScoreCanvas : public MusEGui::View
MusECore::Part* get_dragged_event_part() {return dragged_event_part;}
void set_dragged_event_part(MusECore::Part* p) {dragged_event_part=p; if (dragged_event_part) dragged_event_part_index=dragged_event_part->sn();}
- set<MusECore::Part*> get_all_parts();
+ set<const MusECore::Part*> get_all_parts();
void write_staves(int level, MusECore::Xml& xml) const;
diff --git a/muse2/muse/midievent.cpp b/muse2/muse/midievent.cpp
index 9fd47eaf..5330b518 100644
--- a/muse2/muse/midievent.cpp
+++ b/muse2/muse/midievent.cpp
@@ -45,7 +45,7 @@ MidiEventBase::MidiEventBase(EventType t)
// MidiEventBase::mid
//---------------------------------------------------------
-EventBase* MidiEventBase::mid(unsigned b, unsigned e)
+EventBase* MidiEventBase::mid(unsigned b, unsigned e) const
{
if (tick() < b || tick() >= e)
return 0;
diff --git a/muse2/muse/midievent.h b/muse2/muse/midievent.h
index 30f0d84f..8aa38f0e 100644
--- a/muse2/muse/midievent.h
+++ b/muse2/muse/midievent.h
@@ -71,7 +71,7 @@ class MidiEventBase : public EventBase {
virtual void dump(int n = 0) const;
virtual void read(Xml&);
virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const;
- virtual EventBase* mid(unsigned, unsigned);
+ virtual EventBase* mid(unsigned, unsigned) const;
};
} // namespace MusECore
diff --git a/muse2/muse/miditransform.cpp b/muse2/muse/miditransform.cpp
index 247fdaf8..75e6f4f7 100644
--- a/muse2/muse/miditransform.cpp
+++ b/muse2/muse/miditransform.cpp
@@ -758,7 +758,7 @@ void MidiTransformerDialog::processEvent(MusECore::Event& event, MusECore::MidiP
// return true if event is selected
//---------------------------------------------------------
-bool MidiTransformerDialog::isSelected(MusECore::Event& event, MusECore::MidiPart*)
+bool MidiTransformerDialog::isSelected(const MusECore::Event& event)
{
MusECore::MidiTransformation* cmt = data->cmt;
@@ -926,8 +926,8 @@ void MidiTransformerDialog::apply()
bool copyExtract = (data->cmt->funcOp == MusECore::Copy)
|| (data->cmt->funcOp == MusECore::Extract);
- std::vector< MusECore::EventList* > doneList;
- typedef std::vector< MusECore::EventList* >::iterator iDoneList;
+ QSet< int > doneList;
+ typedef std::set< int >::iterator iDoneList;
iDoneList idl;
MusECore::MidiTrackList* tracks = MusEGlobal::song->midis();
@@ -941,21 +941,18 @@ void MidiTransformerDialog::apply()
// check wether we must generate a new track
for (MusECore::iPart p = pl->begin(); p != pl->end(); ++p) {
MusECore::MidiPart* part = (MusECore::MidiPart *) p->second;
- MusECore::EventList* el = part->events();
+ const MusECore::EventList& el = part->events();
// Check if the event list has already been done. Skip repeated clones.
- for(idl = doneList.begin(); idl != doneList.end(); ++idl)
- if(*idl == el)
- break;
- if(idl != doneList.end())
+ if (doneList.contains(part->clonemaster_sn()))
break;
- doneList.push_back(el);
+ doneList.insert(part->clonemaster_sn());
- for (MusECore::iEvent i = el->begin(); i != el->end(); ++i) {
- MusECore::Event event = i->second;
+ for (MusECore::ciEvent i = el.begin(); i != el.end(); ++i) {
+ const MusECore::Event& event = i->second;
unsigned tick = event.tick();
if (data->cmt->insideLoop && (tick < MusEGlobal::song->lpos() || tick >= MusEGlobal::song->rpos()))
continue;
- if (isSelected(event, part)) {
+ if (isSelected(event)) {
newTrack = new MusECore::MidiTrack();
tl.push_back(newTrack);
break;
@@ -969,23 +966,20 @@ void MidiTransformerDialog::apply()
for (MusECore::iPart p = pl->begin(); p != pl->end(); ++p) {
MusECore::MidiPart* part = (MusECore::MidiPart *) p->second;
MusECore::MidiPart* newPart = 0;
- MusECore::EventList* el = part->events();
+ const MusECore::EventList& el = part->events();
// Check if the event list has already been done. Skip repeated clones.
- for(idl = doneList.begin(); idl != doneList.end(); ++idl)
- if(*idl == el)
+ if (doneList.contains(part->clonemaster_sn()))
break;
- if(idl != doneList.end())
- break;
- doneList.push_back(el);
+ doneList.insert(part->clonemaster_sn());
if (copyExtract) {
// check wether we must generate a new part
- for (MusECore::iEvent i = el->begin(); i != el->end(); ++i) {
- MusECore::Event event = i->second;
+ for (MusECore::ciEvent i = el.begin(); i != el.end(); ++i) {
+ const MusECore::Event& event = i->second;
unsigned tick = event.tick();
if (data->cmt->insideLoop && (tick < MusEGlobal::song->lpos() || tick >= MusEGlobal::song->rpos()))
continue;
- if (isSelected(event, part)) {
+ if (isSelected(event)) {
newPart = new MusECore::MidiPart(newTrack);
newPart->setName(part->name());
newPart->setColorIndex(part->colorIndex());
@@ -998,12 +992,12 @@ void MidiTransformerDialog::apply()
}
}
MusECore::EventList pel;
- for (MusECore::iEvent i = el->begin(); i != el->end(); ++i) {
- MusECore::Event event = i->second;
+ for (MusECore::ciEvent i = el.begin(); i != el.end(); ++i) {
+ const MusECore::Event& event = i->second;
unsigned tick = event.tick();
if (data->cmt->insideLoop && (tick < MusEGlobal::song->lpos() || tick >= MusEGlobal::song->rpos()))
continue;
- int flag = isSelected(event, part);
+ int flag = isSelected(event);
if (data->cmt->funcOp == MusECore::Select)
event.setSelected(flag);
else if (flag)
@@ -1705,9 +1699,9 @@ void MidiTransformerDialog::insideLoopChanged(bool val)
/*!
- \fn MidiTransformerDialog::typesMatch(MusECore::MidiEvent e, unsigned t)
+ \fn MidiTransformerDialog::typesMatch(const MusECore::MidiEvent e, unsigned t)
*/
-bool MidiTransformerDialog::typesMatch(MusECore::Event& e, unsigned selType)
+bool MidiTransformerDialog::typesMatch(const MusECore::Event& e, unsigned selType)
{
bool matched = false;
switch (selType)
diff --git a/muse2/muse/miditransform.h b/muse2/muse/miditransform.h
index 2ed366bf..997c144d 100644
--- a/muse2/muse/miditransform.h
+++ b/muse2/muse/miditransform.h
@@ -71,9 +71,9 @@ class MidiTransformerDialog : public QDialog, public Ui::MidiTransformDialogBase
virtual void accept();
void setValOp(QWidget* a, QWidget* b, MusECore::ValOp op);
void processEvent(MusECore::Event&, MusECore::MidiPart*, MusECore::MidiPart*);
- bool isSelected(MusECore::Event&, MusECore::MidiPart*);
+ bool isSelected(const MusECore::Event&);
void transformEvent(MusECore::Event&, MusECore::MidiPart*, MusECore::MidiPart*);
- bool typesMatch(MusECore::Event& e, unsigned selType);
+ bool typesMatch(const MusECore::Event& e, unsigned selType);
void updatePresetList();
diff --git a/muse2/muse/part.cpp b/muse2/muse/part.cpp
index 7e99fa2b..9c3f0e38 100644
--- a/muse2/muse/part.cpp
+++ b/muse2/muse/part.cpp
@@ -56,6 +56,8 @@ void Part::unchainClone()
// Isolate the part.
_prevClone = this;
_nextClone = this;
+
+ _clonemaster_sn = this->_sn;
}
void Part::chainClone(Part* p)
@@ -63,17 +65,21 @@ void Part::chainClone(Part* p)
// FIXME assertion
this->unchainClone();
-
+
// Make our links to the chain
this->_prevClone = p;
- this->_nextClone = p->nextClone;
+ this->_nextClone = p->_nextClone;
// Make the chain's links to us
this->_nextClone->_prevClone = this;
p->_nextClone = this;
- // Synchronize this->_events to p->_events
- this->_events = p->_events;
+ // Synchronize this->_events to p->_events. Need to deep-copy, i.e. clone() the Events.
+ this->_events.clear();
+ for (ciEvent it = p->_events.begin(); it!=p->_events.end(); it++)
+ this->_events.insert(std::pair<unsigned, Event>(it->first, it->second.clone()));
+
+ this->_clonemaster_sn = p->_sn;
}
void Part::rechainClone()
@@ -94,22 +100,7 @@ void unchainTrackParts(Track* t, bool decRefCount)
{
PartList* pl = t->parts();
for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
- {
- Part* p = ip->second;
- chainCheckErr(p);
-
- // Do we want to decrease the reference count?
- if(decRefCount)
- p->events()->incARef(-1);
-
- // Unchain the part.
- p->prevClone()->setNextClone(p->nextClone());
- p->nextClone()->setPrevClone(p->prevClone());
-
- // Isolate the part.
- p->setPrevClone(p);
- p->setNextClone(p);
- }
+ ip->second->unchainClone();
}
//---------------------------------------------------------
@@ -119,80 +110,8 @@ void unchainTrackParts(Track* t, bool decRefCount)
void chainTrackParts(Track* t, bool incRefCount)
{
PartList* pl = t->parts();
- for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
- {
- Part* p = ip->second;
- chainCheckErr(p);
-
- // Do we want to increase the reference count?
- if(incRefCount)
- p->events()->incARef(1);
-
- Part* p1 = 0;
-
- // Look for a part with the same event list, that we can chain to.
- // It's faster if track type is known...
-
- if(!t || (t && t->isMidiTrack()))
- {
- MidiTrack* mt = 0;
- MidiTrackList* mtl = MusEGlobal::song->midis();
- for(ciMidiTrack imt = mtl->begin(); imt != mtl->end(); ++imt)
- {
- mt = *imt;
- const PartList* pl = mt->cparts();
- for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
- {
- if(ip->second != p && ip->second->cevents() == p->cevents())
- {
- p1 = ip->second;
- break;
- }
- }
- // If a suitable part was found on a different track, we're done. We will chain to it.
- // Otherwise keep looking for parts on another track. If no others found, then we
- // chain to any suitable part which was found on the same given track t.
- if(p1 && mt != t)
- break;
- }
- }
- if((!p1 && !t) || (t && t->type() == Track::WAVE))
- {
- MusECore::WaveTrack* wt = 0;
- MusECore::WaveTrackList* wtl = MusEGlobal::song->waves();
- for(MusECore::ciWaveTrack iwt = wtl->begin(); iwt != wtl->end(); ++iwt)
- {
- wt = *iwt;
- const PartList* pl = wt->cparts();
- for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
- {
- if(ip->second != p && ip->second->cevents() == p->cevents())
- {
- p1 = ip->second;
- break;
- }
- }
- if(p1 && wt != t)
- break;
- }
- }
-
- // No part found with same event list? Done.
- if(!p1)
- continue;
-
- // Make sure the part to be chained is unchained first.
- p->prevClone()->setNextClone(p->nextClone());
- p->nextClone()->setPrevClone(p->prevClone());
-
- // Link the part to be chained.
- p->setPrevClone(p1);
- p->setNextClone(p1->nextClone());
-
- // Re-link the existing part.
- p1->nextClone()->setPrevClone(p);
- p1->setNextClone(p);
- }
+ for(riPart ip = pl->rbegin(); ip != pl->rend(); ++ip) // walk through in opposite direction than we unchained them.
+ ip->second->rechainClone();
}
//---------------------------------------------------------
@@ -487,7 +406,8 @@ Part::Part(Track* t)
_prevClone = this;
_nextClone = this;
_backupClone = NULL;
- setSn(newSn());
+ _sn = newSn();
+ _clonemaster_sn = _sn;
_track = t;
_selected = false;
_mute = false;
@@ -530,13 +450,6 @@ WavePart::WavePart(WaveTrack* t)
setType(FRAMES);
}
-WavePart::WavePart(WaveTrack* t, EventList* ev)
- : Part(t, ev)
- {
- setType(FRAMES);
- }
-
-
//---------------------------------------------------------
// Part
@@ -730,21 +643,21 @@ void Song::cmdResizePart(Track* track, Part* oPart, unsigned int len, bool doClo
// create two new parts p1 and p2
//---------------------------------------------------------
-void Part::splitPart(int tickpos, Part*& p1, Part*& p2)
+void Part::splitPart(int tickpos, Part*& p1, Part*& p2) const
{
int l1 = 0; // len of first new part (ticks or samples)
int l2 = 0; // len of second new part
int samplepos = MusEGlobal::tempomap.tick2frame(tickpos);
- switch (type()) {
- case WAVE:
+ switch (track()->type()) {
+ case Track::WAVE:
l1 = samplepos - frame();
l2 = lenFrame() - l1;
break;
- case MIDI:
- case DRUM:
- case NEW_DRUM:
+ case Track::MIDI:
+ case Track::DRUM:
+ case Track::NEW_DRUM:
l1 = tickpos - tick();
l2 = lenTick() - l1;
break;
@@ -758,15 +671,15 @@ void Part::splitPart(int tickpos, Part*& p1, Part*& p2)
p1 = this->duplicateEmpty(); // new left part
p2 = this->duplicateEmpty(); // new right part
- switch (type()) {
- case WAVE:
+ switch (track()->type()) {
+ case Track::WAVE:
p1->setLenFrame(l1);
p2->setFrame(samplepos);
p2->setLenFrame(l2);
break;
- case MIDI:
- case DRUM:
- case NEW_DRUM:
+ case Track::MIDI:
+ case Track::DRUM:
+ case Track::NEW_DRUM:
p1->setLenTick(l1);
p2->setTick(tickpos);
p2->setLenTick(l2);
@@ -775,16 +688,14 @@ void Part::splitPart(int tickpos, Part*& p1, Part*& p2)
break;
}
- p2->setSn(p2->newSn());
-
- if (type() == WAVE) {
+ if (track()->type() == Track::WAVE) {
int ps = this->frame();
int d1p1 = p1->frame();
int d2p1 = p1->endFrame();
int d1p2 = p2->frame();
int d2p2 = p2->endFrame();
- for (iEvent ie = _events.begin(); ie != _events.end(); ++ie) {
- Event event = ie->second;
+ for (ciEvent ie = _events.begin(); ie != _events.end(); ++ie) {
+ const Event& event = ie->second;
int s1 = event.frame() + ps;
int s2 = event.endFrame() + ps;
@@ -799,7 +710,7 @@ void Part::splitPart(int tickpos, Part*& p1, Part*& p2)
}
}
else {
- for (iEvent ie = se->begin(); ie != se->end(); ++ie) {
+ for (ciEvent ie = _events.begin(); ie != _events.end(); ++ie) {
Event event = ie->second.clone();
int t = event.tick();
if (t >= l1) {
@@ -824,7 +735,7 @@ void Song::cmdSplitPart(Track* track, Part* part, int tick)
return;
Part* p1;
Part* p2;
- track->splitPart(part, tick, p1, p2);
+ part->splitPart(tick, p1, p2);
MusEGlobal::song->informAboutNewParts(part, p1);
MusEGlobal::song->informAboutNewParts(part, p2);
diff --git a/muse2/muse/part.h b/muse2/muse/part.h
index a9241807..d128460b 100644
--- a/muse2/muse/part.h
+++ b/muse2/muse/part.h
@@ -66,6 +66,7 @@ class Part : public PosLen {
private:
static int snGen;
int _sn;
+ int _clonemaster_sn; // the serial number of some clone in the chain. every member of the chain has the same value here.
QString _name;
bool _selected;
@@ -83,12 +84,13 @@ class Part : public PosLen {
public:
Part(Track*);
virtual ~Part();
- virtual Part* duplicate() = 0;
- virtual Part* duplicateEmpty() = 0;
- virtual Part* createNewClone() = 0;
+ virtual Part* duplicate() const = 0;
+ virtual Part* duplicateEmpty() const = 0;
+ virtual Part* createNewClone() const = 0;
+ virtual void splitPart(int tickpos, Part*& p1, Part*& p2) const;
- int sn() { return _sn; }
- void setSn(int n) { _sn = n; }
+ int clonemaster_sn() const { return _clonemaster_sn; }
+ int sn() const { return _sn; }
int newSn() { return snGen++; }
const QString& name() const { return _name; }
@@ -104,20 +106,18 @@ class Part : public PosLen {
int colorIndex() const { return _colorIndex; }
void setColorIndex(int idx) { _colorIndex = idx; }
- bool hasClones() { return _prevClone!=this || _nextClone!=this; }
- int nClones();
- Part* prevClone() { return _prevClone; }
- Part* nextClone() { return _nextClone; }
+ bool isCloneOf(const Part*) const;
+ bool hasClones() const { return _prevClone!=this || _nextClone!=this; }
+ int nClones() const;
+ Part* prevClone() const { return _prevClone; } // FINDMICHJETZT DELETETHIS 2x
+ Part* nextClone() const { return _nextClone; }
void unchainClone();
void chainClone(Part* p); // *this is made a sibling of p! p is not touched (except for its clone-chain), whereas this->events will get altered
void rechainClone(); // re-chains the part to the same clone chain it was unchained before
// Returns combination of HiddenEventsType enum.
- virtual int hasHiddenEvents() = 0;
- // If repeated calls to hasHiddenEvents() are desired, then to avoid re-iteration of the event list,
- // call this after hasHiddenEvents().
- int cachedHasHiddenEvents() const { return _hiddenEvents; }
+ virtual int hasHiddenEvents() const { return _hiddenEvents; }
iEvent addEvent(Event& p); // DEPRECATED. requires the part to be NOT a clone. FIXME remove!
@@ -136,9 +136,9 @@ class MidiPart : public Part {
public:
MidiPart(MidiTrack* t) : Part((Track*)t) {}
virtual ~MidiPart() {}
- virtual MidiPart* duplicate();
- virtual MidiPart* duplicateEmpty();
- virtual MidiPart* createNewClone();
+ virtual MidiPart* duplicate() const;
+ virtual MidiPart* duplicateEmpty() const;
+ virtual MidiPart* createNewClone() const;
MidiTrack* track() const { return (MidiTrack*)Part::track(); }
@@ -160,11 +160,10 @@ class WavePart : public Part {
public:
WavePart(WaveTrack* t);
- WavePart(WaveTrack* t, EventList* ev);
virtual ~WavePart() {}
- virtual WavePart* duplicate();
- virtual WavePart* duplicateEmpty();
- virtual WavePart* createNewClone();
+ virtual WavePart* duplicate() const;
+ virtual WavePart* duplicateEmpty() const;
+ virtual WavePart* createNewClone() const;
WaveTrack* track() const { return (WaveTrack*)Part::track(); }
// Returns combination of HiddenEventsType enum.
@@ -196,8 +195,6 @@ class PartList : public std::multimap<int, Part*, std::less<unsigned> > {
}
};
-extern void chainClone(Part* p1, Part* p2);
-extern void unchainClone(Part* p);
extern void chainCheckErr(Part* p);
extern void unchainTrackParts(Track* t, bool decRefCount);
extern void chainTrackParts(Track* t, bool incRefCount);
diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp
index a9b9a892..be682f3e 100644
--- a/muse2/muse/song.cpp
+++ b/muse2/muse/song.cpp
@@ -646,8 +646,8 @@ void Song::remapPortDrumCtrlEvents(int mapidx, int newnote, int newchan, int new
for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
{
MidiPart* part = (MidiPart*)(ip->second);
- const EventList* el = part->cevents();
- for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ const EventList& el = part->events();
+ for(ciEvent ie = el.begin(); ie != el.end(); ++ie)
{
const Event& ev = ie->second;
if(ev.type() != Controller)
@@ -850,7 +850,7 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, const EventList& events, unsigned
part->setName(mt->name());
// copy events
for (ciEvent i = s; i != e; ++i) {
- Event old = i->second;
+ const Event& old = i->second;
Event event = old.clone();
event.setTick(old.tick() - startTick);
// addEvent also adds port controller values. So does msgAddPart, below. Let msgAddPart handle them.
@@ -869,8 +869,8 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, const EventList& events, unsigned
if (endTick > part->endTick()) {
// Determine new part length...
endTick = 0;
- for (iEvent i = s; i != e; ++i) {
- Event event = i->second;
+ for (ciEvent i = s; i != e; ++i) {
+ const Event& event = i->second;
unsigned tick = event.tick() - partTick + event.lenTick();
if (endTick < tick)
endTick = tick;
@@ -898,12 +898,11 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, const EventList& events, unsigned
part->nonconst_events().erase(si, ei);
}
- for (iEvent i = s; i != e; ++i) {
- Event event = i->second;
+ for (ciEvent i = s; i != e; ++i) {
+ Event event = i->second.clone();
event.setTick(event.tick() - partTick);
- Event e;
// Create an undo op. Indicate do port controller values and clone parts.
- addUndo(UndoOp(UndoOp::AddEvent, e, event, part, true, true));
+ addUndo(UndoOp(UndoOp::AddEvent, event, part, true, true));
if(part->nonconst_events().find(event) == part->nonconst_events().end())
part->nonconst_events().add(event);
@@ -926,8 +925,8 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, const EventList& events, unsigned
}
part->nonconst_events().erase(si, ei);
}
- for (iEvent i = s; i != e; ++i) {
- Event event = i->second;
+ for (ciEvent i = s; i != e; ++i) {
+ Event event = i->second.clone();
int tick = event.tick() - partTick;
event.setTick(tick);
diff --git a/muse2/muse/steprec.cpp b/muse2/muse/steprec.cpp
index 466c4e21..5bbc38c6 100644
--- a/muse2/muse/steprec.cpp
+++ b/muse2/muse/steprec.cpp
@@ -79,9 +79,9 @@ void StepRec::record(Part* part, int pitch, int len, int step, int velo, bool ct
const EventList& events = part->events();
if (ctrl)
{
- for (iEvent i = events.begin(); i != events.end(); ++i)
+ for (ciEvent i = events.begin(); i != events.end(); ++i)
{
- Event ev = i->second;
+ const Event& ev = i->second;
if (ev.isNote() && ev.pitch() == pitch && ((ev.tick() + ev.lenTick() + part->tick()) == tick))
{
Event e = ev.clone();
@@ -109,7 +109,7 @@ void StepRec::record(Part* part, int pitch, int len, int step, int velo, bool ct
EventRange range = events.equal_range(tick - part->tick());
for (ciEvent i = range.first; i != range.second; ++i)
{
- Event ev = i->second;
+ const Event& ev = i->second;
if (ev.isNote() && ev.pitch() == pitch)
{
MusEGlobal::audio->msgDeleteEvent(ev, part, true, false, false);
@@ -163,9 +163,9 @@ void StepRec::record(Part* part, int pitch, int len, int step, int velo, bool ct
set<const Event*> extend_set;
const EventList& events = part->events();
- for (iEvent i = events.begin(); i != events.end(); ++i)
+ for (ciEvent i = events.begin(); i != events.end(); ++i)
{
- Event& ev = i->second;
+ const Event& ev = i->second;
if (ev.isNote() && note_held_down[ev.pitch()] && ((ev.tick() + ev.lenTick() + part->tick()) == tick))
extend_set.insert(&ev);
}
diff --git a/muse2/muse/structure.cpp b/muse2/muse/structure.cpp
index 98763a4a..0c1d673d 100644
--- a/muse2/muse/structure.cpp
+++ b/muse2/muse/structure.cpp
@@ -167,7 +167,7 @@ void globalCut(bool onlySelectedTracks)
{
// cut Events
const EventList& el = part->events();
- for (iEvent ie = el.lower_bound(len); ie != el.end(); ++ie)
+ for (ciEvent ie = el.lower_bound(len); ie != el.end(); ++ie)
operations.push_back(UndoOp(UndoOp::DeleteEvent,ie->second, part, false, false));
}
operations.push_back(UndoOp(UndoOp::ModifyPartLength, part, part->lenTick(), len, true, true));
@@ -179,9 +179,9 @@ void globalCut(bool onlySelectedTracks)
Part* p1;
Part* p2;
Part* p3;
- track->splitPart(part, lpos, p1, p2);
+ part->splitPart(lpos, p1, p2);
delete p2;
- track->splitPart(part, rpos, p2, p3);
+ part->splitPart(rpos, p2, p3);
delete p2;
p3->setTick(lpos);
@@ -195,7 +195,7 @@ void globalCut(bool onlySelectedTracks)
Part* p1;
Part* p2;
- track->splitPart(part, rpos, p1, p2);
+ part->splitPart(rpos, p1, p2);
delete p1;
p2->setTick(lpos);
@@ -254,7 +254,7 @@ Undo movePartsTotheRight(unsigned int startTicks, int moveTicks, bool only_selec
// split part to insert new space
Part* p1;
Part* p2;
- track->splitPart(part, startTicks, p1, p2);
+ part->splitPart(startTicks, p1, p2);
p2->setTick(startTicks+moveTicks);
MusEGlobal::song->informAboutNewParts(part,p1,p2);
@@ -303,7 +303,7 @@ Undo partSplitter(unsigned int pos, bool onlySelectedTracks)
if (pos > p1 && pos < (p1+l0)) {
Part* p1;
Part* p2;
- track->splitPart(part, pos, p1, p2);
+ part->splitPart(pos, p1, p2);
MusEGlobal::song->informAboutNewParts(part, p1);
MusEGlobal::song->informAboutNewParts(part, p2);
diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp
index 7bb516bb..06bc34e1 100644
--- a/muse2/muse/track.cpp
+++ b/muse2/muse/track.cpp
@@ -589,7 +589,7 @@ void MidiTrack::internal_assign(const Track& t, int flags)
Part* spart = ip->second;
Part* dpart;
if (spart->hasClones())
- dpart = spart->createNewClone()
+ dpart = spart->createNewClone();
else
dpart = spart->duplicate();
@@ -787,7 +787,7 @@ void MidiTrack::setInPortAndChannelMask(unsigned int portmask, int chanmask)
Part* MidiTrack::newPart(Part*p, bool clone)
{
- MidiPart* part = clone ? p->createNewClone() : new MidiPart(this);
+ MidiPart* part = clone ? (MidiPart*)p->createNewClone() : new MidiPart(this);
if (p) {
part->setName(p->name());
part->setColorIndex(p->colorIndex());
diff --git a/muse2/muse/track.h b/muse2/muse/track.h
index 2e8f3af5..f3551ce0 100644
--- a/muse2/muse/track.h
+++ b/muse2/muse/track.h
@@ -158,7 +158,6 @@ class Track {
virtual Part* newPart(Part*p=0, bool clone = false) = 0;
void dump() const;
- virtual void splitPart(Part*, int, Part*&, Part*&);
virtual void setMute(bool val);
virtual void setOff(bool val);
diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp
index 747914e1..dc31f043 100644
--- a/muse2/muse/undo.cpp
+++ b/muse2/muse/undo.cpp
@@ -278,8 +278,8 @@ void cleanOperationGroup(Undo& group)
{
using std::set;
- set<Track*> processed_tracks;
- set<Part*> processed_parts;
+ set<const Track*> processed_tracks;
+ set<const Part*> processed_parts;
for (iUndoOp op=group.begin(); op!=group.end();)
{
@@ -588,7 +588,7 @@ UndoOp::UndoOp(UndoType type_, int a_, int b_, int c_)
}
-UndoOp::UndoOp(UndoType type_, int n, Track* track_)
+UndoOp::UndoOp(UndoType type_, int n, const Track* track_)
{
assert(type_==AddTrack || type_==DeleteTrack);
assert(track_);
@@ -598,7 +598,7 @@ UndoOp::UndoOp(UndoType type_, int n, Track* track_)
track = track_;
}
-UndoOp::UndoOp(UndoType type_, Part* part_, unsigned old_len_or_tick, unsigned new_len_or_tick, bool, bool)
+UndoOp::UndoOp(UndoType type_, const Part* part_, unsigned old_len_or_tick, unsigned new_len_or_tick, bool, bool)
{
assert(type_==AddPart || type_==DeletePart || type_==ModifyPartLength || type_==ModifyPartLengthFrames || type_==ModifyPartTick );
assert(part_);
@@ -609,7 +609,7 @@ UndoOp::UndoOp(UndoType type_, Part* part_, unsigned old_len_or_tick, unsigned n
new_partlen_or_tick=new_len_or_tick;
}
-UndoOp::UndoOp(UndoType type_, const Event& oev, const Event& nev, Part* part_, bool doCtrls_, bool doClones_)
+UndoOp::UndoOp(UndoType type_, const Event& oev, const Event& nev, const Part* part_, bool doCtrls_, bool doClones_)
{
assert(type_==ModifyEvent);
assert(part_);
@@ -622,7 +622,7 @@ UndoOp::UndoOp(UndoType type_, const Event& oev, const Event& nev, Part* part_,
doClones = doClones_;
}
-UndoOp::UndoOp(UndoType type_, const Event& nev, Part* part_, bool doCtrls_, bool doClones_)
+UndoOp::UndoOp(UndoType type_, const Event& nev, const Part* part_, bool doCtrls_, bool doClones_)
{
assert(type_==DeleteEvent || type_==AddEvent);
assert(part_);
@@ -657,7 +657,7 @@ UndoOp::UndoOp(UndoType type_, const char* changedFile, const char* changeData,
endframe = endframe_;
}
-UndoOp::UndoOp(UndoOp::UndoType type_, Part* part_, const char* old_name, const char* new_name)
+UndoOp::UndoOp(UndoOp::UndoType type_, const Part* part_, const char* old_name, const char* new_name)
{
assert(type_==ModifyPartName);
assert(part_);
@@ -672,7 +672,7 @@ UndoOp::UndoOp(UndoOp::UndoType type_, Part* part_, const char* old_name, const
strcpy(_newName, new_name);
}
-UndoOp::UndoOp(UndoOp::UndoType type_, Track* track_, const char* old_name, const char* new_name)
+UndoOp::UndoOp(UndoOp::UndoType type_, const Track* track_, const char* old_name, const char* new_name)
{
assert(type_==ModifyTrackName);
assert(track_);
@@ -687,7 +687,7 @@ UndoOp::UndoOp(UndoOp::UndoType type_, Track* track_, const char* old_name, cons
strcpy(_newName, new_name);
}
-UndoOp::UndoOp(UndoOp::UndoType type_, Track* track_, int old_chan, int new_chan)
+UndoOp::UndoOp(UndoOp::UndoType type_, const Track* track_, int old_chan, int new_chan)
{
assert(type_==ModifyTrackChannel);
assert(track_);
diff --git a/muse2/muse/undo.h b/muse2/muse/undo.h
index 570fd5ab..9997d4cb 100644
--- a/muse2/muse/undo.h
+++ b/muse2/muse/undo.h
@@ -67,11 +67,11 @@ struct UndoOp {
int c;
};
struct {
- Track* track;
+ const Track* track;
int trackno;
};
struct {
- Part* part;
+ const Part* part;
unsigned old_partlen_or_tick; // FIXME FINDMICHJETZT XTicks!!
unsigned new_partlen_or_tick;
};
@@ -88,11 +88,11 @@ struct UndoOp {
const char* tmpwavfile; //!< The file with the changed data
};
struct {
- Marker* realMarker;
+ Marker* realMarker;
Marker* copyMarker;
};
struct {
- Track* _propertyTrack;
+ const Track* _propertyTrack;
int _oldPropValue;
int _newPropValue;
};
@@ -110,15 +110,15 @@ struct UndoOp {
UndoOp();
UndoOp(UndoType type, int a, int b, int c=0);
- UndoOp(UndoType type, int n, Track* track);
- UndoOp(UndoType type, Part* part, unsigned old_len_or_tick=-1, unsigned new_len_or_tick=-1, bool doCtrls=false, bool doClones=false); // FIXME these bools are UNUSED!!. XTICKS!
- UndoOp(UndoType type, Part* part, const char* old_name, const char* new_name);
- UndoOp(UndoType type, const Event& oev, const Event& nev, Part* part, bool doCtrls, bool doClones);
- UndoOp(UndoType type, const Event& nev, Part* part, bool doCtrls, bool doClones);
+ UndoOp(UndoType type, int n, const Track* track);
+ UndoOp(UndoType type, const Part* part, unsigned old_len_or_tick=-1, unsigned new_len_or_tick=-1, bool doCtrls=false, bool doClones=false); // FIXME these bools are UNUSED!!. XTICKS!
+ UndoOp(UndoType type, const Part* part, const char* old_name, const char* new_name);
+ UndoOp(UndoType type, const Event& oev, const Event& nev, const Part* part, bool doCtrls, bool doClones);
+ UndoOp(UndoType type, const Event& nev, const Part* part, bool doCtrls, bool doClones);
UndoOp(UndoType type, const char* changedFile, const char* changeData, int startframe, int endframe);
UndoOp(UndoType type, Marker* copyMarker, Marker* realMarker);
- UndoOp(UndoType type, Track* track, const char* old_name, const char* new_name);
- UndoOp(UndoType type, Track* track, int old_chan, int new_chan);
+ UndoOp(UndoType type, const Track* track, const char* old_name, const char* new_name);
+ UndoOp(UndoType type, const Track* track, int old_chan, int new_chan);
};
class Undo : public std::list<UndoOp> {
diff --git a/muse2/muse/waveedit/wavecanvas.cpp b/muse2/muse/waveedit/wavecanvas.cpp
index 5bbe2f1f..0ba0bdbc 100644
--- a/muse2/muse/waveedit/wavecanvas.cpp
+++ b/muse2/muse/waveedit/wavecanvas.cpp
@@ -1936,7 +1936,7 @@ void WaveCanvas::cmd(int cmd)
newEvent->setLenTick(MusEGlobal::song->rpos() - MusEGlobal::song->lpos());
tempPart->addEvent(*newEvent);
}
- std::set<MusECore::Part*> partList;
+ std::set<const MusECore::Part*> partList;
partList.insert(tempPart);
QMimeData *mimeData = MusECore::parts_to_mime(partList);
@@ -2585,7 +2585,7 @@ void WaveCanvas::curPartChanged()
void WaveCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int val, bool delta_mode)
{
// TODO: New WaveCanvas: Convert this routine to frames and remove unneeded operations.
- QList< QPair<MusECore::EventList*,MusECore::Event> > already_done;
+ QList< QPair<int,MusECore::Event> > already_done;
MusEGlobal::audio->msgIdle(true);
MusEGlobal::song->startUndo();
for (MusEGui::iCItem i = items.begin(); i != items.end(); ++i) {
@@ -2598,7 +2598,7 @@ void WaveCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int val, bool d
MusECore::WavePart* part = (MusECore::WavePart*)(e->part());
- if (already_done.contains(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event)))
+ if (already_done.contains(QPair<int,MusECore::Event>(part->clonemaster_sn(), event)))
continue;
MusECore::Event newEvent = event.clone();
@@ -2668,7 +2668,7 @@ void WaveCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int val, bool d
// Indicate do not do port controller values and clone parts.
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false));
- already_done.append(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event));
+ already_done.append(QPair<int,MusECore::Event>(part->clonemaster_sn(), event));
}
MusEGlobal::song->endUndo(SC_EVENT_MODIFIED);
MusEGlobal::audio->msgIdle(false);
diff --git a/muse2/muse/waveevent.cpp b/muse2/muse/waveevent.cpp
index 38ae10c6..842e40b9 100644
--- a/muse2/muse/waveevent.cpp
+++ b/muse2/muse/waveevent.cpp
@@ -53,7 +53,7 @@ WaveEventBase::WaveEventBase(EventType t)
// WaveEventBase::clone
//---------------------------------------------------------
-EventBase* WaveEventBase::clone()
+EventBase* WaveEventBase::clone() const
{
return new WaveEventBase(*this);
}
@@ -62,7 +62,7 @@ EventBase* WaveEventBase::clone()
// WaveEvent::mid
//---------------------------------------------------------
-EventBase* WaveEventBase::mid(unsigned b, unsigned e)
+EventBase* WaveEventBase::mid(unsigned b, unsigned e) const
{
WaveEventBase* ev = new WaveEventBase(*this);
unsigned fr = frame();
diff --git a/muse2/muse/waveevent.h b/muse2/muse/waveevent.h
index e539342c..4174e3f5 100644
--- a/muse2/muse/waveevent.h
+++ b/muse2/muse/waveevent.h
@@ -52,7 +52,7 @@ class WaveEventBase : public EventBase {
virtual void read(Xml&);
virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const;
- virtual EventBase* mid(unsigned, unsigned);
+ virtual EventBase* mid(unsigned, unsigned) const;
virtual void dump(int n = 0) const;
diff --git a/muse2/muse/wavetrack.cpp b/muse2/muse/wavetrack.cpp
index 4faaca43..ce11b222 100644
--- a/muse2/muse/wavetrack.cpp
+++ b/muse2/muse/wavetrack.cpp
@@ -62,7 +62,7 @@ void WaveTrack::internal_assign(const Track& t, int flags)
Part* spart = ip->second;
Part* dpart;
if (spart->hasClones())
- dpart = spart->createNewClone()
+ dpart = spart->createNewClone();
else
dpart = spart->duplicate();
@@ -214,7 +214,7 @@ void WaveTrack::read(Xml& xml)
Part* WaveTrack::newPart(Part*p, bool clone)
{
- WavePart* part = clone ? p->createNewClone() : new WavePart(this);
+ WavePart* part = clone ? (WavePart*)p->createNewClone() : new WavePart(this);
if (p) {
part->setName(p->name());
part->setColorIndex(p->colorIndex());