c80e5f9f8868ccaa8cb990be6f4da3f1011c2b78

Author
Drashna Jaelre <drashna@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

Audio system overhaul (#11820)

* Redo Arm DAC implementation for additive, wavetable synthesis, sample playback

changes by Jack Humbert on an implementation for DAC audio on arm/chibios platforms
this commits bundles the changes from the arm-dac-work branch focused on audio/audio_arm.* into one commit (leaving out the test-keyboard)

f52faeb5d (origin/arm-dac-work) add sample and wavetable examples, parsers for both
  -> only the changes on audio_arm_.*, the keyboard related parts are split off to a separate commit
bfe468ef1 start morphing wavetable
474d100b5 refined a bit
208bee10f play_notes working
3e6478b0b start in-place documentation of dac settings
3e1826a33 fixed blip (rounding error), other waves, added key selection (left/right)
73853d651 5 voices at 44.1khz
dfb401b95 limit voices to working number
9632b3379 configuration for the ez
6241f3f3b notes working in a new way

* Redo Arm DAC implementation for additive, wavetable synthesis, sample playback

changes by Jack Humbert on an implementation for DAC audio on arm/chibios platforms

this commit splits off the plank example keymap from commit
    f52faeb5d (origin/arm-dac-work) add sample and wavetable examples, parsers for both

* refactoring: rename audio_ to reflect their supported hardware-platform and audio-generation method: avr vs arm, and pwm vs dac

* refactoring: deducplicate ISR code to update the pwm duty-cycle and period in the avr-pwm-implementation

pulls three copies of the same code into one function
which should improve readability and maintainability :-)

* refactoring: move common code of arm and avr implementation into a separate/new file

* refactoring: audio_avr_pwm, renaming defines to decouple them from actually used timers, registers and ISRs

* refactoring: audio_avr_pwm - replacing function defines with plain register defines

aligns better with other existing qmk code (and the new audio_arm_pwm) doing similar pwm thing

* add audio-arm-pwm

since not all STM32 have a DAC onboard (STM32F2xx and STM32F3xx), pwm-audio is an alternative (STM32F1xx)
this code works on a "BluePill" clone, with an STM32F103C8B

* clang-format changes on quantum/audio/* only

* audio_arm_dac: stopping the notes caused screeching when using the DAC audio paths

* audio_arm_pwm: use pushpull on the pin; so that a piezzo can be hooked up direclty without additional components (opendrain would require an external pullup)

* refactoring: remove unused file from/for atmel-avr chips

* refactoring: remove unused (avr) wavetable file

* audio_arm_dac: adapt dac_end callback to changed chibios DAC api

the previous chibios (17.6.0) passed along a pointer into the buffer plus a sample_count (which are/already where included in the DACDrivre object) - the current chibios (19.1.0) only passes the driver object.
this patch ports more or less exactly what the previous chibios ISR code did: either have the user-callback work the first or second half of the buffer (dacsample_t pointer, with half the DAC_BUFFER_SIZE samples) by adjusting the pointer and sample count

* audio-arm-dac: show a compile-warning on undefined audio-pins

Co-Authored-By: Drashna Jaelre <drashna@live.com>

* audio_arm_dac: switch from exemplary wavetable generation to sine only

sine+triangle+squrare is exemplary, and not realy fit for "production" use
'stairs' are usefull for debugging (hardware, with an oscilloscope)

* audio_arm_dac: enable output buffers in the STM32

to drive external loads without any additional ciruitry - external opamps and such

* audio: prevent out-of-bounds array access

* audio_arm_dac: add output-frequency correcting factor

* audio_arm_pwm: get both the alternate-function and pm-callback variants back into working condition

and do some code-cleanup, refine documentation, ...

* audio_arm_pwm: increase pwm frequency for "higher fidelity"

on the previous .frequency=100000 higher frequency musical notes came out wrong
(frequency measured on a Tektronix TDS2014B)
note | freq | arm-pwm
C2 | 65.4 | 65.491
C5 | 523.25 | 523.93
C6 | 1046.5 | 1053.38
C7 | 2093 | 2129
C8 | 4186 | 4350.91

with .frequency = 500000
C8 | 4186 | 4204.6

* audio refactoring: remove unused variables

* audio_arm_dac: calibrate note tempo: with a tempo of 60beats-per-second a whole-note should last for exactly one second

* audio: allow feature selection in rules.mk

so the user can switch the audio driver between DAC and PWM on STM32 boards which support both (STM32F2 and up)
or select the "pin alternate" pwm mode, for example on STM32F103

* audio-refactoring: move codeblocks in audio.[ch] into more coherent groups

and add some inline documentation

* audio-refactoring: cleanup and streamline common code between audio_arm_[dac|pwm]

untangeling the relation between audio.c and the two drivers
and adding more documenting comments :-)

* audio_avr_pwm: getting it back into working condition, and cleanup+refactor

* audio-refactoring: documentation and typo fixes

Co-Authored-By: Nick Brassel <nick@tzarc.org>

* audio-refactoring: cleanup defines, inludes and remove debug-prints

* audio_chibios_dac: define&use a minimal sampling rate, based on the available tone-range

to ease up on the cpu-load, while still rendering the higher notes/tones sufficiently
also reenable the lower tones, since with the new implementation there is no evidence of them still beeing 'bugged'

* audio-refactoring: one common AUDIO_MAX_VOICES define for all audio-drivers

* audio-chibios-pwm: pwm-pin-allternate: make the the timer, timer-channel and alternate function user-#definable

* audio_chibios_dac: math.h has fmod for this

* Redo Arm DAC implementation for additive, wavetable synthesis, sample playback

update Jack Humberts dac-example keymaps for the slight changes in the audio-dac interface

* audio-refactoring: use a common AUDIO_PIN configuration switch instead of defines

have the user select a pin by configuration in rules.mk instead of a define in config.h
has the advantage of beeing in a common form/pattern across all audio-driver implementations

* audio-refactoring: switch backlight_avr.c to the new AUDIO_PIN defines

* audio-common: have advance_note return a boolean if the note changed, to the next one in the melody beeing played

* audio-chibios-pwm: fix issue with ~130ms silence between note/frequency changes while playing a SONG

through trial,error and a scope/logic analyzer figured out Chibios-PWMDriver (at least in the current version) misbehaves if the initial period is set to zero (or one; two seems to work); when thats the case subsequent calls to 'pwmChhangePeriod' + pwmEnableChannel took ~135ms of silence, before the PWM continued with the new frequency...

* audio-refactoring: get 'play_note' working again

with a limited number of available voices (say AUDIO_VOICES_MAX=1) allow new frequencies to be played, by discarding the oldest one in the 'frequencies' queue

* audio: set the fallback driver to DAC for chibios and PWM for all others (==avr at the moment)

* audio-refactoring: moore documentation

and some cleanup

* audio-avr-pwm: no fallback on unset AUDIO_PIN

this seems to be the expected behaviour by some keyboards (looking at ckeys/handwire_101:default) which otherwise fail to build because the firmware-image ends up beeing too large for the atmega... so we fail silently instead to keep travis happy

* audio-refactoring: untangling terminology: voice->tone

the code actually was working on tones (combination of pitch/frequency, duration, timbre, intensity/volume) and not voices (characteristic sound of an instrument; think piano vs guitar, which can be played together, each having its own "track" = voice on a music sheet)

* audio-pwm: allow freq=0 aka a pause/rest in a SONG

continue processing, but do not enable pwm units, since freq=0 wouldn't produce any sound anyway (and lead to division by zero on that occasion)

* audio-refactoring: audio_advance_note -> audio_advance_state

since it does not only affect 'one note', but the internally kept state as a whole

* audio-refactoring: untangling terminology: polyphony

the feature om the "inherited" avr code has little to do with polyphony (see wikipedia), but is more a time-multiplexing feature, to work around hardware limitations - like only having one pwm channel, that could on its own only reproduce one voice/instrument at a time

* audio-chibios-dac: add zero-crossing feature

have tones only change/stop when the waveform approaches zero - to avoid audible clicks
note that this also requires the samples to start at zero, since the internally kept index into the samples is reset to zero too

* audio-refactoring: feature: time-multiplexing of tones on a single output channel

this feature was in the original avr-pwm implementation misnomed as "polyphony"
with polyphony_rate and so on; did the same thing though: time-multiplexing multiple active notes so that a single output channel could reproduce more than one note at a time (which is not the same as a polyphony - see wikipedia :-) )

* audio-avr-pwm: get music-mode working (again) on AVRs

with both pwm channels, or either one of the two :-)
play_notes worked already - but music_mode uses play_note

* audio-refactoring: split define MAX_SIMULTANEOUS_TONES -> TONE_STACKSIZE

since the two cases are independant from one another, the hardware might impose limitations on the number of simultaneously reproducable tones, but the audio state should be able to track an unrelated number of notes recently started by play_note

* audio-arm-dac: per define selectable sample-luts

plus generation script in ./util

* audio-refactoring: heh, avr has a MIN...

* audio-refactoring: add basic dac audio-driver based on the current/master implementation

whereas current=d96380e65496912e0f68e6531565f4b45efd1623
which is the state of things before this whole audio-refactoring branch

boiled down to interface with the refactored audio system = removing all
redundant state-managing and frequency calculation

* audio-refactoring: rename audio-drivers to driver_$PLATFORM_$DRIVER

* audio-arm-pwm: split the software/hardware implementations into separate files

which saves us partially from a 'define hell', with the tradeoff that now two somewhat similar chibios_pwm implementations have to be maintained

* audio-refactoring: update documentation

* audio-arm-dac: apply AUDIO_PIN defines to driver_chibios_dac_basic

* audio-arm-dac: dac_additive: stop the hardware when the last sample completed

the audio system calls for a driver_stop, which is delayed until the current sample conversion finishes

* audio-refactoring: make function-namespace consistent

- all (public) audio functions start with audio_
- also refactoring play*_notes/tones to play*_melody, to visually distance it a bit from play*_tone/_note

* audio-refactoring: consistent define namespace: DAC_ -> AUDIO_DAC_

* audio-arm-dac: update (inline) documentation regarding MAX for sample values

* audio-chibios-dac: remove zero-crossing feature

didn't quite work as intended anyway, and stopping the hardware on close-to-zero seems to be enought anyway

* audio-arm-dac: dac_basic: respect the configured sample-rate

* audio-arm-pwm: have 'note_timbre' influence the pwm-duty cycle

like it already does in the avr implementation

* audio-refactoring: get VIBRATO working (again)

with all drivers (verified with chibios_[dac|pwm])

* audio-arm-dac: zero-crossing feature (Mk II)

wait for the generated waveform to approach 'zero' before either turning off the output+timer or switching to the current set of active_tones

* audio-refactoring: re-add note-resting -> introduce short_rest inbetween

- introduce a short pause/rest between two notes of the same frequency, to separate them audibly
- also updating the refactoring comments

* audio-refactoring: cleanup refactoring remnants

remove the former avr-isr code block - since all its features are now refactored into the different parts of the current system

also updates the TODOS

* audio-refactoring: reserve negative numbers as unitialized frequencies

to allow the valid tone/frequency f=0Hz == rest/pause

* audio-refactoring: FIX: first note of melody was missing

the first note was missing because 'goto_next_note'=false overrode a state_change=true of the initial play_tone
and some code-indentations/cleanup of related parts

* audio-arm-dac: fix hardware init-click

due to wron .init= value

* audio-refactoring: new conveniance function: audio_play_click

which can be used to further refactor/remove fauxclicky (avr only) and/or the 'clicky' features

* audio-refactoring: clang-format on quantum/audio/*

* audio-avr-pwm: consecutive notes of the same frequency get a pause inserted inbetween by audio.c

* audio-refactoring: use milliseconds instead of seconds for 'click' parameters

clicks are supposed to be short, seconds make little sense

* audio-refactoring: use timer ticks instead of counters

local counters were used in the original (avr)ISR to advance an index into the lookup tables (for vibrato), and something similar was used for the tone-multiplexing feature
decoupling these from the (possibly irregular) calls to advance_state made sesne, since those counters/lookups need to be in relation to a wall-time anyway

* audio-refactoring: voices.c: drop 'envelope_index' counter in favour of timer ticks

* audio-refactoring: move vibrato and timbre related parts from audio.c to voices.c

also drops the now (globally) unused AUDIO_VIBRATO/AUDIO_ENABLE_VIBRATO defines

* audio.c: use system-ticks instead of counters the drivers have to take care of for the internal state posision

since there already is a system-tick with ms resolution, keeping count separatly with each driver implementation makes little sense; especially since they had to take special care to call audio_advance_state with the correct step/end parameters for the audio state to advance regularly and with the correct pace

* audio.c: stop notes after new ones have been started

avoids brief states of with no notes playing that would otherwise stop the hardware and might lead to clicks

* audio.c: bugfix: actually play a pause

instead of just idling/stopping which lead the pwm drivers to stop entirely...

* audio-arm-pwm: pwm-software: add inverted output

new define AUDIO_PIN_ALT_AS_NEGATIVE will generate an inverted signal on the alternate pin, which boosts the volume if a piezo is connected to both AUDIO_PIN and AUDIO_PIN_ALT

* audio-arm-dac: basic: handle piezo configured&wired to both audio pins

* audio-refactoring: docs: update for AUDIO_PIN_ALT_AS_NEGATIVE and piezo wiring

* audio.c: bugfix: use timer_elapsed32 instad of keeping timestamps

avoids running into issues when the uint32 of the timer overflows

* audio-refactoring: add 'pragma once' and remove deprecated NOTE_REST

* audio_arm_dac: basic: add missing bracket

* audio.c: fix delta calculation

was in the wrong place, needs to use the 'last_timestamp' before it was reset

* audio-refactoring: buildfix: wrong legacy macro for set_timbre

* audio.c: 16bit timerstamps suffice

* audio-refactoring: separate includes for AVR and chibios

* audio-refactoring: timbre: use uint8 instead of float

* audio-refactoring: duration: use uint16 for internal per-tone/note state

* audio-refactoring: tonemultiplexing: use uint16 instead of float

* audio-arm-dac: additive: set second pin output-low

used when a piezo is connected to AUDIO_PIN and AUDIO_PIN_ALT, with PIN_ALT_AS_NEGATIVE

* audio-refactoring: move AUDIO_PIN selection from rules.mk to config.h

to be consistent with how other features are handled in QMK

* audio-refactoring: buildfix: wrong legacy macro for set_tempo

* audio-arm-dac: additive: set second pin output-low -- FIXUP

* audio.c: do duration<>ms conversion in uint instead of float

on AVR, to save a couple of bytes in the firmware size

* audio-refactoring: cleanup eeprom defines/usage

for ARM, avr is handled automagically through the avr libc and common_features.mk

Co-Authored-By: Drashna Jaelre <drashna@live.com>

* audio.h: throw an error if OFF is larger than MAX

* audio-arm-dac: basic: actually stop the dac-conversion on a audio_driver_stop

to put the output pin in a known state == AUDIO_DAC_OFF_VALUE, instead of just leaving them where the last conversion was... with AUDIO_PIN_ALT_AS_NEGATIVE this meant one output was left HIGH while the other was left LOW

one CAVEAT: due to this change the opposing squarewave when using both A4 and A5 with AUDIO_PIN_ALT_AS_NEGATIVE
show extra pulses at the beginning/end on one of the outputs, the two waveforms are in sync otherwise.
the extra pusles probably matter little, since this is no high-fidelity sound generation :P

* audio-arm-dac: additive: move zero-crossing code out of dac_value_generate

which is/should be user-overridable == simple, and doing one thing: providing sample values
state-transitions necessary for the zero crossing are better handled in the surrounding loop in the dac_end callback

* audio-arm-dac: dac-additive: zero-crossing: ramping up or down

after a start trigger ramp up: generate values until zero=OFF_VALUE is reached, then continue normally
same in reverse for strop trigger: output values until zero is reached/crossed, then keep OFF_VALUE on the output

* audio-arm-dac: dac-additive: BUGFIX: return OFF_VALUE when a pause is playing

fixes a bug during SONG playback, which suddenly stopped when it encoutnered a pause

* audio-arm-dac: set a sensible default for AUDIO_DAC_VALUE_OFF

1/2 MAX was probably exemplary, can't think of  a setup where that would make sense :-P

* audio-arm-dac: update synth_sample/_wavetable for new pin-defines

* audio-arm-dac:  default for AUDIO_DAC_VALUE_OFF

turned out that zero or max are bad default choices:
when multiple tones are played (>>5) and released at the same time (!), due to the complex waveform never reaching 'zero' the output can take quite a while to reach zero, and hence the zero-crossing code only "releases" the output waaay to late

* audio-arm-dac: additive: use DAC for negative pin

instead of PAL, which only allows the pin to be configured as output; LOW or HIGH

* audio-arm-dac: more compile-time configuration checks

* audio-refactoring: typo fixed

* audio-refactoring: clang-format on quantum/audio/*

* audio-avr-pwm: add defines for B-pin as primary/only speaker

also updates documentation.

* audio-refactoring: update documentation with proton-c config.h example

* audio-refactoring: move glissando (TODO) to voices.c

refactored/saved from the original glissando implementation in then upstream-master:audio_avr.c

still needs some work though, as it is now the calculation *should* work, but the start-frequency needs to be tracked somewhere/somehow; not only during a SONG playback but also with user input?

* audio-refactoring: cleanup: one round of aspell -c

* audio-avr-pwm: back to AUDIO_PIN

since config_common.h expands them to plain integers, the AUDIO_PIN define can directly be compared to e.g. B5
so there is no need to deal with separate defines like AUDIO_PIN_B5

* audio-refactoring: add technical documentation audio_driver.md

which moves some in-code documentation there

* audio-arm-dac: move AUDIO_PIN checks into c-code

instead of doing everything with the preprocessor, since A4/A5 do not expand to simple integers, preprocessor int-comparison is not possible. but necessary to get a consistent configuration scheme going throughout the audio-code... solution: let c-code handle the different AUDIO_PIN configurations instead (and leave code/size optimizations to the compiler)

* audio-arm-dac: compile-fix: set AUDIO_PIN if unset

workaround to get the build going again, and be backwarts compatible to arm-keyboards which not yet set the AUDIO_PIN define. until the define is enforced through an '#error"

* audio-refactoring: document tone-multiplexing feature

* audio-refactoring: Apply suggestions from documentation review

Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>

* audio-refactoring: Update docs/audio_driver.md

* audio-refactoring: docs: fix markdown newlines

Terminating a line in Markdown with <space>-<space>-<linebreak> creates an HTML single-line break (<br>).

Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>

* audio-arm-dac: additive: fix AUDIO_PIN_ALT handling

* audio-arm-pwm: align define naming with other drivers

Co-authored-by: Joel Challis <git@zvecr.com>

* audio-refactoring: set detault tempo to 120

and add documentation for the override

* audio-refactoring: update backlight define checks to new AUDIO_PIN names

* audio-refactoring: reworking PWM related defines

to be more consistent with other QMK code

Co-authored-by: Joel Challis <git@zvecr.com>

* audio-arm: have the state-update-timer user configurable

defaulting to GPTD6 or GPTD8 for stm32f2+ (=proton-c)
stm32f1 might need to set this to GPTD4, since 6 and 8 are not available

* audio-refactoring: PLAY_NOTE_ARRAY was already removed in master

* Add prototype for startup

* Update chibiOS dac basic to disable pins on stop

* Add defaults for Proton C

* avoid hanging audio if note is completely missed

* Don't redefine pins if they're already defined

* Define A4 and A5 for CTPC support

* Add license headers to keymap files

* Remove figlet? comments

* Add DAC config to audio driver docs

* Apply suggestions from code review

Co-authored-by: Jack Humbert <jack.humb@gmail.com>

* Add license header to py files

* correct license header

* Add JohSchneider's name to modified files

AKA credit where credit's due

* Set executable permission and change interpeter

* Add 'wave' to pip requirements

* Improve documentation

* Add some settings I missed

* Strip AUDIO_DRIVER to parse the name correctly

* fix depreciated

* Update util/audio_generate_dac_lut.py

Co-authored-by: Jack Humbert <jack.humb@gmail.com>

* Fix type in clueboard config

* Apply suggestions from tzarc

Co-authored-by: Nick Brassel <nick@tzarc.org>

Co-authored-by: Johannes <you@example.com>
Co-authored-by: JohSchneider <JohSchneider@googlemail.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Joshua Diamond <josh@windowoffire.com>
Co-authored-by: Jack Humbert <jack.humb@gmail.com>

Diff

This diff is truncated to protect this page.

  1diff --git a/common_features.mk b/common_features.mk
  2index 8338ce4080225a00d170b1f1a3dd91b9290d2ccf..6463efb8ba412c8ab893032b837e565762db8ea6 100644
  3--- a/common_features.mk
  4+++ b/common_features.mk
  5@@ -42,12 +42,31 @@ ifeq ($(strip $(COMMAND_ENABLE)), yes)
  6     OPT_DEFS += -DCOMMAND_ENABLE
  7 endif
  8 
  9+AUDIO_ENABLE ?= no
 10 ifeq ($(strip $(AUDIO_ENABLE)), yes)
 11+    ifeq ($(PLATFORM),CHIBIOS)
 12+        AUDIO_DRIVER ?= dac_basic
 13+        ifeq ($(strip $(AUDIO_DRIVER)), dac_basic)
 14+            OPT_DEFS += -DAUDIO_DRIVER_DAC
 15+        else ifeq ($(strip $(AUDIO_DRIVER)), dac_additive)
 16+            OPT_DEFS += -DAUDIO_DRIVER_DAC
 17+        ## stm32f2 and above have a usable DAC unit, f1 do not, and need to use pwm instead
 18+        else ifeq ($(strip $(AUDIO_DRIVER)), pwm_software)
 19+            OPT_DEFS += -DAUDIO_DRIVER_PWM
 20+        else ifeq ($(strip $(AUDIO_DRIVER)), pwm_hardware)
 21+            OPT_DEFS += -DAUDIO_DRIVER_PWM
 22+        endif
 23+    else
 24+        # fallback for all other platforms is pwm
 25+        AUDIO_DRIVER ?= pwm_hardware
 26+        OPT_DEFS += -DAUDIO_DRIVER_PWM
 27+    endif
 28     OPT_DEFS += -DAUDIO_ENABLE
 29     MUSIC_ENABLE = yes
 30     SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
 31     SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
 32-    SRC += $(QUANTUM_DIR)/audio/audio_$(PLATFORM_KEY).c
 33+    SRC += $(QUANTUM_DIR)/audio/audio.c ## common audio code, hardware agnostic
 34+    SRC += $(QUANTUM_DIR)/audio/driver_$(PLATFORM_KEY)_$(strip $(AUDIO_DRIVER)).c
 35     SRC += $(QUANTUM_DIR)/audio/voices.c
 36     SRC += $(QUANTUM_DIR)/audio/luts.c
 37 endif
 38diff --git a/docs/_summary.md b/docs/_summary.md
 39index 526caf926f1f4c4e4049f007b617c1013bebf3c8..acbfcfaeda5aa5afa0218c4f29ecd582b9de9f1b 100644
 40--- a/docs/_summary.md
 41+++ b/docs/_summary.md
 42@@ -133,6 +133,7 @@
 43     * [Compatible Microcontrollers](compatible_microcontrollers.md)
 44     * [Drivers](hardware_drivers.md)
 45       * [ADC Driver](adc_driver.md)
 46+      * [Audio Driver](audio_driver.md)
 47       * [I2C Driver](i2c_driver.md)
 48       * [SPI Driver](spi_driver.md)
 49       * [WS2812 Driver](ws2812_driver.md)
 50diff --git a/docs/audio_driver.md b/docs/audio_driver.md
 51new file mode 100644
 52index 0000000000000000000000000000000000000000..7cd5a98d9f4643011ba45468e06fc5b9fb46180e
 53--- /dev/null
 54+++ b/docs/audio_driver.md
 55@@ -0,0 +1,221 @@
 56+# Audio Driver :id=audio-driver
 57+
 58diff --git a/docs/config_options.md b/docs/config_options.md
 59index 9a64b9b3d2097bef411a3c102f3b5fc82ed5060f..aeaaf47aaf4ff8a4715cea5c2c03b16cc73752c5 100644
 60--- a/docs/config_options.md
 61+++ b/docs/config_options.md
 62@@ -67,16 +67,22 @@ This is a C header file that is one of the first things included, and will persi
 63   * turns on the alternate audio voices (to cycle through)
 64 * `#define C4_AUDIO`
 65   * enables audio on pin C4
 66+  * Deprecated. Use `#define AUDIO_PIN C4`
 67 * `#define C5_AUDIO`
 68   * enables audio on pin C5
 69+  * Deprecated. Use `#define AUDIO_PIN C5`
 70 * `#define C6_AUDIO`
 71   * enables audio on pin C6
 72+  * Deprecated. Use `#define AUDIO_PIN C6`
 73 * `#define B5_AUDIO`
 74-  * enables audio on pin B5 (duophony is enables if one of B[5-7]\_AUDIO is enabled along with one of C[4-6]\_AUDIO)
 75+  * enables audio on pin B5 (duophony is enabled if one of B pins is enabled along with one of C pins)
 76+  * Deprecated. Use `#define AUDIO_PIN B5`, or use `#define AUDIO_PIN_ALT B5` if a `C` pin is enabled with `AUDIO_PIN`
 77 * `#define B6_AUDIO`
 78-  * enables audio on pin B6 (duophony is enables if one of B[5-7]\_AUDIO is enabled along with one of C[4-6]\_AUDIO)
 79+  * enables audio on pin B5 (duophony is enabled if one of B pins is enabled along with one of C pins)
 80+  * Deprecated. Use `#define AUDIO_PIN B6`, or use `#define AUDIO_PIN_ALT B6` if a `C` pin is enabled with `AUDIO_PIN`
 81 * `#define B7_AUDIO`
 82-  * enables audio on pin B7 (duophony is enables if one of B[5-7]\_AUDIO is enabled along with one of C[4-6]\_AUDIO)
 83+  * enables audio on pin B5 (duophony is enabled if one of B pins is enabled along with one of C pins)
 84+  * Deprecated. Use `#define AUDIO_PIN B7`, or use `#define AUDIO_PIN_ALT B7` if a `C` pin is enabled with `AUDIO_PIN`
 85 * `#define BACKLIGHT_PIN B7`
 86   * pin of the backlight
 87 * `#define BACKLIGHT_LEVELS 3`
 88diff --git a/docs/feature_audio.md b/docs/feature_audio.md
 89index 68ba4477a52a81f971f0cba2c3ec46386b892e9e..9e7ba75f521241700954d331a535007775c098cb 100644
 90--- a/docs/feature_audio.md
 91+++ b/docs/feature_audio.md
 92@@ -1,21 +1,117 @@
 93 # Audio
 94 
 95diff --git a/keyboards/1upkeyboards/sweet16/v2/proton_c/config.h b/keyboards/1upkeyboards/sweet16/v2/proton_c/config.h
 96index 30abf28ee339ce815bc1d8ac503a86ea8db185d2..286af1857f68aa447a5f2d9016ab59c6c2a451d6 100644
 97--- a/keyboards/1upkeyboards/sweet16/v2/proton_c/config.h
 98+++ b/keyboards/1upkeyboards/sweet16/v2/proton_c/config.h
 99@@ -18,3 +18,7 @@
100 #define ENCODERS_PAD_A { A2 }
101 #define ENCODERS_PAD_B { A1 }
102 #define ENCODER_RESOLUTION 4
103+
104+#define AUDIO_PIN A5
105+#define AUDIO_PIN_ALT A4
106+#define AUDIO_PIN_ALT_AS_NEGATIVE
107diff --git a/keyboards/atomic/keymaps/pvc/config.h b/keyboards/atomic/keymaps/pvc/config.h
108index 3803a2ccd013af77e2651cbd06ef69d6268a89fa..01fa0f43134f74def5f06f5430265874efbbd81d 100644
109--- a/keyboards/atomic/keymaps/pvc/config.h
110+++ b/keyboards/atomic/keymaps/pvc/config.h
111@@ -31,7 +31,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
112 #define BACKLIGHT_PIN B7
113 #define BACKLIGHT_BREATHING
114 
115-#define C6_AUDIO
116+#define AUDIO_PIN C6
117 
118 /* COL2ROW or ROW2COL */
119 #define DIODE_DIRECTION COL2ROW
120diff --git a/keyboards/boston_meetup/2019/config.h b/keyboards/boston_meetup/2019/config.h
121index 3f2a0dd5d6097a1aaeac3dfa16a6621d9a27d924..d9fd93da6e282094f993b42d6913b7c38aa8050c 100644
122--- a/keyboards/boston_meetup/2019/config.h
123+++ b/keyboards/boston_meetup/2019/config.h
124@@ -31,7 +31,10 @@
125 
126 //Audio
127 #undef AUDIO_VOICES
128-#undef C6_AUDIO
129+#undef AUDIO_PIN
130+#define AUDIO_PIN A5
131+#define AUDIO_PIN_ALT A4
132+#define AUDIO_PIN_ALT_AS_NEGATIVE
133 
134 #ifdef AUDIO_ENABLE
135     #define STARTUP_SONG SONG(ONE_UP_SOUND)
136diff --git a/keyboards/c39/keymaps/kuchosauronad0/config.h b/keyboards/c39/keymaps/kuchosauronad0/config.h
137index cf0726e2bb02bdffc32753bbba2fbc1b515ce581..d67935a9fd0ad808bad48e5097dac73dcdf727a4 100644
138--- a/keyboards/c39/keymaps/kuchosauronad0/config.h
139+++ b/keyboards/c39/keymaps/kuchosauronad0/config.h
140@@ -32,12 +32,3 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
141 #  define RGB_DI_PIN D0
142 #  define RGBLED_NUM 4
143 #endif // !RGBLIGHT_ENABLE
144-
145-/*
146-#ifdef AUDIO_ENABLE
147-#  Timer 1: #define B5_AUDIO #define B6_AUDIO #define B7_AUDIO
148-#  Timer 3: #define C4_AUDIO #define C5_AUDIO #define C6_AUDIO
149-//TODO: only D0 and D1 available
150-#endif // !AUDIO_ENABLE
151-*/
152-
153diff --git a/keyboards/ckeys/obelus/config.h b/keyboards/ckeys/obelus/config.h
154index eaf4811ba7380c28bd64ee319cbf2fabf43dcff4..25bc1db03c1f944dd8903af89e5c732b3bc0474b 100644
155--- a/keyboards/ckeys/obelus/config.h
156+++ b/keyboards/ckeys/obelus/config.h
157@@ -154,7 +154,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
158 
159 #ifdef AUDIO_ENABLE
160   #define AUDIO_VOICES
161-  #define C6_AUDIO
162+  #define AUDIO_PIN C6
163   #define STARTUP_SONG SONG(STARTUP_SOUND)
164 #endif
165 
166diff --git a/keyboards/ckeys/thedora/config.h b/keyboards/ckeys/thedora/config.h
167index 349e33748b54a7460f1637decc885dbd9ca7acc0..c7557aa62d6d0630c851e16dadda313ccb87fa34 100755
168--- a/keyboards/ckeys/thedora/config.h
169+++ b/keyboards/ckeys/thedora/config.h
170@@ -157,6 +157,9 @@
171 // NOTE: Must change polyphony_rate to a number higher than 0 in voices.c
172 #define AUDIO_VOICES
173 #define PITCH_STANDARD_A 880.0f
174+#define AUDIO_PIN A5
175+#define AUDIO_PIN_ALT A4
176+#define AUDIO_PIN_ALT_AS_NEGATIVE
177 
178 // Mouse keys
179 #define MOUSEKEY_DELAY 0
180diff --git a/keyboards/clueboard/2x1800/2018/config.h b/keyboards/clueboard/2x1800/2018/config.h
181index 40486379eab3a6632eebe3335e028a481a465bf0..9d5b9b514473f70abc21f37146c4a21a40c4d540 100644
182--- a/keyboards/clueboard/2x1800/2018/config.h
183+++ b/keyboards/clueboard/2x1800/2018/config.h
184@@ -20,8 +20,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
185 #include "config_common.h"
186 
187 /* audio support */
188-#define B7_AUDIO
189-#define C4_AUDIO
190+#define AUDIO_PIN_ALT B7
191+#define AUDIO_PIN C4
192 #define AUDIO_CLICKY
193 
194 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
195diff --git a/keyboards/clueboard/2x1800/2019/config.h b/keyboards/clueboard/2x1800/2019/config.h
196index 595dc61081f570365c5fe1e97394eb966e107f42..162d41a2e2a07e6c440d52fb7a91ec194836235a 100644
197--- a/keyboards/clueboard/2x1800/2019/config.h
198+++ b/keyboards/clueboard/2x1800/2019/config.h
199@@ -27,8 +27,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
200 #define ENCODER_RESOLUTION 4
201 
202 /* audio support */
203-#define B7_AUDIO
204-#define C4_AUDIO
205+#define AUDIO_PIN_ALT B7
206+#define AUDIO_PIN C4
207 #define AUDIO_CLICKY
208 
209 /*
210diff --git a/keyboards/clueboard/66/rev4/config.h b/keyboards/clueboard/66/rev4/config.h
211index c745b5a1101d62e637030d64ba21fb6da3c7170e..2c11cf1ec05f59d85e85cbb9daa25b43cf8a4c67 100644
212--- a/keyboards/clueboard/66/rev4/config.h
213+++ b/keyboards/clueboard/66/rev4/config.h
214@@ -22,3 +22,7 @@
215 #define RGBLIGHT_EFFECT_KNIGHT_OFFSET 2   // The led to start at
216 #define RGBLIGHT_EFFECT_KNIGHT_LED_NUM 5  // How many LEDs to travel
217 #define RGBLIGHT_EFFECT_SNAKE_LENGTH 4    // How many LEDs wide to light up
218+
219+#define AUDIO_PIN A5
220+#define AUDIO_PIN_ALT A4
221+#define AUDIO_PIN_ALT_AS_NEGATIVE
222diff --git a/keyboards/clueboard/66_hotswap/gen1/config.h b/keyboards/clueboard/66_hotswap/gen1/config.h
223index 1ddcfacf4d6cb79b9b0815d49e0b40bec650f068..1471af63dcd098f8edf823930319a3f3ec2ac7bd 100644
224--- a/keyboards/clueboard/66_hotswap/gen1/config.h
225+++ b/keyboards/clueboard/66_hotswap/gen1/config.h
226@@ -108,3 +108,7 @@
227 
228 #define LED_DRIVER_COUNT 1
229 #define LED_DRIVER_LED_COUNT 71
230+
231+#define AUDIO_PIN A5
232+#define AUDIO_PIN_ALT A4
233+#define AUDIO_PIN_ALT_AS_NEGATIVE
234diff --git a/keyboards/clueboard/66_hotswap/prototype/config.h b/keyboards/clueboard/66_hotswap/prototype/config.h
235index 5c22b927adc351d001ddc107cfd50b64ed11c3f9..a1ab703c3408ebddecb1fa25628836c8d7b8129f 100644
236--- a/keyboards/clueboard/66_hotswap/prototype/config.h
237+++ b/keyboards/clueboard/66_hotswap/prototype/config.h
238@@ -3,7 +3,7 @@
239 
240 /* Speaker configuration
241  */
242-#define B7_AUDIO
243+#define AUDIO_PIN B7
244 #define NO_MUSIC_MODE
245 #define AUDIO_CLICKY
246 
247diff --git a/keyboards/clueboard/california/config.h b/keyboards/clueboard/california/config.h
248index b8c5759db6b6793a5324896b5f26032be860231b..017f1ddf66dec06dc76616d91f030f50c6b732a3 100644
249--- a/keyboards/clueboard/california/config.h
250+++ b/keyboards/clueboard/california/config.h
251@@ -1,3 +1,7 @@
252 #pragma once
253 
254 #include "config_common.h"
255+
256+#define AUDIO_PIN A5
257+#define AUDIO_PIN_ALT A4
258+#define AUDIO_PIN_ALT_AS_NEGATIVE
259diff --git a/keyboards/clueboard/card/config.h b/keyboards/clueboard/card/config.h
260index 67ddb5e25cadb2448e971f7530c2a5116345cdc2..a115f5d6cf2690411353852c32f0e59eb661044f 100644
261--- a/keyboards/clueboard/card/config.h
262+++ b/keyboards/clueboard/card/config.h
263@@ -23,4 +23,4 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
264 #define BACKLIGHT_LEVELS 6
265 
266 // Enable audio
267-#define C6_AUDIO
268+#define AUDIO_PIN C6
269diff --git a/keyboards/crkbd/keymaps/gotham/config.h b/keyboards/crkbd/keymaps/gotham/config.h
270index ed08203aa156f8c132c63c0e993b35ef9e814750..dd58a0fe05d37e907ab3cce78a7d359ae618dfda 100644
271--- a/keyboards/crkbd/keymaps/gotham/config.h
272+++ b/keyboards/crkbd/keymaps/gotham/config.h
273@@ -15,7 +15,7 @@
274 #define NO_ACTION_ONESHOT
275 
276 #ifdef AUDIO_ENABLE
277-#    define B5_AUDIO
278+#    define AUDIO_PIN B5
279 #    define NO_MUSIC_MODE
280 #    define AUDIO_CLICKY
281 #endif
282diff --git a/keyboards/ergodash/mini/config.h b/keyboards/ergodash/mini/config.h
283index 5e16c78544abeaedbb7b452c843e3fb90a864c7e..b936e0f54e2a7de667a0053c3bf5db9f33c259b2 100644
284--- a/keyboards/ergodash/mini/config.h
285+++ b/keyboards/ergodash/mini/config.h
286@@ -45,7 +45,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
287 /* define if matrix has ghost */
288 //#define MATRIX_HAS_GHOST
289 
290-#define C6_AUDIO
291+#define AUDIO_PIN C6
292 
293 /* number of backlight levels */
294 #ifdef BACKLIGHT_ENABLE
295diff --git a/keyboards/ergodash/rev1/config.h b/keyboards/ergodash/rev1/config.h
296index 6e25194e4b666afe58d462b16d1d5093db82ddc1..07282cdad2871b12427e385d780c6988d12f92e1 100644
297--- a/keyboards/ergodash/rev1/config.h
298+++ b/keyboards/ergodash/rev1/config.h
299@@ -45,7 +45,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
300 /* define if matrix has ghost */
301 //#define MATRIX_HAS_GHOST
302 
303-#define C6_AUDIO
304+#define AUDIO_PIN C6
305 
306 /* number of backlight levels */
307 #ifdef BACKLIGHT_ENABLE
308diff --git a/keyboards/evyd13/plain60/keymaps/audio/config.h b/keyboards/evyd13/plain60/keymaps/audio/config.h
309index 9a43b7fbe346c7bdebe46448f956c91f39eabca5..50309173b4099397743460f6dc0e23ed7d22c860 100644
310--- a/keyboards/evyd13/plain60/keymaps/audio/config.h
311+++ b/keyboards/evyd13/plain60/keymaps/audio/config.h
312@@ -1,3 +1,3 @@
313 #pragma once
314 
315-#define B7_AUDIO
316+#define AUDIO_PIN B7
317diff --git a/keyboards/flehrad/bigswitch/keymaps/wanleg/config.h b/keyboards/flehrad/bigswitch/keymaps/wanleg/config.h
318index 54abb9a6c17e80afb5cd80ddb8f84b1ae1c6e7b8..bb638ce599b660e4b25e76bd51050c5a6b1edb0b 100644
319--- a/keyboards/flehrad/bigswitch/keymaps/wanleg/config.h
320+++ b/keyboards/flehrad/bigswitch/keymaps/wanleg/config.h
321@@ -39,4 +39,4 @@
322 #define QMK_LED B0
323 
324 // set audio pin
325-#define C6_AUDIO
326+#define AUDIO_PIN C6
327diff --git a/keyboards/hadron/ver3/config.h b/keyboards/hadron/ver3/config.h
328index f76ca40603cf40e1547450b1986ff644d6b245b1..8c04575eeab27ab6811d30e7e85c47d111969184 100644
329--- a/keyboards/hadron/ver3/config.h
330+++ b/keyboards/hadron/ver3/config.h
331@@ -50,7 +50,11 @@
332 
333 //Audio
334 #undef AUDIO_VOICES
335-#undef C6_AUDIO
336+#undef AUDIO_PIN
337+#define AUDIO_PIN A5
338+#define AUDIO_PIN_ALT A4
339+#define AUDIO_PIN_ALT_AS_NEGATIVE
340+
341 
342 #ifdef AUDIO_ENABLE
343     #define STARTUP_SONG SONG(PLANCK_SOUND)
344diff --git a/keyboards/handwired/aranck/config.h b/keyboards/handwired/aranck/config.h
345index 5356feb1ef84ffd0a024283a73d236e512120c13..7d0ab25fe4231a5b65a5dcc99134f518f81e95f5 100644
346--- a/keyboards/handwired/aranck/config.h
347+++ b/keyboards/handwired/aranck/config.h
348@@ -101,7 +101,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
349 /**
350  * Aranck-specific definitions
351  */
352-#define B5_AUDIO
353+#define AUDIO_PIN B5
354 /**
355  * Aranck-specific definitions END
356  */
357diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h
358index 6d89314a2ce985e08e500dd7a687c7270127bd6f..d18f08e408570cae42dab7884043e757705e06d6 100644
359--- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h
360+++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h
361@@ -61,7 +61,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
362 #define BOOTMAGIC_LITE_ROW_RIGHT 6
363 #define BOOTMAGIC_LITE_COLUMN_RIGHT 5
364 
365-#define C6_AUDIO
366+#define AUDIO_PIN C6
367 
368 #define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095
369 #define DYNAMIC_KEYMAP_LAYER_COUNT 16
370diff --git a/keyboards/handwired/heisenberg/config.h b/keyboards/handwired/heisenberg/config.h
371index 9fe2ec879ab14d98ef23bc65ef554daa94b5b405..ba35f24aca2f44dbdb9c6ff2714f12ea1de63769 100644
372--- a/keyboards/handwired/heisenberg/config.h
373+++ b/keyboards/handwired/heisenberg/config.h
374@@ -101,7 +101,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
375 /**
376  * Heisenberg-specific definitions
377  */
378-#define B5_AUDIO
379+#define AUDIO_PIN B5
380 /**
381  * Heisenberg-specific definitions END
382  */
383diff --git a/keyboards/handwired/ibm122m/config.h b/keyboards/handwired/ibm122m/config.h
384index e0e95d6d3b7d13b32f34a09e7f8e3bae50a2b29e..bd1fdc97dc2528bdfe1564ab2b25686da3bdb0b1 100644
385--- a/keyboards/handwired/ibm122m/config.h
386+++ b/keyboards/handwired/ibm122m/config.h
387@@ -24,7 +24,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
388 #define PRODUCT_ID      0x0000
389 #define DEVICE_VER      0x0001
390 #define MANUFACTURER    IBM
391-#define PRODUCT         IBM Model M 122 key 
392+#define PRODUCT         IBM Model M 122 key
393 
394 /* key matrix size */
395 #define MATRIX_ROWS 8
396@@ -102,8 +102,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
397  *
398  */
399 
400-#define B6_AUDIO
401-#define C6_AUDIO
402+#define AUDIO_PIN_ALT B6
403+#define AUDIO_PIN C6
404 
405 /* control how magic key switches layers */
406 //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS  true
407diff --git a/keyboards/handwired/xealous/config.h b/keyboards/handwired/xealous/config.h
408index 251e85d4c122651c78ac5a3132d502400e48c246..5c1469b1f0127c1c14e729822e6dbc0d89763a3e 100644
409--- a/keyboards/handwired/xealous/config.h
410+++ b/keyboards/handwired/xealous/config.h
411@@ -34,10 +34,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
412 
413 
414 #ifdef AUDIO_ENABLE
415-  #define C6_AUDIO
416+  #define AUDIO_PIN C6
417   #define STARTUP_SONG SONG(STARTUP_SOUND)
418   #define NO_MUSIC_MODE
419   #define TONE_QWERTY SONG(Q__NOTE(_E4));
420   #define TONE_NUMPAD SONG(Q__NOTE(_D4));
421 #endif
422-
423diff --git a/keyboards/helix/pico/config.h b/keyboards/helix/pico/config.h
424index 3938db30e6a4fde768fe6f8a88e95f353f1a60f2..b01fd3a0016cb77f65b665149f4cd774db555219 100644
425--- a/keyboards/helix/pico/config.h
426+++ b/keyboards/helix/pico/config.h
427@@ -77,7 +77,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
428 
429 /* Audio */
430 #ifdef AUDIO_ENABLE
431-  #define B5_AUDIO
432+  #define AUDIO_PIN B5
433 #endif
434 
435 /* ws2812 RGB LED */
436diff --git a/keyboards/hp69/config.h b/keyboards/hp69/config.h
437index ca0a9eb47b6eab2951d5c40e61494b9b6829b5e5..06dd57145ca898bdfd585e03ae07fc64a7d35ab1 100644
438--- a/keyboards/hp69/config.h
439+++ b/keyboards/hp69/config.h
440@@ -48,5 +48,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
441 #define RGBLED_NUM 20
442 #define RGBLIGHT_ANIMATIONS
443 
444-#define A4_AUDIO
445-#define A5_AUDIO
446+#define AUDIO_PIN A5
447+#define AUDIO_PIN_ALT A4
448+#define AUDIO_PIN_ALT_AS_NEGATIVE
449diff --git a/keyboards/jones/v03/config.h b/keyboards/jones/v03/config.h
450index 3683a43dd19fc76850ce8ab7a00d1cdf76a55b58..0ff82e8d37db465a3835ec1517b14e5fcab9b4dd 100644
451--- a/keyboards/jones/v03/config.h
452+++ b/keyboards/jones/v03/config.h
453@@ -57,8 +57,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
454 
455 /* Audio */
456 #ifdef AUDIO_ENABLE
457-  #define C6_AUDIO
458-  #define B6_AUDIO  // 2nd pin for simultaneous audio.
459+  #define AUDIO_PIN C6
460+  #define AUDIO_PIN_ALT B6  // 2nd pin for simultaneous audio.
461   #define AUDIO_CLICKY
462 #endif
463 
464diff --git a/keyboards/jones/v03_1/config.h b/keyboards/jones/v03_1/config.h
465index a064e56396954adf19a24c52da51043aa1224722..c1d6a577fc49cb3971c92b656b5e963d9076a09a 100644
466--- a/keyboards/jones/v03_1/config.h
467+++ b/keyboards/jones/v03_1/config.h
468@@ -57,8 +57,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
469 
470 /* Audio */
471 #ifdef AUDIO_ENABLE
472-  #define C6_AUDIO
473-  #define B7_AUDIO  // 2nd pin for simultaneous audio.
474+  #define AUDIO_PIN C6
475+  #define AUDIO_PIN_ALT B7  // 2nd pin for simultaneous audio.
476   #define AUDIO_CLICKY
477 #endif
478 
479diff --git a/keyboards/keebio/iris/keymaps/blucky/config.h b/keyboards/keebio/iris/keymaps/blucky/config.h
480index 213445dd3f3dddb84e8be8cfbd587ba83d4df30e..f187addbd33357ce728d3ecb522539e6cad71c04 100644
481--- a/keyboards/keebio/iris/keymaps/blucky/config.h
482+++ b/keyboards/keebio/iris/keymaps/blucky/config.h
483@@ -1,5 +1,5 @@
484 /*
485-Copyright 2019 Brian Luckenbill 
486+Copyright 2019 Brian Luckenbill
487 
488 This program is free software: you can redistribute it and/or modify
489 it under the terms of the GNU General Public License as published by
490@@ -17,7 +17,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
491 
492 #pragma once
493 
494-#define C6_AUDIO
495+#define AUDIO_PIN C6
496 
497 #undef  RGBLED_NUM
498 #define RGBLED_NUM                  12
499diff --git a/keyboards/keebio/iris/keymaps/broswen/config.h b/keyboards/keebio/iris/keymaps/broswen/config.h
500index 19c47780dbfff7181d02d446f41bc0639472e94a..fcfbfe8cf06e4900d36770fa6033d177ce976668 100644
501--- a/keyboards/keebio/iris/keymaps/broswen/config.h
502+++ b/keyboards/keebio/iris/keymaps/broswen/config.h
503@@ -32,7 +32,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
504 #define RGBLIGHT_HUE_STEP 5
505 #define RGBLIGHT_SAT_STEP 8
506 #define RGBLIGHT_VAL_STEP 8
507-#define C6_AUDIO
508+#define AUDIO_PIN C6
509 
510 #define NO_MUSIC_MODE
511 
512diff --git a/keyboards/keebio/iris/keymaps/drashna/config.h b/keyboards/keebio/iris/keymaps/drashna/config.h
513index 63f87b7c4e03332c76394913b68543b5eee2329a..f68166c98f0565c228c92a4dfc9be91e40151007 100644
514--- a/keyboards/keebio/iris/keymaps/drashna/config.h
515+++ b/keyboards/keebio/iris/keymaps/drashna/config.h
516@@ -43,7 +43,7 @@
517 #endif  // RGBLIGHT_ENABLE
518 
519 #ifdef AUDIO_ENABLE
520-#    define C6_AUDIO
521+#    define AUDIO_PIN C6
522 #    ifdef RGBLIGHT_ENABLE
523 #        ifndef __arm__
524 #            define NO_MUSIC_MODE
525diff --git a/keyboards/keebio/iris/keymaps/mtdjr/config.h b/keyboards/keebio/iris/keymaps/mtdjr/config.h
526index 93dc4c211ddc1472d8d2c340995da532352c0cca..9adb6d62715f3bf72537ec9b0dab70cce5a86422 100644
527--- a/keyboards/keebio/iris/keymaps/mtdjr/config.h
528+++ b/keyboards/keebio/iris/keymaps/mtdjr/config.h
529@@ -34,7 +34,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
530 
531 // #define AUDIO_CLICKY
532 // #define AUDIO_CLICKY_ON
533-// #define C6_AUDIO
534+// #define AUDIO_PIN C6
535 // #define AUDIO_CLICKY_FREQ_RANDOMNESS 0.1f
536 // #define AUDIO_CLICKY_FREQ_MAX 100.0f
537 
538diff --git a/keyboards/keebio/iris/keymaps/pvinis/config.h b/keyboards/keebio/iris/keymaps/pvinis/config.h
539index 9574f2a837f5dfb1c6bc8cd6d7b8bf15751f5ada..c2870eba0b94c91a25b7973cce047243eacc0d3c 100644
540--- a/keyboards/keebio/iris/keymaps/pvinis/config.h
541+++ b/keyboards/keebio/iris/keymaps/pvinis/config.h
542@@ -16,7 +16,7 @@
543 
544 // Choose pin to use for audio. C6 is the one iris uses.
545 #ifdef AUDIO_ENABLE
546-#    define C6_AUDIO
547+#    define AUDIO_PIN C6
548 #    define STARTUP_SONG SONG(NO_SOUND)  // No startup song.
549 #endif
550 
551diff --git a/keyboards/keebio/levinson/keymaps/issmirnov/config.h b/keyboards/keebio/levinson/keymaps/issmirnov/config.h
552index 89c2f5ebe82ce6f9edf647561fbe0089d5cb0c06..2f0fbaf33c6a6cbb655dc469da4d9e3066b0087a 100644
553--- a/keyboards/keebio/levinson/keymaps/issmirnov/config.h
554+++ b/keyboards/keebio/levinson/keymaps/issmirnov/config.h
555@@ -29,6 +29,6 @@
556 
557 #ifdef AUDIO_ENABLE
558    #define QMK_SPEAKER C6
559-   #define C6_AUDIO
560+   #define AUDIO_PIN C6
561    #define NO_MUSIC_MODE // Save 2000 bytes
562 #endif
563diff --git a/keyboards/keebio/quefrency/keymaps/drashna_ms/config.h b/keyboards/keebio/quefrency/keymaps/drashna_ms/config.h
564index 089c8cf79e52b30caa863109252e4726a9d9b71e..80a3cb877e2af0175dabc967c71d54c28c998222 100644
565--- a/keyboards/keebio/quefrency/keymaps/drashna_ms/config.h
566+++ b/keyboards/keebio/quefrency/keymaps/drashna_ms/config.h
567@@ -35,6 +35,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
568 #endif
569 
570 #ifdef AUDIO_ENABLE
571-    #define B7_AUDIO
572+    #define AUDIO_PIN B7
573     #define AUDIO_CLICKY
574 #endif
575diff --git a/keyboards/keebio/viterbi/keymaps/drashna/config.h b/keyboards/keebio/viterbi/keymaps/drashna/config.h
576index 5d7ffa8a1d5346d177a45d2ee886625bd39275ed..2decb3b3e9379f7018f25b0df1a04d57630ed43f 100644
577--- a/keyboards/keebio/viterbi/keymaps/drashna/config.h
578+++ b/keyboards/keebio/viterbi/keymaps/drashna/config.h
579@@ -34,7 +34,7 @@
580 #define PRODUCT Drashnas Viterbi Macro Pad
581 
582 #ifdef AUDIO_ENABLE
583-#    define C6_AUDIO
584+#    define AUDIO_PIN C6
585 #    define NO_MUSIC_MODE
586 #endif
587 
588diff --git a/keyboards/keysofkings/twokey/config.h b/keyboards/keysofkings/twokey/config.h
589index d7f4c3cf0a64703519758394fdeefe5cde9c7213..9b77fa73e2439d69e32645695328e073e3efff7e 100755
590--- a/keyboards/keysofkings/twokey/config.h
591+++ b/keyboards/keysofkings/twokey/config.h
592@@ -1,18 +1,18 @@
593  /* Copyright 2020 Keys of Kings
594-  * 
595-  * This program is free software: you can redistribute it and/or modify 
596-  * it under the terms of the GNU General Public License as published by 
597-  * the Free Software Foundation, either version 2 of the License, or 
598-  * (at your option) any later version. 
599-  * 
600-  * This program is distributed in the hope that it will be useful, 
601-  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
602-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
603-  * GNU General Public License for more details. 
604-  * 
605-  * You should have received a copy of the GNU General Public License 
606-  * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
607-  */ 
608+  *
609+  * This program is free software: you can redistribute it and/or modify
610+  * it under the terms of the GNU General Public License as published by
611+  * the Free Software Foundation, either version 2 of the License, or
612+  * (at your option) any later version.
613+  *
614+  * This program is distributed in the hope that it will be useful,
615+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
616+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
617+  * GNU General Public License for more details.
618+  *
619+  * You should have received a copy of the GNU General Public License
620+  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
621+  */
622 
623 #pragma once
624 
625@@ -59,7 +59,7 @@
626 #define RGBLIGHT_HUE_STEP 4
627 #define RGBLIGHT_SAT_STEP 4
628 #define RGBLIGHT_VAL_STEP 4
629-#define B6_AUDIO
630+#define AUDIO_PIN B6
631 #define AUDIO_CLICKY
632 #endif
633 
634diff --git a/keyboards/knops/mini/keymaps/mverteuil/config.h b/keyboards/knops/mini/keymaps/mverteuil/config.h
635index f72145c5a86e9ef97beb792ec435b7f233cec55b..584296cfaada78856862870ed80ca47431fc3dbb 100644
636--- a/keyboards/knops/mini/keymaps/mverteuil/config.h
637+++ b/keyboards/knops/mini/keymaps/mverteuil/config.h
638@@ -18,8 +18,8 @@
639 
640 #if defined(AUDIO_ENABLE)
641     #define AUDIO_CLICKY
642-    #define B5_AUDIO
643-    #define C6_AUDIO
644+    #define AUDIO_PIN_ALT B5
645+    #define AUDIO_PIN C6
646     #define STARTUP_SONG SONG(ZELDA_PUZZLE)
647     #define GOODBYE_SONG SONG(COIN_SOUND)
648 #endif
649diff --git a/keyboards/launchpad/keymaps/drashna/config.h b/keyboards/launchpad/keymaps/drashna/config.h
650index 212b1da805e01b7ff0cb89f115be27ca66641924..b14becc25bf57d433ed1f8b367a665e28b25bf99 100644
651--- a/keyboards/launchpad/keymaps/drashna/config.h
652+++ b/keyboards/launchpad/keymaps/drashna/config.h
653@@ -27,5 +27,5 @@
654 #define RGBLIGHT_VAL_STEP 17
655 
656 #define DRIVER_LED_TOTAL RGBLED_NUM
657-#define B7_AUDIO
658+#define AUDIO_PIN B7
659 #define AUDIO_CLICKY
660diff --git a/keyboards/lets_split/sockets/config.h b/keyboards/lets_split/sockets/config.h
661index 4315ce24fda5ba66cccce1379883072dc923b05e..67fa4b4ccc204bffe9c3d81a639521787f321409 100644
662--- a/keyboards/lets_split/sockets/config.h
663+++ b/keyboards/lets_split/sockets/config.h
664@@ -61,7 +61,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
665 
666 /* Audio settings */
667 #ifdef AUDIO_ENABLE
668-    #define C6_AUDIO // Define this to enable the buzzer
669+    #define AUDIO_PIN C6 // Define this to enable the buzzer
670 #endif
671 
672 /*
673diff --git a/keyboards/lfkeyboards/lfk78/config.h b/keyboards/lfkeyboards/lfk78/config.h
674index 5a855b07c53fd8f1cd6d3121003a4970afd97548..2b0b01d86117541d4891fc919d2125e57abdda97 100644
675--- a/keyboards/lfkeyboards/lfk78/config.h
676+++ b/keyboards/lfkeyboards/lfk78/config.h
677@@ -39,7 +39,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
678 
679 #define TAPPING_TERM 200
680 
681-#define C6_AUDIO
682+#define AUDIO_PIN C6
683 #define AUDIO_VOICES
684 
685 #define RGB_DI_PIN C7 // Have to set it to something to get the ws2812 code to compile
686diff --git a/keyboards/lfkeyboards/lfk87/config.h b/keyboards/lfkeyboards/lfk87/config.h
687index 118c135aa1e20773aec057b0b9d42038b2ad82dd..c030590921e1ddc52faaedaf2db72d99dc82c9e0 100644
688--- a/keyboards/lfkeyboards/lfk87/config.h
689+++ b/keyboards/lfkeyboards/lfk87/config.h
690@@ -50,7 +50,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
691 #endif
692 
693 #define AUDIO_VOICES
694-#define C6_AUDIO
695+#define AUDIO_PIN C6
696 
697 #define BACKLIGHT_LEVELS 10
698 #define BACKLIGHT_PWM_MAP {2, 4, 8, 16, 40, 55, 70, 128, 200, 255}
699diff --git a/keyboards/lfkeyboards/mini1800/config.h b/keyboards/lfkeyboards/mini1800/config.h
700index a6cd675ddfb3f324af3f47768455da4facce32d0..b8c0f2b671d23cbdbdb7f2eca93871cb978bf7c0 100644
701--- a/keyboards/lfkeyboards/mini1800/config.h
702+++ b/keyboards/lfkeyboards/mini1800/config.h
703@@ -37,7 +37,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
704     #define RGBLED_NUM 26     // Number of LEDs
705 
706 #define AUDIO_VOICES
707-#define C6_AUDIO
708+#define AUDIO_PIN C6
709 
710 #define BACKLIGHT_LEVELS 10
711 #define BACKLIGHT_PWM_MAP {2, 4, 8, 16, 40, 55, 70, 128, 200, 255}
712diff --git a/keyboards/lfkeyboards/smk65/revb/config.h b/keyboards/lfkeyboards/smk65/revb/config.h
713index 0d4fe40f358709322bf3d5b4ef282ef91d0bd19d..924a04fd9efc44d9b8ab5f36cf7809c6d4249c4f 100644
714--- a/keyboards/lfkeyboards/smk65/revb/config.h
715+++ b/keyboards/lfkeyboards/smk65/revb/config.h
716@@ -43,8 +43,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
717 //RevB only:
718 
719 #define AUDIO_VOICES
720-#define C6_AUDIO
721-// #define B5_AUDIO
722+#define AUDIO_PIN C6
723 
724 #define BACKLIGHT_LEVELS 8
725 #define BACKLIGHT_PWM_MAP {8, 16, 40, 55, 70, 128, 200, 255}
726diff --git a/keyboards/meira/featherble/config.h b/keyboards/meira/featherble/config.h
727index c6c63556d650d113e61022f9b8691f3a60efe91a..e8db87acbb3aa96211f408d64dfdf3597b6ffb17 100644
728--- a/keyboards/meira/featherble/config.h
729+++ b/keyboards/meira/featherble/config.h
730@@ -37,7 +37,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
731 #define UNUSED_PINS
732 
733 #define QMK_SPEAKER B5
734-#define B5_AUDIO
735+#define AUDIO_PIN B5
736 #define AUDIO_VOICES
737 
738 // #define BACKLIGHT_PIN B7