Anklang C++ API 0.0.0
Loading...
Searching...
No Matches
AudioProcessorabstract

#include "processor.hh"

Inheritance diagram for AudioProcessor:
[legend]

Classes

struct EventStreams
class FloatBuffer
struct IOBus
struct ProcessorSetup
struct RenderContext

Public Types

usingMakeDeviceP = std::function< DeviceP(const String &, StaticInfo, AudioProcessorP)>
usingMakeProcessor = AudioProcessorP(*)(AudioEngine &)
usingMakeProcessorP = AudioProcessorP(*)(CString, AudioEngine &)
usingMaybeParamId = std::pair< ParamId, bool >
usingStaticInfo = void(*)(AudioProcessorInfo &)

Public Member Functions

voidadjust_all_params ()
AtomicBits::Iteratomic_bits_iter (size_t pos=0) const
BusInfobus_info (IBusId busid) const
BusInfobus_info (OBusId busid) const
boolcheck_dirty (Id32 paramid) const
voidconnect_event_input (AudioProcessor &oproc)
boolconnected (OBusId obusid) const
Stringdebug_name () const
voiddisconnect_event_input ()
voidenable_engine_output (bool onoff)
AudioEngine &engine () const
IBusIdfind_ibus (const String &name) const
OBusIdfind_obus (const String &name) const
MaybeParamIdfind_param (const String &identifier) const
DevicePget_device () const
doubleget_normalized (Id32 paramid)
doubleget_param (Id32 paramid)
boolhas_event_input () const
boolhas_event_output () const
const float *ifloats (IBusId b, uint c) const
doubleinyquist () const
boolis_initialized () const
uintn_ibuses () const
uintn_ichannels (IBusId busid) const
uintn_obuses () const
uintn_ochannels (OBusId busid) const
floatnote_to_freq (int note) const
doublenyquist () const
const float *ofloats (OBusId b, uint c) const
MinMaxparam_range (Id32 paramid) const
virtual doubleparam_value_from_text (uint32_t paramid, const String &text) const
virtual Stringparam_value_to_text (uint32_t paramid, double value) const
ParameterCparameter (Id32 paramid) const
uintsample_rate () const
boolsend_param (Id32 paramid, double value)
boolset_normalized (Id32 paramid, double normalized)
Stringtext_param_from_quark (uint32_t paramid, uint vint)
uinttext_param_to_quark (uint32_t paramid, const String &text)
const AudioTransport &transport () const
virtual doublevalue_from_normalized (Id32 paramid, double normalized) const
virtual doublevalue_to_normalized (Id32 paramid, double value) const
- Public Member Functions inherited from NewDeleteBase
voidoperator delete (void *ptr, std::size_t sz)
voidoperator delete (void *ptr, std::size_t sz, std::align_val_t al)
voidoperator delete[] (void *ptr, std::size_t sz)
voidoperator delete[] (void *ptr, std::size_t sz, std::align_val_t al)
void *operator new (std::size_t sz)
void *operator new (std::size_t sz, std::align_val_t al)
void *operator new[] (std::size_t sz)
void *operator new[] (std::size_t sz, std::align_val_t al)

Static Public Member Functions

template<class AudioProc , class ... Args>
static std::shared_ptr< AudioProc >create_processor (AudioEngine &engine, const Args &...args)
static doubleparam_peek_mt (const AudioProcessorP proc, Id32 paramid)
static voidregistry_add (CString aseid, StaticInfo, MakeProcessorP)
static DevicePregistry_create (CString aseid, AudioEngine &engine, const MakeDeviceP &)
static voidregistry_foreach (const std::function< void(const String &aseid, StaticInfo)> &fun)
static uint64timestamp ()

Static Public Attributes

static const StringGUIONLY
static const StringSTANDARD
static const StringSTORAGEONLY

Protected Types

enum {
  INITIALIZED , SCHEDULED , PARAMCHANGE , BUSCONNECT ,
  BUSDISCONNECT , INSERTION , REMOVAL , ENGINE_OUTPUT
}
usingMidiEventInput = MidiEventReader< 2 >
usingMinMax = std::pair< double, double >

Protected Member Functions

IBusIdadd_input_bus (CString uilabel, SpeakerArrangement speakerarrangement, const String &hints="", const String &blurb="")
OBusIdadd_output_bus (CString uilabel, SpeakerArrangement speakerarrangement, const String &hints="", const String &blurb="")
virtual voidadjust_param (uint32_t paramid)
voidapply_event (const MidiEvent &event)
voidapply_input_events ()
voidassign_oblock (OBusId b, uint c, float val)
boolatomic_bit_notify (size_t nth)
voidatomic_bits_resize (size_t count)
AudioProcessor (const ProcessorSetup &)
voidconnect (IBusId ibus, AudioProcessor &oproc, OBusId obus)
voiddisconnect (IBusId ibus)
voiddisconnect_ibuses ()
voiddisconnect_obuses ()
voidenotify_enqueue_mt (uint32 pushmask)
virtual voidinitialize (SpeakerArrangement busses)=0
voidinstall_params (const AudioParams::Map &params)
IOBus &iobus (IBusId busid)
const IOBus &iobus (IBusId busid) const
IOBus &iobus (OBusId busid)
const IOBus &iobus (OBusId busid) const
MidiEventInputmidi_event_input ()
MidiEventOutput &midi_event_output ()
float *oblock (OBusId b, uint c)
doublepeek_param_mt (Id32 paramid) const
voidprepare_event_input ()
voidprepare_event_output ()
voidredirect_oblock (OBusId b, uint c, const float *block)
voidremove_all_buses ()
voidreschedule ()
virtual uintschedule_children ()
uintschedule_processor ()
virtual~AudioProcessor ()

Static Protected Member Functions

static uintschedule_processor (AudioProcessor &p)

Protected Attributes

CStringaseid_
AudioEngine &engine_
std::atomic< uint32 >flags_

Detailed Description

Audio signal AudioProcessor base class, implemented by all effects and instruments.

Member Typedef Documentation

MinMax

using MinMax = std::pair<double,double>
protected

MidiEventInput

using MidiEventInput = MidiEventReader<2>
protected

MakeProcessor

using MakeProcessor = AudioProcessorP (*) (AudioEngine&)

MaybeParamId

using MaybeParamId = std::pair<ParamId,bool>

StaticInfo

using StaticInfo = void (*) (AudioProcessorInfo&)

MakeDeviceP

using MakeDeviceP = std::function<DeviceP (const String&, StaticInfo, AudioProcessorP)>

MakeProcessorP

using MakeProcessorP = AudioProcessorP (*) (CString,AudioEngine&)

Member Enumeration Documentation

anonymous enum

anonymous enum
protected
Enumerator
INITIALIZED
SCHEDULED
PARAMCHANGE
BUSCONNECT
BUSDISCONNECT
INSERTION
REMOVAL
ENGINE_OUTPUT

Constructor & Destructor Documentation

AudioProcessor()

AudioProcessor ( const ProcessorSetup & psetup)
explicitprotected

Constructor for AudioProcessor.

~AudioProcessor()

~AudioProcessor ( )
protectedvirtual

The destructor is called when the last std::shared_ptr<> reference drops.

Member Function Documentation

initialize()

void initialize ( SpeakerArrangement busses)
protectedpure virtual

Mandatory method to setup parameters and I/O busses. See add_param(), add_input_bus() / add_output_bus(). This method will be called once per instance after construction.

Implemented in ClapAudioProcessor, AudioChain::Inlet, AudioChain, and MidiProducerImpl.

enotify_enqueue_mt()

void enotify_enqueue_mt ( uint32 pushmask)
protected

Queue an AudioProcessor notification This function is MT-Safe after proper AudioProcessor initialization.

schedule_processor() [1/2]

uint schedule_processor ( )
protected

Schedule this node and its dependencies for engine rendering.

reschedule()

void reschedule ( )
protected

Request recreation of the audio engine rendering schedule.

schedule_children()

virtual uint schedule_children ( )
protectedvirtual

Reimplemented in AudioChain.

schedule_processor() [2/2]

static uint schedule_processor ( AudioProcessor & p)
staticprotected

install_params()

void install_params ( const AudioParams::Map & params)
protected

Reset list of parameters, enqueues parameter value initializaiton events.

apply_event()

void apply_event ( const MidiEvent & event)
protected

Assign MidiEvent::PARAM_VALUE event values to parameters.

apply_input_events()

void apply_input_events ( )
protected

Process all input events via apply_event() and adjust_param(). This applies all incoming parameter changes, events like NOTE_ON are not handled.

adjust_param()

virtual void adjust_param ( uint32_t paramid)
protectedvirtual

peek_param_mt()

double peek_param_mt ( Id32 paramid) const
protected

Fetch the current parameter value of an AudioProcessor. This function does not modify the parameter `dirty` flag. This function is MT-Safe after proper AudioProcessor initialization.

add_input_bus()

IBusId add_input_bus ( CString uilabel,
SpeakerArrangement speakerarrangement,
const String & hints = "",
const String & blurb = ""
)
protected

Add an input bus with `uilabel` and channels configured via `speakerarrangement`.

add_output_bus()

OBusId add_output_bus ( CString uilabel,
SpeakerArrangement speakerarrangement,
const String & hints = "",
const String & blurb = ""
)
protected

Add an output bus with `uilabel` and channels configured via `speakerarrangement`.

remove_all_buses()

void remove_all_buses ( )
protected

Remove existing bus configurations, useful at the start of configure().

iobus() [1/4]

AudioProcessor::IOBus & iobus ( OBusId busid)
protected

Get internal output bus handle.

iobus() [2/4]

AudioProcessor::IOBus & iobus ( IBusId busid)
protected

Get internal input bus handle.

iobus() [3/4]

const IOBus & iobus ( OBusId busid) const
protected

iobus() [4/4]

const IOBus & iobus ( IBusId busid) const
protected

disconnect_ibuses()

void disconnect_ibuses ( )
protected

Reset input bus buffer data.

disconnect_obuses()

void disconnect_obuses ( )
protected

Disconnect inputs of all Processors that are connected to outputs of `this`.

disconnect()

void disconnect ( IBusId ibus)
protected

Disconnect input `ibusid`.

connect()

void connect ( IBusId ibus,
AudioProcessor & oproc,
OBusId obus
)
protected

Connect input `ibusid` to output `obusid` of AudioProcessor `prev`.

oblock()

float * oblock ( OBusId b,
uint c
)
protected

Reset buffer redirections and access float buffer of output bus `b`, channel `c`. See also ofloats() for readonly access and redirect_oblock() for redirections.

assign_oblock()

void assign_oblock ( OBusId b,
uint c,
float val
)
protected

Fill the output buffer of bus `b`, channel `c` with `v`.

redirect_oblock()

void redirect_oblock ( OBusId b,
uint c,
const float * block
)
protected

Redirect output buffer of bus `b`, channel `c` to point to `block`, or zeros if `block==nullptr`.

prepare_event_input()

void prepare_event_input ( )
protected

Prepare the AudioProcessor to receive Event objects during render() via get_event_input(). Note, remove_all_buses() will remove the Event input created by this function.

prepare_event_output()

void prepare_event_output ( )
protected

Prepare the AudioProcessor to produce Event objects during render() via get_event_output(). Note, remove_all_buses() will remove the Event output created by this function.

midi_event_input()

AudioProcessor::MidiEventInput midi_event_input ( )
protected

Access the current MidiEvent inputs during render(), needs prepare_event_input().

midi_event_output()

MidiEventOutput & midi_event_output ( )
protected

Access the current output EventStream during render(), needs prepare_event_output().

atomic_bits_resize()

void atomic_bits_resize ( size_t count)
protected

Prepare `count` bits for atomic notifications.

atomic_bit_notify()

bool atomic_bit_notify ( size_t nth)
protected

Set the nth atomic notification bit, return if enotify_enqueue_mt() is needed.

atomic_bits_iter()

AtomicBits::Iter atomic_bits_iter ( size_t pos = 0) const

Allow iterations over the atomic bits.

note_to_freq()

float note_to_freq ( int note) const

Convert MIDI note to Hertz according to the current MusicalTuning.

debug_name()

String debug_name ( ) const

engine()

AudioEngine & engine ( ) const

Retrieve AudioEngine handle for this AudioProcessor.

transport()

const AudioTransport & transport ( ) const

Sample rate mixing frequency in Hz as unsigned, used for render().

sample_rate()

uint sample_rate ( ) const

nyquist()

double nyquist ( ) const

Half the sample rate in Hz as double, used for render().

inyquist()

double inyquist ( ) const

Inverse Nyquist frequency, i.e. 1.0 / nyquist().

get_param()

double get_param ( Id32 paramid)

Fetch `value` of parameter `id`.

send_param()

bool send_param ( Id32 paramid,
double value
)

Set parameter `id` to `value` within `ParamInfo.get_minmax()`.

parameter()

ParameterC parameter ( Id32 paramid) const

Retrieve supplemental information for parameters, usually to enhance the user interface.

find_param()

auto find_param ( const String & identifier) const

Return the ParamId for parameter `identifier` or else 0.

param_range()

AudioProcessor::MinMax param_range ( Id32 paramid) const

Retrieve the minimum / maximum values for a parameter.

check_dirty()

bool check_dirty ( Id32 paramid) const

Check if the parameter `dirty` flag is set. Return `true` if the parameter value changed during render().

adjust_all_params()

void adjust_all_params ( )

param_value_to_text()

String param_value_to_text ( uint32_t paramid,
double value
) const
virtual

Format a parameter `paramid` value as text string. Currently, this function may be called from any thread, so `this` must be treated as `const` (it might be used concurrently by a different thread).

param_value_from_text()

double param_value_from_text ( uint32_t paramid,
const String & text
) const
virtual

Extract a parameter `paramid` value from a text string. The string might contain unit information or consist only of number characters. Non-recognized characters should be ignored, so a best effort conversion is always undertaken. This function may be called from any thread, so `this` must be treated as `const` (it might be used concurrently by a different thread).

value_to_normalized()

double value_to_normalized ( Id32 paramid,
double value
) const
virtual

value_from_normalized()

double value_from_normalized ( Id32 paramid,
double normalized
) const
virtual

get_normalized()

double get_normalized ( Id32 paramid)

Get param value normalized into 0…1.

set_normalized()

bool set_normalized ( Id32 paramid,
double normalized
)

Set param value normalized into 0…1.

is_initialized()

bool is_initialized ( ) const

Check if AudioProcessor has been properly intiialized (so the parameter set is fixed).

text_param_to_quark()

uint text_param_to_quark ( uint32_t paramid,
const String & text
)

Ase main-thread helper for temporary string<->uint conversions.

text_param_from_quark()

String text_param_from_quark ( uint32_t paramid,
uint vint
)

Helper for temporary uint<->string conversions.

find_ibus()

IBusId find_ibus ( const String & name) const

Return the IBusId for input bus `uilabel` or else 0.

find_obus()

OBusId find_obus ( const String & name) const

Return the OBusId for output bus `uilabel` or else 0.

n_ibuses()

uint n_ibuses ( ) const

Number of input buses configured for this AudioProcessor.

n_obuses()

uint n_obuses ( ) const

Number of output buses configured for this AudioProcessor.

n_ichannels()

uint n_ichannels ( IBusId busid) const

Number of channels of input bus `busid` configured for this AudioProcessor.

n_ochannels()

uint n_ochannels ( OBusId busid) const

Number of channels of output bus `busid` configured for this AudioProcessor.

bus_info() [1/2]

BusInfo bus_info ( IBusId busid) const

Retrieve BusInfo for an input bus.

bus_info() [2/2]

BusInfo bus_info ( OBusId busid) const

Retrieve BusInfo for an output bus.

connected()

bool connected ( OBusId obusid) const

Indicator for connected output buses. Not connected output bus buffers do not need to be filled.

ifloats()

const float * ifloats ( IBusId b,
uint c
) const

Access readonly float buffer of input bus `b`, channel `c`, see also ofloats().

ofloats()

const float * ofloats ( OBusId b,
uint c
) const

Access readonly float buffer of output bus `b`, channel `c`, see also oblock().

timestamp()

uint64 timestamp ( )
static

The current timestamp in sample frames.

get_device()

DeviceP get_device ( ) const

Gain access to the Device handle of `this` AudioProcessor.

has_event_input()

bool has_event_input ( ) const

Returns `true` if this AudioProcessor has an event input stream.

has_event_output()

bool has_event_output ( ) const

Returns `true` if this AudioProcessor has an event output stream.

connect_event_input()

void connect_event_input ( AudioProcessor & oproc)

Connect event input to event output of AudioProcessor `oproc`.

disconnect_event_input()

void disconnect_event_input ( )

Disconnect event input if a connection is present.

enable_engine_output()

void enable_engine_output ( bool onoff)

Configure if the main output of this module is mixed into the engine output.

param_peek_mt()

double param_peek_mt ( const AudioProcessorP proc,
Id32 paramid
)
static

Fetch the current parameter value of a AudioProcessor from any thread. This function is MT-Safe after proper AudioProcessor initialization.

registry_add()

void registry_add ( CString aseid,
StaticInfo static_info,
MakeProcessorP makeproc
)
static

Add a new type to the AudioProcessor type registry. New AudioProcessor types must have a unique URI (see `query_info()`) and will be created with the factory function `create()`.

registry_create()

DeviceP registry_create ( CString aseid,
AudioEngine & engine,
const MakeDeviceP & makedevice
)
static

registry_foreach()

void registry_foreach ( const std::function< void(const String &aseid, StaticInfo)> & fun)
static

Iterate over the known AudioProcessor types.

create_processor()

template<class AudioProc , class ... Args>
std::shared_ptr< AudioProc > create_processor ( AudioEngine & engine,
const Args &... args
)
static

Member Data Documentation

flags_

std::atomic<uint32> flags_
protected

engine_

AudioEngine& engine_
protected

aseid_

CString aseid_
protected

GUIONLY

const String GUIONLY
static

":G:r:w:" - GUI READABLE WRITABLE

GUI READABLE WRITABLE.

STANDARD

const String STANDARD
static

":G:S:r:w:" - GUI STORAGE READABLE WRITABLE

GUI STORAGE READABLE WRITABLE.

STORAGEONLY

const String STORAGEONLY
static

":S:r:w:" - STORAGE READABLE WRITABLE

STORAGE READABLE WRITABLE.