Beatmup
Beatmup::Audio::AbstractPlayback Class Reference

Abstract audio playback base class. More...

#include <abstract_playback.h>

Inheritance diagram for Beatmup::Audio::AbstractPlayback:
Beatmup::AbstractTask Beatmup::Object Beatmup::Audio::BasicRealtimePlayback Beatmup::Audio::Android::AAudioPlayback Beatmup::Audio::Android::SLESPlayback

Classes

struct  Mode
 Playback configuration. More...
 

Public Member Functions

ThreadIndex getMaxThreads () const
 Gives the upper limint on the number of threads the task may be performed by. More...
 
void beforeProcessing (ThreadIndex threadCount, ProcessingTarget target, GraphicPipeline *gpu)
 Instruction called before the task is executed. More...
 
virtual void initialize (Mode mode)
 Initializes the playback setting its main parameters. More...
 
void setSource (Source *source)
 Specifies a Source to sample. More...
 
SourcegetSource () const
 Returns the signal source to sample. More...
 
- Public Member Functions inherited from Beatmup::AbstractTask
virtual void afterProcessing (ThreadIndex threadCount, GraphicPipeline *gpu, bool aborted)
 Instruction called after the task is executed. More...
 
virtual bool process (TaskThread &thread)=0
 Executes the task on CPU within a given thread. More...
 
virtual bool processOnGPU (GraphicPipeline &gpu, TaskThread &thread)
 Executes the task on GPU. More...
 
virtual TaskDeviceRequirement getUsedDevices () const
 Communicates devices (CPU and/or GPU) the task is run on. More...
 
- Public Member Functions inherited from Beatmup::Object
virtual ~Object ()
 

Protected Member Functions

 AbstractPlayback ()
 
void advanceTime ()
 Moves time pointer one buffer forward. More...
 

Protected Attributes

Mode mode
 
Sourcesource
 
dtime clock
 

Additional Inherited Members

- Public Types inherited from Beatmup::AbstractTask
enum class  TaskDeviceRequirement { CPU_ONLY , GPU_OR_CPU , GPU_ONLY }
 Specifies which device (CPU and/or GPU) is used to run the task. More...
 
- Static Public Member Functions inherited from Beatmup::AbstractTask
static ThreadIndex validThreadCount (int number)
 Valid thread count from a given integer value. More...
 

Detailed Description

Abstract audio playback base class.

An AbstractTask incarnation that samples a given Source in a buffered fashion. The further processing of the sampled signal (e.g., sending to a device or writing to file) is done in subclasses.

Definition at line 34 of file abstract_playback.h.

Constructor & Destructor Documentation

◆ AbstractPlayback()

AbstractPlayback::AbstractPlayback ( )
protected

Definition at line 72 of file abstract_playback.cpp.

Member Function Documentation

◆ advanceTime()

void AbstractPlayback::advanceTime ( )
protected

Moves time pointer one buffer forward.

Definition at line 91 of file abstract_playback.cpp.

91  {
93 }
dtime bufferLength
length of each atomic buffer in samples

◆ getMaxThreads()

ThreadIndex AbstractPlayback::getMaxThreads ( ) const
virtual

Gives the upper limint on the number of threads the task may be performed by.

The actual number of threads running a specific task may be less or equal to the returned value, depending on the number of workers in ThreadPool running the task.

Reimplemented from Beatmup::AbstractTask.

Definition at line 80 of file abstract_playback.cpp.

80  {
81  return source ? source->getMaxThreads() : 1;
82 }
virtual ThreadIndex getMaxThreads()
Returns the maximum number of working threads for rendering from this source.
Definition: source.h:63

◆ beforeProcessing()

void AbstractPlayback::beforeProcessing ( ThreadIndex  threadCount,
ProcessingTarget  target,
GraphicPipeline gpu 
)
virtual

Instruction called before the task is executed.

Parameters
threadCountNumber of threads used to perform the task
targetDevice used to perform the task
gpuA graphic pipeline instance; may be null.

Reimplemented from Beatmup::AbstractTask.

Definition at line 84 of file abstract_playback.cpp.

84  {
85  if (source) {
88  }
89 }
virtual void setClock(dtime time)
Called by the source user when an abrupt time change occurs (e.g., due to seeking)
Definition: source.cpp:29
virtual void prepare(const dtime sampleRate, const AudioSampleFormat sampleFormat, const unsigned char numChannels, const dtime maxBufferLen)=0
Prepares a source to render audio data.
AudioSampleFormat sampleFormat
format of each sample
dtime sampleRate
samples per second / sample rate in Hz
unsigned char numChannels
number of channels

◆ initialize()

void AbstractPlayback::initialize ( AbstractPlayback::Mode  mode)
virtual

Initializes the playback setting its main parameters.

Reimplemented in Beatmup::Audio::BasicRealtimePlayback, Beatmup::Audio::Android::SLESPlayback, and Beatmup::Audio::Android::AAudioPlayback.

Definition at line 74 of file abstract_playback.cpp.

74  {
75  this->mode = mode;
76  clock = 0;
77 }

◆ setSource()

void Beatmup::Audio::AbstractPlayback::setSource ( Source source)
inline

Specifies a Source to sample.

Parameters
[in]sourceThe source of audio signal to play from

Definition at line 88 of file abstract_playback.h.

88 { this->source = source; }

◆ getSource()

Source* Beatmup::Audio::AbstractPlayback::getSource ( ) const
inline

Returns the signal source to sample.

Definition at line 93 of file abstract_playback.h.

93 { return source; }

Member Data Documentation

◆ mode

Mode Beatmup::Audio::AbstractPlayback::mode
protected

Definition at line 65 of file abstract_playback.h.

◆ source

Source* Beatmup::Audio::AbstractPlayback::source
protected

Definition at line 66 of file abstract_playback.h.

◆ clock

dtime Beatmup::Audio::AbstractPlayback::clock
protected

Definition at line 68 of file abstract_playback.h.


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