BSE Interface Reference

/opt/src/beast/bse/bseengine.h

SYNOPSIS

struct  BseEngineLoop;
struct  _BseIStream;
struct  _BseJStream;
struct  _BseModule;
struct  _BseModuleClass;
struct  _BseOStream;
   
void  bse_engine_add_user_callback  (data, free_func);
gboolean  bse_engine_check  (loop);
gboolean  bse_engine_configure  (latency_ms, sample_freq, control_freq);
gfloat*  bse_engine_const_values  (value);
gfloat*  bse_engine_const_zeros  (smaller_than_BSE_STREAM_MAX_VALUES);
void  bse_engine_constrain  (latency_ms, sample_freq, control_freq, block_size_p, control_raster_p);
void  bse_engine_dispatch  ();
void  bse_engine_free_ostreams  (n_ostreams, ostreams);
BirnetThread**  bse_engine_get_threads  (n_threads);
gboolean  bse_engine_has_garbage  ();
void  bse_engine_init  (threaded);
gboolean  bse_engine_prepare  (loop);
guint64  bse_engine_tick_stamp_from_systime  (systime);
void  bse_engine_user_thread_collect  ();
void  bse_engine_wait_on_trans  ();
BseJob*  bse_job_access  (module, access_func, data, free_func);
BseJob*  bse_job_add_poll  (poll_func, data, free_func, n_fds, fds);
BseJob*  bse_job_add_timer  (timer_func, data, free_func);
BseJob*  bse_job_boundary_access  (module, tick_stamp, access_func, data, free_func);
BseJob*  bse_job_boundary_discard  (module);
BseJob*  bse_job_connect  (src_module, src_ostream, dest_module, dest_istream);
BseJob*  bse_job_debug  (debug);
BseJob*  bse_job_discard  (module);
BseJob*  bse_job_disconnect  (dest_module, dest_istream);
BseJob*  bse_job_flow_access  (module, tick_stamp, access_func, data, free_func);
BseJob*  bse_job_force_reset  (module);
BseJob*  bse_job_integrate  (module);
BseJob*  bse_job_jconnect  (src_module, src_ostream, dest_module, dest_jstream);
BseJob*  bse_job_jdisconnect  (dest_module, dest_jstream, src_module, src_ostream);
BseJob*  bse_job_kill_inputs  (module);
BseJob*  bse_job_kill_outputs  (module);
BseJob*  bse_job_nop  ();
BseJob*  bse_job_probe_request  (module, probe, data);
BseJob*  bse_job_remove_poll  (poll_func, data);
BseJob*  bse_job_resume_at  (module, tick_stamp);
BseJob*  bse_job_set_consumer  (module, is_toplevel_consumer);
BseJob*  bse_job_suspend_now  (module);
gboolean  bse_module_has_source  (module, istream);
gboolean  bse_module_is_scheduled  (module);
BseModule*  bse_module_new  (klass, user_data);
BseModule*  bse_module_new_virtual  (n_iostreams, user_data, free_data);
guint64  bse_module_tick_stamp  (module);
void  bse_trans_add  (trans, job);
guint64  bse_trans_commit  (trans);
void  bse_trans_commit_delayed  (trans, tick_stamp);
void  bse_trans_dismiss  (trans);
BseTrans*  bse_trans_merge  (trans1, trans2);
BseTrans*  bse_trans_open  ();
void  bse_transact  (job, ...);

DESCRIPTION

BseEngineLoop

/opt/src/beast/bse/bseengine.h:222
struct BseEngineLoop
{
  glong    timeout;
  gboolean fds_changed;
  guint    n_fds;
  GPollFD *fds;
  gboolean revents_filled;
};

_BseIStream

/opt/src/beast/bse/bseengine.h:103
struct _BseIStream
{
  const gfloat *values;
  gboolean      connected;
};

_BseJStream

/opt/src/beast/bse/bseengine.h:96
struct _BseJStream
{
  const gfloat **values;
  guint          n_connections;
  guint          jcount;
};

_BseModule

/opt/src/beast/bse/bseengine.h:87
struct _BseModule
{
  const BseModuleClass *klass;
  gpointer              user_data;
  BseIStream           *istreams;
  BseJStream           *jstreams;
  BseOStream           *ostreams;
};

_BseModuleClass

/opt/src/beast/bse/bseengine.h:75
struct _BseModuleClass
{
  guint               n_istreams;
  guint               n_jstreams;
  guint               n_ostreams;
  BseProcessFunc      process;
  BseProcessDeferFunc process_defer;
  BseModuleResetFunc  reset;
  BseModuleFreeFunc   free;
  BseCostType         mflags;
};

_BseOStream

/opt/src/beast/bse/bseengine.h:108
struct _BseOStream
{
  gfloat  *values;
  gboolean connected;
};

bse_engine_add_user_callback

/opt/src/beast/bse/bseengine.h:211
Queues data to be collected by bse_engine_user_thread_collect(), so free_func() will be called with data as argument during the next garbage collection cycle in the user thread. This function is MT-safe and may be called from any thread.
data: Data passed in to the free_func
free_func: Function to free data (executed in user thread)

bse_engine_check

/opt/src/beast/bse/bseengine.h:231

bse_engine_configure

/opt/src/beast/bse/bseengine.h:202
gboolean  bse_engine_configure 
(guint latency_ms,
 guint sample_freq,
 guint control_freq);
Reconfigure engine parameters. This function may only be called after engine initialization and can only succeed if no modules are currently integrated.
latency_ms: calculation latency in milli seconds
sample_freq: mixing frequency
control_freq: frequency at which to check control values or 0
returns: whether reconfiguration was successful

bse_engine_const_values

/opt/src/beast/bse/bseengine.h:191

bse_engine_const_zeros

/opt/src/beast/bse/bseengine.h:205
gfloat*  bse_engine_const_zeros 
(guint smaller_than_BSE_STREAM_MAX_VALUES);

bse_engine_constrain

/opt/src/beast/bse/bseengine.h:198
void  bse_engine_constrain 
(guint  latency_ms,
 guint  sample_freq,
 guint  control_freq,
 guint *block_size_p,
 guint *control_raster_p);
Calculate a suitable block size and control raster for a sample_freq at a specific latency_ms (the latency should be > 0). The control_freq if specified should me much smaller than the sample_freq. It determines how often control values are to be checked when calculating blocks of sample values. The block size determines the amount by which the global tick stamp (see gsl_tick_stamp()) is updated everytime the whole module network completed processing block size values. This function is MT-safe and may be called prior to engine initialization.
latency_ms: calculation latency in milli seconds
sample_freq: mixing frequency
control_freq: frequency at which to check control values or 0
block_size_p: location of number of values to process block wise
control_raster_p: location of number of values to skip between control values

bse_engine_dispatch

/opt/src/beast/bse/bseengine.h:232
Perform necessary work the engine has to handle in the user thread. This function may only be called from the user thread, since it will invoke BseFreeFunc() functions (see bse_engine_user_thread_collect()) and do other things which are guranteed to be executed in the user thread.

bse_engine_free_ostreams

/opt/src/beast/bse/bseengine.h:209
void  bse_engine_free_ostreams 
(guint       n_ostreams,
 BseOStream *ostreams);

bse_engine_get_threads

/opt/src/beast/bse/bseengine.h:229
BirnetThread**  bse_engine_get_threads 
(guint *n_threads);

bse_engine_has_garbage

/opt/src/beast/bse/bseengine.h:206

bse_engine_init

/opt/src/beast/bse/bseengine.h:199
void  bse_engine_init 
(gboolean threaded);
Initialize the BSE Engine, this function must be called prior to any other engine related function and can only be invoked once.
run_threaded: whether the engine should be run threaded

bse_engine_prepare

/opt/src/beast/bse/bseengine.h:230

bse_engine_tick_stamp_from_systime

/opt/src/beast/bse/bseengine.h:213
Depending on the engine's sample frequency and the time of the last global tick stamp update, calculate the corresponding engine tick stamp from a given system time. This function is MT-safe and may be called from any thread.
systime: System time in micro seconds.
RETURNS: Engine tick stamp value

bse_engine_user_thread_collect

/opt/src/beast/bse/bseengine.h:207
BSE Engine user thread function. Collects processed jobs and transactions from the engine and frees them. This involves callback invocation of BseFreeFunc() functions, e.g. from bse_job_access() or bse_job_flow_access() jobs. This function may only be called from the user thread, as BseFreeFunc() functions are guranteed to be executed in the user thread.

bse_engine_wait_on_trans

/opt/src/beast/bse/bseengine.h:212
Wait until all pending transactions have been processed by the BSE Engine. This function, when done waiting, will run a garbage collection cycle before returning. See bse_engine_user_thread_collect(), the same restrictions apply to invokations of this function.

bse_job_access

/opt/src/beast/bse/bseengine.h:163
BseJob*  bse_job_access 
(BseModule          *module,
 BseEngineAccessFunc access_func,
 gpointer            data,
 BseFreeFunc         free_func);
Create a new transaction job which will invoke access_func on module with data when the transaction queue is processed to modify the module's state. This function is MT-safe and may be called from any thread.
module: The module to access
access_func: The accessor function (executed in master thread)
data: Data passed in to the accessor
free_func: Function to free data (executed in user thread)
Returns: New job suitable for bse_trans_add()

bse_job_add_poll

/opt/src/beast/bse/bseengine.h:154
BseJob*  bse_job_add_poll 
(BseEnginePollFunc poll_func,
 gpointer          data,
 BseFreeFunc       free_func,
 guint             n_fds,
 const GPollFD    *fds);
Create a new transaction job which adds a poll function to the engine. The poll function is used by the engine to determine whether processing is currently necessary. This function is MT-safe and may be called from any thread.
poll_func: Poll function to add
data: Data of poll function
free_func: Function to free data
n_fds: Number of poll file descriptors
fds: File descriptors to select(2) or poll(2) on
Returns: New job suitable for bse_trans_add()

bse_job_add_timer

/opt/src/beast/bse/bseengine.h:159
BseJob*  bse_job_add_timer 
(BseEngineTimerFunc timer_func,
 gpointer           data,
 BseFreeFunc        free_func);
Create a new transaction job which adds a timer function to the engine. The timer function is called after the engine caused new tick stamp updates. This function is MT-safe and may be called from any thread.
timer_func: Timer function to add
data: Data of timer function
free_func: Function to free data
Returns: New job suitable for bse_trans_add()

bse_job_boundary_access

/opt/src/beast/bse/bseengine.h:176
BseJob*  bse_job_boundary_access 
(BseModule          *module,
 guint64             tick_stamp,
 BseEngineAccessFunc access_func,
 gpointer            data,
 BseFreeFunc         free_func);
Create a new transaction job which inserts access_func with data into the boundary job queue of module. Boundary jobs are executed at block boundaries, after all ordinary jobs have been processed and before global time stamp counter passed tick_stamp. Boundary jobs queued for executaion after a node's destruction will not be executed but destroyed together with the node. This function is MT-safe and may be called from any thread.
module: The module to access
tick_stamp: Engine time stamp
access_func: The accessor function
data: Data passed in to the accessor
free_func: Function to free data
Returns: New job suitable for bse_trans_add()

bse_job_boundary_discard

/opt/src/beast/bse/bseengine.h:177
Discard module at block boundaries, after all ordinary jobs have been processed. This job type should be used instead of jobs from bse_job_discard() in situations where queueing of past-discard jobs before the next block boundary is hard to avoid (such as queing disconnection/suspend jobs from within process()). This function is MT-safe and may be called from any thread.
module: The module to access
Returns: New job suitable for bse_trans_add()

bse_job_connect

/opt/src/beast/bse/bseengine.h:127
BseJob*  bse_job_connect 
(BseModule *src_module,
 guint      src_ostream,
 BseModule *dest_module,
 guint      dest_istream);
Create a new transaction job which connects the ouput stream src_ostream of module src_module to the input stream dest_istream of module dest_module (it is an error if the input stream is already connected by the time the job is executed). This function is MT-safe and may be called from any thread.
src_module: Module with output stream
src_ostream: Index of output stream of src_module
dest_module: Module with unconnected input stream
dest_istream: Index of input stream of dest_module
Returns: New job suitable for bse_trans_add()

bse_job_debug

/opt/src/beast/bse/bseengine.h:148
BseJob*  bse_job_debug 
(const gchar *debug);
Create a new transaction job which issues debug message when the job is executed. This function is meant for debugging purposes during development phase only and shouldn't be used in production code. This function is MT-safe and may be called from any thread.
debug: Debug message
Returns: New job suitable for bse_trans_add()

bse_job_discard

/opt/src/beast/bse/bseengine.h:141
BseJob*  bse_job_discard 
(BseModule *module);
Create a new transaction job which removes module from the engine and destroys it. This function is MT-safe and may be called from any thread.
module: The module to discard
Returns: New job suitable for bse_trans_add()

bse_job_disconnect

/opt/src/beast/bse/bseengine.h:133
BseJob*  bse_job_disconnect 
(BseModule *dest_module,
 guint      dest_istream);
Create a new transaction job which causes the input stream dest_istream of dest_module to be disconnected (it is an error if the input stream isn't connected by the time the job is executed). This function is MT-safe and may be called from any thread.
dest_module: Module with connected input stream
dest_istream: Index of input stream of dest_module
Returns: New job suitable for bse_trans_add()

bse_job_flow_access

/opt/src/beast/bse/bseengine.h:171
BseJob*  bse_job_flow_access 
(BseModule          *module,
 guint64             tick_stamp,
 BseEngineAccessFunc access_func,
 gpointer            data,
 BseFreeFunc         free_func);
Create a new transaction job which inserts access_func with data into the flow job queue of module. Flow jobs are jobs with limited impact on modules, which are executed during flow system progress at specific times. Once the time stamp counter of module passed tick_stamp, access_func is called to modify the module's state. Flow jobs queued for executaion after a node's destruction will not be executed but destroyed together with the node. This function is MT-safe and may be called from any thread.
module: The module to access
tick_stamp: Engine time stamp
access_func: The accessor function
data: Data passed in to the accessor
free_func: Function to free data
Returns: New job suitable for bse_trans_add()

bse_job_force_reset

/opt/src/beast/bse/bseengine.h:142
Forces a reset of module before its next call to process(), if its class provides a reset() implementation. This is usually not a good idea, as forcing an immediate reset can lead to multiple unnecessary reset() invocations. The logic used to invoke reset() automatically is usually good enough to cover all required cases. This function is MT-safe and may be called from any thread.
module: The module to be reset
Returns: New job suitable for bse_trans_add()

bse_job_integrate

/opt/src/beast/bse/bseengine.h:140
Create a new transaction job to integrate module into the engine. This function is MT-safe and may be called from any thread.
module: The module to integrate
Returns: New job suitable for bse_trans_add()

bse_job_jconnect

/opt/src/beast/bse/bseengine.h:131
BseJob*  bse_job_jconnect 
(BseModule *src_module,
 guint      src_ostream,
 BseModule *dest_module,
 guint      dest_jstream);
Create a new transaction job which connects the ouput stream src_ostream of module src_module to the joint input stream dest_istream of module dest_module. This function is MT-safe and may be called from any thread.
src_module: Module with output stream
src_ostream: Index of output stream of src_module
dest_module: Module with unconnected joint input stream
dest_jstream: Index of joint input stream of dest_module
Returns: New job suitable for bse_trans_add()

bse_job_jdisconnect

/opt/src/beast/bse/bseengine.h:137
BseJob*  bse_job_jdisconnect 
(BseModule *dest_module,
 guint      dest_jstream,
 BseModule *src_module,
 guint      src_ostream);
Create a new transaction job which causes the joint input stream dest_jstream of dest_module to be disconnected from the output stream src_ostream of src_module (it is an error if this connection isn't established by the time the job is executed). Beware, the order of dest_module and src_module is different from bse_job_jconnect(). This function is MT-safe and may be called from any thread.
dest_module: Module with connected input stream
dest_jstream: Index of input stream of dest_module
src_module: Module with output stream
src_ostream: Index of output stream of src_module
Returns: New job suitable for bse_trans_add()

bse_job_kill_inputs

/opt/src/beast/bse/bseengine.h:138
Create a new transaction job which causes all connected input streams of module to be disconnected, like it's done upon discarding the module. This function is MT-safe and may be called from any thread.
module: Module with input streams
Returns: New job suitable for bse_trans_add()

bse_job_kill_outputs

/opt/src/beast/bse/bseengine.h:139
Create a new transaction job which causes all connected output streams of module to be disconnected, like it's done upon discarding the module. This function is MT-safe and may be called from any thread.
module: Module with output streams
Returns: New job suitable for bse_trans_add()

bse_job_nop

/opt/src/beast/bse/bseengine.h:149
Create a new transaction job which does nothing. The job enforces a roundtrip to the engine's master thread however, which may be relevant when comitting otherwise empty transactions and calling bse_engine_wait_on_trans(). This function is MT-safe and may be called from any thread.
Returns: New job suitable for bse_trans_add()

bse_job_probe_request

/opt/src/beast/bse/bseengine.h:166
BseJob*  bse_job_probe_request 
(BseModule         *module,
 BseEngineProbeFunc probe,
 gpointer           data);
Create a new transaction job which inserts probe_func with data into the job queue of module. Probe jobs are jobs which collect data from the output channels of a module as probe data. The job then returns to the user thread before the next block boundary, and probe_func() will be invoked as early as possible. There's no free_func() supplied to delete data, because such a function would always be called immediately after probe_func(). So instead, any data specific release handling should be integrated into probe_func(). For multiple probe jobs enqueued on a module simultaneously, no ordering is preserved. This function is MT-safe and may be called from any thread.
module: The module to access
probe_func: Function invoked with data in the user thread
data: Data passed in to the accessor
Returns: New job suitable for bse_trans_add()

bse_job_remove_poll

/opt/src/beast/bse/bseengine.h:156
BseJob*  bse_job_remove_poll 
(BseEnginePollFunc poll_func,
 gpointer          data);
Create a new transaction job which removes a previously inserted poll function from the engine. This function is MT-safe and may be called from any thread.
poll_func: Poll function to remove
data: Data of poll function
Returns: New job suitable for bse_trans_add()

bse_job_resume_at

/opt/src/beast/bse/bseengine.h:147
BseJob*  bse_job_resume_at 
(BseModule *module,
 guint64    tick_stamp);
Create a new transaction job which inserts a resumption event into the job queue of module. Once the time stamp counter of module passed tick_stamp, if it is supended, its reset() method is called and the module is resumed, causing it's process() method to be called again. Resuming a module also resumes all input modules it has, unless those were explicitely suspended via bse_job_suspend_now(). This function is MT-safe and may be called from any thread.
module: Module to resume
tick_stamp: Sample tick at which to resume module
Returns: New job suitable for bse_trans_add()

bse_job_set_consumer

/opt/src/beast/bse/bseengine.h:144
BseJob*  bse_job_set_consumer 
(BseModule *module,
 gboolean   is_toplevel_consumer);

bse_job_suspend_now

/opt/src/beast/bse/bseengine.h:145
Create a new transaction job which suspends the module and all it's input modules which don't have other non-suspended output connections. Suspension of a module prevents it's process() method from being called, it's outputs are simply filled with zero's instead. This function is MT-safe and may be called from any thread.
module: Module not currently suspended
Returns: New job suitable for bse_trans_add()

bse_module_has_source

/opt/src/beast/bse/bseengine.h:122
gboolean  bse_module_has_source 
(BseModule *module,
 guint      istream);
Check whether istream may be disconnected via bse_job_disconnect(). This is not an indication for whether BSE_MODULE_ISTREAM (module, istream).connected will be TRUE during process(), as the source may be a dangling virtual module, resulting in BSE_MODULE_ISTREAM (module, istream).connected being FALSE. See also bse_module_new_virtual(). This function is MT-safe and may be called from any thread.
module: a BSE Engine Module
istream: Index of input stream
RETURNS: whether the module has a possible input

bse_module_is_scheduled

/opt/src/beast/bse/bseengine.h:123
Check whether module is part of the schedule required to calculate the signal flow up to the consumer modules. This state may frequently change with for instance connection changes of other modules. This function is MT-safe and may be called from any thread.
module: a BSE Engine Module
RETURNS: whether the module is scheduled

bse_module_new

/opt/src/beast/bse/bseengine.h:116
BseModule*  bse_module_new 
(const BseModuleClass *klass,
 gpointer              user_data);
Create a new module with methods specified in klass and a user_data field set to user_data. The returned module can then be integrated into the engine with bse_job_integrate(). This function is MT-safe and may be called from any thread.
klass: the BseModuleClass which determines the module's behaviour
user_data: user data pointer
RETURNS: a newly created module

bse_module_new_virtual

/opt/src/beast/bse/bseengine.h:119
BseModule*  bse_module_new_virtual 
(guint       n_iostreams,
 gpointer    user_data,
 BseFreeFunc free_data);
Create a new virtual module which has n_iostreams input streams and n_iostreams output streams. Simply put, virtual modules just pass all input stream signals through to the corresponsding output stream. However, they are cheaper to compute than a literal module implementation that just passes through all data in its progress() method, because the connections can be virtualized in a connection optimization stage during scheduling, so that they don't end up in the list of modules which need to be processed during calculation phase. Beware though, flow jobs may not be scheduled on virtual modules (thusly, suspend jobs cannot be queued on them either), as virtual modules are ignored during calculation phase. They do, however, work just like ordinary modules with regards to suspension propagation, so the suspension state from output modules does only propagate across the virtual module to its input modules, if all its outputs are suspended. Instead of a single virtual module with multiple input/output streams, multiple virtual modules can be used if suspension is desired to propagate per stream. This function is MT-safe and may be called from any thread.
n_iostreams: number of input and output streams
user_data: user data, stored in module->user_data
free_data: function to free user_data when the module is discarded
RETURNS: a newly created module

bse_module_tick_stamp

/opt/src/beast/bse/bseengine.h:120
Any thread may call this function on a valid engine module. The module specific tick stamp is updated to gsl_tick_stamp() + n_values every time its BseProcessFunc() function was called. See also gsl_tick_stamp(). This function is MT-safe and may be called from any thread.
module: a BSE Engine Module
RETURNS: the module's tick stamp, indicating its process status

bse_trans_add

/opt/src/beast/bse/bseengine.h:180
void  bse_trans_add 
(BseTrans *trans,
 BseJob   *job);
Append a job to an opened transaction. This function is MT-safe and may be called from any thread.
trans: Opened transaction
job: Job to add

bse_trans_commit

/opt/src/beast/bse/bseengine.h:183
Close the transaction and commit it to the engine. The engine will execute the jobs contained in this transaction as soon as it has completed its current processing cycle, at which point gsl_tick_stamp() matches the returned tick stamp. The jobs will be executed in the exact order they were added to the transaction. This function is MT-safe and may be called from any thread.
trans: open transaction
RETURNS: tick stamp of job execution

bse_trans_commit_delayed

/opt/src/beast/bse/bseengine.h:185
void  bse_trans_commit_delayed 
(BseTrans *trans,
 guint64   tick_stamp);
Commit the transaction like bse_trans_commit(), but make sure that the commit happens no earlier than tick_stamp. This function will block until the commit occoured, so it will not return any earlier than tick_stamp. This function is MT-safe and may be called from any thread.
trans: open transaction
tick_stamp: earliest stamp

bse_trans_dismiss

/opt/src/beast/bse/bseengine.h:186
Close and discard the transaction, causes destruction of all jobs currently contained in it and prevents their execution. This function is MT-safe and may be called from any thread.
trans: Opened transaction

bse_trans_merge

/opt/src/beast/bse/bseengine.h:182
BseTrans*  bse_trans_merge 
(BseTrans *trans1,
 BseTrans *trans2);
Merge two open transactions by appending the jobs of trans2 to the jobs of trans1, returning the resulting transaction. The empty transaction trans2 will be dismissed after the merge. This function is MT-safe and may be called from any thread.
trans1: open transaction
trans2: open transaction
Returns: open transaction trans1

bse_trans_open

/opt/src/beast/bse/bseengine.h:178
Open up a new transaction to commit jobs to the BSE Engine. While the distinct functions to operate on a transaction are MT-safe, the caller has to take measures himself, to assure that only one function operates on the transaction at a time. This function is MT-safe and may be called from any thread.
Returns: Newly opened empty transaction

bse_transact

/opt/src/beast/bse/bseengine.h:188
void  bse_transact 
(BseJob *job,
 ...);
Convenience function which openes up a new transaction, collects the NULL terminated job list passed to the function, and commits the transaction. This function is MT-safe and may be called from any thread.
job: First job
...: NULL terminated job list