mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a safety assertion to check if an Oscillator's been initialised
This commit is contained in:
parent
0b19702306
commit
c1bdfc6a55
1 changed files with 5 additions and 0 deletions
|
|
@ -55,6 +55,9 @@ public:
|
|||
initialise (function, lookupTableNumPoints);
|
||||
}
|
||||
|
||||
/** Returns true if the Oscillator has been initialised. */
|
||||
bool isInitialised() const noexcept { return static_cast<bool> (generator); }
|
||||
|
||||
/** Initialises the oscillator with a waveform. */
|
||||
void initialise (const std::function<NumericType (NumericType)>& function, size_t lookupTableNumPoints = 0)
|
||||
{
|
||||
|
|
@ -102,6 +105,7 @@ public:
|
|||
/** Returns the result of processing a single sample. */
|
||||
SampleType JUCE_VECTOR_CALLTYPE processSample (SampleType) noexcept
|
||||
{
|
||||
jassert (isInitialised());
|
||||
auto increment = static_cast<NumericType> (2.0 * double_Pi) * frequency.getNextValue() / sampleRate;
|
||||
auto value = generator (pos - static_cast<NumericType> (double_Pi));
|
||||
pos = std::fmod (pos + increment, static_cast<NumericType> (2.0 * double_Pi));
|
||||
|
|
@ -113,6 +117,7 @@ public:
|
|||
template <typename ProcessContext>
|
||||
void process (const ProcessContext& context) noexcept
|
||||
{
|
||||
jassert (isInitialised());
|
||||
auto&& outBlock = context.getOutputBlock();
|
||||
|
||||
// this is an output-only processory
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue