Skip to content

Commit

Permalink
Noise::gen -> Noise::fbm
Browse files Browse the repository at this point in the history
  • Loading branch information
artfwo committed May 27, 2018
1 parent 3b1c80c commit fdf4ecc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Source/AndesVoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void AndesVoice::renderNextBlock(AudioSampleBuffer& outputBuffer, int startSampl
{
float phase = fmod(currentPhase, 2);
const float envLevel = envGen.next();
const float currentSample = processor.noise.gen(phase,
const float currentSample = processor.noise.fbm(phase,
(int) *processor.parameters.getRawParameterValue("octaves"),
*processor.parameters.getRawParameterValue("persistence"),
*processor.parameters.getRawParameterValue("offset"),
Expand Down
13 changes: 4 additions & 9 deletions Source/Noise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ void Noise::setSeed(uint32_t seed)
}
}

static inline float lerp(float a0, float a1, float w)
{
return (1.0f - w) * a0 + w * a1;
}

float Noise::gen1(float z, float offset)
float Noise::noise(float z, float offset)
{
float g1, g2, d2;
float result = 0;
Expand Down Expand Up @@ -82,16 +77,16 @@ float Noise::gen1(float z, float offset)
return result * 3.33; // temp normalization value
}

float Noise::gen(float z, int octaves, float persistence, float offset, float warping)
float Noise::fbm(float z, int octaves, float persistence, float offset, float warping)
{
float result = 0;
float multiplier = 1.0f;
float warpOffset = gen1(z, offset) * warping;
float warpOffset = noise(z, offset) * warping;

for (int octave = 0; octave < octaves; ++octave)
{
float t = fmod(offset, 4);
float value = gen1(z * (1 << octave) + warpOffset, t) * multiplier;
float value = noise(z * (1 << octave) + warpOffset, t) * multiplier;
warpOffset = value * warping;
result += value;
multiplier *= persistence;
Expand Down
4 changes: 2 additions & 2 deletions Source/Noise.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Noise
Noise();
~Noise();

float gen(float z, int octaves, float persistence, float offset, float warping);
float fbm(float z, int octaves, float persistence, float offset, float warping);

uint32_t getSeed();
void setSeed(uint32_t seed);
Expand All @@ -36,5 +36,5 @@ class Noise
std::mt19937 random;
uint32_t seed_;

float gen1(float z, float offset);
float noise(float z, float offset);
};
2 changes: 1 addition & 1 deletion Source/WaveformVisualiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void WaveformVisualiser::paint(Graphics& g)
{
float z = ((float) i) / ((float) w) * 2.0f;

p.lineTo(i, h / 2 - (processor.noise.gen(
p.lineTo(i, h / 2 - (processor.noise.fbm(
z,
(int) *processor.parameters.getRawParameterValue("octaves"),
*processor.parameters.getRawParameterValue("persistence"),
Expand Down

0 comments on commit fdf4ecc

Please sign in to comment.