X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_playlist.cc;h=67764d66aeefa5880d5c1a6f6ccd6c7336ba1925;hb=b25cd7683b25a502094a2ecefbadb4b7d6e6db09;hp=49b5ff2c4f6f8282fd967301456586dfe20bc478;hpb=33da74c8e353ac56194956cae8e2b7d74ec1a1b0;p=ardour.git diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 49b5ff2c4f..67764d66ae 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -1,6 +1,6 @@ /* Copyright (C) 2006 Paul Davis - Written by Dave Robillard, 2006 + 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 @@ -17,204 +17,290 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include - #include +#include +#include +#include +#include -#include - -#include +#include "evoral/EventList.hpp" +#include "evoral/Control.hpp" -#include "ardour/types.h" -#include "ardour/configuration.h" +#include "ardour/beats_frames_converter.h" +#include "ardour/debug.h" +#include "ardour/midi_model.h" #include "ardour/midi_playlist.h" #include "ardour/midi_region.h" +#include "ardour/midi_source.h" +#include "ardour/midi_state_tracker.h" #include "ardour/session.h" -#include "ardour/midi_ring_buffer.h" - -#include "pbd/error.h" +#include "ardour/types.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace ARDOUR; -using namespace sigc; +using namespace PBD; using namespace std; MidiPlaylist::MidiPlaylist (Session& session, const XMLNode& node, bool hidden) - : Playlist (session, node, DataType::MIDI, hidden) - , _note_mode(Sustained) + : Playlist (session, node, DataType::MIDI, hidden) + , _note_mode(Sustained) + , _read_end(0) { - const XMLProperty* prop = node.property("type"); +#ifndef NDEBUG + XMLProperty const * prop = node.property("type"); assert(prop && DataType(prop->value()) == DataType::MIDI); +#endif in_set_state++; - set_state (node, Stateful::loading_state_version); + 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) + , _read_end(0) { } MidiPlaylist::MidiPlaylist (boost::shared_ptr other, string name, bool hidden) - : Playlist (other, name, hidden) + : Playlist (other, name, hidden) + , _note_mode(other->_note_mode) + , _read_end(0) { - throw; // nope - - /* - 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++; - } -*/ } -MidiPlaylist::MidiPlaylist (boost::shared_ptr other, nframes_t start, nframes_t dur, string name, bool hidden) - : Playlist (other, start, dur, 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) + , _read_end(0) { - /* this constructor does NOT notify others (session) */ } MidiPlaylist::~MidiPlaylist () { - GoingAway (); /* EMIT SIGNAL */ - - /* drop connections to signals */ - - notify_callbacks (); } -struct RegionSortByLayer { - bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - return a->layer() < b->layer(); +template +struct EventsSortByTimeAndType { + bool operator() (const Evoral::Event