Quellcode durchsuchen

Fix mixer gain function

dds
PaulStoffregen vor 11 Jahren
Ursprung
Commit
6431c2f185
2 geänderte Dateien mit 9 neuen und 3 gelöschten Zeilen
  1. +0
    -3
      Audio.h
  2. +9
    -0
      examples/PlayFromSketch/PlayFromSketch.ino

+ 0
- 3
Audio.h Datei anzeigen

@@ -313,18 +313,15 @@ class AudioMixer4 : public AudioStream
{
public:
AudioMixer4(void) : AudioStream(4, inputQueueArray) {
//for (int i=0; i<4; i++) gain(i, 1.0f);
for (int i=0; i<4; i++) multiplier[i] = 65536;
}
virtual void update(void);
/*
void gain(unsigned int channel, float gain) {
if (channel >= 4) return;
if (gain > 32767.0f) gain = 32767.0f;
else if (gain < 0.0f) gain = 0.0f;
multiplier[channel] = gain * 65536.0f; // TODO: proper roundoff?
}
*/
private:
int32_t multiplier[4];
audio_block_t *inputQueueArray[4];

+ 9
- 0
examples/PlayFromSketch/PlayFromSketch.ino Datei anzeigen

@@ -69,6 +69,15 @@ void setup() {
// turn on the output
audioShield.enable();
audioShield.volume(50);

// reduce the gain on mixer channels, so more than 1
// sound can play simultaneously without clipping
mix1.gain(0, 0.4);
mix1.gain(1, 0.4);
mix1.gain(2, 0.4);
mix1.gain(3, 0.4);
mix2.gain(1, 0.4);
mix2.gain(2, 0.4);
}

void loop() {

Laden…
Abbrechen
Speichern