]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Adds a configurable initial delay to the audio clicky feature (#4286)
authorJosh <josh@visionistinc.com>
Fri, 17 May 2019 20:48:53 +0000 (16:48 -0400)
committerDrashna Jaelre <drashna@live.com>
Fri, 17 May 2019 20:48:53 +0000 (13:48 -0700)
* Adding an AUDIO_CLICKY_DELAY_DURATION configurable value to the AUDIO_CLICKY feature.

* Tweaking my community keymap to work better with my rev 4 planck.

docs/feature_audio.md
layouts/community/ortho_4x12/mindsound/config.h
quantum/process_keycode/process_clicky.c

index e1dd4c5a85c105dc5ad6529ed9d525a88dce93c3..7511598bcfb3417b74ef568e526a100d5b43d428 100644 (file)
@@ -175,8 +175,9 @@ You can configure the default, min and max frequencies, the stepping and built i
 | `AUDIO_CLICKY_FREQ_DEFAULT` | 440.0f | Sets the default/starting audio frequency for the clicky sounds. |
 | `AUDIO_CLICKY_FREQ_MIN` | 65.0f | Sets the lowest frequency (under 60f are a bit buggy). |
 | `AUDIO_CLICKY_FREQ_MAX` | 1500.0f | Sets the the highest frequency. Too high may result in coworkers attacking you. |
-| `AUDIO_CLICKY_FREQ_FACTOR` | 1.18921f| Sets the stepping of UP/DOWN key codes. |
+| `AUDIO_CLICKY_FREQ_FACTOR` | 1.18921f| 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.  |
 | `AUDIO_CLICKY_FREQ_RANDOMNESS`     |  0.05f |  Sets a factor of randomness for the clicks, Setting this to `0f` will make each click identical, and `1.0f` will make this sound much like the 90's computer screen scrolling/typing effect. | 
+| `AUDIO_CLICKY_DELAY_DURATION` | 1 | An integer note duration where 1 is 1/16th of the tempo, or a sixty-fourth note (see `quantum/audio/musical_notes.h` 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. |
 
 
 
index 76e7da20498e90563c5d2d91a5a52a0705344f4e..e615fe77ebb3022a59dece2fec578c7cff5a0af1 100644 (file)
   #define STARTUP_SONG SONG(ADVENTURE_TIME)
   #define AUDIO_CLICKY
   #define AUDIO_CLICKY_ON
+  #define AUDIO_CLICKY_DELAY_DURATION 0
   #define AUDIO_CLICKY_FREQ_MAX 2500.0f
-  #define AUDIO_CLICKY_FREQ_RANDOMNESS 0.2f
-  #define AUDIO_CLICKY_FREQ_DEFAULT 110.0f
+  #define AUDIO_CLICKY_FREQ_RANDOMNESS 0.3f
+  #define AUDIO_CLICKY_FREQ_DEFAULT 880.0f
 #endif
 
 // for some reason the LSvi rev1 disables action tapping...
index 12fef51f9e5473e5735f2d471ecfec1baa87cdab..43b803afe7fd465a7a3646c7f57ead9f7f0c82ef 100644 (file)
@@ -3,6 +3,9 @@
 
 #ifdef AUDIO_CLICKY
 
+#ifndef AUDIO_CLICKY_DELAY_DURATION
+#define AUDIO_CLICKY_DELAY_DURATION 1
+#endif // !AUDIO_CLICKY_DELAY_DURATION
 #ifndef AUDIO_CLICKY_FREQ_DEFAULT
 #define AUDIO_CLICKY_FREQ_DEFAULT 440.0f
 #endif // !AUDIO_CLICKY_FREQ_DEFAULT
@@ -21,7 +24,9 @@
 
 float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
 float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS;
-float clicky_song[][2]  = {{AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations
+
+// the first "note" is an intentional delay; the 2nd and 3rd notes are the "clicky"
+float clicky_song[][2]  = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations
 
 extern audio_config_t audio_config;
 
@@ -34,8 +39,8 @@ void clicky_play(void) {
 #ifndef NO_MUSIC_MODE
   if (music_activated || midi_activated || !audio_config.enable) return;
 #endif // !NO_MUSIC_MODE
-  clicky_song[0][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
-  clicky_song[1][0] = clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
+  clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
+  clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
   PLAY_SONG(clicky_song);
 }