Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

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

  1. #1
    Junior Member
    Join Date
    Dec 2018

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

    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 ( 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,

  2. #2
    Senior Member
    Join Date
    Feb 2017
    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.

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Thanks! I can work with that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts