Pārlūkot izejas kodu

Fix mixer gain function

dds
PaulStoffregen pirms 11 gadiem
vecāks
revīzija
6431c2f185
2 mainītis faili ar 9 papildinājumiem un 3 dzēšanām
  1. +0
    -3
      Audio.h
  2. +9
    -0
      examples/PlayFromSketch/PlayFromSketch.ino

+ 0
- 3
Audio.h Parādīt failu

@@ -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 Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt