Playing multiple audio files in sequence with 1 push button


hi there all,
i've started learning c++ within arduino ide.
trying teensy v3.1  playback 3 different sound files.
the first played once when button pushed in.
the second played in loop while button held down.
the third played once when button released.
btw i'm not using audio shield.
the board being powered 3v coin cell miniature amplifier.
my code compiles doesn't seem work desired.


#include <audio.h>
#include <wire.h>
#include <spi.h>
#include <sd.h>
#include "mngs1.h"
#include "mngs2.h"
#include "mngs3.h"

audioplaymemory gunsound; // creates audio memory object
audiooutputanalog dac; // play on-chip dac
audioconnection c1(gunsound, 0, dac, 0);
audiocontrolsgtl5000 audioshield;
int inpin = 2;
int val = 0;

void setup()
{
pinmode(2, input); //sets digital pin input:
audiomemory(1); //allocates 1 memory spaces audio file played

// turn on output
audioshield.enable();
audioshield.volume(0.5);
}

void loop()
{
val = (digitalread(inpin));
if (val == high)
{
gunsound.play(mngs1);
}
if (!gunsound.isplaying())
{
val = (digitalread(inpin));
while (val == high)
{
if (gunsound.isplaying())
{
val = (digitalread(inpin));
}
gunsound.play(mngs2);
}
}
if (val == low)
{
gunsound.play(mngs3);
}
};


please let me know if i've made booboos i'm trying achieve.

btw i'm not using audio shield.
what using then? want use cortex m4 dac?

quote
my code compiles doesn't seem work desired.
what's not working? or working?  ;)


Arduino Forum > Using Arduino > Audio > Playing multiple audio files in sequence with 1 push button


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code