Generates a signal based on a user-supplied function. More...
#include <juce_Oscillator.h>
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< NumericType > | frequency { static_cast<NumericType> (440.0) } |
std::function< NumericType(NumericType)> | generator |
std::unique_ptr< LookupTableTransform< NumericType > > | lookupTable |
Phase< NumericType > | phase |
Array< NumericType > | rampBuffer |
NumericType | sampleRate = 48000.0 |
Generates a signal based on a user-supplied function.
{DSP}
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)
|
inline |
Creates an uninitialised oscillator.
Call initialise before first use.
|
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().
|
inlinenoexcept |
Returns the current frequency of the oscillator.
References juce::dsp::Oscillator< SampleType >::frequency, and juce::LinearSmoothedValue< FloatType >::getTargetValue().
|
inline |
Initialises the oscillator with a waveform.
References juce::dsp::Oscillator< SampleType >::generator, and juce::dsp::Oscillator< SampleType >::lookupTable.
Referenced by juce::dsp::Oscillator< SampleType >::Oscillator().
|
inlinenoexcept |
Returns true if the Oscillator has been initialised.
References juce::dsp::Oscillator< SampleType >::generator.
Referenced by juce::dsp::Oscillator< SampleType >::process(), and juce::dsp::Oscillator< SampleType >::processSample().
|
inlinenoexcept |
|
inlinenoexcept |
Processes the input and output buffers supplied in the processing context.
References juce::dsp::Phase< Type >::advance(), juce::dsp::Oscillator< SampleType >::frequency, juce::dsp::Oscillator< SampleType >::generator, juce::LinearSmoothedValue< FloatType >::getNextValue(), juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::getRawDataPointer(), juce::dsp::Oscillator< SampleType >::isInitialised(), juce::LinearSmoothedValue< FloatType >::isSmoothing(), jassert, juce::jmin(), juce::dsp::Oscillator< SampleType >::phase, juce::dsp::Oscillator< SampleType >::rampBuffer, juce::dsp::Oscillator< SampleType >::sampleRate, juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::size(), and juce::LinearSmoothedValue< FloatType >::skip().
|
inlinenoexcept |
Returns the result of processing a single sample.
References juce::dsp::Phase< Type >::advance(), juce::dsp::Oscillator< SampleType >::frequency, juce::dsp::Oscillator< SampleType >::generator, juce::LinearSmoothedValue< FloatType >::getNextValue(), juce::dsp::Oscillator< SampleType >::isInitialised(), jassert, juce::dsp::Oscillator< SampleType >::phase, and juce::dsp::Oscillator< SampleType >::sampleRate.
|
inlinenoexcept |
Resets the internal state of the oscillator.
References juce::dsp::Oscillator< SampleType >::frequency, juce::dsp::Oscillator< SampleType >::phase, juce::dsp::Phase< Type >::reset(), juce::LinearSmoothedValue< FloatType >::reset(), and juce::dsp::Oscillator< SampleType >::sampleRate.
Referenced by juce::dsp::Oscillator< SampleType >::prepare().
|
inlinenoexcept |
Sets the frequency of the oscillator.
References juce::dsp::Oscillator< SampleType >::frequency, and juce::LinearSmoothedValue< FloatType >::setValue().
|
private |
|
private |
|
private |
Referenced by juce::dsp::Oscillator< SampleType >::initialise().
|
private |
|
private |
|
private |