Beatmup
Beatmup::Audio::Source Class Referenceabstract

Abstract source of audio signal. More...

#include <source.h>

Inheritance diagram for Beatmup::Audio::Source:
Beatmup::Audio::HarmonicSource Beatmup::Audio::Signal::Source

Public Member Functions

virtual ~Source ()
 
virtual void prepare (const dtime sampleRate, const AudioSampleFormat sampleFormat, const unsigned char numChannels, const dtime maxBufferLen)=0
 Prepares a source to render audio data. More...
 
virtual void setClock (dtime time)
 Called by the source user when an abrupt time change occurs (e.g., due to seeking) More...
 
virtual ThreadIndex getMaxThreads ()
 Returns the maximum number of working threads for rendering from this source. More...
 
virtual void render (TaskThread &thread, sample8 *buffer, const dtime bufferLength)=0
 Renders audio data to the target output buffer given by the user. More...
 

Detailed Description

Abstract source of audio signal.

Produces samples in time, possibly in multiple threads running in parallel.

Definition at line 30 of file source.h.

Constructor & Destructor Documentation

◆ ~Source()

virtual Beatmup::Audio::Source::~Source ( )
inlinevirtual

Definition at line 32 of file source.h.

32 {};

Member Function Documentation

◆ prepare()

virtual void Beatmup::Audio::Source::prepare ( const dtime  sampleRate,
const AudioSampleFormat  sampleFormat,
const unsigned char  numChannels,
const dtime  maxBufferLen 
)
pure virtual

Prepares a source to render audio data.

Called by the user before any rendering to communicate the configuration of the upcoming rendering process.

Parameters
sampleRateThe output sample rate in Hz
sampleFormatThe output sample format
numChannelsNumber of channels in the output
maxBufferLenMaximum expected length of target audio buffers on rendering phase, in samples per one channel

Implemented in Beatmup::Audio::HarmonicSource, and Beatmup::Audio::Signal::Source.

◆ setClock()

void Source::setClock ( dtime  time)
virtual

Called by the source user when an abrupt time change occurs (e.g., due to seeking)

Reimplemented in Beatmup::Audio::HarmonicSource, and Beatmup::Audio::Signal::Source.

Definition at line 29 of file source.cpp.

29  {
30  // nothing to do by default
31 }

◆ getMaxThreads()

virtual ThreadIndex Beatmup::Audio::Source::getMaxThreads ( )
inlinevirtual

Returns the maximum number of working threads for rendering from this source.

The actual number of threads may be less than the one returned by this function. It is the source duty to deal with the actual number of workers.

Reimplemented in Beatmup::Audio::Signal::Source.

Definition at line 63 of file source.h.

63 { return 1; }

◆ render()

virtual void Beatmup::Audio::Source::render ( TaskThread thread,
sample8 buffer,
const dtime  bufferLength 
)
pure virtual

Renders audio data to the target output buffer given by the user.

Called after at least one call to prepare(). The sampling parameters must match the ones communicated on the preparation phase. The requested buffer length does not exceed the one set before. The time is given by the clock set before, and with every call it advances by {bufferLength} samples.

Parameters
threadthe task thread issuing this rendering call
buffera pointer to the beginning of a channelwise-multiplexed output buffer
bufferLengththe requested buffer length, in samples per single channel

Implemented in Beatmup::Audio::HarmonicSource, and Beatmup::Audio::Signal::Source.


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