add function to get data width for ARDOUR::SampleFormat
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 24 Jan 2015 23:53:10 +0000 (18:53 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 24 Jan 2015 23:53:10 +0000 (18:53 -0500)
libs/ardour/ardour/sndfile_helpers.h
libs/ardour/sndfile_helpers.cc

index 02f486a975ac61e561df6dde43b9a8334888637e..b475b082befd3f8caf305f49325beeff0ddc1c66 100644 (file)
@@ -23,6 +23,8 @@
 #include <string>
 #include <stdint.h>
 
+#include "ardour/types.h"
+
 // Use this define when initializing arrarys for use in sndfile_*_format()
 #define SNDFILE_STR_LENGTH 32
 
@@ -47,6 +49,7 @@ int sndfile_header_format_by_index (int);
 int sndfile_endian_format_by_index (int);
 
 int sndfile_data_width (int format);
+int sndfile_data_width (ARDOUR::SampleFormat);
 
 // It'd be nice if libsndfile did this for us
 std::string sndfile_major_format (int);
index 2e618e043bb3b5cba8f52a297ff9ab5a1f00373c..e3e80b48e5ab73e21ce5b000b4e4874c9aa4b55d 100644 (file)
@@ -140,6 +140,19 @@ sndfile_data_width (int format)
        }
 }
 
+int
+sndfile_data_width (ARDOUR::SampleFormat format)
+{
+       switch (format) {
+       case ARDOUR::FormatInt16:
+               return sndfile_data_width (SF_FORMAT_PCM_16);
+       case ARDOUR::FormatInt24:
+               return sndfile_data_width (SF_FORMAT_PCM_24);
+       default:
+               return sndfile_data_width (SF_FORMAT_FLOAT);
+       }
+}
+
 string
 sndfile_major_format(int format)
 {