Yet Another Synthesizer Engine
 
Loading...
Searching...
No Matches
yase::Module Class Referenceabstract

#include <module.hh>

+ Inheritance diagram for yase::Module:

Detailed Description

An abstract base class for modules.

Derived classes should imlement the init and update methods.

Public Member Functions

virtual void init ()=0
 
virtual void update ()=0
 
int add_input (string name)
 
int add_output (string name)
 
int get_input_index (string name) const
 
string get_input_name (int index) const
 
string get_output_name (int index) const
 
int get_output_index (string name) const
 
void set_input (string name, double value)
 
void set_input (int index, double value)
 
double get_input (int index) const
 
double get_input (string name) const
 
double get_output (string name) const
 
double get_output (int index) const
 
void set_output (int index, double value)
 
void copy_inputs (const Module &source)
 
void copy_outputs (Module &destination) const
 
void configure (std::vector< std::tuple< string, double > > assignments)
 
int num_inputs () const
 
int num_outputs () const
 
void emit (Event e)
 
void set_ts (double s)
 
double get_ts ()
 

Member Function Documentation

◆ add_input()

int yase::Module::add_input ( string  name)

This method is used to add a new input to the module. The name can be later used to refer to this input. This method is typically called in the constructor of derived classes.

Parameters
nameThe name of the input
Returns
The index of the input, which can also be used to refer to this input.

◆ add_output()

int yase::Module::add_output ( string  name)

This method is used to add a new output to the module. The name can be later used to refer to this input. This method is typically called in the constructor of derived classes.

Parameters
nameThe name of the output
Returns
The index of the output, which can also be used to refer to this input.

◆ copy_inputs()

void yase::Module::copy_inputs ( const Module source)

Copy the inputs of the source module to the inputs of this module. The modules should have the same number of inputs. This can be useful for modules that contain other modules.

Parameters
Thesource module

◆ copy_outputs()

void yase::Module::copy_outputs ( Module destination) const

Copy the outputs of this module to the destination module. The modules should have the same number of outputs. This can be useful for modules that contain other modules.

Parameters
Thedestination module

◆ emit()

void yase::Module::emit ( Event  e)

Emit an event. A containing synthesizer can listen for such events and respond to them.

Parameters
eThe event to emit

◆ get_input() [1/2]

double yase::Module::get_input ( int  index) const

Get the value of the input refered to the index parameter. This version of the get method is prefered in update functions because it is faster than using the string name.

Parameters
nameThe index of the input
Returns
The value of the input

◆ get_input() [2/2]

double yase::Module::get_input ( string  name) const

Get the index corresponding to the name used when the input added using add_input. The index is should be used in the update method of a module rather than the name because it is faster.

Parameters
Thename of the input
Returns
The index of the input

◆ get_input_index()

int yase::Module::get_input_index ( string  name) const

Get the index corresponding to the name used when the input added using add_input. The index is should be used in the update method of a module rather than the name because it is faster.

Parameters
Thename of the output
Returns
The index of the output

◆ get_input_name()

string yase::Module::get_input_name ( int  index) const

Get the name of the input with the given index

Parameters
index

◆ get_output() [1/2]

double yase::Module::get_output ( int  index) const

Get the value of the output refered to the index parameter. This version of the get method is prefered in update functions because it is faster than using the string name.

Parameters
nameThe name of the input
Returns
The value of the output

◆ get_output() [2/2]

double yase::Module::get_output ( string  name) const

Get the value of the output refered to the index parameter. Slower than using the index of the output.

Parameters
nameThe name of the input
Returns
The valueof the output

◆ get_output_index()

int yase::Module::get_output_index ( string  name) const

Get the index corresponding to the name used when the output added using add_output. The index is should be used in the update method of a module rather than the name because it is faster.

Parameters
Thename of the input
Returns
The index of the input

◆ get_output_name()

string yase::Module::get_output_name ( int  index) const

Get the name of the output with the given index

Parameters
index

◆ init()

◆ set_input() [1/2]

void yase::Module::set_input ( int  index,
double  value 
)

Set the value of the input refered to the index parameter. This version of the set method is prefered in update functions because it is faster than usig the string name.

Parameters
nameThe name of the input
valueThe value to set the input to

◆ set_input() [2/2]

void yase::Module::set_input ( string  name,
double  value 
)

Set the value of the input refered to by name. This version of the set method be used during setup, with the name as a convenience.

Parameters
nameThe name of the input
valueThe value to set the input to

◆ set_output()

void yase::Module::set_output ( int  index,
double  value 
)

Set the value of the output refered to by the index.

Parameters
indexThe index of the output
Thevalue to set the output to

◆ update()


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