Преглед на файлове

Fix multiple white noise instances

dds
PaulStoffregen преди 10 години
родител
ревизия
e1535addce
променени са 3 файла, в които са добавени 10 реда и са изтрити 5 реда
  1. +4
    -4
      Audio.h
  2. +1
    -0
      synth_whitenoise.cpp
  3. +5
    -1
      synth_whitenoise.h

+ 4
- 4
Audio.h Целия файл

#define Audio_h_ #define Audio_h_


#if TEENSYDUINO < 120 #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 #endif


// When changing multiple audio object settings that must update at // When changing multiple audio object settings that must update at
#include "synth_whitenoise.h" #include "synth_whitenoise.h"
#include "synth_pinknoise.h" #include "synth_pinknoise.h"


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

#endif #endif

+ 1
- 0
synth_whitenoise.cpp Целия файл

release(block); release(block);
} }


uint16_t AudioSynthNoiseWhite::instance_count = 0;





+ 5
- 1
synth_whitenoise.h Целия файл

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


#endif #endif

Loading…
Отказ
Запис