Klang C++ 0.7.15
Language Reference (draft)
Loading...
Searching...
No Matches
klang::Generic::Oscillator< SIGNAL >abstract

Audio oscillator object (output) More...

#include <klang.h>

+ Inheritance diagram for klang::Generic::Oscillator< SIGNAL >:

Public Member Functions

virtual ~Oscillator ()
 
virtual void reset ()
 
virtual void set (param frequency)
 
virtual void set (param frequency, param phase)
 
virtual void set (param frequency, relative phase)
 
virtual void set (relative phase)
 
template<typename... params>
Output< SIGNAL > & operator() (params &&... p)
 
 operator const SIGNAL & () override
 
 operator const SIGNAL & () const override
 
virtual const SIGNAL & output () const
 
template<typename TYPE , class = decltype( std::declval<TYPE&>() = std::declval<SIGNAL&>())>
TYPE & operator>> (TYPE &destination)
 
template<typename TYPE >
SIGNAL operator+ (TYPE &other)
 
template<typename TYPE >
SIGNAL operator* (TYPE &other)
 
template<typename TYPE >
SIGNAL operator- (TYPE &other)
 
template<typename TYPE >
SIGNAL operator/ (TYPE &other)
 

Public Attributes

Frequency frequency = 1000.f
 
Phase offset = 0
 
SIGNAL out = { 0.f }
 

Protected Attributes

Phase increment
 
Phase position = 0
 

Detailed Description

template<typename SIGNAL>
struct klang::Generic::Oscillator< SIGNAL >

Definition at line 3642 of file klang.h.

Constructor & Destructor Documentation

◆ ~Oscillator()

template<typename SIGNAL >
virtual klang::Generic::Oscillator< SIGNAL >::~Oscillator ( )
inlinevirtual

Reimplemented in klang::Stereo::Oscillator.

Definition at line 3650 of file klang.h.

3650{}

Member Function Documentation

◆ operator const SIGNAL &() [1/2]

template<typename SIGNAL >
klang::Generic::Generator< SIGNAL >::operator const SIGNAL & ( ) const
inlineoverridevirtualinherited

Reimplemented from klang::Generic::Output< SIGNAL >.

Definition at line 3057 of file klang.h.

3057{ return out; } // return last output

References klang::Generic::Output< SIGNAL >::out.

◆ operator const SIGNAL &() [2/2]

template<typename SIGNAL >
klang::Generic::Generator< SIGNAL >::operator const SIGNAL & ( )
inlineoverridevirtualinherited

Reimplemented from klang::Generic::Output< SIGNAL >.

Definition at line 3056 of file klang.h.

3056{ this->process(); return out; } // return processed output
virtual void process()=0

References klang::Generic::Output< SIGNAL >::out, and klang::Generic::Output< SIGNAL >::process().

◆ operator()()

template<typename SIGNAL >
template<typename... params>
Output< SIGNAL > & klang::Generic::Generator< SIGNAL >::operator() ( params &&... p)
inlineinherited

Definition at line 3050 of file klang.h.

3050 {
3051 set(std::forward<params>(p)...); return *this;
3052 }

◆ operator*()

template<typename SIGNAL >
template<typename TYPE >
SIGNAL klang::Generic::Output< SIGNAL >::operator* ( TYPE & other)
inlineinherited

Definition at line 2977 of file klang.h.

2977{ this->process(); return out * SIGNAL(other); }

References klang::Generic::Output< SIGNAL >::process().

◆ operator+()

template<typename SIGNAL >
template<typename TYPE >
SIGNAL klang::Generic::Output< SIGNAL >::operator+ ( TYPE & other)
inlineinherited

Definition at line 2976 of file klang.h.

2976{ this->process(); return out + SIGNAL(other); }

References klang::Generic::Output< SIGNAL >::process().

◆ operator-()

template<typename SIGNAL >
template<typename TYPE >
SIGNAL klang::Generic::Output< SIGNAL >::operator- ( TYPE & other)
inlineinherited

Definition at line 2978 of file klang.h.

2978{ this->process(); return out - SIGNAL(other); }

References klang::Generic::Output< SIGNAL >::process().

◆ operator/()

template<typename SIGNAL >
template<typename TYPE >
SIGNAL klang::Generic::Output< SIGNAL >::operator/ ( TYPE & other)
inlineinherited

Definition at line 2979 of file klang.h.

2979{ this->process(); return out / SIGNAL(other); }

References klang::Generic::Output< SIGNAL >::process().

◆ operator>>()

template<typename SIGNAL >
template<typename TYPE , class = decltype( std::declval<TYPE&>() = std::declval<SIGNAL&>())>
TYPE & klang::Generic::Output< SIGNAL >::operator>> ( TYPE & destination)
inlineinherited

Definition at line 2969 of file klang.h.

2969{ this->process(); return destination = out; }

References klang::Generic::Output< SIGNAL >::out, and klang::Generic::Output< SIGNAL >::process().

◆ output()

template<typename SIGNAL >
virtual const SIGNAL & klang::Generic::Output< SIGNAL >::output ( ) const
inlinevirtualinherited

Definition at line 2964 of file klang.h.

2964{ return out; }

References klang::Generic::Output< SIGNAL >::out.

◆ process()

template<typename SIGNAL >
virtual void klang::Generic::Output< SIGNAL >::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::Function< signal, Args... >, klang::Generic::Modifier< SIGNAL >, 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.

Referenced by klang::Generic::Generator< SIGNAL >::operator const SIGNAL &(), klang::Generic::Output< SIGNAL >::operator const SIGNAL &(), klang::Generic::Output< SIGNAL >::operator*(), klang::Generic::Output< SIGNAL >::operator+(), klang::Generic::Output< SIGNAL >::operator-(), klang::Generic::Output< SIGNAL >::operator/(), and klang::Generic::Output< SIGNAL >::operator>>().

◆ reset()

template<typename SIGNAL >
virtual void klang::Generic::Oscillator< SIGNAL >::reset ( )
inlinevirtual

Reimplemented in klang::Generators::Fast::Phasor, and klang::Generators::Fast::Sine.

Definition at line 3651 of file klang.h.

3651{ position = 0; }

◆ set() [1/4]

template<typename SIGNAL >
virtual void klang::Generic::Oscillator< SIGNAL >::set ( param frequency)
inlinevirtual

Reimplemented in klang::Generators::Fast::Phasor, klang::Generators::Fast::Sine, and klang::Wavetable.

Definition at line 3654 of file klang.h.

3654 {
3656 increment = frequency * 2.f * pi.f / fs;
3657 }
constexpr constant pi
The mathematical constant, pi (and it's inverse).
Definition klang.h:287
klang::dB fs
const float f
Constant as float.
Definition klang.h:162

References klang::constant::f, klang::fs, and klang::pi.

◆ set() [2/4]

template<typename SIGNAL >
virtual void klang::Generic::Oscillator< SIGNAL >::set ( param frequency,
param phase )
inlinevirtual

Reimplemented in klang::Generators::Fast::Phasor, klang::Generators::Fast::Sine, and klang::Wavetable.

Definition at line 3659 of file klang.h.

3659 {
3660 position = phase;
3661 set(frequency);
3662 }
virtual void set(param frequency)
Definition klang.h:3654

◆ set() [3/4]

template<typename SIGNAL >
virtual void klang::Generic::Oscillator< SIGNAL >::set ( param frequency,
relative phase )
inlinevirtual

Reimplemented in klang::Generators::Fast::Phasor, klang::Generators::Fast::Sine, and klang::Wavetable.

Definition at line 3664 of file klang.h.

3664 {
3665 set(frequency);
3666 set(phase);
3667 }

◆ set() [4/4]

template<typename SIGNAL >
virtual void klang::Generic::Oscillator< SIGNAL >::set ( relative phase)
inlinevirtual

Reimplemented in klang::Generators::Fast::Phasor, klang::Generators::Fast::Sine, and klang::Wavetable.

Definition at line 3669 of file klang.h.

3669 {
3670 offset = phase * (2 * pi);
3671 }

References klang::pi.

Member Data Documentation

◆ frequency

template<typename SIGNAL >
Frequency klang::Generic::Oscillator< SIGNAL >::frequency = 1000.f

Definition at line 3647 of file klang.h.

◆ increment

template<typename SIGNAL >
Phase klang::Generic::Oscillator< SIGNAL >::increment
protected

Definition at line 3644 of file klang.h.

◆ offset

template<typename SIGNAL >
Phase klang::Generic::Oscillator< SIGNAL >::offset = 0

Definition at line 3648 of file klang.h.

◆ out

◆ position

template<typename SIGNAL >
Phase klang::Generic::Oscillator< SIGNAL >::position = 0
protected

Definition at line 3645 of file klang.h.