Allow for sample rate to be changed when used as a library#552
Allow for sample rate to be changed when used as a library#552jgartrel wants to merge 2 commits intoshorepine:mainfrom
Conversation
|
I agree with this in spirit. An issue we had is the arduino environment seems to never allow anyone to #define things before a library is included. Are you using AMY in arduino and if so does this work for you ? |
|
I was using it as included under the src folder. I intended to test it in the library context next. |
|
Also, The limited code and changes provided in this pull request are provided freely and completely to the shorepine/amy project to be used as its maintainers see fit and under any copyright they deem approprate. |
|
@bwhitman , You are right ... I tried to include it this way and it does NOT work, let me do some research and see if there is a way to accomplish this in a sustainable way. |
|
@bwhitman , Setting the define through the build.extra.flags mechanism (through a boards.local.txt or a platform.local.txt file) does seem to work, allowing for a pre define to change the sample rate. I guess that leaves 3 options:
Ultimately, I think this pull request provides some individuals a way to consume the AMY code as a read-only library without increasing the difficulty of maintaining AMY long-term. If we do find a better way, this is not complex to remove and would actually be removed in the natural workflow of such a change. I vote to go forward with the pull request (but I am biased after all, given that I created the feature request) :-D What do you all think? |
|
This was tested by extending the definition of build.extra.flags as a part of the board definition file (boards.txt and boards.local.txt): Ultimately this gets translated into a compile command through platform.txt (and platform_local.txt): This pattern seem to be used by other libraries, especially those bundled with various arduino cores to pass configurable defines into the library. |
|
I like (2) to be honest. But i'm still hunting for a good (3) in Arduino. We have definitely tested making sample rate, channels etc an |
|
No doubt you all tested this as a runtime arg. I just don't see how the compiler could fully optimize in such a case. Also I want to include a reference to how to extend a core and build properties to include such defines for future people that go down this path (assuming this pull request is accepted): arduino/arduino-cli#1684 (comment) |
This pull request allows for the ability to re-define key parameters within AMY without actually modifying the core AMY code. This allows AMY to be adapted for many platforms and use cases when used as a library. Resolves issue #551