eDSP  0.0.1
A cross-platform DSP library written in C++.
Public Types | Public Member Functions | List of all members
edsp::oscillators::oscillator< T > Class Template Reference

The oscillator class generates a periodic signal. More...

#include <sinusoidal.hpp>

Inheritance diagram for edsp::oscillators::oscillator< T >:
edsp::oscillators::sawtooth_oscillator< T > edsp::oscillators::sin_oscillator< T > edsp::oscillators::square_oscillator< T > edsp::oscillators::triangular_oscillator< T >

Public Types

using value_type = T
 

Public Member Functions

constexpr oscillator (value_type amplitude, value_type samplerate, value_type frequency, value_type phase) noexcept
 Creates an oscillator that generates a waveform with the configuration. More...
 
constexpr value_type frequency () const noexcept
 Returns the fundamental frequency in Hz. More...
 
constexpr void set_frequency (value_type frequency) noexcept
 Sets the fundamental frequency of the periodic signal. More...
 
constexpr value_type phase () const noexcept
 Returns the phase shift in radians. More...
 
constexpr void set_phase (value_type phase) noexcept
 Sets the phase shift of the periodic signal. More...
 
constexpr value_type timestamp () const noexcept
 Returns the current timestamp of the signal in seconds. More...
 
constexpr void set_timestamp (value_type timestamp) noexcept
 Sets the current timestamp of the periodic signal. More...
 
constexpr value_type samplerate () const noexcept
 Returns the sampling frequency in Hz. More...
 
constexpr void set_samplerate (value_type samplerate) noexcept
 Sets the sampling frequency. More...
 
constexpr value_type sampling_period () const noexcept
 Returns the sampling period in secs. More...
 
constexpr value_type amplitude () const noexcept
 Returns the amplitude of the periodic signal. More...
 
constexpr void set_amplitude (value_type amplitude) noexcept
 Set the amplitude of the periodic signal. More...
 
constexpr void reset () noexcept
 Reset the oscillator to the original state. More...
 

Detailed Description

template<typename T>
class edsp::oscillators::oscillator< T >

The oscillator class generates a periodic signal.

An oscillator is a repeating waveform with a fundamental frequency and peak amplitude. Aside from the frequency or pitch of the oscillator and its amplitude, one of the most important features is the shape of its waveform.

Template Parameters
T

Member Typedef Documentation

◆ value_type

template<typename T>
using edsp::oscillators::oscillator< T >::value_type = T

Constructor & Destructor Documentation

◆ oscillator()

template<typename T >
constexpr edsp::oscillators::oscillator< T >::oscillator ( value_type  amplitude,
value_type  samplerate,
value_type  frequency,
value_type  phase 
)
noexcept

Creates an oscillator that generates a waveform with the configuration.

Parameters
amplitudeAmplitude of the waveform.
samplerateThe sampling frequency in Hz.
frequencyThe fundamental frequency of the signal (also known as pitch).
phasePhase shift in radians.

Member Function Documentation

◆ amplitude()

template<typename T >
constexpr oscillator< T >::value_type edsp::oscillators::oscillator< T >::amplitude ( ) const
noexcept

Returns the amplitude of the periodic signal.

Returns
Amplitude of the periodic signal.

◆ frequency()

template<typename T >
constexpr oscillator< T >::value_type edsp::oscillators::oscillator< T >::frequency ( ) const
noexcept

Returns the fundamental frequency in Hz.

Returns
Fundamental frequency in Hz.

◆ phase()

template<typename T >
constexpr oscillator< T >::value_type edsp::oscillators::oscillator< T >::phase ( ) const
noexcept

Returns the phase shift in radians.

Returns
Phase shift in radians,

◆ reset()

template<typename T >
constexpr void edsp::oscillators::oscillator< T >::reset ( )
noexcept

Reset the oscillator to the original state.

◆ samplerate()

template<typename T >
constexpr oscillator< T >::value_type edsp::oscillators::oscillator< T >::samplerate ( ) const
noexcept

Returns the sampling frequency in Hz.

Returns
Sampling frequency in Hz.

◆ sampling_period()

template<typename T >
constexpr oscillator< T >::value_type edsp::oscillators::oscillator< T >::sampling_period ( ) const
noexcept

Returns the sampling period in secs.

Returns
Sampling period in secs.
See also
frequency

◆ set_amplitude()

template<typename T >
constexpr void edsp::oscillators::oscillator< T >::set_amplitude ( value_type  amplitude)
noexcept

Set the amplitude of the periodic signal.

Parameters
amplitudeAmplitude of the signal

◆ set_frequency()

template<typename T >
constexpr void edsp::oscillators::oscillator< T >::set_frequency ( value_type  frequency)
noexcept

Sets the fundamental frequency of the periodic signal.

Parameters
frequencyFundamental frequency in Hz.

◆ set_phase()

template<typename T >
constexpr void edsp::oscillators::oscillator< T >::set_phase ( value_type  phase)
noexcept

Sets the phase shift of the periodic signal.

Parameters
phasePhase shift in radians.

◆ set_samplerate()

template<typename T >
constexpr void edsp::oscillators::oscillator< T >::set_samplerate ( value_type  samplerate)
noexcept

Sets the sampling frequency.

Parameters
samplerateSampling frequency in Hz.

◆ set_timestamp()

template<typename T >
constexpr void edsp::oscillators::oscillator< T >::set_timestamp ( value_type  timestamp)
noexcept

Sets the current timestamp of the periodic signal.

Parameters
timestampTimestamp of the signal in secs.

◆ timestamp()

template<typename T >
constexpr oscillator< T >::value_type edsp::oscillators::oscillator< T >::timestamp ( ) const
noexcept

Returns the current timestamp of the signal in seconds.

Returns
Timestamp of the periodic signal in secs.

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