feat(dsp): add core synthesizer oscillators, wavetable and voice engine
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#include "NoiseOscillator.h"
|
||||
|
||||
namespace serum
|
||||
{
|
||||
|
||||
void NoiseOscillator::reset()
|
||||
{
|
||||
pinkB0 = pinkB1 = pinkB2 = 0.0f;
|
||||
}
|
||||
|
||||
void NoiseOscillator::noteOn (juce::uint32 seed)
|
||||
{
|
||||
rng.setSeed (seed);
|
||||
}
|
||||
|
||||
void NoiseOscillator::processAdd (int type, float level, float& out) noexcept
|
||||
{
|
||||
if (level <= 0.0f)
|
||||
return;
|
||||
|
||||
const float white = rng.nextFloat() * 2.0f - 1.0f;
|
||||
|
||||
float s = white;
|
||||
if (type == (int) NoiseType::Pink)
|
||||
{
|
||||
// Paul Kellet's economy pink-noise filter.
|
||||
pinkB0 = 0.99765f * pinkB0 + white * 0.0990460f;
|
||||
pinkB1 = 0.96300f * pinkB1 + white * 0.2965164f;
|
||||
pinkB2 = 0.57000f * pinkB2 + white * 1.0526913f;
|
||||
s = pinkB0 + pinkB1 + pinkB2 + white * 0.1848f;
|
||||
}
|
||||
|
||||
out += s * level;
|
||||
}
|
||||
|
||||
} // namespace serum
|
||||
Reference in New Issue
Block a user