TimerFreeTone Library v1.5: Play tones without timers and therefore no conflicts

You kind of combined TimerFreeTone with my toneAC library. The purpose of TimerFreeTone is to not use timers, so no, it doesn't play in the background. To do that, you must use timers.

I'm guessing you found my TimerFreeTone library because you can't use typical libraries that use timers with the ARM processor on the Feather M0 board. This is one of the reasons I don't purchase these off boards. Sure, they can do simple things, but you really can't use most Arduino libraries as they haven't made them very compatible. They support the basics, but nothing else.

This is why I suggest to only purchase Arduino AVR boards or if you want more speed/features to get a Teensy 3.x board. Not only is the Teensy 3.x platform very fast, very inexpensive, and capable of doing all sorts of things, Paul Stoffregen spends the time to make them VERY compatible with most Arduino libraries or works with the library authors to make them compatible.

The other problem using ARM-based platforms is that the voltage is 3.3v instead of 5. While this is the direction of modern devices, there's lots of legacy stuff that uses 5v. Also, in the case of a speaker, 3.3v isn't much. It's probably best to build an amp for the speaker instead of what you're doing. Then, look into the timers of your chip to see if there's a library you can use to interface with it to create sound. Seriously, it would probably be easier to do Bluetooth and sound playing in the background easier with an Arduino Uno that with the Feather M0 board.

Also, I wouldn't suggest anyone using an Arduino AVR to use your code, it's too slow so you'll have a long time with both pins high going to the piezo. My library uses shift registers which are MUCH faster to almost totally avoid this problem.

I'll release a TimerFreeToneAC which will do what you want but also be safer for Arduino AVR boards.

Tim