#include <module.hh>
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 () |
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.
name | The name of the input |
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.
name | The name of the output |
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.
The | source module |
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.
The | destination module |
void yase::Module::emit | ( | Event | e | ) |
Emit an event. A containing synthesizer can listen for such events and respond to them.
e | The event to emit |
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.
name | The index of the input |
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.
The | name of the input |
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.
The | name of the output |
string yase::Module::get_input_name | ( | int | index | ) | const |
Get the name of the input with the given index
index |
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.
name | The name of the input |
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.
name | The name of the input |
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.
The | name of the input |
string yase::Module::get_output_name | ( | int | index | ) | const |
Get the name of the output with the given index
index |
|
pure virtual |
This method should be overridden by derived classes. It will usually be called once, after all modules and connections objects have been added to a synthesizer, but before the synthesizer starts running.
Implemented in yase::AdditiveSaw, yase::AntiAlias, yase::Audio, yase::AutoLoad, yase::Biquad, yase::Buffer< n >, yase::Buttons, yase::Compressor, yase::Container, yase::Controls, yase::Delay, yase::Echo, yase::Envelope, yase::ExpDecay, yase::FadableDelay, yase::Fader, yase::FFT, yase::Gain, yase::IIRFilter, yase::Impulse, yase::LinearTransform, yase::MidiInput, yase::MidiToAnalog, yase::Mix, yase::Mixer, yase::Monitor, yase::MultiClock, yase::Noop, yase::Oscillator, yase::Player, yase::Resonator, yase::Sample, yase::SampleAndHold, yase::Sampler, yase::Sequencer, yase::SimpleSequencer, yase::Sum, yase::TappedDelay, yase::Timer, yase::Transform, and yase::Triggerable.
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.
name | The name of the input |
value | The value to set the input to |
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.
name | The name of the input |
value | The value to set the input to |
void yase::Module::set_output | ( | int | index, |
double | value | ||
) |
Set the value of the output refered to by the index.
index | The index of the output |
The | value to set the output to |
|
pure virtual |
This method should be overridden by derived classes. It will be called repeatedly by a synthesizer at a frequency determined by SAMPLE_RATE.
Implemented in yase::AdditiveSaw, yase::AdditiveSquare, yase::AdditiveTriangle, yase::AntiAlias, yase::Audio, yase::AutoLoad, yase::Biquad, yase::Buffer< n >, yase::Buttons, yase::Clock, yase::Compressor, yase::Container, yase::Controls, yase::Delay, yase::Echo, yase::Envelope, yase::ExpDecay, yase::FadableDelay, yase::Fader, yase::FFT, yase::Gain, yase::IIRFilter, yase::Impulse, yase::Jenny, yase::LinearTransform, yase::MidiInput, yase::MidiToAnalog, yase::Mix, yase::Mixer, yase::Monitor, yase::MultiClock, yase::Noise, yase::Noop, yase::OscGroup, yase::Oscillator, yase::Player, yase::Resonator, yase::Sample, yase::SampleAndHold, yase::Sampler, yase::Saw, yase::Sequencer, yase::SimpleSequencer, yase::Sine, yase::Square, yase::Sum, yase::TappedDelay, yase::Timer, yase::Transform, yase::Triangle, yase::Triggerable, and yase::Wavetable.