JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::AudioFormatWriter::ThreadedWriter Class Reference

Provides a FIFO for an AudioFormatWriter, allowing you to push incoming data into a buffer which will be flushed to disk by a background thread. More...

#include <juce_AudioFormatWriter.h>

Collaboration diagram for juce::AudioFormatWriter::ThreadedWriter:

Classes

class  IncomingDataReceiver
 Receiver for incoming data. More...
 

Public Member Functions

 ThreadedWriter (AudioFormatWriter *writer, TimeSliceThread &backgroundThread, int numSamplesToBuffer)
 Creates a ThreadedWriter for a given writer and a thread. More...
 
 ~ThreadedWriter ()
 Destructor. More...
 
void setDataReceiver (IncomingDataReceiver *)
 Allows you to specify a callback that this writer should update with the incoming data. More...
 
void setFlushInterval (int numSamplesPerFlush) noexcept
 Sets how many samples should be written before calling the AudioFormatWriter::flush method. More...
 
bool write (const float *const *data, int numSamples)
 Pushes some incoming audio data into the FIFO. More...
 

Private Attributes

std::unique_ptr< Buffer > buffer
 

Detailed Description

Provides a FIFO for an AudioFormatWriter, allowing you to push incoming data into a buffer which will be flushed to disk by a background thread.

Constructor & Destructor Documentation

◆ ThreadedWriter()

juce::AudioFormatWriter::ThreadedWriter::ThreadedWriter ( AudioFormatWriter writer,
TimeSliceThread backgroundThread,
int  numSamplesToBuffer 
)

Creates a ThreadedWriter for a given writer and a thread.

The writer object which is passed in here will be owned and deleted by the ThreadedWriter when it is no longer needed.

To stop the writer and flush the buffer to disk, simply delete this object.

◆ ~ThreadedWriter()

juce::AudioFormatWriter::ThreadedWriter::~ThreadedWriter ( )

Destructor.

Member Function Documentation

◆ setDataReceiver()

void juce::AudioFormatWriter::ThreadedWriter::setDataReceiver ( IncomingDataReceiver )

Allows you to specify a callback that this writer should update with the incoming data.

The receiver will be cleared and the writer will begin adding data to it as the data arrives. Pass a null pointer to remove the current receiver.

The object passed-in must not be deleted while this writer is still using it.

◆ setFlushInterval()

void juce::AudioFormatWriter::ThreadedWriter::setFlushInterval ( int  numSamplesPerFlush)
noexcept

Sets how many samples should be written before calling the AudioFormatWriter::flush method.

Set this to 0 to disable flushing (this is the default).

◆ write()

bool juce::AudioFormatWriter::ThreadedWriter::write ( const float *const *  data,
int  numSamples 
)

Pushes some incoming audio data into the FIFO.

If there's enough free space in the buffer, this will add the data to it,

If the FIFO is too full to accept this many samples, the method will return false - then you could either wait until the background thread has had time to consume some of the buffered data and try again, or you can give up and lost this block.

The data must be an array containing the same number of channels as the AudioFormatWriter object is using. None of these channels can be null.

Member Data Documentation

◆ buffer

std::unique_ptr<Buffer> juce::AudioFormatWriter::ThreadedWriter::buffer
private

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