JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::dsp::Oscillator< SampleType > Class Template Reference

Generates a signal based on a user-supplied function. More...

#include <juce_Oscillator.h>

Collaboration diagram for juce::dsp::Oscillator< SampleType >:

Public Types

using NumericType = typename SampleTypeHelpers::ElementType< SampleType >::Type
 The NumericType is the underlying primitive type used by the SampleType (which could be either a primitive or vector) More...
 

Public Member Functions

 Oscillator ()
 Creates an uninitialised oscillator. More...
 
 Oscillator (const std::function< NumericType(NumericType)> &function, size_t lookupTableNumPoints=0)
 Creates an oscillator with a periodic input function (-pi..pi). More...
 
NumericType getFrequency () const noexcept
 Returns the current frequency of the oscillator. More...
 
void initialise (const std::function< NumericType(NumericType)> &function, size_t lookupTableNumPoints=0)
 Initialises the oscillator with a waveform. More...
 
bool isInitialised () const noexcept
 Returns true if the Oscillator has been initialised. More...
 
void prepare (const ProcessSpec &spec) noexcept
 Called before processing starts. More...
 
template<typename ProcessContext >
void process (const ProcessContext &context) noexcept
 Processes the input and output buffers supplied in the processing context. More...
 
SampleType JUCE_VECTOR_CALLTYPE processSample (SampleType input) noexcept
 Returns the result of processing a single sample. More...
 
void reset () noexcept
 Resets the internal state of the oscillator. More...
 
void setFrequency (NumericType newFrequency, bool force=false) noexcept
 Sets the frequency of the oscillator. More...
 

Private Attributes

LinearSmoothedValue< NumericTypefrequency { static_cast<NumericType> (440.0) }
 
std::function< NumericType(NumericType)> generator
 
std::unique_ptr< LookupTableTransform< NumericType > > lookupTable
 
Phase< NumericTypephase
 
Array< NumericTyperampBuffer
 
NumericType sampleRate = 48000.0
 

Detailed Description

template<typename SampleType>
class juce::dsp::Oscillator< SampleType >

Generates a signal based on a user-supplied function.

{DSP}

Member Typedef Documentation

◆ NumericType

template<typename SampleType >
using juce::dsp::Oscillator< SampleType >::NumericType = typename SampleTypeHelpers::ElementType<SampleType>::Type

The NumericType is the underlying primitive type used by the SampleType (which could be either a primitive or vector)

Constructor & Destructor Documentation

◆ Oscillator() [1/2]

template<typename SampleType >
juce::dsp::Oscillator< SampleType >::Oscillator ( )
inline

Creates an uninitialised oscillator.

Call initialise before first use.

◆ Oscillator() [2/2]

template<typename SampleType >
juce::dsp::Oscillator< SampleType >::Oscillator ( const std::function< NumericType(NumericType)> &  function,
size_t  lookupTableNumPoints = 0 
)
inline

Creates an oscillator with a periodic input function (-pi..pi).

If lookup table is not zero, then the function will be approximated with a lookup table.

References juce::dsp::Oscillator< SampleType >::initialise().

Member Function Documentation

◆ getFrequency()

template<typename SampleType >
NumericType juce::dsp::Oscillator< SampleType >::getFrequency ( ) const
inlinenoexcept

Returns the current frequency of the oscillator.

References juce::dsp::Oscillator< SampleType >::frequency, and juce::LinearSmoothedValue< FloatType >::getTargetValue().

◆ initialise()

template<typename SampleType >
void juce::dsp::Oscillator< SampleType >::initialise ( const std::function< NumericType(NumericType)> &  function,
size_t  lookupTableNumPoints = 0 
)
inline

◆ isInitialised()

template<typename SampleType >
bool juce::dsp::Oscillator< SampleType >::isInitialised ( ) const
inlinenoexcept

◆ prepare()

◆ process()

◆ processSample()

◆ reset()

◆ setFrequency()

template<typename SampleType >
void juce::dsp::Oscillator< SampleType >::setFrequency ( NumericType  newFrequency,
bool  force = false 
)
inlinenoexcept

Member Data Documentation

◆ frequency

◆ generator

◆ lookupTable

template<typename SampleType >
std::unique_ptr<LookupTableTransform<NumericType> > juce::dsp::Oscillator< SampleType >::lookupTable
private

◆ phase

◆ rampBuffer

template<typename SampleType >
Array<NumericType> juce::dsp::Oscillator< SampleType >::rampBuffer
private

◆ sampleRate


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