summaryrefslogtreecommitdiff
path: root/users/alfrdmalr/alfrdmalr.c
blob: 39d2b62e00350ba71d8b0c4e4d8ed96de1225318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "alfrdmalr.h"
#include "muse.h"

bool muse_mode = false;
uint8_t last_muse_note = 0;
uint16_t muse_counter = 0;
uint8_t muse_offset = 70;
uint16_t muse_tempo = 50;

LEADER_EXTERNS();

void matrix_scan_user(void) {
#ifdef AUDIO_ENABLE
    if (muse_mode) {
        if (muse_counter == 0) {
            uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
            if (muse_note != last_muse_note) {
                stop_note(compute_freq_for_midi_note(last_muse_note));
                play_note(compute_freq_for_midi_note(muse_note), 0xF);
                last_muse_note = muse_note;
            }
        }
        muse_counter = (muse_counter + 1) % muse_tempo;
    } else {
        if (muse_counter) {
            stop_all_notes();
            muse_counter = 0;
        }
    }
#endif

  LEADER_DICTIONARY() {
    leading = false;
    // reset keyboard to bootloader
    SEQ_FIVE_KEYS(KC_R, KC_E, KC_S, KC_E, KC_T) {
      reset_keyboard();
    }
    // minimize window (Windows)
    SEQ_THREE_KEYS(KC_M, KC_I, KC_N) {
      SEND_STRING(SS_LALT(" ")"n");
    }
    leader_end(); 
  }
}