HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
HephAudio::Oscillator Class Referenceabstract

base class for oscillators. More...

#include <Oscillator.h>

Inheritance diagram for HephAudio::Oscillator:
HephAudio::SawToothWaveOscillator HephAudio::SineWaveOscillator HephAudio::SquareWaveOscillator HephAudio::TriangleWaveOscillator

Public Member Functions

virtual ~Oscillator ()=default
 
virtual double operator[] (size_t n) const =0
 
Heph::DoubleBuffer GenerateBuffer () const
 
Heph::DoubleBuffer GenerateBuffer (size_t size) const
 
Heph::DoubleBuffer GenerateBuffer (size_t index, size_t size) const
 

Public Attributes

double peakAmplitude
 
double frequency
 
double phase_rad
 
uint32_t sampleRate
 

Protected Member Functions

 Oscillator ()
 
 Oscillator (double peakAmplitude, double frequency, uint32_t sampleRate, double phase_rad)
 

Detailed Description

base class for oscillators.

Constructor & Destructor Documentation

◆ Oscillator() [1/2]

HephAudio::Oscillator::Oscillator ( )
protected

creates a new instance and initializes it with default values.

◆ Oscillator() [2/2]

HephAudio::Oscillator::Oscillator ( double peakAmplitude,
double frequency,
uint32_t sampleRate,
double phase_rad )
protected

creates a new instance and initializes it with the provided values.

Parameters
peakAmplitudemaximum amplitude of the periodic signal.
frequencyfrequency of the periodic signal.
sampleRatesampling rate of the periodic signal.
phase_radphase angle, in radians, of the periodic signal.

◆ ~Oscillator()

virtual HephAudio::Oscillator::~Oscillator ( )
virtualdefault

releases the resources and destroys the instance.

Member Function Documentation

◆ operator[]()

virtual double HephAudio::Oscillator::operator[] ( size_t n) const
pure virtual

◆ GenerateBuffer() [1/3]

Heph::DoubleBuffer HephAudio::Oscillator::GenerateBuffer ( ) const

generates a one-period-long buffer.

◆ GenerateBuffer() [2/3]

Heph::DoubleBuffer HephAudio::Oscillator::GenerateBuffer ( size_t size) const

generates a buffer with the provided size.

Parameters
sizesize of the buffer in samples.

◆ GenerateBuffer() [3/3]

Heph::DoubleBuffer HephAudio::Oscillator::GenerateBuffer ( size_t index,
size_t size ) const

generates a buffer with the provided size.

Parameters
indexindex of the first sample.
sizesize of the buffer in samples.

Member Data Documentation

◆ peakAmplitude

double HephAudio::Oscillator::peakAmplitude

maximum amplitude of the periodic signal.

◆ frequency

double HephAudio::Oscillator::frequency

frequency of the periodic signal.

◆ phase_rad

double HephAudio::Oscillator::phase_rad

phase angle, in radians, of the periodic signal.

◆ sampleRate

uint32_t HephAudio::Oscillator::sampleRate

sampling rate of the periodic signal.