Support volume on each input channel
Call stub->SetGain(float) to set an input's volume before mixing.
This commit is contained in:
1 parent
ca50839712
commit
3c7ffbe0b3
2 files changed
+7
-2
No files matched your search
@@ -29,6 +29,7 @@ void setup()
|
||||
out = new AudioOutputI2S();
|
||||
mixer = new AudioOutputMixer(32, out);
|
||||
stub[0] = mixer->NewInput();
|
||||
stub[0]->SetGain(0.3);
|
||||
wav[0] = new AudioGeneratorWAV();
|
||||
wav[0]->begin(file[0], stub[0]);
|
||||
// Begin wav[1] later in loop()
|
||||
@@ -50,6 +51,7 @@ void loop()
|
||||
if (!go) {
|
||||
Serial.printf("starting 2\n");
|
||||
stub[1] = mixer->NewInput();
|
||||
stub[1]->SetGain(0.4);
|
||||
wav[1] = new AudioGeneratorWAV();
|
||||
file[1] = new AudioFileSourcePROGMEM( viola, sizeof(viola) );
|
||||
wav[1]->begin(file[1], stub[1]);
|
||||
|
||||
@@ -25,6 +25,7 @@ AudioOutputMixerStub::AudioOutputMixerStub(AudioOutputMixer *sink, int id) : Aud
|
||||
{
|
||||
this->id = id;
|
||||
this->parent = sink;
|
||||
SetGain(1.0);
|
||||
}
|
||||
|
||||
AudioOutputMixerStub::~AudioOutputMixerStub()
|
||||
@@ -54,8 +55,10 @@ bool AudioOutputMixerStub::begin()
|
||||
|
||||
bool AudioOutputMixerStub::ConsumeSample(int16_t sample[2])
|
||||
{
|
||||
// int16_t amp[2] = { Amplify(sample[LEFTCHANNEL]), Amplify(sample[RIGHTCHANNEL]) };
|
||||
return parent->ConsumeSample(sample, id);
|
||||
int16_t amp[2];
|
||||
amp[LEFTCHANNEL] = Amplify(sample[LEFTCHANNEL]);
|
||||
amp[RIGHTCHANNEL] = Amplify(sample[RIGHTCHANNEL]);
|
||||
return parent->ConsumeSample(amp, id);
|
||||
}
|
||||
|
||||
bool AudioOutputMixerStub::stop()
|
||||
|
||||
Reference in new issue
Block a user