Beatmup
Beatmup::Audio::Signal::Source Class Reference

Audio::Source reading samples from a given Signal. More...

#include <signal.h>

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

Public Member Functions

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

Private Attributes

Signalsignal
 
dtime time
 
AudioSampleFormat sampleFormat
 
unsigned char numChannels
 

Detailed Description

Audio::Source reading samples from a given Signal.

Definition at line 146 of file signal.h.

Constructor & Destructor Documentation

◆ Source()

Signal::Source::Source ( Signal signal)

Definition at line 351 of file signal.cpp.

351 : signal(&signal) {}

Member Function Documentation

◆ getMaxThreads()

ThreadIndex Beatmup::Audio::Signal::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 from Beatmup::Audio::Source.

Definition at line 156 of file signal.h.

156 { return 1; }

◆ prepare()

void Signal::Source::prepare ( const dtime  sampleRate,
const AudioSampleFormat  sampleFormat,
const unsigned char  numChannels,
const dtime  maxBufferLen 
)
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

Implements Beatmup::Audio::Source.

Definition at line 354 of file signal.cpp.

359  {
360  this->numChannels = numChannels;
361  this->sampleFormat = sampleFormat;
362 }
unsigned char numChannels
Definition: signal.h:151
AudioSampleFormat sampleFormat
Definition: signal.h:150

◆ setClock()

void Signal::Source::setClock ( dtime  time)
virtual

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

Reimplemented from Beatmup::Audio::Source.

Definition at line 365 of file signal.cpp.

365  {
366  this->time = time;
367 }

◆ render()

void Signal::Source::render ( TaskThread thread,
sample8 buffer,
const dtime  bufferLength 
)
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

Implements Beatmup::Audio::Source.

Definition at line 370 of file signal.cpp.

374  {
375  Reader ptr(*signal, time);
376  Processing::pipeline<Kernels::RenderAudio>(signal->getSampleFormat(), sampleFormat, nullptr, buffer, ptr, bufferLength, signal->getChannelCount(), numChannels);
377  time += bufferLength;
378 }
unsigned char getChannelCount() const
Definition: signal.h:232
AudioSampleFormat getSampleFormat() const
Definition: signal.h:237

Member Data Documentation

◆ signal

Signal* Beatmup::Audio::Signal::Source::signal
private

Definition at line 148 of file signal.h.

◆ time

dtime Beatmup::Audio::Signal::Source::time
private

Definition at line 149 of file signal.h.

◆ sampleFormat

AudioSampleFormat Beatmup::Audio::Signal::Source::sampleFormat
private

Definition at line 150 of file signal.h.

◆ numChannels

unsigned char Beatmup::Audio::Signal::Source::numChannels
private

Definition at line 151 of file signal.h.


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