I'm trying to cross fade using two AudioEffectFades and an AudioMixer4.
When I try the cross fade, the second sound begins playing at full volume even though it should just fade in.
I tried explicitly fading out the second fader initially, but its sound still comes in at full volume.
When I try the cross fade, the second sound begins playing at full volume even though it should just fade in.
I tried explicitly fading out the second fader initially, but its sound still comes in at full volume.
Code:
#include <Audio.h>
#include <SerialFlash.h>
AudioPlaySerialflashRaw sound1;
AudioPlaySerialflashRaw sound2;
AudioEffectFade fader1;
AudioEffectFade fader2;
AudioMixer4 mix;
AudioOutputI2S headphones;
AudioConnection patchCord1( sound1, 0, fader1, 0 );
AudioConnection patchCord2( sound2, 0, fader2, 0 );
AudioConnection patchCord3( fader1, 0, mix, 0 );
AudioConnection patchCord4( fader2, 0, mix, 1 );
AudioConnection patchCord5( mix, 0, headphones, 0 );
AudioConnection patchCord6( mix, 0, headphones, 1 );
AudioControlSGTL5000 sgtl5000;
void loop()
{
}
void setup()
{
AudioMemory( 32 );
SPI.setMOSI( 7 ); // MOSI_PIN for audio board
SPI.setSCK( 14 ); // SCK_PIN for audio board
if ( !SerialFlash.begin() )
Serial.println( "Unable to access SPI Flash chip" );
sgtl5000.enable();
sgtl5000.volume( .1 );
// Play the first sound
sound1.play( "SOUND.RAW" );
// Wait a bit
delay( 3000 );
// Initialize fader2 to 0 volume
fader2.fadeOut( 1 );
// Setup the cross fade
fader1.fadeOut( 1000 );
fader2.fadeIn( 1000 );
// Play the second sound
sound2.play( "SOUND.RAW" );
}
Last edited: