Klang C++
Language Reference (draft)
Loading...
Searching...
No Matches
klang::Oscillatorabstract

Audio oscillator object (mono output) More...

#include <klang.h>

+ Inheritance diagram for klang::Oscillator:

Public Member Functions

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)
 
Output< signal > & operator() (params... p)
 
 operator const signal & () override
 
 operator const signal & () const override
 
virtual const signaloutput () const
 
TYPE & operator>> (TYPE &destination)
 
signal operator+ (TYPE &other)
 
signal operator* (TYPE &other)
 
signal operator- (TYPE &other)
 
signal operator/ (TYPE &other)
 

Public Attributes

Frequency frequency
 
Phase offset
 
signal out
 

Protected Attributes

Phase increment
 
Phase position
 

Detailed Description

Definition at line 1990 of file klang.h.

Member Function Documentation

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

klang::Generic::Generator< signal >::operator const signal & ( ) const
inlineoverridevirtualinherited

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

Definition at line 1416 of file klang.h.

1416{ return out; } // return last output

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

klang::Generic::Generator< signal >::operator const signal & ( )
inlineoverridevirtualinherited

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

Definition at line 1415 of file klang.h.

1415{ process(); return out; } // return processed output

◆ operator()()

Output< signal > & klang::Generic::Generator< signal >::operator() ( params... p)
inlineinherited

Definition at line 1409 of file klang.h.

1409 {
1410 set(p...); return *this;
1411 }

◆ operator*()

signal klang::Generic::Output< signal >::operator* ( TYPE & other)
inlineinherited

Definition at line 1372 of file klang.h.

1372{ process(); return out * (other); }

◆ operator+()

signal klang::Generic::Output< signal >::operator+ ( TYPE & other)
inlineinherited

Definition at line 1371 of file klang.h.

1371{ process(); return out + (other); }

◆ operator-()

signal klang::Generic::Output< signal >::operator- ( TYPE & other)
inlineinherited

Definition at line 1373 of file klang.h.

1373{ process(); return out - (other); }

◆ operator/()

signal klang::Generic::Output< signal >::operator/ ( TYPE & other)
inlineinherited

Definition at line 1374 of file klang.h.

1374{ process(); return out / (other); }

◆ operator>>()

TYPE & klang::Generic::Output< signal >::operator>> ( TYPE & destination)
inlineinherited

Definition at line 1364 of file klang.h.

1364{ process(); return destination = out; }

◆ output()

virtual const signal & klang::Generic::Output< signal >::output ( ) const
inlinevirtualinherited

Definition at line 1360 of file klang.h.

1360{ return out; }

◆ process()

◆ reset()

virtual void klang::Generic::Oscillator< signal >::reset ( )
inlinevirtualinherited

Reimplemented in klang::Generators::Fast::Sine.

Definition at line 1957 of file klang.h.

◆ set() [1/4]

virtual void klang::Generic::Oscillator< signal >::set ( param frequency)
inlinevirtualinherited

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

Definition at line 1960 of file klang.h.

1960 {
1962 increment = frequency * 2.f * pi.f / fs;
1963 }
constexpr constant pi
The mathematical constant, pi (and it's inverse).
Definition klang.h:218
klang::dB fs
const float f
Constant as float.
Definition klang.h:95

◆ set() [2/4]

virtual void klang::Generic::Oscillator< signal >::set ( param frequency,
param phase )
inlinevirtualinherited

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

Definition at line 1965 of file klang.h.

1965 {
1966 position = phase;
1967 set(frequency);
1968 }

◆ set() [3/4]

virtual void klang::Generic::Oscillator< signal >::set ( param frequency,
relative phase )
inlinevirtualinherited

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

Definition at line 1970 of file klang.h.

1970 {
1971 set(frequency);
1972 set(phase);
1973 }

◆ set() [4/4]

virtual void klang::Generic::Oscillator< signal >::set ( relative phase)
inlinevirtualinherited

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

Definition at line 1975 of file klang.h.

1975 {
1976 offset = phase * (2 * pi);
1977 }

Member Data Documentation

◆ frequency

Frequency klang::Generic::Oscillator< signal >::frequency
inherited

Definition at line 1953 of file klang.h.

◆ increment

Phase klang::Generic::Oscillator< signal >::increment
protectedinherited

Definition at line 1950 of file klang.h.

◆ offset

Phase klang::Generic::Oscillator< signal >::offset
inherited

Definition at line 1954 of file klang.h.

◆ out

Definition at line 1357 of file klang.h.

1357{ 0.f };

◆ position

Phase klang::Generic::Oscillator< signal >::position
protectedinherited

Definition at line 1951 of file klang.h.