diff options
author | Jack Humbert <jack.humb@gmail.com> | 2017-07-24 12:44:03 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-07-24 12:45:34 -0400 |
commit | cefc09ae7dd88cd6b92412881888404da1abdfcb (patch) | |
tree | d19e222daf3aa1e2a1c7341ace677c5b2a86c770 | |
parent | a543ad4c1d2c9782b779d63e3eef8d39370441af (diff) | |
download | qmk_firmware-cefc09ae7dd88cd6b92412881888404da1abdfcb.tar.gz qmk_firmware-cefc09ae7dd88cd6b92412881888404da1abdfcb.zip |
adds option for alt pitch standards
-rw-r--r-- | docs/modding_your_keyboard.md | 4 | ||||
-rw-r--r-- | quantum/process_keycode/process_audio.c | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/docs/modding_your_keyboard.md b/docs/modding_your_keyboard.md index 5613bf525..a58fbd52b 100644 --- a/docs/modding_your_keyboard.md +++ b/docs/modding_your_keyboard.md | |||
@@ -79,6 +79,10 @@ By default, `MUSIC_MASK` is set to `keycode < 0xFF` which means keycodes less th | |||
79 | 79 | ||
80 | Which will capture all keycodes - be careful, this will get you stuck in music mode until you restart your keyboard! | 80 | Which will capture all keycodes - be careful, this will get you stuck in music mode until you restart your keyboard! |
81 | 81 | ||
82 | The pitch standard (`PITCH_STANDARD_A`) is 440.0f by default - to change this, add something like this to your `config.h`: | ||
83 | |||
84 | #define PITCH_STANDARD_A 432.0f | ||
85 | |||
82 | ## MIDI functionalty | 86 | ## MIDI functionalty |
83 | 87 | ||
84 | This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile. | 88 | This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile. |
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c index eb74796fa..32057ae8d 100644 --- a/quantum/process_keycode/process_audio.c +++ b/quantum/process_keycode/process_audio.c | |||
@@ -6,10 +6,14 @@ | |||
6 | #endif | 6 | #endif |
7 | float voice_change_song[][2] = VOICE_CHANGE_SONG; | 7 | float voice_change_song[][2] = VOICE_CHANGE_SONG; |
8 | 8 | ||
9 | #ifndef PITCH_STANDARD_A | ||
10 | #define PITCH_STANDARD_A 440.0f | ||
11 | #endif | ||
12 | |||
9 | static float compute_freq_for_midi_note(uint8_t note) | 13 | static float compute_freq_for_midi_note(uint8_t note) |
10 | { | 14 | { |
11 | // https://en.wikipedia.org/wiki/MIDI_tuning_standard | 15 | // https://en.wikipedia.org/wiki/MIDI_tuning_standard |
12 | return pow(2.0, (note - 69) / 12.0) * 440.0f; | 16 | return pow(2.0, (note - 69) / 12.0) * PITCH_STANDARD_A; |
13 | } | 17 | } |
14 | 18 | ||
15 | bool process_audio(uint16_t keycode, keyrecord_t *record) { | 19 | bool process_audio(uint16_t keycode, keyrecord_t *record) { |