qmk_firmware/features/audio.html

55 lines
138 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Audio | QMK Firmware</title>
<meta name="description" content="Documentation for QMK Firmware">
<meta name="generator" content="VitePress v1.1.3">
<link rel="preload stylesheet" href="/assets/style.No8zk9aC.css" as="style">
<script type="module" src="/assets/app.lJkKpnnX.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/theme.Onz3p0tR.js">
<link rel="modulepreload" href="/assets/chunks/framework.B9AX-CPi.js">
<link rel="modulepreload" href="/assets/features_audio.md.B4yww0JU.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar has-sidebar top" data-v-ae24b3ad data-v-ccf7ddec><div class="wrapper" data-v-ccf7ddec><div class="container" data-v-ccf7ddec><div class="title" data-v-ccf7ddec><div class="VPNavBarTitle has-sidebar" data-v-ccf7ddec data-v-ab179fa1><a class="title" href="/" data-v-ab179fa1><!--[--><!--]--><!--[--><!--[--><!--[--><img class="VPImage dark logo" src="/qmk-logo-dark.svg" alt data-v-8426fc1a><!--]--><!--[--><img class="VPImage light logo" src="/qmk-logo-light.svg" alt data-v-8426fc1a><!--]--><!--]--><!--]--><span data-v-ab179fa1>QMK Firmware</span><!--[--><!--]--></a></div></div><div class="content" data-v-ccf7ddec><div class="content-body" data-v-ccf7ddec><!--[--><!--]--><div class="VPNavBarSearch search" data-v-ccf7ddec><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-ccf7ddec data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Home</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-ccf7ddec data-v-e6aabb21><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-e6aabb21 data-v-d1f28634 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-d1f28634></span><span class="vpi-moon moon" data-v-d1f28634></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-ccf7ddec data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://reddit.com/r/olkb" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px"><path d="M 29 3 C 28.0625 3 27.164063 3.382813 26.5 4 C 25.835938 4.617188 25.363281 5.433594 25 6.40625 C 24.355469 8.140625 24.085938 10.394531 24.03125 13.03125 C 19.234375 13.179688 14.820313 14.421875 11.28125 16.46875 C 10.214844 15.46875 8.855469 14.96875 7.5 14.96875 C 6.089844 14.96875 4.675781 15.511719 3.59375 16.59375 C 1.425781 18.761719 1.425781 22.238281 3.59375 24.40625 L 3.84375 24.65625 C 3.3125 26.035156 3 27.488281 3 29 C 3 33.527344 5.566406 37.585938 9.5625 40.4375 C 13.558594 43.289063 19.007813 45 25 45 C 30.992188 45 36.441406 43.289063 40.4375 40.4375 C 44.433594 37.585938 47 33.527344 47 29 C 47 27.488281 46.6875 26.035156 46.15625 24.65625 L 46.40625 24.40625 C 48.574219 22.238281 48.574219 18.761719 46.40625 16.59375 C 45.324219 15.511719 43.910156 14.96875 42.5 14.96875 C 41.144531 14.96875 39.785156 15.46875 38.71875 16.46875 C 35.195313 14.433594 30.800781 13.191406 26.03125 13.03125 C 26.09375 10.546875 26.363281 8.46875 26.875 7.09375 C 27.164063 6.316406 27.527344 5.757813 27.875 5.4375 C 28.222656 5.117188 28.539063 5 29 5 C 29.460938 5 29.683594 5.125 30.03125 5.40625 C 30.378906 5.6875 30.785156 6.148438 31.3125 6.6875 C 32.253906 7.652344 33.695313 8.714844 36.09375 8.9375 C 36.539063 11.238281 38.574219 13 41 13 C 43.75 13 46 10.75 46 8 C 46 5.25 43.75 3 41 3 C 38.605469 3 36.574219 4.710938 36.09375 6.96875 C 34.3125 6.796875 33.527344 6.109375 32.75 5.3125 C 32.300781 4.851563 31.886719 4
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> AUDIO_PIN_ALT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> A4</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> AUDIO_PIN_ALT_AS_NEGATIVE</span></span></code></pre></div><h3 id="dac-additive" tabindex="-1">DAC (additive) <a class="header-anchor" href="#dac-additive" aria-label="Permalink to &quot;DAC (additive)&quot;"></a></h3><p>Another option, besides dac_basic (which produces sound through a square-wave), is to use the DAC to do additive wave synthesis. With a number of predefined wave-forms or by providing your own implementation to generate samples on the fly. To use this feature set <code>AUDIO_DRIVER = dac_additive</code> in your <code>rules.mk</code>, and select in <code>config.h</code> EITHER <code>#define AUDIO_PIN A4</code> or <code>#define AUDIO_PIN A5</code>.</p><p>The used waveform <em>defaults</em> to sine, but others can be selected by adding one of the following defines to <code>config.h</code>:</p><ul><li><code>#define AUDIO_DAC_SAMPLE_WAVEFORM_SINE</code></li><li><code>#define AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE</code></li><li><code>#define AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID</code></li><li><code>#define AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE</code></li></ul><p>Should you rather choose to generate and use your own sample-table with the DAC unit, implement <code>uint16_t dac_value_generate(void)</code> with your keyboard - for an example implementation see keyboards/planck/keymaps/synth_sample or keyboards/planck/keymaps/synth_wavetable</p><h3 id="pwm-software" tabindex="-1">PWM (software) <a class="header-anchor" href="#pwm-software" aria-label="Permalink to &quot;PWM (software)&quot;"></a></h3><p>if the DAC pins are unavailable (or the MCU has no usable DAC at all, like STM32F1xx); PWM can be an alternative. Note that there is currently only one speaker/pin supported.</p><p>set in <code>rules.mk</code>:</p><p><code>AUDIO_DRIVER = pwm_software</code> and in <code>config.h</code>: <code>#define AUDIO_PIN C13</code> (can be any pin) to have the selected pin output a pwm signal, generated from a timer callback which toggles the pin in software.</p><h4 id="wiring-2" tabindex="-1">Wiring <a class="header-anchor" href="#wiring-2" aria-label="Permalink to &quot;Wiring&quot;"></a></h4><p>the usual piezo wiring: red goes to the selected AUDIO_PIN, black goes to ground.</p><p>OR if you can chose to drive one piezo with two pins, for example <code>#define AUDIO_PIN B1</code>, <code>#define AUDIO_PIN_ALT B2</code> in <code>config.h</code>, with <code>#define AUDIO_PIN_ALT_AS_NEGATIVE</code> - then the red lead could go to B1, the black to B2.</p><h3 id="pwm-hardware" tabindex="-1">PWM (hardware) <a class="header-anchor" href="#pwm-hardware" aria-label="Permalink to &quot;PWM (hardware)&quot;"></a></h3><p>STM32F1xx have to fall back to using PWM, but can do so in hardware; but again on currently only one speaker/pin.</p><p><code>AUDIO_DRIVER = pwm_hardware</code> in <code>rules.mk</code>, and in <code>config.h</code>: <code>#define AUDIO_PIN A8</code><code>#define AUDIO_PWM_DRIVER PWMD1</code><code>#define AUDIO_PWM_CHANNEL 1</code> (as well as <code>#define AUDIO_PWM_PAL_MODE 42</code> if you are on STM32F2 or larger) which will use Timer 1 to directly drive pin PA8 through the PWM hardware (TIM1_CH1 = PA8). Should you want to use the pwm-hardware on another pin and timer - be ready to dig into the STM32 data-sheet to pick the right TIMx_CHy and pin-alternate function.</p><h2 id="tone-multiplexing" tabindex="-1">Tone Multiplexing <a class="header-anchor" href="#tone-multiplexing" aria-label="Permalink to &quot;Tone Multiplexing&quot;"></a></h2><p>Since most drivers can only render one tone per speaker at a time (with the one exception: arm dac-additive) there also exists a &quot;workaround-feature&quot; that does time-slicing/multiplexing - which does what the name implies: cycle through a set of active tones (e.g. when playing chords in Music Mode) at a given rate, and put one tone at a time out through the one/few speakers that are available.</p><p>To enable this fe
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 10</span></span></code></pre></div><p>The audio core offers interface functions to get/set/change the tone multiplexing rate from within <code>keymap.c</code>.</p><h2 id="songs" tabindex="-1">Songs <a class="header-anchor" href="#songs" aria-label="Permalink to &quot;Songs&quot;"></a></h2><p>There&#39;s a couple of different sounds that will automatically be enabled without any other configuration:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span>STARTUP_SONG // plays when the keyboard starts up (audio.c)</span></span>
<span class="line"><span>GOODBYE_SONG // plays when you press the QK_BOOT key (quantum.c)</span></span>
<span class="line"><span>AG_NORM_SONG // plays when you press AG_NORM (quantum.c)</span></span>
<span class="line"><span>AG_SWAP_SONG // plays when you press AG_SWAP (quantum.c)</span></span>
<span class="line"><span>CG_NORM_SONG // plays when you press CG_NORM (quantum.c)</span></span>
<span class="line"><span>CG_SWAP_SONG // plays when you press CG_SWAP (quantum.c)</span></span>
<span class="line"><span>MUSIC_ON_SONG // plays when music mode is activated (process_music.c)</span></span>
<span class="line"><span>MUSIC_OFF_SONG // plays when music mode is deactivated (process_music.c)</span></span>
<span class="line"><span>CHROMATIC_SONG // plays when the chromatic music mode is selected (process_music.c)</span></span>
<span class="line"><span>GUITAR_SONG // plays when the guitar music mode is selected (process_music.c)</span></span>
<span class="line"><span>VIOLIN_SONG // plays when the violin music mode is selected (process_music.c)</span></span>
<span class="line"><span>MAJOR_SONG // plays when the major music mode is selected (process_music.c)</span></span></code></pre></div><p>You can override the default songs by doing something like this in your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#ifdef</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> AUDIO_ENABLE</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"># define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> STARTUP_SONG</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SONG</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(STARTUP_SOUND)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#endif</span></span></code></pre></div><p>A full list of sounds can be found in <a href="https://github.com/qmk/qmk_firmware/blob/master/quantum/audio/song_list.h" target="_blank" rel="noreferrer">quantum/audio/song_list.h</a> - feel free to add your own to this list! All available notes can be seen in <a href="https://github.com/qmk/qmk_firmware/blob/master/quantum/audio/musical_notes.h" target="_blank" rel="noreferrer">quantum/audio/musical_notes.h</a>.</p><p>Additionally, if you with to maintain your own list of songs (such as ones that may be copyrighted) and not have them added to the repo, you can create a <code>user_song_list.h</code> file and place it in your keymap (or userspace) folder. This file will be automatically included, it just needs to exist.</p><p>To play a custom sound at a particular time, you can define a song like this (near the top of the file):</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">float</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> my_song</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SONG</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(QWERTY_SOUND);</span></span></code></pre></div><p>And then play your song like this:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">PLAY_SONG</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(my_song);</span></span></code></pre></div><p>Alternatively, you can play it in a loop like this:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">PLAY_LOOP</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(my_song);</span></span></code></pre></div><p>It&#39;s advised that you wrap all audio features in <code>#ifdef AUDIO_ENABLE</code> / <code>#endif</code> to avoid causing problems when audio isn&#39;t built into the keyboard.</p><p>The available keycodes for audio are:</p><table><thead><tr><th>Key</th><th>Aliases</th><th>Description</th></tr></thead><tbody><tr><td><code>QK_AUDIO_ON</code></td><td><code>AU_ON</code></td><td>Turns on Audio Feature</td></tr><tr><td><code>QK_AUDIO_OFF</code></td><td><code>AU_OFF</code></td><td>Turns off Audio Feature</td></tr><tr><td><code>QK_AUDIO_TOGGLE</code></td><td><code>AU_TOGG</code></td><td>Toggles Audio state</td></tr></tbody></table><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>These keycodes turn all of the audio functionality on and off. Turning it off means that audio feedback, audio clicky, music mode, etc. are disabled, completely.</p></div><h2 id="audio-config" tabindex="-1">Audio Config <a class="header-anchor" href="#audio-config" aria-label="Permalink to &quot;Audio Config&quot;"></a></h2><table><thead><tr><th>Settings</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>AUDIO_PIN</code></td><td><em>Not defined</em></td><td>Configures the pin that the speaker is connected to.</td></tr><tr><td><code>AUDIO_PIN_ALT</code></td><td><em>Not defined</em></td><td>Configures the pin for a second speaker or second pin connected to one sp
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> audio_increase_tempo</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint8_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> tempo_change</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> audio_decrease_tempo</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint8_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> tempo_change</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><h2 id="arm-audio-volume" tabindex="-1">ARM Audio Volume <a class="header-anchor" href="#arm-audio-volume" aria-label="Permalink to &quot;ARM Audio Volume&quot;"></a></h2><p>For ARM devices, you can adjust the DAC sample values. If your board is too loud for you or your coworkers, you can set the max using <code>AUDIO_DAC_SAMPLE_MAX</code> in your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> AUDIO_DAC_SAMPLE_MAX</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 4095</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">U</span></span></code></pre></div><p>the DAC usually runs in 12Bit mode, hence a volume of 100% = 4095U</p><p>Note: this only adjusts the volume aka &#39;works&#39; if you stick to WAVEFORM_SQUARE, since its samples are generated on the fly - any other waveform uses a hardcoded/precomputed sample-buffer.</p><h2 id="voices" tabindex="-1">Voices <a class="header-anchor" href="#voices" aria-label="Permalink to &quot;Voices&quot;"></a></h2><p>Aka &quot;audio effects&quot;, different ones can be enabled by setting in <code>config.h</code> these defines: <code>#define AUDIO_VOICES</code> to enable the feature, and <code>#define AUDIO_VOICE_DEFAULT something</code> to select a specific effect for details see quantum/audio/voices.h and .c</p><p>Keycodes available:</p><table><thead><tr><th>Key</th><th>Aliases</th><th>Description</th></tr></thead><tbody><tr><td><code>QK_AUDIO_VOICE_NEXT</code></td><td><code>AU_NEXT</code></td><td>Cycles through the audio voices</td></tr><tr><td><code>QK_AUDIO_VOICE_PREVIOUS</code></td><td><code>AU_PREV</code></td><td>Cycles through the audio voices in reverse</td></tr></tbody></table><h2 id="music-mode" tabindex="-1">Music Mode <a class="header-anchor" href="#music-mode" aria-label="Permalink to &quot;Music Mode&quot;"></a></h2><p>The music mode maps your columns to a chromatic scale, and your rows to octaves. This works best with ortholinear keyboards, but can be made to work with others. All keycodes less than <code>0xFF</code> get blocked, so you won&#39;t type while playing notes - if you have special keys/mods, those will still work. A work-around for this is to jump to a different layer with KC_NOs before (or after) enabling music mode.</p><p>Recording is experimental due to some memory issues - if you experience some weird behavior, unplugging/replugging your keyboard will fix things.</p><p>Keycodes available:</p><table><thead><tr><th>Key</th><th>Aliases</th><th>Description</th></tr></thead><tbody><tr><td><code>QK_MUSIC_ON</code></td><td><code>MU_ON</code></td><td>Turns on Music Mode</td></tr><tr><td><code>QK_MUSIC_OFF</code></td><td><code>MU_OFF</code></td><td>Turns off Music Mode</td></tr><tr><td><code>QK_MUSIC_TOGGLE</code></td><td><code>MU_TOGG</code></td><td>Toggles Music Mode</td></tr><tr><td><code>QK_MUSIC_MODE_NEXT</code></td><td><code>MU_NEXT</code></td><td>Cycles through the music modes</td></tr></tbody></table><p>Available Modes:</p><ul><li><code>CHROMATIC_MODE</code> - Chromatic scale, row changes the octave</li><li><code>GUITAR_MODE</code> - Chromatic scale, but the row changes the string (+5 st)</li><li><code>VIOLIN_MODE</code> - Chromatic scale, but the row changes the string (+7 st)</li><li><code>MAJOR_MODE</code> - Major scale</li></ul><p
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> RAISE:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> LOWER:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> false</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span></code></pre></div><p>Things that return false are not part of the mask, and are always processed.</p><h3 id="music-map" tabindex="-1">Music Map <a class="header-anchor" href="#music-map" aria-label="Permalink to &quot;Music Map&quot;"></a></h3><p>By default, the Music Mode uses the columns and row to determine the scale for the keys. For a board that uses a rectangular matrix that matches the keyboard layout, this is just fine. However, for boards that use a more complicated matrix (such as the Planck Rev6, or many split keyboards) this would result in a very skewed experience.</p><p>However, the Music Map option allows you to remap the scaling for the music mode, so it fits the layout, and is more natural.</p><p>To enable this feature, add <code>#define MUSIC_MAP</code> to your <code>config.h</code> file, and then you will want to add a <code>uint8_t music_map</code> to your keyboard&#39;s <code>c</code> file, or your <code>keymap.c</code>.</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> uint8_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> music_map</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[MATRIX_ROWS][MATRIX_COLS] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> LAYOUT_ortho_4x12</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 36</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">37</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">38</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">39</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">40</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">41</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">42</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">43</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">44</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">45</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">46</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">47</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 24</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">25</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">26</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">27</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">28</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">29</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">30</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">31</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">32</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">33</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">34</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">35</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 12</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">13</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">14</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">15</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">16</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">17</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">18</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">19</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">20</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">21</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">22</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">23</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">7</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">9</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">11</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><p>You will want to use whichever <code>LAYOUT</code> macro that your keyboard uses here. This maps it to the correct key location. Start in the bottom left of the keyboard layout, and move to the right, and then upwards. Fill in all the entries until you have a complete matrix.</p><p>You can look at the <a href="https://github.com/qmk/qmk_firmware/blob/e9ace1487887c1f8b4a7e8e6d87c322988bec9ce/keyboards/planck/planck.c#L24-L29" target="_blank" rel="noreferrer">Planck Keyboard</a> as an example of how to implement this.</p><h2 id="audio-click" tabindex="-1">Audio Click <a class="header-anchor" href="#audio-click" aria-label="Permalink to &quot;Audio Click&quot;"></a></h2><p>This adds a click sound each time you hit a button, to simulate click sounds from the keyboard. And the sounds are slightly different for each keypress, so it doesn&#39;t sound like a single long note, if you type rapidly.</p><p>Keycodes available:</p><table><thead><tr><th>Key</th><th>Aliases</th><th>Description</th></tr></thead><tbody><tr><td><code>QK_AUDIO_CLICKY_TOGGLE</code></td><td><code>CK_TOGG</code></td><td>Toggles Audio clicky mode</td></tr><tr><td><code>QK_AUDIO_CLICKY_ON</code></td><td><code>CK_ON</code></td><td>Turns on Audio clicky mode</td></tr><tr><td><code>QK_AUDIO_CLICKY_OFF</code></td><td><code>CK_OFF</code></td><td>Turns on Audio clicky mode</td></tr><tr><td><code>QK_AUDIO_CLICKY_UP</code></td><td><code>CK_UP</code></td><td>Increases frequency of the clicks</td></tr><tr><td><code>QK_AUDIO_CLICKY_DOWN</code></td><td><code>CK_DOWN</code></td><td>Decreases frequency of the clicks</td></tr><tr><td><code>QK_AUDIO_CLICKY_RESET</code></td><td><code>CK_RST</code></td><td>Resets frequency to default</td></tr></tbody></table><p>The feature is disabled by default, to save space. To enable it, add this to your <code>config.h</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> AUDIO_CLICKY</span></span></code></pre></div><p>You can configure the default, min and max frequencies, the stepping and built in randomness by defining these values:</p><table><thead><tr><th>Option</th><th>Default Value</th><th>Description</th></tr></thead><tbody><tr><td><code>AUDIO_CLICKY_FREQ_DEFAULT</code></td><td>440.0f</td><td>Sets the default/starting audio frequency for the clicky sounds.</td></tr><tr><td><code>AUDIO_CLICKY_FREQ_MIN</code></td><td>65.0f</td><td>Sets the lowest frequency (under 60f are a bit buggy).</td></tr><tr><td><code>AUDIO_CLICKY_FREQ_MAX</code></td><td>1500.0f</td><td>Sets the highest frequency. Too high may result in coworkers attacking you.</td></tr><tr><td><code>AUDIO_CLICKY_FREQ_FACTOR</code></td><td>1.18921f</td><td>Sets the stepping of UP/DOWN key codes. This is a multiplicative factor. The default steps the frequency up/down by a musical minor third.</td></tr><tr><td><code>AUDIO_CLICKY_FREQ_RANDOMNESS</code></td><td>0.05f</td><td>Sets a factor of randomness for the clicks, Setting this to <code>0f</code> will make each click identical, and <code>1.0f</code> will make this sound much like the 90&#39;s computer screen scrolling/typing effect.</td></tr><tr><td><code>AUDIO_CLICKY_DELAY_DURATION</code></td><td>1</td><td>An integer note duration where 1 is 1/16th of the tempo, or a sixty-fourth note (see <code>quantum/audio/musical_notes.h</code> for implementation details). The main clicky effect will be delayed by this duration. Adjusting this to values around 6-12 will help compensate for loud switches.</td></tr></tbody></table><h2 id="midi-functionality" tabindex="-1">MIDI Functionality <a class="header-anchor" href="#midi-functionality" aria-label="Permalink to &quot;MIDI Functionality&quot;"></a></h2><p>See <a href="./midi">MIDI<
<script>window.__VP_HASH_MAP__=JSON.parse("{\"changelog_20190830.md\":\"6XixyP8L\",\"changelog_20200229.md\":\"BmeRJene\",\"changelog_20200530.md\":\"q1Nx4Bsf\",\"changelog_20200829.md\":\"DPwMxUVb\",\"changelog_20201128.md\":\"cyEKi6md\",\"changelog_20210227.md\":\"D-qZNAtE\",\"changelog_20210529.md\":\"CMCDBsST\",\"changelog_20210828.md\":\"Bz_Cqhkz\",\"changelog_20211127.md\":\"CKqQnO6y\",\"changelog_20220226.md\":\"CyVoLONs\",\"changelog_20220528.md\":\"CihUA7fi\",\"changelog_20220827.md\":\"Df1nzx8O\",\"changelog_20221126.md\":\"Coqj0YNT\",\"changelog_20230226.md\":\"kWJusvXj\",\"changelog_20230528.md\":\"BQOXA7rR\",\"changelog_20230827.md\":\"CysqTdAP\",\"changelog_20231126.md\":\"D6JlaCSH\",\"changelog_20240225.md\":\"DmbHo-aA\",\"changelog_20240526.md\":\"ChevS3SM\",\"changelog_20240825.md\":\"Bim1xI09\",\"capabilities.md\":\"C8eGasTO\",\"capabilities_inc.md\":\"Pt72L4b9\",\"api_development_environment.md\":\"Co1Lkuhl\",\"api_development_overview.md\":\"iUK6GGbG\",\"api_docs.md\":\"DrPevC-R\",\"api_overview.md\":\"B3sDKDJg\",\"arm_debugging.md\":\"BiRXU6nl\",\"breaking_changes.md\":\"BIpM1JDF\",\"breaking_changes_history.md\":\"B_yw4mvF\",\"breaking_changes_instructions.md\":\"DUu8Tdu8\",\"chibios_upgrade_instructions.md\":\"BkS-xCQh\",\"cli.md\":\"Ct8-gh67\",\"cli_commands.md\":\"CijNW8-t\",\"cli_configuration.md\":\"DT4O5Qrb\",\"cli_development.md\":\"C1RMbrqW\",\"cli_tab_complete.md\":\"CT9NBEM3\",\"coding_conventions_c.md\":\"Bi7EH0Zk\",\"coding_conventions_python.md\":\"C45woQX8\",\"compatible_microcontrollers.md\":\"C3RSssel\",\"config_options.md\":\"BroSRrlf\",\"configurator_architecture.md\":\"ClRUnOlV\",\"configurator_default_keymaps.md\":\"Btb4Y_-z\",\"configurator_step_by_step.md\":\"Bhhrr-KZ\",\"configurator_troubleshooting.md\":\"CyTH_MO_\",\"contributing.md\":\"Z2KawZJM\",\"custom_matrix.md\":\"C5Wxxs18\",\"custom_quantum_functions.md\":\"CchHkQ2j\",\"data_driven_config.md\":\"CemhrDnh\",\"documentation_best_practices.md\":\"D_2t5SCy\",\"documentation_templates.md\":\"DNSTMFQT\",\"driver_installation_zadig.md\":\"CzMMyItw\",\"drivers_adc.md\":\"CdK8AtnR\",\"drivers_apa102.md\":\"D1i8N4Yl\",\"drivers_audio.md\":\"FGaarcoq\",\"drivers_aw20216s.md\":\"DFO5qaXQ\",\"drivers_eeprom.md\":\"DjbSpQAl\",\"drivers_flash.md\":\"TpToebZV\",\"drivers_gpio.md\":\"_T-XR1i8\",\"drivers_i2c.md\":\"CZ3yUqUc\",\"drivers_is31fl3218.md\":\"Bw4QYvxz\",\"drivers_is31fl3236.md\":\"kw_4WomB\",\"drivers_is31fl3729.md\":\"B05FYaEa\",\"drivers_is31fl3731.md\":\"EbaJGcwl\",\"drivers_is31fl3733.md\":\"CxiWN3qf\",\"drivers_is31fl3736.md\":\"CNsB35Bn\",\"drivers_is31fl3737.md\":\"dFrKnsKN\",\"drivers_is31fl3741.md\":\"DCbdJxE4\",\"drivers_is31fl3742a.md\":\"Bh9Q6Zt4\",\"drivers_is31fl3743a.md\":\"W_EODxfi\",\"drivers_is31fl3745.md\":\"Dd_riPpV\",\"drivers_is31fl3746a.md\":\"DaWS07Rz\",\"drivers_serial.md\":\"B9cdhvZY\",\"drivers_snled27351.md\":\"C202OTO_\",\"drivers_spi.md\":\"KJwJ1bDT\",\"drivers_uart.md\":\"D5bf2Ez7\",\"drivers_ws2812.md\":\"_cnUpPJK\",\"easy_maker.md\":\"B1e0p_KP\",\"faq_build.md\":\"CdMV-bmr\",\"faq_debug.md\":\"fagccKfw\",\"faq_general.md\":\"BS8dICfT\",\"faq_keymap.md\":\"CmJjc7AB\",\"faq_misc.md\":\"pugCgT23\",\"feature_advanced_keycodes.md\":\"Dc44pi1G\",\"feature_converters.md\":\"nbsy9vmL\",\"feature_debounce_type.md\":\"BcX3faCS\",\"feature_eeprom.md\":\"CrKIb9by\",\"feature_layers.md\":\"mZMmAI4u\",\"feature_layouts.md\":\"CC3GUG9e\",\"feature_macros.md\":\"bo5m05vP\",\"feature_userspace.md\":\"DzgyEZm9\",\"features_audio.md\":\"B4yww0JU\",\"features_auto_shift.md\":\"gbN4UbG7\",\"features_autocorrect.md\":\"BgqtSxc-\",\"features_backlight.md\":\"BtYuf8hb\",\"features_bluetooth.md\":\"DB3PFlcy\",\"features_bootmagic.md\":\"DBdRU139\",\"features_caps_word.md\":\"Cz8-Ua5R\",\"features_combo.md\":\"nQwtfYKJ\",\"features_command.md\":\"DDU6fJSP\",\"features_digitizer.md\":\"qNC7cDmj\",\"features_dip_switch.md\":\"DQ7jEipz\",\"features_dynamic_macros.md\":\"CmY3EYfK\",\"features_encoders.md\":\"Cw1N3hGV\",\"features_grave_esc.md\":\"RGWiZPw2\",\"features_haptic_feedback.md\":\"gCZCxZph\",\"features_hd4
</body>
</html>