A lot of refactoring, changing all mixed up Samplerate to SampleRate (because spell: sample rate).

Switching from unsigned int to all in. Max WAV file size now 2GB instead of 4GB.
Fixing painful implicit conversion of ITADomain and ITAQuantization (was simple enum) to enum classes (can not be converted implicitly, i.e. by false function call).
parent 06cab9ae
......@@ -24,7 +24,8 @@
#include <string>
ITA_BASE_API typedef enum
//! Quantization type
ITA_BASE_API enum struct ITAQuantization
{
ITA_UNKNOWN_QUANTIZATION,
ITA_INT16,
......@@ -33,32 +34,43 @@ ITA_BASE_API typedef enum
ITA_INT32,
ITA_FLOAT,
ITA_DOUBLE
} ITAQuantization;
};
// Name einer Quantisierung als Zeichenkette (Deutsch) zurckgeben
ITA_BASE_API std::string toString(ITAQuantization eQuantization);
//! Return quantization as human readible string
ITA_BASE_API std::string toString( ITAQuantization eQuantization );
ITA_BASE_API typedef enum
//! Domain type
ITA_BASE_API enum struct ITADomain
{
ITA_UNKNOWN_DOMAIN,
ITA_TIME_DOMAIN,
ITA_FREQUENCY_DOMAIN
} ITADomain;
ITA_FREQUENCY_DOMAIN,
ITA_SPHERICAL_HARMONICS_DOMAIN,
};
// Name einer Domne als Zeichenkette (Deutsch) zurckgeben
ITA_BASE_API std::string toString(ITADomain eDomain);
//! Return domain as human readible string
ITA_BASE_API std::string toString( ITADomain eDomain );
ITA_BASE_API typedef struct
struct ITA_BASE_API ITAAudiofileProperties
{
inline ITAAudiofileProperties()
{
eQuantization = ITAQuantization::ITA_FLOAT;
eDomain = ITADomain::ITA_TIME_DOMAIN;
iChannels = -1;
dSampleRate = 44100.0f;
iLength = -1;
};
ITAQuantization eQuantization;
ITADomain eDomain;
unsigned int uiChannels;
double dSamplerate;
unsigned int uiLength;
int iChannels;
double dSampleRate;
int iLength;
std::string sComment;
} ITAAudiofileProperties;
} ;
//! Audiodateieigenschaften auf der Konsole ausgeben
ITA_BASE_API void print(const ITAAudiofileProperties& props);
//! Print audio file properties to console
ITA_BASE_API void print( const ITAAudiofileProperties& props );
#endif // INCLUDE_WATCHER_ITA_AUDIOFILE_COMMON
......@@ -15,7 +15,6 @@
* ----------------------------------------------------------------
*
*/
// $Id: ITAAudiofileReader.h,v 1.3 2006-05-21 12:29:29 wefers Exp $
#ifndef INCLUDE_WATHER_ITA_AUDIOFILE_READER
#define INCLUDE_WATHER_ITA_AUDIOFILE_READER
......@@ -37,7 +36,7 @@ public:
/**
* \note Gibt niemals NULL zurck. Lst aber ggf. eine ITAException aus
*/
static ITAAudiofileReader* create(std::string sFilename);
static ITAAudiofileReader* create( const std::string& sFilePath );
//! Destruktor
virtual ~ITAAudiofileReader();
......@@ -47,40 +46,40 @@ public:
//! Quantisierungstyp zurckgeben
ITAQuantization getQuantization() const;
//! Domne zurckgeben
ITADomain getDomain() const;
//! Anzahl der Kanle zurckgeben
unsigned int getNumberOfChannels() const;
int getNumberOfChannels() const;
//! Samplerate zurckgeben
double getSamplerate() const;
//! Lnge der Audiodatei in Samples zurckgeben
unsigned int getLength() const;
int getLength() const;
//! Aktuelle Position in der Audiodatei zurckgeben
unsigned int getCursor() const;
int getCursor() const;
//! Kommentar der Audio zurckgeben
std::string getComment() const;
//! An eine Position in der Datei springen
virtual void seek(unsigned int uiOffset)=0;
virtual void seek( int iOffset ) = 0;
//! Lesen und Zielpuffer erzeugen
/**
* Liet uiLength Samples aus der Audiodatei in Float-Puffer,
* welche automatisch von der Methode erzeugt werden. Die Anzahl
* der Float-Puffer ist gleich der Anzahl der Kanle der Audiodatei.
*
*
* \param uiLength Anzahl der zu lesenden Samples
* \return Vektor mit den Allozierten und mit Daten gefllten Float-Puffern
*
* \note Im Fehlerfall lst die Methode eine Ausnahme des Typs ITAException aus
*/
std::vector<float*> read(unsigned int uiLength);
std::vector< float* > read( int iLength );
//! Lesen in vorgegebene Zielpuffer
/**
......@@ -93,32 +92,32 @@ public:
* Ferner kann man den Lader anweisen, nur gewisse Kanle zu laden,
* indem man in den Vektor Nullzeiger einfgt. Ist ein Zeiger Null,
* so ignoriert der Lader diesen.
*
*
* \param uiLength Anzahl der zu lesenden Samples
* \param vpfDest Vektor mit Zeigern auf die Puffer,
* in denen die Daten abgelegt werden sollen.
*
* \note Im Fehlerfall lst die Methode eine Ausnahme des Typs ITAException aus
*/
virtual void read(unsigned int uiLength, std::vector<float*> vpfDest)=0;
virtual void read( int iLength, std::vector< float* > vpfDest ) = 0;
protected:
ITAQuantization _eQuantization;
ITADomain _eDomain;
unsigned int _uiChannels;
double _dSamplerate;
unsigned int _uiLength;
unsigned int _uiCursor;
std::string _sComment;
ITAQuantization m_eQuantization;
ITADomain m_eDomain;
int m_iChannels;
double m_dSampleRate;
int m_iLength;
int m_iCursor;
std::string m_sComment;
};
//! Schnffelfunktion (Nur die Eigenschaften einer Audiodatei ermitteln)
ITA_BASE_API void sneakAudiofile(std::string sFilename, ITAAudiofileProperties& props);
ITA_BASE_API void sneakAudiofile( const std::string& sFilePath, ITAAudiofileProperties& props );
//! Audiodatei in Puffer laden (Puffer werden erzeugt)
ITA_BASE_API std::vector<float*> readAudiofile(std::string sFilename, ITAAudiofileProperties& props);
ITA_BASE_API std::vector<float*> readAudiofile( const std::string& sFilePath, ITAAudiofileProperties& props );
//! Audiodatei in Puffer laden (Puffer sind vorgegeben)
ITA_BASE_API void readAudiofile(std::string sFilename, ITAAudiofileProperties& props, std::vector<float*>& vpfData);
ITA_BASE_API void readAudiofile( const std::string& sFilePath, ITAAudiofileProperties& props, std::vector< float* >& vpfData );
#endif // INCLUDE_WATHER_ITA_AUDIOFILE_READER
......@@ -15,7 +15,6 @@
* ----------------------------------------------------------------
*
*/
// $Id: ITAAudiofileWriter.h,v 1.5 2010-02-22 09:53:46 schluetter Exp $
#ifndef INCLUDE_WATHER_ITA_AUDIOFILE_WRITER
#define INCLUDE_WATHER_ITA_AUDIOFILE_WRITER
......@@ -37,15 +36,8 @@ class ITASampleFrame;
class ITA_BASE_API ITAAudiofileWriter
{
public:
//! Factory-Method (Lader erzeugen)
/**
* \note Das Feld uiLength in props wird ignoriert!
* \note Gibt niemals NULL zurück. Löst aber ggf. eine ITAException aus
*/
static ITAAudiofileWriter* create(std::string sFilename,
const ITAAudiofileProperties& props);
//! Destruktor
//! Factory-Method
static ITAAudiofileWriter* create( const std::string& sFilePath, const ITAAudiofileProperties& props );
virtual ~ITAAudiofileWriter();
//! Schreiben
......@@ -61,55 +53,52 @@ public:
* indem man in den Vektor Nullzeiger einf�gt. Ist ein Zeiger Null,
* so ignoriert der Schreiber diesen und belegt den korrespondierenden
* Kanal mit Nullsamples.
*
*
* \param uiLength Anzahl der zu lesenden Samples
* \param vpfSource Vektor mit Zeigern auf die Puffer,
* aus denen die Daten gelesen werden sollen.
*
* \note Im Fehlerfall l�st die Methode eine Ausnahme des Typs ITAException aus
*/
virtual void write(unsigned int uiLength, std::vector<const float*> vpfSource)=0;
virtual void write( int iLength, std::vector< const float* > vpfSource ) = 0;
//! Schreiben
/**
* Variante ohne const-Pointer.
*/
virtual void write(unsigned int uiLength, std::vector<float*> vpfSource);
virtual void write( int iLength, std::vector< float* > vpfSource );
//! Schreiben (SampleFrame)
/**
* Diese Variante schreibt einen kompletten SampleFrame in die Datei
*/
virtual void write(const ITASampleFrame* psfSource);
virtual void write( const ITASampleFrame* psfSource );
//! Schreiben (SampleFrame)
/**
* Diese Variante schreibt einen SampleFrame in die Datei, wobei
* die Anzahl Samples und der Startoffset im Frame gesetzt werden können.
*/
virtual void write(const ITASampleFrame* psfSource, int iNumSamples, int iOffset=0);
virtual void write( const ITASampleFrame* psfSource, int iNumSamples, int iOffset = 0 );
};
//! Inhalte von Puffer in Audiodatei schreiben
/**
* \note Hier muss die L�nge in props explizit angegeben werden!
*/
ITA_BASE_API void writeAudiofile(std::string sFilename, const ITAAudiofileProperties& props, std::vector<const float*>& vpfSource);
ITA_BASE_API void writeAudiofile(std::string sFilename, const ITAAudiofileProperties& props, std::vector<float*>& vpfSource);
ITA_BASE_API void writeAudiofile( const std::string& sFilename, const ITAAudiofileProperties& props, std::vector< const float* >& vpfSource );
ITA_BASE_API void writeAudiofile( const std::string& sFilename, const ITAAudiofileProperties& props, std::vector< float* >& vpfSource );
//! Mono-Zeitsignal in Audiodatei schreiben
ITA_BASE_API void writeAudiofile(std::string sFilename, const float* pfData, unsigned int uiLength, double dSamplerate, ITAQuantization eQuantization=ITA_INT16);
ITA_BASE_API void writeAudiofile( const std::string& sFilename, const float* pfData, int iLength, double dSampleRate, ITAQuantization eQuantization = ITAQuantization::ITA_FLOAT );
//! Stereo-Zeitsignal in Audiodatei schreiben
ITA_BASE_API void writeAudiofile(std::string sFilename, const float* pfDataCh0, const float* pfDataCh1, unsigned int uiLength, double dSamplerate, ITAQuantization eQuantization=ITA_INT16);
ITA_BASE_API void writeAudiofile( const std::string& sFilename, const float* pfDataCh0, const float* pfDataCh1, int iLength, double dSampleRate, ITAQuantization eQuantization = ITAQuantization::ITA_FLOAT );
//! Inhalt eines Samplebuffer in Audiodatei schreiben
ITA_BASE_API void writeAudiofile(std::string sFilename, const ITASampleBuffer* psbData, double dSamplerate, ITAQuantization eQuantization=ITA_INT16);
ITA_BASE_API void writeAudiofile( const std::string& sFilename, const ITASampleBuffer* psbData, double dSampleRate, ITAQuantization eQuantization = ITAQuantization::ITA_FLOAT );
//! Inhalt eines Sampleframe in Audiodatei schreiben
ITA_BASE_API void writeAudiofile(std::string sFilename, const ITASampleFrame* psfData, double dSamplerate, ITAQuantization eQuantization=ITA_INT16);
//! Inhalt eines Sampleframe in Audiodatei schreiben (mit SampleRate von SampleFrame)
//ITA_BASE_API void writeAudiofile(std::string sFilename, const ITASampleFrame* psfData, ITAQuantization eQuantization=ITA_INT16);
ITA_BASE_API void writeAudiofile( const std::string& sFilename, const ITASampleFrame* psfData, double dSampleRate, ITAQuantization eQuantization = ITAQuantization::ITA_FLOAT );
#endif // INCLUDE_WATHER_ITA_AUDIOFILE_WRITER
/*
+-----------------------------------------------------------------------+
| |
| ITAFileIO C++-Bibliothek zum Lesen und Schreiben von Audiodateien |
| |
| (c) Copyright Institut f�r technische Akustik (ITA) |
| RWTH Aachen University of Technology |
| |
+-----------------------------------------------------------------------+
| |
| File: ITAAudiofileCommon.cpp |
| Purpose: Grundlegende Datentypdefinitionen und Hilfsfunktionen |
| Authors: Frank Wefers |
| |
+-----------------------------------------------------------------------+
*/
// $Id: ITAAudiofileCommon.cpp,v 1.6 2009-12-23 10:05:20 fwefers Exp $
#include "ITAAudiofileCommon.h"
#include <cstdio>
std::string toString(ITAQuantization eQuantization) {
switch (eQuantization) {
case ITA_INT16: return "Ganzzahlen 16-Bit";
case ITA_INT20: return "Ganzzahlen 20-Bit";
case ITA_INT24: return "Ganzzahlen 24-Bit";
case ITA_INT32: return "Ganzzahlen 32-Bit";
case ITA_FLOAT: return "Fließkomma 32-Bit";
case ITA_DOUBLE: return "Fließkomma 64-Bit";
default: return "Unbekannt";
std::string toString( ITAQuantization eQuantization )
{
switch( eQuantization )
{
case ITAQuantization::ITA_INT16: return "Integer with 16-Bit";
case ITAQuantization::ITA_INT20: return "Integer with 20-Bit";
case ITAQuantization::ITA_INT24: return "Integer with 24-Bit";
case ITAQuantization::ITA_INT32: return "Integer with 32-Bit";
case ITAQuantization::ITA_FLOAT: return "Floating point with 32-Bit";
case ITAQuantization::ITA_DOUBLE: return "Floating point with 64-Bit";
default: return "Unkown";
}
}
std::string toString(ITADomain eDomain) {
return (eDomain == ITA_TIME_DOMAIN ? "Zeitbereich" : "Frequenzbereich");
std::string toString( ITADomain eDomain )
{
return ( eDomain == ITADomain::ITA_TIME_DOMAIN ? "Zeitbereich" : "Frequenzbereich" );
}
void print(const ITAAudiofileProperties& props) {
printf("%s | %0.1f Hz | %d Kanäle | %s | Länge: %d Samples",
toString(props.eDomain).c_str(),
props.dSamplerate,
props.uiChannels,
toString(props.eQuantization).c_str(),
props.uiLength);
if (!props.sComment.empty())
printf(" | Kommentar: \"%s\"", props.sComment.c_str());
printf("\n");
}
void print( const ITAAudiofileProperties& props )
{
printf( "%s | %0.1f Hz | %i channels | %s | length: %i Samples",
toString( props.eDomain ).c_str(),
props.dSampleRate,
props.iChannels,
toString( props.eQuantization ).c_str(),
props.iLength );
if( !props.sComment.empty() )
printf( " | Comment: \"%s\"", props.sComment.c_str() );
printf( "\n" );
}
......@@ -7,71 +7,77 @@
#include "libsndfileAudiofileReader.h"
ITAAudiofileReader* ITAAudiofileReader::create(std::string sFilename)
ITAAudiofileReader* ITAAudiofileReader::create( const std::string& sFilePath )
{
VistaFileSystemFile oFile( sFilename );
VistaFileSystemFile oFile( sFilePath );
// Check if the file exists
if( oFile.Exists() == false )
ITA_EXCEPT1(FILE_NOT_FOUND, std::string("Audiofile \"") + sFilename + std::string("\" not found"));
return new libsndfileAudiofileReader(sFilename);
if( oFile.Exists() == false )
ITA_EXCEPT1( FILE_NOT_FOUND, std::string( "Audiofile \"" ) + sFilePath + std::string( "\" not found" ) );
return new libsndfileAudiofileReader( sFilePath );
}
ITAAudiofileReader::~ITAAudiofileReader() { };
ITAAudiofileProperties ITAAudiofileReader::getAudiofileProperties() const {
ITAAudiofileProperties ITAAudiofileReader::getAudiofileProperties() const
{
ITAAudiofileProperties result;
result.dSamplerate = _dSamplerate;
result.eDomain = _eDomain;
result.eQuantization = _eQuantization;
result.sComment = _sComment;
result.uiChannels = _uiChannels;
result.uiLength = _uiLength;
result.dSampleRate = m_dSampleRate;
result.eDomain = m_eDomain;
result.eQuantization = m_eQuantization;
result.sComment = m_sComment;
result.iChannels = m_iChannels;
result.iLength = m_iLength;
return result;
}
ITAQuantization ITAAudiofileReader::getQuantization() const { return _eQuantization; }
ITADomain ITAAudiofileReader::getDomain() const { return _eDomain; }
unsigned int ITAAudiofileReader::getNumberOfChannels() const { return _uiChannels; }
double ITAAudiofileReader::getSamplerate() const { return _dSamplerate; }
unsigned int ITAAudiofileReader::getLength() const { return _uiLength; }
unsigned int ITAAudiofileReader::getCursor() const { return _uiCursor; }
std::string ITAAudiofileReader::getComment() const { return _sComment; }
ITAQuantization ITAAudiofileReader::getQuantization() const { return m_eQuantization; }
ITADomain ITAAudiofileReader::getDomain() const { return m_eDomain; }
int ITAAudiofileReader::getNumberOfChannels() const { return m_iChannels; }
double ITAAudiofileReader::getSamplerate() const { return m_dSampleRate; }
int ITAAudiofileReader::getLength() const { return m_iLength; }
int ITAAudiofileReader::getCursor() const { return m_iCursor; }
std::string ITAAudiofileReader::getComment() const { return m_sComment; }
std::vector<float*> ITAAudiofileReader::read(unsigned int uiLength) {
std::vector<float*> ITAAudiofileReader::read( int uiLength )
{
// Fehler mit der Lnge bereits vor dem Allozieren abfangen!
if (uiLength > (_uiLength - _uiCursor))
ITA_EXCEPT1(IO_ERROR, "Versuch ber das Ende der Datei hinaus zu lesen");
if( uiLength > ( m_iLength - m_iCursor ) )
ITA_EXCEPT1( IO_ERROR, "Versuch ber das Ende der Datei hinaus zu lesen" );
// Puffer allozieren
std::vector<float*> vpfResult;
for (unsigned int i=0; i<_uiChannels; i++)
vpfResult.push_back(new float[uiLength]);
for( int i = 0; i < m_iChannels; i++ )
vpfResult.push_back( new float[ uiLength ] );
// Daten lesen
try {
read(uiLength, vpfResult);
} catch (...) {
for (unsigned int i=0; i<vpfResult.size(); i++) delete[] vpfResult[i];
read( uiLength, vpfResult );
}
catch( ... ) {
for( unsigned int i = 0; i < vpfResult.size(); i++ ) delete[] vpfResult[ i ];
throw;
}
return vpfResult;
}
void sneakAudiofile(std::string sFilename, ITAAudiofileProperties& props) {
ITAAudiofileReader* pReader = ITAAudiofileReader::create(sFilename);
void sneakAudiofile( const std::string& sFilePath, ITAAudiofileProperties& props )
{
ITAAudiofileReader* pReader = ITAAudiofileReader::create( sFilePath );
props = pReader->getAudiofileProperties();
delete pReader;
}
std::vector<float*> readAudiofile(std::string sFilename, ITAAudiofileProperties& props) {
ITAAudiofileReader* pReader = ITAAudiofileReader::create(sFilename);
std::vector<float*> readAudiofile( const std::string& sFilePath, ITAAudiofileProperties& props )
{
ITAAudiofileReader* pReader = ITAAudiofileReader::create( sFilePath );
props = pReader->getAudiofileProperties();
std::vector<float*> vpfResult;
try {
vpfResult = pReader->read(pReader->getLength());
} catch (...) {
vpfResult = pReader->read( pReader->getLength() );
}
catch( ... ) {
delete pReader;
throw;
}
......@@ -79,12 +85,14 @@ std::vector<float*> readAudiofile(std::string sFilename, ITAAudiofileProperties&
return vpfResult;
}
void readAudiofile(std::string sFilename, ITAAudiofileProperties& props, std::vector<float*>& vpfData) {
ITAAudiofileReader* pReader = ITAAudiofileReader::create(sFilename);
void readAudiofile( const std::string& sFilePath, ITAAudiofileProperties& props, std::vector<float*>& vpfData )
{
ITAAudiofileReader* pReader = ITAAudiofileReader::create( sFilePath );
props = pReader->getAudiofileProperties();
try {
pReader->read(pReader->getLength(), vpfData);
} catch (...) {
pReader->read( pReader->getLength(), vpfData );
}
catch( ... ) {
delete pReader;
throw;
}
......
......@@ -6,140 +6,164 @@
#include <ITASampleFrame.h>
#include "libsndfileAudiofileWriter.h"
ITAAudiofileWriter* ITAAudiofileWriter::create(std::string sFilename, const ITAAudiofileProperties& props) {
return new libsndfileAudiofileWriter(sFilename, props);
ITAAudiofileWriter* ITAAudiofileWriter::create( const std::string& sFilePath, const ITAAudiofileProperties& props )
{
return new libsndfileAudiofileWriter( sFilePath, props );
}
ITAAudiofileWriter::~ITAAudiofileWriter() { };
void ITAAudiofileWriter::write(unsigned int uiLength, std::vector<float*> vpfSource) {
// const entfernen
write(uiLength, *reinterpret_cast< std::vector<const float*>* >( &vpfSource ));
void ITAAudiofileWriter::write( int iLength, std::vector< float* > vpfSource )
{
write( iLength, *reinterpret_cast< std::vector< const float* >* >( &vpfSource ) );
}
void ITAAudiofileWriter::write(const ITASampleFrame* psfSource) {
if (!psfSource)
ITA_EXCEPT1(INVALID_PARAMETER, "Nullpointer argument");
void ITAAudiofileWriter::write( const ITASampleFrame* psfSource )
{
if( !psfSource )
ITA_EXCEPT1( INVALID_PARAMETER, "Nullpointer argument" );
write(psfSource, psfSource->length(), 0);
write( psfSource, psfSource->length(), 0 );
}
void ITAAudiofileWriter::write(const ITASampleFrame* psfSource, int iNumSamples, int iOffset) {
if (!psfSource)
ITA_EXCEPT1(INVALID_PARAMETER, "Nullpointer argument");
void ITAAudiofileWriter::write( const ITASampleFrame* psfSource, int iNumSamples, int iOffset )
{
if( !psfSource )
ITA_EXCEPT1( INVALID_PARAMETER, "Nullpointer argument" );
if ((iOffset+iNumSamples) > psfSource->length())
ITA_EXCEPT1(INVALID_PARAMETER, "Number of samples and offset exceed sample frame range");
if( ( iOffset + iNumSamples ) > psfSource->length() )
ITA_EXCEPT1( INVALID_PARAMETER, "Number of samples and offset exceed sample frame range" );
// Datenzeiger aufsetzen
std::vector<const float*> vpfData(psfSource->channels());
for (int i=0; i<psfSource->channels(); i++) vpfData[i] = (*psfSource)[i].GetData() + iOffset;
std::vector< const float* > vpfData( psfSource->channels() );
for( int i = 0; i < psfSource->channels(); i++ )
vpfData[ i ] = ( *psfSource )[ i ].GetData() + iOffset;
// Schreiben mit der Variante std::vector<const float*>
write(iNumSamples, vpfData);
write( iNumSamples, vpfData );
}
void writeAudiofile(std::string sFilename, const ITAAudiofileProperties& props, std::vector<const float*>& vpfSource) {
ITAAudiofileWriter* pWriter = ITAAudiofileWriter::create(sFilename, props);
try {
pWriter->write(props.uiLength, vpfSource);
} catch (...) {
void writeAudiofile( const std::string& sFilePath, const ITAAudiofileProperties& props, std::vector< const float* >& vpfSource )
{
ITAAudiofileWriter* pWriter = ITAAudiofileWriter::create( sFilePath, props );
try
{
pWriter->write( props.iLength, vpfSource );
}
catch( ... )
{
delete pWriter;
throw;
}
delete pWriter;
}
void writeAudiofile(std::string sFilename, const ITAAudiofileProperties& props, std::vector<float*>& vpfSource) {
writeAudiofile(sFilename, props, reinterpret_cast< std::vector<const float*>& >( vpfSource ));
void writeAudiofile( const std::string& sFilePath, const ITAAudiofileProperties& props, std::vector<float*>& vpfSource )
{
writeAudiofile( sFilePath, props, reinterpret_cast< std::vector<const float*>& >( vpfSource ) );
}
void writeAudiofile(std::string sFilename, const float* pfData, unsigned int uiLength, double dSamplerate, ITAQuantization eQuantization) {
void writeAudiofile( std::string sFilename, const float* pfData, unsigned int uiLength, double dSamplerate, ITAQuantization eQuantization )
{
ITAAudiofileProperties props;
props.uiChannels = 1;
props.uiLength = uiLength;
props.dSamplerate = dSamplerate;
props.eDomain = ITA_TIME_DOMAIN;
props.iChannels = 1;
props.iLength = uiLength;
props.dSampleRate = dSamplerate;
props.eDomain = ITADomain::ITA_TIME_DOMAIN;
props.eQuantization = eQuantization;
props.sComment = "";
std::vector<const float*> data(1);
data[0] = pfData;
std::vector<const float*> data( 1 );
data[ 0 ] = pfData;
ITAAudiofileWriter* writer = ITAAudiofileWriter::create(sFilename, props);
ITAAudiofileWriter* writer = ITAAudiofileWriter::create( sFilename, props );
try {
writer->write(props.uiLength, data);
} catch (...) {
writer->write( props.iLength, data );
}
catch( ... ) {
delete writer;
throw;
}
delete writer;
}
void writeAudiofile(std::string sFilename, const float* pfDataCh0, const float* pfDataCh1, unsigned int uiLength, double dSamplerate, ITAQuantization eQuantization) {
void writeAudiofile( const std::string& sFilePath, const float* pfDataCh0, const float* pfDataCh1, int iLength, double dSamplerate, ITAQuantization eQuantization )
{
ITAAudiofileProperties props;
props.uiChannels = 2;
props.uiLength = uiLength;
props.dSamplerate = dSamplerate;
props.eDomain = ITA_TIME_DOMAIN;
props.iChannels = 2;
props.iLength = iLength;
props.dSampleRate = dSamplerate;