remove all remaining vestiges of per-track varispeed from libardour
[ardour.git] / libs / ardour / audiofilesource.cc
index bb3c18f810470ed3b33853da73b2dece1d0ba686..ee8364212fb888c54dd1d5aea63841c1bf998caa 100644 (file)
@@ -61,7 +61,7 @@
 #include <AudioToolbox/AudioFormat.h>
 #endif // HAVE_COREAUDIO
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -131,7 +131,12 @@ AudioFileSource::AudioFileSource (Session& s, const string& path, Source::Flag f
 }
 
 
-/** Constructor used for existing internal-to-session files via XML.  File must exist. */
+/** Constructor used for sources listed in session-files (XML)
+ * and missing sources (SilentFileSource).
+ *
+ * If _origin is an absolute path after ::set_state(), then the
+ * file is external to the session.
+ */
 AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist)
        : Source (s, node)
        , AudioSource (s, node)
@@ -141,6 +146,10 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exi
                throw failed_constructor ();
        }
 
+       if (Glib::path_is_absolute (_origin)) {
+               _path = _origin;
+       }
+
        if (init (_path, must_exist)) {
                throw failed_constructor ();
        }
@@ -199,10 +208,9 @@ XMLNode&
 AudioFileSource::get_state ()
 {
        XMLNode& root (AudioSource::get_state());
-       char buf[32];
-       snprintf (buf, sizeof (buf), "%u", _channel);
-       root.add_property (X_("channel"), buf);
-        root.add_property (X_("origin"), _origin);
+       root.set_property (X_("channel"), _channel);
+       root.set_property (X_("origin"), _origin);
+       root.set_property (X_("gain"), _gain);
        return root;
 }
 
@@ -274,6 +282,20 @@ AudioFileSource::setup_peakfile ()
        }
 }
 
+void
+AudioFileSource::set_gain (float g, bool temporarily)
+{
+       if (_gain == g) {
+               return;
+       }
+       _gain = g;
+       if (temporarily) {
+               return;
+       }
+       close_peakfile();
+       setup_peakfile ();
+}
+
 bool
 AudioFileSource::safe_audio_file_extension(const string& file)
 {