Explorar el Código

Fix mixer gain function

dds
PaulStoffregen hace 11 años
padre
commit
6431c2f185
Se han modificado 2 ficheros con 9 adiciones y 3 borrados
  1. +0
    -3
      Audio.h
  2. +9
    -0
      examples/PlayFromSketch/PlayFromSketch.ino

+ 0
- 3
Audio.h Ver fichero

@@ -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 Ver fichero

@@ -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() {

Cargando…
Cancelar
Guardar