summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorNebuleon <2391500+Nebuleon@users.noreply.github.com>2023-12-12 14:06:56 -0500
committerGitHub <noreply@github.com>2023-12-12 20:06:56 +0100
commit229a1690a7fcfcebc64d07068c885cc8966d0d57 (patch)
treef8dab1e1dca8f722403f67b87c807f19ec5c060a /docs
parent02c5afc7d5d2a2b3f71671da974f85e0b81d45a7 (diff)
dac_additive: Decouple the buffer length from the waveform length (#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 6f2d37908d6e73e1505ce61e63190f32f051586f.
Diffstat (limited to 'docs')
-rw-r--r--docs/audio_driver.md31
1 files changed, 22 insertions, 9 deletions
diff --git a/docs/audio_driver.md b/docs/audio_driver.md
index a0bbb22e19..7bce6c2d9b 100644
--- a/docs/audio_driver.md
+++ b/docs/audio_driver.md
@@ -116,19 +116,32 @@ Additionally, in the board config, you'll want to make changes to enable the DAC
| Define | Defaults | Description |
| -------------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AUDIO_DAC_SAMPLE_MAX` | `4095U` | Highest value allowed. Lower value means lower volume. And 4095U is the upper limit, since this is limited to a 12 bit value. Only effects non-pregenerated samples. |
-| `AUDIO_DAC_OFF_VALUE` | `AUDIO_DAC_SAMPLE_MAX / 2` | The value of the DAC when notplaying anything. Some setups may require a high (`AUDIO_DAC_SAMPLE_MAX`) or low (`0`) value here. |
+| `AUDIO_DAC_OFF_VALUE` | `AUDIO_DAC_SAMPLE_MAX / 2` | The value of the DAC when not playing anything. Some setups may require a high (`AUDIO_DAC_SAMPLE_MAX`) or low (`0`) value here. |
| `AUDIO_MAX_SIMULTANEOUS_TONES` | __see next table__ | The number of tones that can be played simultaneously. A value that is too high may freeze the controller or glitch out when too many tones are being played. |
| `AUDIO_DAC_SAMPLE_RATE` | __see next table__ | Effective bit rate of the DAC (in hertz), higher limits simultaneous tones, and lower sacrifices quality. |
+| `AUDIO_DAC_BUFFER_SIZE` | __see next table__ | Number of samples generated every refill. Too few may cause excessive CPU load; too many may cause freezes, RAM or flash exhaustion or lags during matrix scanning. |
-There are a number of predefined quality settings that you can use, with "sane minimum" being the default. You can use custom values by simply defining the sample rate and number of simultaneous tones, instead of using one of the listed presets.
+There are a number of predefined quality settings that you can use, with "sane minimum" being the default. You can use custom values by simply defining the sample rate, number of simultaneous tones and buffer size, instead of using one of the listed presets.
-| Define | Sample Rate | Simultaneous tones |
-| --------------------------------- | ----------- | ------------------- |
-| `AUDIO_DAC_QUALITY_VERY_LOW` | `11025U` | `8` |
-| `AUDIO_DAC_QUALITY_LOW` | `22040U` | `4` |
-| `AUDIO_DAC_QUALITY_HIGH` | `44100U` | `2` |
-| `AUDIO_DAC_QUALITY_VERY_HIGH` | `88200U` | `1` |
-| `AUDIO_DAC_QUALITY_SANE_MINIMUM` | `16384U` | `8` |
+| Define | Sample Rate | Simultaneous tones | Buffer size |
+| --------------------------------- | ----------- | ------------------- | ----------- |
+| `AUDIO_DAC_QUALITY_VERY_LOW` | `11025U` | `8` | `64U` |
+| `AUDIO_DAC_QUALITY_LOW` | `22050U` | `4` | `128U` |
+| `AUDIO_DAC_QUALITY_HIGH` | `44100U` | `2` | `256U` |
+| `AUDIO_DAC_QUALITY_VERY_HIGH` | `88200U` | `1` | `256U` |
+| `AUDIO_DAC_QUALITY_SANE_MINIMUM` | `16384U` | `8` | `64U` |
+
+#### Notes on buffer size :id=buffer-size
+
+By default, the buffer size attempts to keep to these constraints:
+
+* The interval between buffer refills can't be too short, since the microcontroller would then only be servicing buffer refills and would freeze up.
+* On the additive driver, the interval between buffer refills can't be too long, since matrix scanning would suffer lengthy pauses every so often, which would delay key presses or releases or lose some short taps altogether.
+* The interval between buffer refills is kept to a minimum, which allows notes to stop as soon as possible after they should.
+* For greater compatibility, the buffer size should be a power of 2.
+* The buffer size being too large causes resource exhaustion leading to build failures or freezing at runtime: RAM usage (on the additive driver) or flash usage (on the basic driver).
+
+You can lower the buffer size if you need a bit more space in your firmware, or raise it if your keyboard freezes up.
```c