Public Member Functions | Static Public Member Functions

Soundfile Class Reference

A format-independent class that provides functionality for sound manipulation, reading and writing. More...

#include <soundfile.hpp>

List of all members.

Public Member Functions

 Soundfile ()
 Soundfile (const QString &fname)
void reset ()
 Forget the loaded file.
void load (const QString &fname)
 Loads the specified file.
const QString & error () const
 If the loaded file isn't valid, this function gives the reason.
bool valid () const
 Used to determine if a file was loaded successfully.
real_vec read_channel (int channel)
 Read the audio data of the given channel from the loaded file.
const SoundfileDatadata () const
 Allows access to low-level information about the file (eg. samplerate).

Static Public Member Functions

static QString writeSound (const QString &fname, const real_vec &data, int samplerate, int format=-1)
 Writes pcm data to an audio file encoded according to the extension.
static int guessFormat (const QString &filename)
 Returns the format specification guessed from the specified file extension.

Detailed Description

A format-independent class that provides functionality for sound manipulation, reading and writing.

It aggregates all implementations of SndfileData.

Definition at line 79 of file soundfile.hpp.


Constructor & Destructor Documentation

Soundfile::Soundfile (  ) 

Definition at line 47 of file soundfile.cpp.

Soundfile::Soundfile ( const QString &  fname  ) 

Definition at line 52 of file soundfile.cpp.


Member Function Documentation

const SoundfileData & Soundfile::data (  )  const

Allows access to low-level information about the file (eg. samplerate).

Definition at line 93 of file soundfile.cpp.

const QString & Soundfile::error (  )  const

If the loaded file isn't valid, this function gives the reason.

Definition at line 67 of file soundfile.cpp.

int Soundfile::guessFormat ( const QString &  filename  )  [static]

Returns the format specification guessed from the specified file extension.

Definition at line 35 of file soundfile.cpp.

void Soundfile::load ( const QString &  fname  ) 

Loads the specified file.

Definition at line 72 of file soundfile.cpp.

real_vec Soundfile::read_channel ( int  channel  ) 

Read the audio data of the given channel from the loaded file.

Returns:
PCM data of the specified audio channel

Definition at line 57 of file soundfile.cpp.

void Soundfile::reset (  ) 

Forget the loaded file.

Definition at line 87 of file soundfile.cpp.

bool Soundfile::valid (  )  const

Used to determine if a file was loaded successfully.

Definition at line 62 of file soundfile.cpp.

QString Soundfile::writeSound ( const QString &  fname,
const real_vec data,
int  samplerate,
int  format = -1 
) [static]

Writes pcm data to an audio file encoded according to the extension.

Encoding is performed by libsndfile (no mp3 writing support).

Returns:
a string error, or null string on success.

Definition at line 10 of file soundfile.cpp.


The documentation for this class was generated from the following files: