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 ()=default | |
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 | |
SmoothedValue< 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.
@tags{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)
|
default |
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::SmoothedValueBase< SmoothedValueType >::getTargetValue().
|
inline |
Initialises the oscillator with a waveform.
References juce::dsp::Oscillator< SampleType >::generator, juce::dsp::Oscillator< SampleType >::lookupTable, and juce::gl::x.
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::gl::buffer, juce::gl::dst, juce::dsp::Oscillator< SampleType >::frequency, juce::dsp::Oscillator< SampleType >::generator, juce::SmoothedValue< FloatType, SmoothingType >::getNextValue(), juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::getRawDataPointer(), juce::dsp::Oscillator< SampleType >::isInitialised(), juce::SmoothedValueBase< SmoothedValueType >::isSmoothing(), jassert, juce::jmin(), juce::gl::len, juce::gl::p, juce::dsp::Oscillator< SampleType >::phase, juce::dsp::Oscillator< SampleType >::rampBuffer, juce::dsp::Oscillator< SampleType >::sampleRate, juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::size(), juce::SmoothedValue< FloatType, SmoothingType >::skip(), and juce::gl::src.
|
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::SmoothedValue< FloatType, SmoothingType >::getNextValue(), juce::gl::input, 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::SmoothedValue< FloatType, SmoothingType >::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, juce::SmoothedValueBase< SmoothedValueType >::setCurrentAndTargetValue(), and juce::SmoothedValue< FloatType, SmoothingType >::setTargetValue().
|
private |
|
private |
|
private |
Referenced by juce::dsp::Oscillator< SampleType >::initialise().
|
private |
|
private |
|
private |