revert inadvertently committed debug settings
[ardour.git] / libs / ardour / export_format_base.cc
index a994b97ac3bbe30498efbac605a78f187949a9ad..1eda44991550f3e6267170c3f3718faef8c80fc7 100644 (file)
@@ -70,12 +70,6 @@ ExportFormatBase::get_intersection (ExportFormatBase const & other) const
        return do_set_operation (other, SetIntersection);
 }
 
-boost::shared_ptr<ExportFormatBase>
-ExportFormatBase::get_difference (ExportFormatBase const & other) const
-{
-       return do_set_operation (other, SetDifference);
-}
-
 boost::shared_ptr<ExportFormatBase>
 ExportFormatBase::get_union (ExportFormatBase const & other) const
 {
@@ -101,9 +95,6 @@ ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation
                  case SetIntersection:
                        std::set_intersection (start1, end1, start2, end2, insert);
                        break;
-                 case SetDifference:
-                       std::set_difference (start1, end1, start2, end2, insert);
-                       break;
                  case SetUnion:
                        std::set_union (start1, end1, start2, end2, insert);
                        break;
@@ -122,9 +113,6 @@ ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation
                  case SetIntersection:
                        std::set_intersection (start1, end1, start2, end2, insert);
                        break;
-                 case SetDifference:
-                       std::set_difference (start1, end1, start2, end2, insert);
-                       break;
                  case SetUnion:
                        std::set_union (start1, end1, start2, end2, insert);
                        break;
@@ -144,9 +132,6 @@ ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation
                  case SetIntersection:
                        std::set_intersection (start1, end1, start2, end2, insert);
                        break;
-                 case SetDifference:
-                       std::set_difference (start1, end1, start2, end2, insert);
-                       break;
                  case SetUnion:
                        std::set_union (start1, end1, start2, end2, insert);
                        break;
@@ -165,9 +150,6 @@ ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation
                  case SetIntersection:
                        std::set_intersection (start1, end1, start2, end2, insert);
                        break;
-                 case SetDifference:
-                       std::set_difference (start1, end1, start2, end2, insert);
-                       break;
                  case SetUnion:
                        std::set_union (start1, end1, start2, end2, insert);
                        break;
@@ -186,9 +168,6 @@ ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation
                  case SetIntersection:
                        std::set_intersection (start1, end1, start2, end2, insert);
                        break;
-                 case SetDifference:
-                       std::set_difference (start1, end1, start2, end2, insert);
-                       break;
                  case SetUnion:
                        std::set_union (start1, end1, start2, end2, insert);
                        break;
@@ -198,4 +177,30 @@ ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation
        return result;
 }
 
+ExportFormatBase::SampleRate
+ExportFormatBase::nearest_sample_rate (framecnt_t sample_rate)
+{
+       int diff = 0;
+       int smallest_diff = INT_MAX;
+       SampleRate best_match = SR_None;
+
+       #define DO_SR_COMPARISON(rate) \
+       diff = std::fabs((double)((rate) - sample_rate)); \
+       if(diff < smallest_diff) { \
+               smallest_diff = diff; \
+               best_match = (rate); \
+       }
+
+       DO_SR_COMPARISON(SR_8);
+       DO_SR_COMPARISON(SR_22_05);
+       DO_SR_COMPARISON(SR_44_1);
+       DO_SR_COMPARISON(SR_48);
+       DO_SR_COMPARISON(SR_88_2);
+       DO_SR_COMPARISON(SR_96);
+       DO_SR_COMPARISON(SR_192);
+
+       return best_match;
+       #undef DO_SR_COMPARISON
+}
+
 }; // namespace ARDOUR