How to play audio while doing other processing

Does anyone have a good suggestion on this? I need to play samples of 1-2 seconds duration but also receive and process data from the ADC at the same time. I think it should be technically possible but have not seen a clear route. I am not tied to any particular processor at the moment. I have been thinking of using the Arduino mkr zero and ArduinoSound WavePlayback for this, but am open to all suggestions!

Thanks!

the YX-5300 module plays sound from an on board TF card. you send a command, it plays and stops on its own without further interaction with the Arduino. just a serial trigger and move on to the next thing

I don't know exactly how to do it and I've never used the Zero but it might be possible depending on how much "processing" you're doing.

Conceptually.... You just need an interrupt timer to read the ADC and write the DAC at the desired sample rate. If the ADC & DAC sample rates are the same you can use the same interrupt.

Then of course, your processing has to be fast-enough to keep-up with the sample rate. And, you're probably going to use the same interrupt timing.

You have to play back the sound asynchronously. Most sound libraries worth there salt will offer this option.

I did this with the following project Arduino Voice - YouTube
The waveform was set playing asynchronously and then the code monitored the audio through a peak detector circuit and changed the mouth part of the face so that as the sound got louder the mouth got bigger. I was using the Adafruit wav shield circuit to produce the sound so samples were fetched on a timed interrupt routine.

Thanks all - I'm keen to just use one arduino rather than trigger to a second. An asynch option from a sound library is definitely what they need - I haven't yet found one of these? Can you point me to what you used?
Thanks!

An asynch option from a sound library is definitely what they need - I haven't yet found one of these?

From the heading:-

Arduino library for asynchronous playback of PCM/WAV files direct from SD card.

Thanks Mike - I'm not sure this will be good enough for me as I need a fair amount of compute power left over - I think a 32bit ARM based arduino will be needed - I don't think the 328 series has very much CPU power?

Yes but you can implement the same thing as that library does on any processor and you will have more cycles in between what it has to do.

Well that would be great - but in the wiki it only says 328 boards supported? Will it definitely run on a zero?

No that is not what I said. Please read my last post again.

Ah -so you are saying I could write the equivalent function targeting a zero? Not that the code in the link would run on a zero? Doesn't sound like that's getting me closer then :frowning:

Doesn't sound like that's getting me closer then :frowning:

Why is that then? Is it your lack of programming skills?

No Mike. It is lack of time.