From 5ff6402dad5b9aa8de0ce2ac44e8f3189ef9439e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 24 Jan 2015 18:53:10 -0500 Subject: add function to get data width for ARDOUR::SampleFormat --- libs/ardour/ardour/sndfile_helpers.h | 3 +++ libs/ardour/sndfile_helpers.cc | 13 +++++++++++++ 2 files changed, 16 insertions(+) (limited to 'libs') diff --git a/libs/ardour/ardour/sndfile_helpers.h b/libs/ardour/ardour/sndfile_helpers.h index 02f486a975..b475b082be 100644 --- a/libs/ardour/ardour/sndfile_helpers.h +++ b/libs/ardour/ardour/sndfile_helpers.h @@ -23,6 +23,8 @@ #include #include +#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); diff --git a/libs/ardour/sndfile_helpers.cc b/libs/ardour/sndfile_helpers.cc index 2e618e043b..e3e80b48e5 100644 --- a/libs/ardour/sndfile_helpers.cc +++ b/libs/ardour/sndfile_helpers.cc @@ -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) { -- cgit v1.2.3