X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_playlist.cc;h=9c1e338b6c320e9ce9981df9e9e6c9695d1c3677;hb=16a8762dd494adb68756b8d549f349ed7bdccd9b;hp=443c5b57bf49681f1643fd7545b93a67f01e404b;hpb=d752986314eb37151983393c1d62efefe503e47c;p=ardour.git diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 443c5b57bf..9c1e338b6c 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -1,17 +1,17 @@ /* - Copyright (C) 2006 Paul Davis - Written by Dave Robillard, 2006 + Copyright (C) 2006 Paul Davis + Author: David Robillard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -20,441 +20,317 @@ #include #include +#include +#include #include -#include - -#include -#include -#include -#include -#include +#include "evoral/EventList.hpp" -#include +#include "ardour/debug.h" +#include "ardour/midi_model.h" +#include "ardour/midi_playlist.h" +#include "ardour/midi_region.h" +#include "ardour/types.h" #include "i18n.h" using namespace ARDOUR; -using namespace sigc; +using namespace PBD; using namespace std; -MidiPlaylist::State::~State () -{} - MidiPlaylist::MidiPlaylist (Session& session, const XMLNode& node, bool hidden) - : Playlist (session, node, DataType::MIDI, hidden) + : Playlist (session, node, DataType::MIDI, hidden) + , _note_mode(Sustained) { +#ifndef NDEBUG const XMLProperty* prop = node.property("type"); assert(prop && DataType(prop->value()) == DataType::MIDI); +#endif - in_set_state = true; - set_state (node); - in_set_state = false; - - save_state (_("initial state")); - - if (!hidden) { - PlaylistCreated (this); /* EMIT SIGNAL */ + in_set_state++; + if (set_state (node, Stateful::loading_state_version)) { + throw failed_constructor (); } + in_set_state--; + + relayer (); } MidiPlaylist::MidiPlaylist (Session& session, string name, bool hidden) - : Playlist (session, name, DataType::MIDI, hidden) + : Playlist (session, name, DataType::MIDI, hidden) + , _note_mode(Sustained) { - save_state (_("initial state")); - - if (!hidden) { - PlaylistCreated (this); /* EMIT SIGNAL */ - } - } -MidiPlaylist::MidiPlaylist (const MidiPlaylist& other, string name, bool hidden) - : Playlist (other, name, hidden) +MidiPlaylist::MidiPlaylist (boost::shared_ptr other, string name, bool hidden) + : Playlist (other, name, hidden) + , _note_mode(other->_note_mode) { - throw; // nope - save_state (_("initial state")); - - /* - list::const_iterator in_o = other.regions.begin(); - list::iterator in_n = regions.begin(); - - while (in_o != other.regions.end()) { - MidiRegion *ar = dynamic_cast( (*in_o) ); - - for (list::const_iterator xfades = other._crossfades.begin(); xfades != other._crossfades.end(); ++xfades) { - if ( &(*xfades)->in() == ar) { - // We found one! Now copy it! - - list::const_iterator out_o = other.regions.begin(); - list::const_iterator out_n = regions.begin(); - - while (out_o != other.regions.end()) { - - MidiRegion *ar2 = dynamic_cast( (*out_o) ); - - if ( &(*xfades)->out() == ar2) { - MidiRegion *in = dynamic_cast( (*in_n) ); - MidiRegion *out = dynamic_cast( (*out_n) ); - Crossfade *new_fade = new Crossfade( *(*xfades), in, out); - add_crossfade(*new_fade); - break; - } - - out_o++; - out_n++; - } - // cerr << "HUH!? second region in the crossfade not found!" << endl; - } - } - - in_o++; - in_n++; - } -*/ - if (!hidden) { - PlaylistCreated (this); /* EMIT SIGNAL */ - } } -MidiPlaylist::MidiPlaylist (const MidiPlaylist& other, jack_nframes_t start, jack_nframes_t cnt, string name, bool hidden) - : Playlist (other, start, cnt, name, hidden) +MidiPlaylist::MidiPlaylist (boost::shared_ptr other, framepos_t start, framecnt_t dur, string name, bool hidden) + : Playlist (other, start, dur, name, hidden) + , _note_mode(other->_note_mode) { - save_state (_("initial state")); - /* this constructor does NOT notify others (session) */ } MidiPlaylist::~MidiPlaylist () { - set all_regions; - - GoingAway (this); - - /* find every region we've ever used, and add it to the set of - all regions. - */ - - for (RegionList::iterator x = regions.begin(); x != regions.end(); ++x) { - all_regions.insert (*x); - } - - for (StateMap::iterator i = states.begin(); i != states.end(); ++i) { - - MidiPlaylist::State* apstate = dynamic_cast (*i); - - for (RegionList::iterator r = apstate->regions.begin(); r != apstate->regions.end(); ++r) { - all_regions.insert (*r); - } - - delete apstate; - } - - /* delete every region */ - - for (set::iterator ar = all_regions.begin(); ar != all_regions.end(); ++ar) { - (*ar)->unlock_sources (); - delete *ar; - } - } -struct RegionSortByLayer -{ - bool operator() (Region *a, Region *b) - { - return a->layer() < b->layer(); - } +template +struct EventsSortByTimeAndType { + bool operator() (Evoral::Event