瀏覽代碼

Fix mixer gain function

dds
PaulStoffregen 11 年之前
父節點
當前提交
6431c2f185
共有 2 個檔案被更改,包括 9 行新增3 行删除
  1. +0
    -3
      Audio.h
  2. +9
    -0
      examples/PlayFromSketch/PlayFromSketch.ino

+ 0
- 3
Audio.h 查看文件

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

+ 9
- 0
examples/PlayFromSketch/PlayFromSketch.ino 查看文件

// turn on the output // turn on the output
audioShield.enable(); audioShield.enable();
audioShield.volume(50); 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() { void loop() {

Loading…
取消
儲存