Skip to content

Class daisysp::HarmonicOscillator

template <int num_harmonics>

ClassList > daisysp > HarmonicOscillator

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

  • #include <harmonic_osc.h>

Public Functions

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

Detailed Description

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.

Public Functions Documentation

function HarmonicOscillator

inline daisysp::HarmonicOscillator::HarmonicOscillator () 

function Init

inline void daisysp::HarmonicOscillator::Init (
    float sample_rate
) 

Initialize harmonic oscillator

Parameters:

  • sample_rate Audio engine samplerate

function Process

inline float daisysp::HarmonicOscillator::Process () 

Get the next floating point sample


function SetAmplitudes

inline void daisysp::HarmonicOscillator::SetAmplitudes (
    const  float * amplitudes
) 

Set the amplitudes of each harmonic of the root.

Parameters:

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

function SetFirstHarmIdx

inline void daisysp::HarmonicOscillator::SetFirstHarmIdx (
    int idx
) 

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

Parameters:

  • idx Default behavior is 1. Values < 0 default to 1.

function SetFreq

inline void daisysp::HarmonicOscillator::SetFreq (
    float freq
) 

Set the main frequency

Parameters:

  • freq Freq to be set in Hz.

function SetSingleAmp

inline void daisysp::HarmonicOscillator::SetSingleAmp (
    const  float amp,
    int idx
) 

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

Parameters:

  • amp Amplitude to set
  • idx Which harmonic to set.

function ~HarmonicOscillator

inline daisysp::HarmonicOscillator::~HarmonicOscillator () 


The documentation for this class was generated from the following file external-docs/DaisySP/Source/Synthesis/harmonic_osc.h