Language Guide / Signal Generators
Generator
klang::Generator
Base class for mono signal sources.
A generator has an output and no audio input. Derive from Generator when the source does not need the frequency and phase handling of Oscillator. Implement process() to produce one sample in out.
Read or route a sample
Assign the generator to a signal to run it once, or route it directly with generator >> out. Store the sample if it needs to go to more than one destination. Calling output() reads the last sample without running the generator again.
Example ยท Emit a trigger
Call trigger() when an event should emit an impulse. The next read returns 1 and clears the trigger. Subsequent reads return 0 until the next event.
struct Trigger : Generator {
bool pending = false;
void trigger() { pending = true; }
void process() {
out = pending ? 1 : 0;
pending = false;
}
};
Signal generator object (mono)
More...
#include <klang.h>
Definition at line 3680 of file klang.h.
◆ operator const signal &() [1/2]
|
|
inlineoverridevirtualinherited |
◆ operator const signal &() [2/2]
|
|
inlineoverridevirtualinherited |
◆ operator()()
Definition at line 3050 of file klang.h.
3050 {
3051 set(std::forward<params>(p)...); return *this;
3052 }
◆ operator*()
◆ operator+()
◆ operator-()
◆ operator/()
◆ operator>>()
◆ output()
◆ process()
|
|
protectedpure virtualinherited |
Implemented in klang::Delay< SIZE >, klang::Delay< 0 >, klang::Effect, klang::Envelope::Follower::AR, klang::Envelope::Follower, klang::Envelope::Follower::Window< WINDOW >, klang::Envelope, klang::Envelope::Ramp, klang::Filters::Biquad::Filter, klang::Filters::Butterworth::LPF< 1 >, klang::Filters::DCF, klang::Filters::IIR< ORDER >, klang::Filters::IIR< 1 >, klang::Filters::OnePole::Filter, klang::Filters::OnePole::LPF, klang::Generators::Basic::Noise, klang::Generators::Basic::Phasor, klang::Generators::Basic::Pulse, klang::Generators::Basic::Saw, klang::Generators::Basic::Sine, klang::Generators::Basic::Square, klang::Generators::Basic::Triangle, klang::Generators::Fast::Noise, klang::Generators::Fast::Phasor, klang::Generators::Fast::Sine, klang::Generic::Function< signal, Args... >, klang::Generic::Modifier< signal >, klang::Modifiers::Modal, klang::Note, klang::Sample, klang::Sound, klang::Stereo::Effect, klang::Stereo::Mono::Note, klang::Stereo::Note, klang::Stereo::Sound, klang::Stereo::Synth, klang::Synth, and klang::Wavetable.
◆ reset()
◆ out