summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboard/atomic/keymaps/pvc/config.h4
-rw-r--r--keyboard/atomic/keymaps/pvc/keymap.c69
-rw-r--r--quantum/audio/audio.h6
-rw-r--r--quantum/audio/voices.c41
-rw-r--r--quantum/audio/voices.h4
5 files changed, 85 insertions, 39 deletions
diff --git a/keyboard/atomic/keymaps/pvc/config.h b/keyboard/atomic/keymaps/pvc/config.h
index cb0b78e447..cc92634646 100644
--- a/keyboard/atomic/keymaps/pvc/config.h
+++ b/keyboard/atomic/keymaps/pvc/config.h
@@ -62,6 +62,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
+// Enable Keyboard Locking via magic key
+#define KEYBOARD_LOCK_ENABLE
+
+
/*
* Force NKRO
*
diff --git a/keyboard/atomic/keymaps/pvc/keymap.c b/keyboard/atomic/keymaps/pvc/keymap.c
index 95a26c5b4d..c6642919b8 100644
--- a/keyboard/atomic/keymaps/pvc/keymap.c
+++ b/keyboard/atomic/keymaps/pvc/keymap.c
@@ -13,9 +13,9 @@
#define LAYER_DVORAK 2
#define LAYER_LOWER 3
#define LAYER_RAISE 4
-#define LAYER_ADJUST 5
-#define LAYER_FUNCTION 6
-#define LAYER_MUSIC 7
+#define LAYER_FUNCTION 5
+#define LAYER_MUSIC 6
+#define LAYER_ADJUST 7
#define MACRO_QWERTY 0
#define MACRO_COLEMAK 1
@@ -34,6 +34,8 @@
#define MACRO_MUSIC_OFF 14
#define MACRO_AUDIO_ON 15
#define MACRO_AUDIO_OFF 16
+#define MACRO_INC_VOICE 17
+#define MACRO_DEC_VOICE 18
#define M_QWRTY M(MACRO_QWERTY)
#define M_COLMK M(MACRO_COLEMAK)
@@ -54,6 +56,8 @@
#define MUS_OFF M(MACRO_MUSIC_OFF)
#define AUD_OFF M(MACRO_AUDIO_OFF)
#define AUD_ON M(MACRO_AUDIO_ON)
+#define VC_UP M(MACRO_INC_VOICE)
+#define VC_DOWN M(MACRO_DEC_VOICE)
#define SC_UNDO LCTL(KC_Z)
@@ -164,20 +168,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{ _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R },
},
+ [LAYER_MUSIC] = {
+ { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
+ { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
+ { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
+ { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
+ { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_RAISE, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
+ },
+
[LAYER_ADJUST] = { /* ADJUST */
{ _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, _______, MUS_ON, MUS_OFF, AUD_ON, AUD_OFF, ___T___, ___T___ },
{ _______, M_QWRTY, M_COLMK, M_DVORK, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
{ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ },
- { _______, _______, _______, _______, _______, RESET, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ },
- { _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______, _______, _______, _______, _______, _______, _______ },
- },
-
- [LAYER_MUSIC] = {
- { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___ },
- { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
- { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ },
- { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ },
- { _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______, _______, _______, _______, _______, _______, _______ },
+ { _______, _______, _______, _______, _______, RESET, _______, _______, _______, _______, _______, ___T___, ___T___, VC_UP, _______ },
+ { _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______, _______, _______, _______, _______, VC_DOWN, _______ },
},
};
@@ -187,8 +191,8 @@ float tone_my_startup[][2] = SONG(ODE_TO_JOY);
float tone_my_goodbye[][2] = SONG(ROCK_A_BYE_BABY);
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
-float tone_dvorak[][2] = SONG(COLEMAK_SOUND);
-float tone_colemak[][2] = SONG(DVORAK_SOUND);
+float tone_dvorak[][2] = SONG(DVORAK_SOUND);
+float tone_colemak[][2] = SONG(COLEMAK_SOUND);
float tone_audio_on[][2] = SONG(CLOSE_ENCOUNTERS_5_NOTE);
float tone_music_on[][2] = SONG(DOE_A_DEER);
@@ -198,6 +202,7 @@ float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND);
float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND);
float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
+float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
#endif /* AUDIO_ENABLE */
@@ -380,6 +385,26 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
}
break;
+ case MACRO_INC_VOICE:
+ if (record->event.pressed)
+ {
+ #ifdef AUDIO_ENABLE
+ voice_iterate();
+ PLAY_NOTE_ARRAY(music_scale, false, STACCATO);
+ #endif
+ }
+ break;
+
+ case MACRO_DEC_VOICE:
+ if (record->event.pressed)
+ {
+ #ifdef AUDIO_ENABLE
+ voice_deiterate();
+ PLAY_NOTE_ARRAY(music_scale, false, STACCATO);
+ #endif
+ }
+ break;
+
default:
break;
@@ -390,12 +415,13 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
#ifdef AUDIO_ENABLE
-uint8_t starting_note = 0x0C;
-int offset = 7;
-
void process_action_user(keyrecord_t *record)
{
+
+ uint8_t starting_note = 0x0C;
+ int offset = 7;
+
if (IS_LAYER_ON(LAYER_MUSIC))
{
if (record->event.pressed)
@@ -412,7 +438,7 @@ void process_action_user(keyrecord_t *record)
void matrix_init_user(void)
{
- init_notes();
+ set_voice(default_voice);
play_startup_tone();
println("Matrix Init");
}
@@ -421,6 +447,8 @@ void led_set_user(uint8_t usb_led)
{
static uint8_t old_usb_led = 0;
+ _delay_ms(10); // gets rid of tick
+
if ((usb_led & (1<<USB_LED_CAPS_LOCK)) && !(old_usb_led & (1<<USB_LED_CAPS_LOCK)))
{
// If CAPS LK LED is turning on...
@@ -457,13 +485,14 @@ void led_set_user(uint8_t usb_led)
void play_startup_tone()
{
+ _delay_ms(10); // gets rid of tick
PLAY_NOTE_ARRAY(tone_my_startup, false, STACCATO);
}
void play_goodbye_tone()
{
PLAY_NOTE_ARRAY(tone_my_goodbye, false, STACCATO);
- _delay_ms(2000);
+ _delay_ms(1000);
}
#endif /* AUDIO_ENABLE */
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index d1ccfdb824..89769507e1 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -50,8 +50,8 @@ void decrease_vibrato_strength(float change);
// Polyphony functions
void set_polyphony_rate(float rate);
-void enable_polyphony();
-void disable_polyphony();
+void enable_polyphony(void);
+void disable_polyphony(void);
void increase_polyphony_rate(float change);
void decrease_polyphony_rate(float change);
@@ -61,7 +61,7 @@ void set_tempo(float tempo);
void increase_tempo(uint8_t tempo_change);
void decrease_tempo(uint8_t tempo_change);
-void audio_init();
+void audio_init(void);
#ifdef PWM_AUDIO
void play_sample(uint8_t * s, uint16_t l, bool r);
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c
index 8b3978f3d8..8861011871 100644
--- a/quantum/audio/voices.c
+++ b/quantum/audio/voices.c
@@ -1,4 +1,5 @@
#include "voices.h"
+#include "stdlib.h"
// these are imported from audio.c
extern uint16_t envelope_index;
@@ -27,26 +28,31 @@ float voice_envelope(float frequency) {
case default_voice:
note_timbre = TIMBRE_50;
polyphony_rate = 0;
- break;
+ break;
+
case butts_fader:
polyphony_rate = 0;
switch (compensated_index) {
case 0 ... 9:
frequency = frequency / 4;
note_timbre = TIMBRE_12;
- break;
+ break;
+
case 10 ... 19:
frequency = frequency / 2;
note_timbre = TIMBRE_12;
- break;
+ break;
+
case 20 ... 200:
note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125;
- break;
+ break;
+
default:
note_timbre = 0;
- break;
+ break;
}
- break;
+ break;
+
case octave_crunch:
polyphony_rate = 0;
switch (compensated_index) {
@@ -56,17 +62,20 @@ float voice_envelope(float frequency) {
frequency = frequency / 2;
note_timbre = TIMBRE_12;
break;
+
case 10 ... 19:
case 25 ... 29:
case 33 ... 35:
frequency = frequency * 2;
note_timbre = TIMBRE_12;
- break;
+ break;
+
default:
note_timbre = TIMBRE_12;
- break;
+ break;
}
- break;
+ break;
+
case duty_osc:
// This slows the loop down a substantial amount, so higher notes may freeze
polyphony_rate = 0;
@@ -78,9 +87,10 @@ float voice_envelope(float frequency) {
// note_timbre = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5;
// triangle wave is a bit faster
note_timbre = (float)abs((compensated_index*OCS_SPEED % 3000) - 1500) * ( OCS_AMP / 1500 ) + (1 - OCS_AMP) / 2;
- break;
+ break;
}
- break;
+ break;
+
case duty_octave_down:
polyphony_rate = 0;
note_timbre = (envelope_index % 2) * .125 + .375 * 2;
@@ -88,18 +98,21 @@ float voice_envelope(float frequency) {
note_timbre = 0.5;
if ((envelope_index % 8) == 0)
note_timbre = 0;
- break;
+ break;
case duty_fifth_down:
note_timbre = 0.5;
if ((envelope_index % 5) == 0)
note_timbre = 0.75;
- break;
+ break;
case duty_fourth_down:
if ((envelope_index % 12) == 0)
note_timbre = 0.25;
else
note_timbre = 0.5;
- break;
+ break;
+
+ default:
+ break;
}
return frequency;
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h
index 718671f77f..cdd14798b1 100644
--- a/quantum/audio/voices.h
+++ b/quantum/audio/voices.h
@@ -22,7 +22,7 @@ typedef enum {
} voice_type;
void set_voice(voice_type v);
-void voice_iterate();
-void voice_deiterate();
+void voice_iterate(void);
+void voice_deiterate(void);
#endif \ No newline at end of file