Respond to MMC even when synced to JACK. Fixes #3700.
[ardour.git] / libs / ardour / ardour / export_format_base.h
index 210452add2814c91d87ae5513d8196e30db4ff28..00da1c75c88e1b158e429ad3f7cc36dd866ae7ed 100644 (file)
 #define __ardour_export_format_base_h__
 
 #include <set>
-#include <string>
 #include <algorithm>
 #include <boost/shared_ptr.hpp>
-#include <glibmm/ustring.h>
+#include <string>
 
 #include <sndfile.h>
 #include <samplerate.h>
-#include <ardour/gdither_types.h>
-#include <ardour/ardour.h>
 
-using std::string;
+#include "ardour/ardour.h"
+
+#include "audiographer/general/sample_format_converter.h"
 
 namespace ARDOUR
 {
@@ -46,7 +45,7 @@ class ExportFormatBase {
                T_None = 0,
                T_Sndfile
        };
-       
+
        enum FormatId {
                F_None = 0,
                F_WAV = SF_FORMAT_WAV,
@@ -58,7 +57,7 @@ class ExportFormatBase {
                F_FLAC = SF_FORMAT_FLAC,
                F_Ogg = SF_FORMAT_OGG
        };
-       
+
        enum Endianness {
                E_FileDefault = SF_ENDIAN_FILE, /* Default file endian-ness. */
                E_Little = SF_ENDIAN_LITTLE,    /* Force little endian-ness. */
@@ -77,14 +76,14 @@ class ExportFormatBase {
                SF_Double = SF_FORMAT_DOUBLE,
                SF_Vorbis = SF_FORMAT_VORBIS
        };
-       
+
        enum DitherType {
-               D_None = GDitherNone,
-               D_Rect = GDitherRect,
-               D_Tri = GDitherTri,
-               D_Shaped = GDitherShaped
+               D_None = AudioGrapher::D_None,
+               D_Rect = AudioGrapher::D_Rect,
+               D_Tri = AudioGrapher::D_Tri,
+               D_Shaped = AudioGrapher::D_Shaped
        };
-       
+
        enum Quality {
                Q_None = 0,
                Q_Any,
@@ -92,9 +91,10 @@ class ExportFormatBase {
                Q_LosslessCompression,
                Q_LossyCompression
        };
-       
+
        enum SampleRate {
                SR_None = 0,
+               SR_Session = 1,
                SR_22_05 = 220500,
                SR_44_1 = 44100,
                SR_48 = 48000,
@@ -102,7 +102,7 @@ class ExportFormatBase {
                SR_96 = 96000,
                SR_192 = 192000
        };
-       
+
        enum SRCQuality {
                SRC_SincBest = SRC_SINC_BEST_QUALITY,
                SRC_SincMedium = SRC_SINC_MEDIUM_QUALITY,
@@ -110,41 +110,41 @@ class ExportFormatBase {
                SRC_ZeroOrderHold = SRC_ZERO_ORDER_HOLD,
                SRC_Linear = SRC_LINEAR
        };
-       
+
        /// Class for managing selection and compatibility states
        class SelectableCompatible {
          public:
-               SelectableCompatible () :
-                 _selected (false), _compatible (true) { }
+               SelectableCompatible ()
+                       : _selected (false), _compatible (true) { }
                ~SelectableCompatible () {}
-               
-               sigc::signal<void, bool> SelectChanged;
-               sigc::signal<void, bool> CompatibleChanged;
-               
+
+               PBD::Signal1<void,bool> SelectChanged;
+               PBD::Signal1<void,bool> CompatibleChanged;
+
                bool selected () const { return _selected; }
                bool compatible () const { return _compatible; }
-               Glib::ustring name () const { return _name; }
-               
+               std::string name () const { return _name; }
+
                void set_selected (bool value);
                void set_compatible (bool value);
-               
+
          protected:
-               void set_name (Glib::ustring name) { _name = name; }
-               
+               void set_name (std::string name) { _name = name; }
+
          private:
                bool _selected;
                bool _compatible;
-               
-               Glib::ustring _name;
+
+               std::string _name;
        };
 
   public:
 
        ExportFormatBase ();
        ExportFormatBase (ExportFormatBase const & other);
-       
+
        virtual ~ExportFormatBase ();
-       
+
        boost::shared_ptr<ExportFormatBase> get_intersection (ExportFormatBase const & other) const;
        boost::shared_ptr<ExportFormatBase> get_difference (ExportFormatBase const & other) const;
        boost::shared_ptr<ExportFormatBase> get_union (ExportFormatBase const & other) const;
@@ -154,15 +154,17 @@ class ExportFormatBase {
        bool sample_rates_empty () const { return sample_rates.empty (); }
        bool formats_empty () const { return format_ids.empty (); }
        bool qualities_empty () const { return qualities.empty (); }
-       
+
        bool has_endianness (Endianness endianness) const { return endiannesses.find (endianness) != endiannesses.end() ; }
        bool has_sample_format (SampleFormat format) const { return sample_formats.find (format) != sample_formats.end(); }
        bool has_sample_rate (SampleRate rate) const { return sample_rates.find (rate) != sample_rates.end(); }
        bool has_format (FormatId format) const { return format_ids.find (format) != format_ids.end(); }
        bool has_quality (Quality quality) const { return qualities.find (quality) != qualities.end(); }
+
+       void set_extension (std::string const & extension) { _extension = extension; }
+       std::string const & extension () const { return _extension; }
        
-       void set_extension (Glib::ustring const & extension) { _extension = extension; }
-       Glib::ustring const & extension () const { return _extension; }
+       static SampleRate nearest_sample_rate (framecnt_t sample_rate);
 
   protected:
 
@@ -175,22 +177,22 @@ class ExportFormatBase {
        typedef std::set<SampleRate> SampleRateSet;
        typedef std::set<FormatId> FormatSet;
        typedef std::set<Quality> QualitySet;
-       
+
        EndianSet       endiannesses;
        SampleRateSet   sample_rates;
        FormatSet       format_ids;
        QualitySet      qualities;
-       
+
   private:
 
-       Glib::ustring  _extension;
-       
+       std::string  _extension;
+
        enum SetOperation {
                SetUnion,
                SetDifference,
                SetIntersection
        };
-       
+
        boost::shared_ptr<ExportFormatBase> do_set_operation (ExportFormatBase const & other, SetOperation operation) const;
 };