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

Wavetable-based oscillator. More...

#include <klang.h>

+ Inheritance diagram for klang::Wavetable:

Public Member Functions

 Wavetable (int size=2048)
 
template<typename TYPE >
 Wavetable (TYPE oscillator, int size=2048)
 
signaloperator[] (int index)
 
template<typename TYPE >
Wavetableoperator= (TYPE &oscillator)
 
virtual void set (param frequency) override
 
virtual void set (param frequency, param phase) override
 
virtual void set (relative phase) override
 
virtual void set (param frequency, relative phase) override
 
void process () override
 
virtual void reset ()
 
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

buffer buffer
 
const int size
 
Phase increment
 
Phase position
 

Detailed Description

Definition at line 2557 of file klang.h.

Constructor & Destructor Documentation

◆ Wavetable() [1/2]

klang::Wavetable::Wavetable ( int size = 2048)
inline

Definition at line 2563 of file klang.h.

2563: buffer(size), size(size) { }
const int size
Definition klang.h:2561
buffer buffer
Definition klang.h:2560

References klang::buffer::buffer(), and size.

◆ Wavetable() [2/2]

template<typename TYPE >
klang::Wavetable::Wavetable ( TYPE oscillator,
int size = 2048 )
inline

Definition at line 2566 of file klang.h.

2566 : buffer(size), size(size) {
2567 operator=(oscillator);
2568 }
Wavetable & operator=(TYPE &oscillator)
Definition klang.h:2575

References klang::buffer::buffer(), and size.

Referenced by klang::Generators::Wavetables::Saw::Saw(), and klang::Generators::Wavetables::Sine::Sine().

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=()

template<typename TYPE >
Wavetable & klang::Wavetable::operator= ( TYPE & oscillator)
inline

Definition at line 2575 of file klang.h.

2575 {
2576 oscillator.set(fs / size);
2577 for (int s = 0; s < size; s++)
2578 buffer[s] = oscillator;
2579 return *this;
2580 }
klang::dB fs

References klang::buffer::operator[](), and size.

◆ operator>>()

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

Definition at line 1364 of file klang.h.

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

◆ operator[]()

signal & klang::Wavetable::operator[] ( int index)
inline

Definition at line 2570 of file klang.h.

2570 {
2571 return buffer[index];
2572 }

References klang::buffer::operator[]().

◆ output()

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

Definition at line 1360 of file klang.h.

1360{ return out; }

◆ process()

void klang::Wavetable::process ( )
inlineoverridevirtual

◆ reset()

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

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

Definition at line 1957 of file klang.h.

1957{ position = 0; }

◆ set() [1/4]

virtual void klang::Wavetable::set ( param frequency)
inlineoverridevirtual

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

Definition at line 2582 of file klang.h.

References klang::signal::operator*(), and size.

Referenced by set(), and set().

◆ set() [2/4]

virtual void klang::Wavetable::set ( param frequency,
param phase )
inlineoverridevirtual

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

Definition at line 2587 of file klang.h.

2587 {
2588 position = phase * float(size);
2589 set(frequency);
2590 }
virtual void set(param frequency) override
Definition klang.h:2582

References klang::signal::operator*(), set(), and size.

◆ set() [3/4]

virtual void klang::Wavetable::set ( param frequency,
relative phase )
inlineoverridevirtual

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

Definition at line 2597 of file klang.h.

2597 {
2598 set(frequency);
2599 set(phase);
2600 }

References set(), and set().

◆ set() [4/4]

virtual void klang::Wavetable::set ( relative phase)
inlineoverridevirtual

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

Definition at line 2592 of file klang.h.

2592 {
2593
2594 offset = phase * float(size);
2595 }

References klang::signal::operator*(), and size.

Referenced by set().

Member Data Documentation

◆ buffer

buffer klang::Wavetable::buffer
protected

Definition at line 2560 of file klang.h.

◆ 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.

◆ size

const int klang::Wavetable::size
protected

Definition at line 2561 of file klang.h.

Referenced by Wavetable(), Wavetable(), operator=(), process(), set(), set(), and set().