All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Resonant::AudioFileHandler Class Reference

Read/write multiple audio files at the same time in one background-thread. More...

#include <Resonant/AudioFileHandler.hpp>

Inheritance diagram for Resonant::AudioFileHandler:
Radiant::Thread Patterns::NotCopyable

Classes

class  Handle
 A handle that offers access to the audio files. More...
 

Public Member Functions

void done (Handle *)
 Tells the handler, that a given file handle can be deleted. More...
 
HandlereadFile (const char *filename, long startFrame, Radiant::AudioSampleFormat userFormat=Radiant::ASF_FLOAT32)
 Starts the reading process for a given file. More...
 
void start ()
 Start the audio file IO thread.
 
void stop ()
 Stop the audio file IO thread.
 
HandlewriteFile (const char *filename, int channels, int samplerate, int sfFormat, Radiant::AudioSampleFormat userFormat=Radiant::ASF_FLOAT32)
 Starts the writing process for a file. More...
 
- Public Member Functions inherited from Radiant::Thread
bool isRunning () const
 Check if the thread is running. More...
 
void run ()
 Starts the thread.
 
void setName (const QString &name)
 Set the thread name. More...
 
 Thread (const QString &name="Radiant::Thread")
 Construct a thread structure. More...
 
bool waitEnd (int timeoutms=0)
 Waits until thread is finished. More...
 
virtual ~Thread ()
 Destructor. More...
 

Static Public Member Functions

static bool getInfo (const char *filename, SF_INFO *info)
 Gets information about a given audio file. More...
 
static AudioFileHandlerinstance ()
 Returns the first AudioFileHandler instance. More...
 
static SNDFILE_tag * open (const QString &filename, int openMode, SF_INFO *info)
 
- Static Public Member Functions inherited from Radiant::Thread
static id_t myThreadId ()
 The id of the calling thread. More...
 

Friends

class Handle
 

Additional Inherited Members

- Public Types inherited from Radiant::Thread
typedef void * id_t
 Thread id type. More...
 

Detailed Description

Read/write multiple audio files at the same time in one background-thread.

Member Function Documentation

void Resonant::AudioFileHandler::done ( Handle )

Tells the handler, that a given file handle can be deleted.

After calling this function, you should not use this handle any more.

static bool Resonant::AudioFileHandler::getInfo ( const char *  filename,
SF_INFO *  info 
)
static

Gets information about a given audio file.

Parameters
filenameThe name of the audio file.
infoThe information structure, that will be filled with relevant information
Returns
True if the information was successfully obtained, and false otherwise.
static AudioFileHandler* Resonant::AudioFileHandler::instance ( )
inlinestatic

Returns the first AudioFileHandler instance.

This function is not thread-safe.

Handle* Resonant::AudioFileHandler::readFile ( const char *  filename,
long  startFrame,
Radiant::AudioSampleFormat  userFormat = Radiant::ASF_FLOAT32 
)

Starts the reading process for a given file.

Parameters
filenameThe name of the file to read
startFrameThe initial frame for reading. This value is usually zero, for reading from the beginning of the file.
userFormatThe sample format the user of the handle is going to use.
Returns
Read-only handle to the new audio file
Handle* Resonant::AudioFileHandler::writeFile ( const char *  filename,
int  channels,
int  samplerate,
int  sfFormat,
Radiant::AudioSampleFormat  userFormat = Radiant::ASF_FLOAT32 
)

Starts the writing process for a file.

Parameters
filenameThe name of the audio file
channelsThe number of audio channels in the file.
samplerateThe sampling rate of the audio file, typically 44100, 48000 etc.
sfFormatThe format of the sound file. The format is created by combining libsndfile sample type with lbsndfile file type. For example SF_FORMAT_WAV | SF_FORMAT_PCM_24 will give file in wav format, with 24-bits per sample.
userFormatThe sample format the user of the handle is going to use.
Returns
Write-only handle to the new audio file
See Also
http://www.mega-nerd.com/libsndfile/api.html#open