DaisySP
Loading...
Searching...
No Matches
daisysp::HarmonicOscillator< num_harmonics > Class Template Reference

Harmonic Oscillator Module based on Chebyshev polynomials. More...

#include <harmonic_osc.h>

Public Member Functions

void Init (float sample_rate)
 
float Process ()
 
void SetFreq (float freq)
 
void SetFirstHarmIdx (int idx)
 
void SetAmplitudes (const float *amplitudes)
 
void SetSingleAmp (const float amp, int idx)
 

Detailed Description

template<int num_harmonics = 16>
class daisysp::HarmonicOscillator< num_harmonics >

Harmonic Oscillator Module based on Chebyshev polynomials.

Author
Ben Sergentanis
Date
Dec 2020 Harmonic Oscillator Module based on Chebyshev polynomials
Works well for a small number of harmonics. For the higher order harmonics.
We need to reinitialize the recurrence by computing two high harmonics.

Ported from pichenettes/eurorack/plaits/dsp/oscillator/harmonic_oscillator.h
to an independent module.
Original code written by Emilie Gillet in 2016.

Member Function Documentation

◆ Init()

template<int num_harmonics = 16>
void daisysp::HarmonicOscillator< num_harmonics >::Init ( float sample_rate)
inline

Initialize harmonic oscillator

Parameters
sample_rateAudio engine samplerate

◆ Process()

template<int num_harmonics = 16>
float daisysp::HarmonicOscillator< num_harmonics >::Process ( )
inline

Get the next floating point sample

◆ SetAmplitudes()

template<int num_harmonics = 16>
void daisysp::HarmonicOscillator< num_harmonics >::SetAmplitudes ( const float * amplitudes)
inline

Set the amplitudes of each harmonic of the root.

Parameters
amplitudesAmplitudes to set. Sum of all amplitudes must be < 1. The array referenced must be at least as large as num_harmonics.

◆ SetFirstHarmIdx()

template<int num_harmonics = 16>
void daisysp::HarmonicOscillator< num_harmonics >::SetFirstHarmIdx ( int idx)
inline

Offset the set of harmonics. Passing in 3 means "harmonic 0" is the 3rd harm., 1 is the 4th, etc.

Parameters
idxDefault behavior is 1. Values < 0 default to 1.

◆ SetFreq()

template<int num_harmonics = 16>
void daisysp::HarmonicOscillator< num_harmonics >::SetFreq ( float freq)
inline

Set the main frequency

Parameters
freqFreq to be set in Hz.

◆ SetSingleAmp()

template<int num_harmonics = 16>
void daisysp::HarmonicOscillator< num_harmonics >::SetSingleAmp ( const float amp,
int idx )
inline

Sets one amplitude. Does nothing if idx out of range.

Parameters
ampAmplitude to set
idxWhich harmonic to set.

The documentation for this class was generated from the following file: