Skip to content

Commit 0ac57c5

Browse files
committed
NoiseGenerator correct amplitude
1 parent a83fafa commit 0ac57c5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/AudioEffects/SoundGenerator.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,18 @@ class SquareWaveGenerator : public SineWaveGenerator<T> {
265265
template <class T>
266266
class NoiseGenerator : public SoundGenerator<T> {
267267
public:
268-
// the scale defines the max value which is generated
269-
NoiseGenerator(double scale=1.0) {
270-
this->scale = scale;
268+
/// the scale defines the max value which is generated
269+
NoiseGenerator(T amplitude = 32767) {
270+
this->amplitude = amplitude;
271271
}
272272

273273
/// Provides a single sample
274274
T readSample() {
275-
return ((rand() % (static_cast<T>(2 * scale)) - scale)); // generate number between -scale / scale
275+
return (random(-amplitude, amplitude));
276276
}
277277

278278
protected:
279-
double scale;
279+
T amplitude;
280280

281281
};
282282

0 commit comments

Comments
 (0)