A module and event manager that can contain other modules.
It can be used as a top level module for constructing an entire synthesizer, or as a way to group together a few modules into a commonly used function, as with, for example a phasor which would contain a delay and a sum. A good example of a container is the Echo Module, which contains a Delay, a a Gain and a Sum. Additionally, most examples use a main container to add sub-modules to. For example, the following code sets up a Container called synth, adds a few modules to it.
#include "yase.hh"
int main(int argc, char * argv[]) {
synth.
connect(sine1,
"signal",audio,
"left")
.
connect(sine2,
"signal",audio,
"right");
return 0;
}
A module wrapper for a stereo PortAudio interface (http://www.portaudio.com/).
Definition audio.hh:46
A module and event manager that can contain other modules.
Definition container.hh:63
Container & connect(Module &source, string output, Module &dest, string input)
Definition container.cc:111
void run(int num_steps)
Definition container.cc:374
void set_input(string name, double value)
Definition module.cc:86
A sine wave oscillator.
Definition sine.hh:39
#define UNTIL_INTERRUPTED
Use as in Synthesizer::run(UNTIL_INTERUPTED)
Definition globals.hh:27
Definition additive_saw.cc:24
|
void | init () |
|
void | update () |
|
Container & | add (Module &module) |
|
Container & | add_if_new (Module &module) |
|
Container & | propagate_to (EventManager &em) |
|
void | run (int num_steps) |
|
void | run_again (int num_steps) |
|
void | stop () |
|
Container & | connect (Module &source, string output, Module &dest, string input) |
|
Container & | connect (Module &source, string output, Module &dest, int input) |
|
Container & | connect (AutoLoad &loader, string category, Module &module) |
|
Container & | connect (Module &source, Module &dest) |
|
Container & | path (Module &a, Module &b, Module &c) |
|
Container & | path (Module &a, Module &b, Module &c, Module &d) |
|
Container & | path (Module &a, Module &b, Module &c, Module &d, Module &e) |
|
Container & | disconnect (Module &source, string output, Module &dest, string input) |
|
bool | connected (Module *module, string input_name) |
|
Container & | equate_input (string input, Module &sub_module, string sub_input) |
|
Container & | attach_inputs (std::vector< std::tuple< string, Module &, string > > attachments) |
|
Container & | equate_output (string output, Module &sub_module, string sub_output) |
|
Container & | attach_outputs (std::vector< std::tuple< string, Module &, string > > attachments) |
|
Container & | set_thread_number (int n) |
| EXPERIMENTAL.
|
|
Container & | add (Module &module, int n) |
| EXPERIMENTAL.
|
|
void | run_threaded (int num_steps) |
| EXPERIMENTAL.
|
|
void | update_threaded () |
| EXPERIMENTAL.
|
|
void | thread_loop (int i) |
| EXPERIMENTAL.
|
|
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 () |
|
| EventManager () |
| Make a new event manager.
|
|
void | process_events (vector< Module * > &modules) |
|
void | respond_to (const Event &event) |
|
EventManager & | listen (int event_type, function< void(const Event &)> handler) |
|
EventManager & | listen (int event_type, int port, function< void(const Event &)> handler) |
|
Tell the container to propagate all events to another event manager. Thus, if some module contained within the container emits an event, the event manager em will hear the event too. Usually used in conjunction with add().
- Parameters
-
em | The event manager (another module) that should receive events |
- Returns
- A reference to the container for method chaining
In the following example, a Controls object is constructed, added, and propagated to. When MidiEvents are received by the container, they are sent to the control, which responds to them by adjusting the associated input.
#include <iostream>
#include "yase.hh"
int main(int argc, char * argv[]) {
synth.
connect(osc1,
"signal",audio,
"left")
.
connect(osc2,
"signal",audio,
"right");
controls.
map(osc1,
"frequency", 55, 110, 74)
.
map(osc2,
"frequency", 55, 110, 71);
return 0;
}
Container & propagate_to(EventManager &em)
Definition container.cc:95
Container & add(Module &module)
Definition container.cc:62
Use a Controls object to connect MIDI knobs and faders to Module inputs.
Definition controls.hh:82
Controls & map(Fader &fader, int midi_id)
Definition controls.cc:50
A sawtooth wave oscillator.
Definition saw.hh:40