TracktionEngine
Public Member Functions | Public Attributes | List of all members
tracktion::engine::AudioFileWriter Class Reference

Smart wrapper for writing to an audio file. More...

Inherits juce::ReferenceCountedObject.

Public Member Functions

 AudioFileWriter (const AudioFile &file, juce::AudioFormat *formatToUse, int numChannels, double sampleRate, int bitsPerSample, const juce::StringPairArray &metadata, int quality)
 
 ~AudioFileWriter ()
 Destructor, calls closeForWriting. More...
 
bool isOpen () const noexcept
 Returns true if the file is open and ready to write to. More...
 
double getSampleRate () const noexcept
 Returns the sample rate of the writer, should only be called on an open writer. More...
 
int getNumChannels () const noexcept
 Returns the num channels of the writer, should only be called on an open writer. More...
 
bool appendBuffer (juce::AudioBuffer< float > &buffer, int numSamples)
 Appends an AudioBuffer to the file. More...
 
bool appendBuffer (const int **buffer, int numSamples)
 Appends an block of samples to the file. More...
 
bool writeFromAudioReader (juce::AudioFormatReader &, SampleCount startSample, SampleCount numSamples)
 Appends a block of samples to the file from an audio format reader. More...
 
void closeForWriting ()
 Deletes the writer and releases the file handle. More...
 

Public Attributes

AudioFile file
 

Detailed Description

Smart wrapper for writing to an audio file.

Internally this opens a File for writng and provides some helper methods to append to it and free the file handle when done.

Constructor & Destructor Documentation

◆ AudioFileWriter()

tracktion::engine::AudioFileWriter::AudioFileWriter ( const AudioFile file,
juce::AudioFormat *  formatToUse,
int  numChannels,
double  sampleRate,
int  bitsPerSample,
const juce::StringPairArray &  metadata,
int  quality 
)

◆ ~AudioFileWriter()

tracktion::engine::AudioFileWriter::~AudioFileWriter ( )

Destructor, calls closeForWriting.

Member Function Documentation

◆ isOpen()

bool tracktion::engine::AudioFileWriter::isOpen ( ) const
noexcept

Returns true if the file is open and ready to write to.

Referenced by tracktion::engine::AudioFileUtils::readFromFormat(), and tracktion::engine::WarpTimeRenderJob::renderNextBlock().

◆ getSampleRate()

double tracktion::engine::AudioFileWriter::getSampleRate ( ) const
noexcept

Returns the sample rate of the writer, should only be called on an open writer.

◆ getNumChannels()

int tracktion::engine::AudioFileWriter::getNumChannels ( ) const
noexcept

Returns the num channels of the writer, should only be called on an open writer.

◆ appendBuffer() [1/2]

bool tracktion::engine::AudioFileWriter::appendBuffer ( juce::AudioBuffer< float > &  buffer,
int  numSamples 
)

Appends an AudioBuffer to the file.

◆ appendBuffer() [2/2]

bool tracktion::engine::AudioFileWriter::appendBuffer ( const int **  buffer,
int  numSamples 
)

Appends an block of samples to the file.

◆ writeFromAudioReader()

bool tracktion::engine::AudioFileWriter::writeFromAudioReader ( juce::AudioFormatReader &  ,
SampleCount  startSample,
SampleCount  numSamples 
)

Appends a block of samples to the file from an audio format reader.

Referenced by tracktion::engine::AudioFileUtils::readFromFormat().

◆ closeForWriting()

void tracktion::engine::AudioFileWriter::closeForWriting ( )

Deletes the writer and releases the file handle.

Member Data Documentation

◆ file

AudioFile tracktion::engine::AudioFileWriter::file

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