13
0

add function to get data width for ARDOUR::SampleFormat

This commit is contained in:
Paul Davis 2015-01-24 18:53:10 -05:00
parent ccd881d518
commit 5ff6402dad
2 changed files with 16 additions and 0 deletions

View 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);

View 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)
{