Avoiding the delay(), RAW or re-use the WAV header?

Status
Not open for further replies.

cow_n_berg

Active member
Hi Paul,

I'm very excited about the possibilities of the Teensy, and at the moment I'm building a project using almost all of the pins of a Teensy 3.6.

As I don't want to work with delay(), I thought RAW would fit my project. Now I see here (https://forum.pjrc.com/threads/28246-how-to-play-raw-audio-file-in-PC?highlight=raw+audio) that only Mono quality is supported. Hm...

What I want to do:
1 - Play background sound over and over again
2 - Play effect sound after button, mixed through the background sound

File 1 could be 2 minutes, I repeated it into a 10 minute WAV file of 100 MB. File 2 is 3 seconds, 500 kB WAV.

As file 1 will be played over and over again, can't I just replay it with the existing WAV header info?

For the delay(): I'm no expert on Arduino programming. We had a student (Electronics engineering) working here last year, he told me to avoid delays. Now this project is watching a keypad of 4 x 5, and switching MOSFETs accordingly. The switching is not a matter of milliseconds, the delay might not hurt...

So I'll start working with the WAVs and the delays, and hopefully learn some new things in this thread.

Kind regards,
Rob
 
The delay() shown in the example code is only 10ms. And, that’s just to avoid calling the ‘isPlaying()’ method while the header is being parsed. If you really think that’s going to cause a problem, you don’t have to use delay(). Just avoid calling ‘isPlaying()’ for at least 10ms after you call ‘play()’. You can do that with a millis timer or a elapsedMillis variable -- essentially the same thing.
 
Status
Not open for further replies.
Back
Top