How to install Audio library to be local to the project?

AlexL

Member
Hello,
I'd like to change audio library's AUDIO_BLOCK_SAMPLES=128 to some other value. However I'd like to make the change local to one of my projects so that other projects that use this library with default AUDIO_BLOCK_SAMPLES setting are not affected. Can somebody help? Thanks!
 
The value is actually set in the cores part of Teensyduino, not in the Audio library itself - you can find it in the AudioStream.h file.

The value can be changed without editing the file, by providing it in the compiler’s command line. Unfortunately if you’re using the Arduino IDE you can’t easily do this, and there’s no mechanism to do so per-project (PlatformIO may make it easier, but I don’t use that so not sure).

It is possible to add options to the Arduino Tools menu: for an example see the ReadMe and changedConfigFiles in this repository. If the provided boards.local.txt doesn’t have the block size you want, it should be fairly obvious how to add it in. Note the requirement to delete the cache files if you’re using Arduino 2.x; if you don’t do this, the new options won’t show up.

You still won’t have per-project settings, so you’ll have to remember to change the Tools selection as needed. You could use a #if section to throw an error when you forget to do that.
 
Thank you very much for your reply! I've also noticed that AUDIO_BLOCK_SAMPLES is defined outside of the Audio library (why?). At least it is not part of github zip archive. My more general question is: does anyone know (1)why teensy's Audio library is not designed as "regular" Arduiono library so it can easily be installed, uninstalled, included as a part of the project and modified as needed and (2) is there a "scaled back" version of the same library that can be installed/modified on per project basis?
I was able to extract Audio lib files relevant to my project, modifiy and compile it locally (i.e. in the project) without referencing <Audio.h>. Running it "appear" to work. However I am not sure about correctness of what I have done. Can someone provide suggestions? Thanks again!
 
Back
Top