-
-
Notifications
You must be signed in to change notification settings - Fork 42.4k
dac_additive: Decouple the buffer length from the waveform length #22276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dac_additive: Decouple the buffer length from the waveform length #22276
Conversation
|
Currently lint fails on the trapezoid wave, but I formatted it like the existing sine wave. Should I add a comment like in the sine wave array, or format it like the linter says? |
|
You may also add a trailing comma to make the formatting less horrible (the line length remains huge though). |
|
Adding a comma and rerunning As for the huge lines, they are undeniably giving the least vertical space and visual attention possible to static data of this nature, i.e. just two lines (but give way for some gnarly horizontal scroll bars if not wrapping!). Since I'm in that code anyway, I might as well either reformat the arrays in rows of 8 entries, ending at column 60, or in rows of 16 entries, ending at column 116. But that fails linting, and |
…olumn 116" This reverts commit 6f2d379.
|
Compiles and works properly, for me. |
On what driver, |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
…k#22276) * dac_additive: Decouple the buffer length from the waveform length * Formatting changes for the previous commit * Reformat waveform tables with rows of 16 entries, ending at column 116 * Revert "Reformat waveform tables with rows of 16 entries, ending at column 116" This reverts commit 6f2d379.
…k#22276) * dac_additive: Decouple the buffer length from the waveform length * Formatting changes for the previous commit * Reformat waveform tables with rows of 16 entries, ending at column 116 * Revert "Reformat waveform tables with rows of 16 entries, ending at column 116" This reverts commit 6f2d379.
…k#22276) * dac_additive: Decouple the buffer length from the waveform length * Formatting changes for the previous commit * Reformat waveform tables with rows of 16 entries, ending at column 116 * Revert "Reformat waveform tables with rows of 16 entries, ending at column 116" This reverts commit 6f2d379.
…k#22276) * dac_additive: Decouple the buffer length from the waveform length * Formatting changes for the previous commit * Reformat waveform tables with rows of 16 entries, ending at column 116 * Revert "Reformat waveform tables with rows of 16 entries, ending at column 116" This reverts commit 6f2d379.
Description
In the additive DAC driver, I saw these two pieces of code:
qmk_firmware/platforms/chibios/drivers/audio_dac_additive.c
Lines 56 to 57 in 184c584
qmk_firmware/platforms/chibios/drivers/audio_dac_additive.c
Line 87 in 184c584
To me, it made no sense to have the runtime audio buffer in that driver sized according to the number of entries in the sine wave table or require all waveform tables to be sized like the runtime audio buffer, especially because the runtime audio buffer gets filled from generated samples that come from a waveform table indirectly after calculations.
This PR makes the buffer size for both DAC drivers configurable, documents it and adds sane defaults depending on the sample rate. In
dac_additive, I've also changed the waveform tables to remove the explicit size in the array definitions, and while I was at it, I also changed the square wave and the commented-out staircase wave to give them only 2 and 4 steps, respectively. In the future, the waveform tables may also be made more or less precise, as required, by adding or removing entries within them.For users of the
dac_additivedriver, on default settings, this change reduces RAM usage by 384 bytes; for those who choose the square wave, the flash usage also gets reduced by 508 bytes.For users of the
dac_basicdriver, on default settings, this change reduces flash usage by 768 bytes, because the square waves, which are also the runtime buffers, are stored in flash.In either case, on default settings, this PR also reduces the latency to stop a note after the relevant input stops being applied (music mode, melody, MIDI, etc.) from a maximum of 15.6 ms to a maximum of 3.9 ms.
Tested on
moonlanderusingdac_additive. Needs testing on keyboards usingdac_basic.Types of Changes
Checklist
I do not have hardware to test all of the things I changed.