Optimizing ita audio file reader / writer

style
cleanups
moving definitions to ITATypes (domain, quantization)
parent 09fc9f83
......@@ -101,6 +101,7 @@ set( ITABaseSources
"src/ITASampleTypeConversion.cpp"
"src/ITASimpleConvolution.cpp"
"src/ITAStopWatch.cpp"
"src/ITATypes.cpp"
"src/ITAWinPCClock.cpp"
)
......
......@@ -20,36 +20,10 @@
#define INCLUDE_WATCHER_ITA_AUDIOFILE_COMMON
#include <ITABaseDefinitions.h>
#include <ITATypes.h>
#include <string>
//! Quantization type
ITA_BASE_API enum struct ITAQuantization
{
ITA_UNKNOWN_QUANTIZATION,
ITA_INT16,
ITA_INT20,
ITA_INT24,
ITA_INT32,
ITA_FLOAT,
ITA_DOUBLE
};
//! Return quantization as human readible string
ITA_BASE_API std::string toString( ITAQuantization eQuantization );
//! Domain type
ITA_BASE_API enum struct ITADomain
{
ITA_UNKNOWN_DOMAIN,
ITA_TIME_DOMAIN,
ITA_FREQUENCY_DOMAIN,
ITA_SPHERICAL_HARMONICS_DOMAIN,
};
//! Return domain as human readible string
ITA_BASE_API std::string toString( ITADomain eDomain );
struct ITA_BASE_API ITAAudiofileProperties
{
inline ITAAudiofileProperties()
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATHER_ITA_AUDIOFILE_READER
#define INCLUDE_WATHER_ITA_AUDIOFILE_READER
#ifndef INCLUDE_WATCHER_ITA_AUDIOFILE_READER
#define INCLUDE_WATCHER_ITA_AUDIOFILE_READER
#include <ITABaseDefinitions.h>
#include <ITAAudiofileCommon.h>
// Includes der Standard Template Library (STL)
#include <string>
#include <vector>
/**
* Abstrakte Klasse welche allgemeine Leser fr Audiodateien realisiert
*/
//! Abstract reader interface for audio files
class ITA_BASE_API ITAAudiofileReader
{
public:
//! Factory-Method (Lader erzeugen)
//! Factory-Method (creates loader)
/**
* \note Gibt niemals NULL zurck. Lst aber ggf. eine ITAException aus
* \note Never returns NULL but raises ITAException on error.
*/
static ITAAudiofileReader* create( const std::string& sFilePath );
//! Destruktor
virtual ~ITAAudiofileReader();
//! Eigenschaften zurckgeben
ITAAudiofileProperties getAudiofileProperties() const;
//! Quantisierungstyp zurckgeben
ITAQuantization getQuantization() const;
//! Domne zurckgeben
ITADomain getDomain() const;
//! Anzahl der Kanle zurckgeben
int getNumberOfChannels() const;
//! Samplerate zurckgeben
double getSamplerate() const;
//! Lnge der Audiodatei in Samples zurckgeben
//! Returns absolute length of audio file in samples
int getLength() const;
//! Aktuelle Position in der Audiodatei zurckgeben
//! Returns current read cursor position
int getCursor() const;
//! Kommentar der Audio zurckgeben
std::string getComment() const;
//! An eine Position in der Datei springen
//! Seek to a specified position inside audio file
virtual void seek( int iOffset ) = 0;
//! Lesen und Zielpuffer erzeugen
......@@ -120,4 +104,4 @@ ITA_BASE_API std::vector<float*> readAudiofile( const std::string& sFilePath, IT
//! Audiodatei in Puffer laden (Puffer sind vorgegeben)
ITA_BASE_API void readAudiofile( const std::string& sFilePath, ITAAudiofileProperties& props, std::vector< float* >& vpfData );
#endif // INCLUDE_WATHER_ITA_AUDIOFILE_READER
#endif // INCLUDE_WATCHER_ITA_AUDIOFILE_READER
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATHER_ITA_AUDIOFILE_WRITER
#define INCLUDE_WATHER_ITA_AUDIOFILE_WRITER
#ifndef INCLUDE_WATCHER_ITA_AUDIOFILE_WRITER
#define INCLUDE_WATCHER_ITA_AUDIOFILE_WRITER
#include <ITABaseDefinitions.h>
#include <ITAAudiofileCommon.h>
// Includes der Standard Template Library (STL)
#include <string>
#include <vector>
// Vorwärtsdeklarationen
class ITASampleBuffer;
class ITASampleFrame;
/**
* Abstrakte Klasse welche allgemeine Schreiber für Audiodateien realisiert
*/
//! Abstract class for writing audio files
class ITA_BASE_API ITAAudiofileWriter
{
public:
......@@ -82,10 +78,6 @@ public:
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( 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 );
......@@ -101,4 +93,4 @@ ITA_BASE_API void writeAudiofile( const std::string& sFilename, const ITASampleB
//! Inhalt eines Sampleframe in Audiodatei schreiben
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
#endif // INCLUDE_WATCHER_ITA_AUDIOFILE_WRITER
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_BLOCK_MATH
#define INCLUDE_WATCHER_ITA_BLOCK_MATH
......
......@@ -19,7 +19,6 @@
#ifndef INCLUDE_WATCHER_ITA_CLOCK
#define INCLUDE_WATCHER_ITA_CLOCK
// ITABase
#include <ITABaseDefinitions.h>
#include <string>
......
......@@ -166,4 +166,4 @@ private:
double m_dSquareSum; // Summe der Messwertquadrate fr Berechnung der Varianz und StdDer.
};
#endif // INCLUDE_WATCHER_ITA_TIME_SERIES_ANALYZER
\ No newline at end of file
#endif // INCLUDE_WATCHER_ITA_TIME_SERIES_ANALYZER
......@@ -19,8 +19,39 @@
#ifndef INCLUDE_WATCHER_ITA_TYPES
#define INCLUDE_WATCHER_ITA_TYPES
#ifdef WIN32
#include <ITABaseDefinitions.h>
#include <ITATypes.h>
#include <string>
//! Quantization type
ITA_BASE_API enum struct ITAQuantization
{
ITA_UNKNOWN_QUANTIZATION,
ITA_INT16,
ITA_INT20,
ITA_INT24,
ITA_INT32,
ITA_FLOAT,
ITA_DOUBLE
};
//! Return quantization as human readible string
ITA_BASE_API std::string toString( ITAQuantization eQuantization );
//! Domain type
ITA_BASE_API enum struct ITADomain
{
ITA_UNKNOWN_DOMAIN,
ITA_TIME_DOMAIN,
ITA_FREQUENCY_DOMAIN,
ITA_SPHERICAL_HARMONICS_DOMAIN,
};
//! Return domain as human readible string
ITA_BASE_API std::string toString( ITADomain eDomain );
#ifdef WIN32
// Define necessary typedef from stdint.h for Microsoft compilers before Visual C++ 2010
#if _MSC_VER < 1600
......
......@@ -2,25 +2,6 @@
#include <cstdio>
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 == ITADomain::ITA_TIME_DOMAIN ? "time domain" : "frequency domain" );
}
void print( const ITAAudiofileProperties& props )
{
printf( "%s | %0.1f Hz | %i channels | %s | length: %i Samples",
......
......@@ -174,7 +174,9 @@ bool listFilesInDirectory(const std::string& sPath, std::vector<std::string>& vs
vsFilenames.push_back(sFilename);
} while (FindNextFile(h, &oData) != 0);
#ifdef DEBUG
DWORD dwError = GetLastError();
#endif
FindClose(h);
......
#include <ITATypes.h>
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 == ITADomain::ITA_TIME_DOMAIN ? "time domain" : "frequency domain" );
}
......@@ -2,6 +2,7 @@
#include <algorithm>
#include <ITAException.h>
#include <ITATypes.h>
#include <algorithm>
#include <sys/stat.h>
......
#include "libsndfileAudiofileWriter.h"
#include <ITAException.h>
#include <ITATypes.h>
#include <algorithm>
#include <locale>
......@@ -61,7 +62,7 @@ libsndfileAudiofileWriter::libsndfileAudiofileWriter( const std::string& sFilePa
ITA_EXCEPT1( INVALID_PARAMETER, "Eigenschaften nicht untersttzt oder kompatibel" );
// Versuchen die Datei zu ffnen
if( !( _sf = sf_open( sFilePath.c_str(), SFM_WRITE, &info ) ) )
if( ( _sf = sf_open( sFilePath.c_str(), SFM_WRITE, &info ) ) == nullptr )
ITA_EXCEPT1( IO_ERROR, sf_strerror( _sf ) );
// Kommentar setzen
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment