ofxPDSP
pdsp::Function Class Reference

powerful class for sequencing. Function executed a given code with a rate defined by timing variable and by pdsp::Engine sequencer tempo. Into the executed assignable lambda you can send out triggers or value messages to the pdsp::Function outputs More...

#include <Function.h>

Public Member Functions

pdsp::SequencerGateOutputout_trig (std::string name)
 get a trigger output for the given name. More...
 
pdsp::SequencerGateOutputout_trig (int number)
 get a trigger output for the given name. More...
 
pdsp::SequencerValueOutputout_value (std::string name)
 get a value output for the given name. More...
 
pdsp::SequencerValueOutputout_value (int number)
 get a value output for the given name. More...
 
void send (std::string name, float value) noexcept
 use this method inside the assigned code to send a value to a given output name More...
 
void send (int number, float value) noexcept
 use this method inside the assigned code to send a value to a given output number id More...
 
int frame ()
 returns the playback timepoint in bars, multiplied by the timing, as integer.
 
float urand ()
 internal random, returns a value from 0.0f to 1.0f ( included ).
 
float brand ()
 internal random, returns a value from -1.0f to 1.0f ( included ).
 
int dice (int max)
 internal random, returns value from 0 to max-1 More...
 
bool chance (float probablility)
 randomly returns true of false, with the argument setting the chance of being "true". More...
 

Public Attributes

std::function< void()> code
 this lambda function is executed each step, at the timing assigned to the class. Assign your own functions to it. The step number is passed to the function as int value. Remember that this function will be executed into the audio-thread so the access to some variable used also into the main thread could cause race conditions.
 
std::atomic< int > timing
 timing for the function frames, defaults to 16 ( 1/16th of a bar ). Thread-safe to set.
 
std::atomic< bool > active
 enable / disable exectution of lambda, true by default, Thread-safe to set.
 

Friends

class SequencerProcessor
 

Detailed Description

powerful class for sequencing. Function executed a given code with a rate defined by timing variable and by pdsp::Engine sequencer tempo. Into the executed assignable lambda you can send out triggers or value messages to the pdsp::Function outputs

Member Function Documentation

◆ chance()

bool pdsp::Function::chance ( float  probablility)

randomly returns true of false, with the argument setting the chance of being "true".

Parameters
[in]probablilitychance of output being true

◆ dice()

int pdsp::Function::dice ( int  max)

internal random, returns value from 0 to max-1

Parameters
[in]maxmax exclusive

◆ out_trig() [1/2]

pdsp::SequencerGateOutput & pdsp::Function::out_trig ( std::string  name)

get a trigger output for the given name.

Parameters
[in]nameoutput name tag

◆ out_trig() [2/2]

pdsp::SequencerGateOutput & pdsp::Function::out_trig ( int  number)

get a trigger output for the given name.

Parameters
[in]numberoutput number id

◆ out_value() [1/2]

pdsp::SequencerValueOutput & pdsp::Function::out_value ( std::string  name)

get a value output for the given name.

Parameters
[in]nameoutput name tag

◆ out_value() [2/2]

pdsp::SequencerValueOutput & pdsp::Function::out_value ( int  number)

get a value output for the given name.

Parameters
[in]numberoutput number id

◆ send() [1/2]

void pdsp::Function::send ( std::string  name,
float  value 
)
noexcept

use this method inside the assigned code to send a value to a given output name

Parameters
[in]nameoutput name
[in]valuevalue to send

◆ send() [2/2]

void pdsp::Function::send ( int  number,
float  value 
)
noexcept

use this method inside the assigned code to send a value to a given output number id

Parameters
[in]nameoutput name
[in]valuevalue to send

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