ape  0.5.0
Audio Programming Environment
Public Types | Public Member Functions | List of all members
ape::OutputAudioFile Class Reference

Provides capability to record streamed audio asynchronously to a file on disk. More...

#include <outputfile.h>

Public Types

enum  BitDepth { BitDepth::Int8 = 8, BitDepth::Int16 = 16, BitDepth::Int24 = 24, BitDepth::Float32 = 32 }
 For non-compressed formats supporting it, provides a choice of bitdepths More...
 

Public Member Functions

 OutputAudioFile ()
 Default-initialize an output file. More...
 
 OutputAudioFile (const char *whereWithExtension, int numChannels, double sampleRate, BitDepth bitsPerSample=BitDepth::Int24, float quality=1)
 Create an output file ready to be streamed. More...
 
 OutputAudioFile (const char *whereWithExtension, const IOConfig &cfg, BitDepth bitsPerSample=BitDepth::Int24, float quality=1)
 Create an output file ready to be streamed. More...
 
 OutputAudioFile (OutputAudioFile &&other)
 Move and take ownership of the other file More...
 
OutputAudioFileoperator= (OutputAudioFile &&other)
 Move-assign and take ownership of the other file More...
 
void write (const umatrix< const float > &matrix)
 Stream the matrix to the file. More...
 
template<typename Container >
auto write (const Container &c) -> decltype(c.size(), c.data(), void())
 Stream a container supporting .size() and .data() More...
 
void write (std::size_t numSamples, const float *data)
 Stream a flat buffer. More...
 
void write (std::size_t numSamples, const float *const *data)
 Stream a flat rectangular buffer More...
 
 ~OutputAudioFile ()
 Close this file, if it hasn't been moved or properly initialized More...
 

Detailed Description

Provides capability to record streamed audio asynchronously to a file on disk.

Member Enumeration Documentation

◆ BitDepth

For non-compressed formats supporting it, provides a choice of bitdepths

Enumerator
Int8 
Int16 
Int24 
Float32 

Constructor & Destructor Documentation

◆ OutputAudioFile() [1/4]

ape::OutputAudioFile::OutputAudioFile ( )
inline

Default-initialize an output file.

◆ OutputAudioFile() [2/4]

ape::OutputAudioFile::OutputAudioFile ( const char *  whereWithExtension,
int  numChannels,
double  sampleRate,
BitDepth  bitsPerSample = BitDepth::Int24,
float  quality = 1 
)
inline

Create an output file ready to be streamed.

Parameters
whereWithExtensionRelative to your script's location. If the file already exists, it will be renamed with a numbered suffix (up to 1000)

Supported extensions depend on platform, but following are always supported:

  • .wav
  • .flac
  • .aiff
  • .ogg

Depending on platform, these may be available:

  • .mp3
  • .wma
  • .caf
Parameters
numChannelsHow many channels in the recorded audio file
sampleRateThe sample rate of the recorded file.
bitsPerSampleChoice of bitdepth in the recorded file.
qualityFor compressed formats, indicates a quality between 0 (worst) and 1 (best).

◆ OutputAudioFile() [3/4]

ape::OutputAudioFile::OutputAudioFile ( const char *  whereWithExtension,
const IOConfig cfg,
BitDepth  bitsPerSample = BitDepth::Int24,
float  quality = 1 
)
inline

Create an output file ready to be streamed.

Parameters
whereWithExtensionRelative to your script's location. If the file already exists, it will be renamed with a numbered suffix (up to 1000)

Supported extensions depend on platform, but following are always supported:

  • .wav
  • .flac
  • .aiff
  • .ogg

Depending on platform, these may be available:

  • .mp3
  • .wma
  • .caf
Parameters
cfgUse IOConfig::sampleRate and IOConfig::outputs for channels
bitsPerSampleChoice of bitdepth in the recorded file.
qualityFor compressed formats, indicates a quality between 0 (worst) and 1 (best).

◆ OutputAudioFile() [4/4]

ape::OutputAudioFile::OutputAudioFile ( OutputAudioFile &&  other)
inline

Move and take ownership of the other file

◆ ~OutputAudioFile()

ape::OutputAudioFile::~OutputAudioFile ( )
inline

Close this file, if it hasn't been moved or properly initialized

Member Function Documentation

◆ operator=()

OutputAudioFile& ape::OutputAudioFile::operator= ( OutputAudioFile &&  other)
inline

Move-assign and take ownership of the other file

◆ write() [1/4]

template<typename Container >
auto ape::OutputAudioFile::write ( const Container &  c) -> decltype(c.size(), c.data(), void())
inline

Stream a container supporting .size() and .data()

The container is assumed to only have one channel.

◆ write() [2/4]

void ape::OutputAudioFile::write ( const umatrix< const float > &  matrix)
inline

Stream the matrix to the file.

◆ write() [3/4]

void ape::OutputAudioFile::write ( std::size_t  numSamples,
const float *const *  data 
)
inline

Stream a flat rectangular buffer

Assumed to have as many channels as this file was initialized with.

◆ write() [4/4]

void ape::OutputAudioFile::write ( std::size_t  numSamples,
const float *  data 
)
inline

Stream a flat buffer.

Data is assumed to only have one channel.


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