Backwards compatible sndfile support
authorRobin Gareus <robin@gareus.org>
Thu, 22 Nov 2018 19:36:41 +0000 (20:36 +0100)
committerRobin Gareus <robin@gareus.org>
Thu, 22 Nov 2018 19:36:41 +0000 (20:36 +0100)
SFC_SET_COMPRESSION_LEVEL was only added in 2012 and only available in
libsndfile 1.0.26 or later.

libs/ardour/export_graph_builder.cc

index f9b9ad1b561ee553f08125c8466be8cf79b96337..dad0f47219ef9e227f3a6948792abde9f04565bd 100644 (file)
@@ -307,10 +307,13 @@ ExportGraphBuilder::Encoder::init_writer (boost::shared_ptr<AudioGrapher::Sndfil
        writer.reset (new AudioGrapher::SndfileWriter<T> (writer_filename, format, channels, config.format->sample_rate(), config.broadcast_info));
        writer->FileWritten.connect_same_thread (copy_files_connection, boost::bind (&ExportGraphBuilder::Encoder::copy_files, this, _1));
        if (format & ExportFormatBase::SF_Vorbis) {
-               /* libsndfile uses range 0..1 (best .. worst) */
+               /* libsndfile uses range 0..1 (worst.. best) for
+                * SFC_SET_VBR_ENCODING_QUALITY and maps
+                * SFC_SET_COMPRESSION_LEVEL = 1.0 - VBR_ENCODING_QUALITY
+                */
                double vorbis_quality = 1.0 - config.format->codec_quality () / 100.f;
                if (vorbis_quality >= 0 && vorbis_quality <= 1.0) {
-                       writer->command (SFC_SET_COMPRESSION_LEVEL, &vorbis_quality, sizeof (double));
+                       writer->command (SFC_SET_VBR_ENCODING_QUALITY, &vorbis_quality, sizeof (double));
                }
        }
 }