Replace use of pbd/filesystem.h with Glib alternative
[ardour.git] / libs / ardour / midi_region.cc
index fe98261248447be7f07f7da3b3c4f63c3dbce140..518413e2de20da3d3eca1a2e919c045701fc5a3b 100644 (file)
 
 #include <glibmm/thread.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)) {
@@ -425,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 */
@@ -434,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 ();
+}