Bladeren bron

Fix multiple white noise instances

dds
PaulStoffregen 10 jaren geleden
bovenliggende
commit
e1535addce
3 gewijzigde bestanden met toevoegingen van 10 en 5 verwijderingen
  1. +4
    -4
      Audio.h
  2. +1
    -0
      synth_whitenoise.cpp
  3. +5
    -1
      synth_whitenoise.h

+ 4
- 4
Audio.h Bestand weergeven

@@ -28,7 +28,10 @@
#define Audio_h_

#if TEENSYDUINO < 120
#error "Teensyduino version 1.20 or later is required to compile the Audio library"
#error "Teensyduino version 1.20 or later is required to compile the Audio library."
#endif
#ifdef __AVR__
#error "The Audio Library only works with Teensy 3.X. Teensy 2.0 is unsupported."
#endif

// When changing multiple audio object settings that must update at
@@ -81,7 +84,4 @@
#include "synth_whitenoise.h"
#include "synth_pinknoise.h"

// TODO: more audio processing objects....
// waveforms with bandwidth limited tables for synth

#endif

+ 1
- 0
synth_whitenoise.cpp Bestand weergeven

@@ -78,5 +78,6 @@ void AudioSynthNoiseWhite::update(void)
release(block);
}

uint16_t AudioSynthNoiseWhite::instance_count = 0;



+ 5
- 1
synth_whitenoise.h Bestand weergeven

@@ -32,7 +32,10 @@
class AudioSynthNoiseWhite : public AudioStream
{
public:
AudioSynthNoiseWhite() : AudioStream(0, NULL), level(0), seed(1) {}
AudioSynthNoiseWhite() : AudioStream(0, NULL) {
level = 0;
seed = 1 + instance_count++;
}
void amplitude(float n) {
if (n < 0.0) n = 0.0;
else if (n > 1.0) n = 1.0;
@@ -42,6 +45,7 @@ public:
private:
int32_t level; // 0=off, 65536=max
uint32_t seed; // must start at 1
static uint16_t instance_count;
};

#endif

Laden…
Annuleren
Opslaan