aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c75
1 files changed, 61 insertions, 14 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 5a978d332..e4d7b9185 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -1,4 +1,5 @@
1#include "quantum.h" 1#include "quantum.h"
2#include "timer.h"
2 3
3__attribute__ ((weak)) 4__attribute__ ((weak))
4void matrix_init_kb(void) {} 5void matrix_init_kb(void) {}
@@ -17,11 +18,11 @@ void leader_start(void) {}
17__attribute__ ((weak)) 18__attribute__ ((weak))
18void leader_end(void) {} 19void leader_end(void) {}
19 20
21uint8_t starting_note = 0x0C;
22int offset = 7;
23
20#ifdef AUDIO_ENABLE 24#ifdef AUDIO_ENABLE
21 uint8_t starting_note = 0x0C;
22 int offset = 7;
23 bool music_activated = false; 25 bool music_activated = false;
24 float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
25#endif 26#endif
26 27
27#ifdef MIDI_ENABLE 28#ifdef MIDI_ENABLE
@@ -105,7 +106,7 @@ bool process_record_quantum(keyrecord_t *record) {
105 #ifdef MIDI_ENABLE 106 #ifdef MIDI_ENABLE
106 if (keycode == MI_ON && record->event.pressed) { 107 if (keycode == MI_ON && record->event.pressed) {
107 midi_activated = true; 108 midi_activated = true;
108 PLAY_NOTE_ARRAY(music_scale, false, 0); 109 play_music_scale();
109 return false; 110 return false;
110 } 111 }
111 112
@@ -181,7 +182,6 @@ bool process_record_quantum(keyrecord_t *record) {
181 #ifdef AUDIO_ENABLE 182 #ifdef AUDIO_ENABLE
182 if (keycode == AU_ON && record->event.pressed) { 183 if (keycode == AU_ON && record->event.pressed) {
183 audio_on(); 184 audio_on();
184 audio_on_callback();
185 return false; 185 return false;
186 } 186 }
187 187
@@ -190,31 +190,53 @@ bool process_record_quantum(keyrecord_t *record) {
190 return false; 190 return false;
191 } 191 }
192 192
193 if (keycode == AU_TOG && record->event.pressed) {
194 if (is_audio_on())
195 {
196 audio_off();
197 }
198 else
199 {
200 audio_on();
201 }
202 return false;
203 }
204
193 if (keycode == MU_ON && record->event.pressed) { 205 if (keycode == MU_ON && record->event.pressed) {
194 music_activated = true; 206 music_on();
195 PLAY_NOTE_ARRAY(music_scale, false, 0);
196 return false; 207 return false;
197 } 208 }
198 209
199 if (keycode == MU_OFF && record->event.pressed) { 210 if (keycode == MU_OFF && record->event.pressed) {
200 music_activated = false; 211 music_off();
201 stop_all_notes();
202 return false; 212 return false;
203 } 213 }
204 214
215 if (keycode == MU_TOG && record->event.pressed) {
216 if (music_activated)
217 {
218 music_off();
219 }
220 else
221 {
222 music_on();
223 }
224 return false;
225 }
226
205 if (keycode == MUV_IN && record->event.pressed) { 227 if (keycode == MUV_IN && record->event.pressed) {
206 voice_iterate(); 228 voice_iterate();
207 PLAY_NOTE_ARRAY(music_scale, false, 0); 229 play_music_scale();
208 return false; 230 return false;
209 } 231 }
210 232
211 if (keycode == MUV_DE && record->event.pressed) { 233 if (keycode == MUV_DE && record->event.pressed) {
212 voice_deiterate(); 234 voice_deiterate();
213 PLAY_NOTE_ARRAY(music_scale, false, 0); 235 play_music_scale();
214 return false; 236 return false;
215 } 237 }
216 238
217 if (music_activated) { 239 if (music_activated) {
218 240
219 if (keycode == KC_LCTL && record->event.pressed) { // Start recording 241 if (keycode == KC_LCTL && record->event.pressed) { // Start recording
220 stop_all_notes(); 242 stop_all_notes();
@@ -258,7 +280,7 @@ bool process_record_quantum(keyrecord_t *record) {
258 } 280 }
259 } else { 281 } else {
260 stop_note(freq); 282 stop_note(freq);
261 } 283 }
262 284
263 if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through 285 if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through
264 return false; 286 return false;
@@ -347,4 +369,29 @@ void matrix_scan_quantum() {
347 #endif 369 #endif
348 370
349 matrix_scan_kb(); 371 matrix_scan_kb();
350} \ No newline at end of file 372}
373
374bool is_music_on(void) {
375 return (music_activated != 0);
376}
377
378void music_toggle(void) {
379 if (!music_activated) {
380 music_on();
381 } else {
382 music_off();
383 }
384}
385
386void music_on(void) {
387 music_activated = 1;
388 music_on_user();
389}
390
391void music_off(void) {
392 music_activated = 0;
393 stop_all_notes();
394}
395
396__attribute__ ((weak))
397void music_on_user() {} \ No newline at end of file