diff options
author | Drashna Jaelre <drashna@live.com> | 2018-04-21 09:30:10 -0700 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-04-21 12:30:10 -0400 |
commit | 33fdd1d2551591a5c295c6dc68ccf52c4698b9c1 (patch) | |
tree | 8d8134cecf3121fad4e81c2f16d1804ae233edb2 /quantum/process_keycode/process_audio.c | |
parent | d1c3419d2ade6341bb7eba130bf8c77005705519 (diff) | |
download | qmk_firmware-33fdd1d2551591a5c295c6dc68ccf52c4698b9c1.tar.gz qmk_firmware-33fdd1d2551591a5c295c6dc68ccf52c4698b9c1.zip |
Fix Audio Clicky sub-feature (#2784)
* Fix Audio Clicky feature
* Add to features
Diffstat (limited to 'quantum/process_keycode/process_audio.c')
-rw-r--r-- | quantum/process_keycode/process_audio.c | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c index fc0f23ee3..e9b20512e 100644 --- a/quantum/process_keycode/process_audio.c +++ b/quantum/process_keycode/process_audio.c | |||
@@ -10,45 +10,7 @@ float voice_change_song[][2] = VOICE_CHANGE_SONG; | |||
10 | #define PITCH_STANDARD_A 440.0f | 10 | #define PITCH_STANDARD_A 440.0f |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | #ifdef AUDIO_CLICKY | ||
14 | #ifdef AUDIO_CLICKY_ON | ||
15 | bool clicky_enable = true; | ||
16 | #else | ||
17 | bool clicky_enable = false; | ||
18 | #endif | ||
19 | #ifndef AUDIO_CLICKY_FREQ_DEFAULT | ||
20 | #define AUDIO_CLICKY_FREQ_DEFAULT 440.0f | ||
21 | #endif | ||
22 | #ifndef AUDIO_CLICKY_FREQ_MIN | ||
23 | #define AUDIO_CLICKY_FREQ_MIN 65.0f | ||
24 | #endif | ||
25 | #ifndef AUDIO_CLICKY_FREQ_MAX | ||
26 | #define AUDIO_CLICKY_FREQ_MAX 1500.0f | ||
27 | #endif | ||
28 | #ifndef AUDIO_CLICKY_FREQ_FACTOR | ||
29 | #define AUDIO_CLICKY_FREQ_FACTOR 1.18921f | ||
30 | #endif | ||
31 | #ifndef AUDIO_CLICKY_FREQ_RANDOMNESS | ||
32 | #define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f | ||
33 | #endif | ||
34 | |||
35 | float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; | ||
36 | float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations | ||
37 | 13 | ||
38 | #ifndef NO_MUSIC_MODE | ||
39 | extern bool music_activated; | ||
40 | extern bool midi_activated; | ||
41 | #endif | ||
42 | |||
43 | void clicky_play(void) { | ||
44 | #ifndef NO_MUSIC_MODE | ||
45 | if (music_activated || midi_activated) return; | ||
46 | #endif | ||
47 | clicky_song[0][0] = 2.0f * clicky_freq * (1.0f + AUDIO_CLICKY_FREQ_RANDOMNESS * ( ((float)rand()) / ((float)(RAND_MAX)) ) ); | ||
48 | clicky_song[1][0] = clicky_freq * (1.0f + AUDIO_CLICKY_FREQ_RANDOMNESS * ( ((float)rand()) / ((float)(RAND_MAX)) ) ); | ||
49 | PLAY_SONG(clicky_song); | ||
50 | } | ||
51 | #endif | ||
52 | 14 | ||
53 | static float compute_freq_for_midi_note(uint8_t note) | 15 | static float compute_freq_for_midi_note(uint8_t note) |
54 | { | 16 | { |
@@ -89,33 +51,6 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) { | |||
89 | return false; | 51 | return false; |
90 | } | 52 | } |
91 | 53 | ||
92 | #ifdef AUDIO_CLICKY | ||
93 | if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_enable = !clicky_enable; } | ||
94 | |||
95 | if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; } | ||
96 | |||
97 | if (keycode == CLICKY_UP && record->event.pressed) { | ||
98 | float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR; | ||
99 | if (new_freq < AUDIO_CLICKY_FREQ_MAX) { | ||
100 | clicky_freq = new_freq; | ||
101 | } | ||
102 | } | ||
103 | if (keycode == CLICKY_TOGGLE && record->event.pressed) { | ||
104 | float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR; | ||
105 | if (new_freq > AUDIO_CLICKY_FREQ_MIN) { | ||
106 | clicky_freq = new_freq; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | |||
111 | if ( clicky_enable ) { | ||
112 | if (record->event.pressed) { | ||
113 | stop_all_notes(); | ||
114 | clicky_play();; | ||
115 | } | ||
116 | } | ||
117 | #endif // AUDIO_CLICKY | ||
118 | |||
119 | return true; | 54 | return true; |
120 | } | 55 | } |
121 | 56 | ||