part-way through getting the audioengine changes to compile
[ardour.git] / libs / ardour / midi_region.cc
index c79c4e4bd23989c3c833ba004dd41fb0281f8e6f..8509e55f97017a06597897bbdcc92e5615edd4d9 100644 (file)
 
 #include <set>
 
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 
-#include "pbd/basename.h"
 #include "pbd/xml++.h"
-#include "pbd/enumwriter.h"
+#include "pbd/basename.h"
 
 #include "ardour/automation_control.h"
-#include "ardour/dB.h"
-#include "ardour/gain.h"
 #include "ardour/midi_model.h"
 #include "ardour/midi_region.h"
 #include "ardour/midi_ring_buffer.h"
 #include "ardour/midi_source.h"
-#include "ardour/playlist.h"
 #include "ardour/region_factory.h"
 #include "ardour/session.h"
 #include "ardour/tempo.h"
@@ -129,17 +125,17 @@ MidiRegion::~MidiRegion ()
 /** Create a new MidiRegion that has its own version of some/all of the Source used by another.
  */
 boost::shared_ptr<MidiRegion>
-MidiRegion::clone () const
+MidiRegion::clone (string path) const
 {
        BeatsFramesConverter bfc (_session.tempo_map(), _position);
        Evoral::MusicalTime const bbegin = bfc.from (_start);
        Evoral::MusicalTime const bend = bfc.from (_start + _length);
 
-       boost::shared_ptr<MidiSource> ms = midi_source(0)->clone (bbegin, bend);
+       boost::shared_ptr<MidiSource> ms = midi_source(0)->clone (path, bbegin, bend);
 
        PropertyList plist;
 
-       plist.add (Properties::name, ms->name());
+       plist.add (Properties::name, PBD::basename_nosuffix (ms->name()));
        plist.add (Properties::whole_file, true);
        plist.add (Properties::start, _start);
        plist.add (Properties::start_beats, _start_beats);
@@ -154,7 +150,7 @@ void
 MidiRegion::post_set (const PropertyChange& pc)
 {
        Region::post_set (pc);
-       
+
        if (pc.contains (Properties::length) && !pc.contains (Properties::length_beats)) {
                update_length_beats ();
        } else if (pc.contains (Properties::start) && !pc.contains (Properties::start_beats)) {
@@ -258,7 +254,7 @@ MidiRegion::_read_at (const SourceList& /*srcs*/, Evoral::EventSink<framepos_t>&
        src->set_note_mode(mode);
 
        /*
-         cerr << "MR read @ " << position << " * " << to_read
+         cerr << "MR " << name () << " read @ " << position << " * " << to_read
          << " _position = " << _position
          << " _start = " << _start
          << " intoffset = " << internal_offset
@@ -350,12 +346,6 @@ MidiRegion::model() const
        return midi_source()->model();
 }
 
-int
-MidiRegion::exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&)
-{
-       return -1;
-}
-
 boost::shared_ptr<MidiSource>
 MidiRegion::midi_source (uint32_t n) const
 {
@@ -417,7 +407,7 @@ MidiRegion::model_automation_state_changed (Evoral::Parameter const & p)
           for a given set of filtered_parameters, so now that we've changed that list we must invalidate
           the iterator.
        */
-       Glib::Mutex::Lock lm (midi_source(0)->mutex());
+       Glib::Threads::Mutex::Lock lm (midi_source(0)->mutex());
        midi_source(0)->invalidate ();
 }
 
@@ -431,6 +421,7 @@ MidiRegion::fix_negative_start ()
 
        model()->insert_silence_at_start (c.from (-_start));
        _start = 0;
+       _start_beats = 0;
 }
 
 /** Transpose the notes in this region by a given number of semitones */
@@ -440,3 +431,10 @@ MidiRegion::transpose (int semitones)
        BeatsFramesConverter c (_session.tempo_map(), _start);
        model()->transpose (c.from (_start), c.from (_start + _length), semitones);
 }
+
+void
+MidiRegion::set_start_internal (framecnt_t s)
+{
+       Region::set_start_internal (s);
+       set_start_beats_from_start_frames ();
+}