diff options
-rw-r--r-- | docs/modding_your_keyboard.md | 22 | ||||
-rw-r--r-- | keyboards/planck/keymaps/default/keymap.c | 4 | ||||
-rw-r--r-- | keyboards/preonic/keymaps/default/keymap.c | 4 | ||||
-rw-r--r-- | quantum/audio/audio.c | 5 |
4 files changed, 19 insertions, 16 deletions
diff --git a/docs/modding_your_keyboard.md b/docs/modding_your_keyboard.md index 30ff4f91a..29b0b3b0f 100644 --- a/docs/modding_your_keyboard.md +++ b/docs/modding_your_keyboard.md | |||
@@ -1,12 +1,23 @@ | |||
1 | 1 | ||
2 | ## Audio output from a speaker | 2 | ## Audio output from a speaker |
3 | 3 | ||
4 | Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any keyboard that allows access to the C6 or B5 port (`#define C6_AUDIO` and `#define B5_AUDIO`), you can hook up a simple speaker and make it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes. | 4 | Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any keyboard that allows access to the C6 or B5 port (`#define C6_AUDIO` and/or `#define B5_AUDIO`), you can hook up a simple speaker and make it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes. |
5 | 5 | ||
6 | The audio code lives in [quantum/audio/audio.h](https://github.com/qmk/qmk_firmware/blob/master/quantum/audio/audio.h) and in the other files in the audio directory. It's enabled by default on the Planck [stock keymap](https://github.com/qmk/qmk_firmware/blob/master/keyboards/planck/keymaps/default/keymap.c). Here are the important bits: | 6 | If you add this to your `rules.mk`: |
7 | 7 | ||
8 | ``` | 8 | ``` |
9 | #include "audio.h" | 9 | AUDIO_ENABLE = yes |
10 | ``` | ||
11 | |||
12 | there's a couple different sounds that will automatically be enabled without any other configuration: | ||
13 | |||
14 | |||
15 | If you want to implement something custom, you can | ||
16 | |||
17 | ``` | ||
18 | #ifdef AUDIO_ENABLE | ||
19 | #include "audio.h" | ||
20 | #endif | ||
10 | ``` | 21 | ``` |
11 | 22 | ||
12 | Then, lower down the file: | 23 | Then, lower down the file: |
@@ -41,14 +52,11 @@ Wherein we bind predefined songs (from [quantum/audio/song_list.h](https://githu | |||
41 | So now you have something called `tone_plover` for example. How do you make it play the Plover tune, then? If you look further down the keymap, you'll see this: | 52 | So now you have something called `tone_plover` for example. How do you make it play the Plover tune, then? If you look further down the keymap, you'll see this: |
42 | 53 | ||
43 | ``` | 54 | ``` |
44 | PLAY_NOTE_ARRAY(tone_plover, false, LEGATO); // song name, repeat, rest style | 55 | PLAY_SONG(tone_plover); // song name |
45 | PLAY_SONG(tone_plover); // song name (repeat is false, rest is STACCATO) | ||
46 | ``` | 56 | ``` |
47 | 57 | ||
48 | This is inside one of the macros. So when that macro executes, your keyboard plays that particular chime. | 58 | This is inside one of the macros. So when that macro executes, your keyboard plays that particular chime. |
49 | 59 | ||
50 | "Rest style" in the method signature above (the last parameter) specifies if there's a rest (a moment of silence) between the notes. | ||
51 | |||
52 | ## Music mode | 60 | ## Music mode |
53 | 61 | ||
54 | The music mode maps your columns to a chromatic scale, and your rows to octaves. This works best with ortholinear keyboards, but can be made to work with others. All keycodes less than `0xFF` get blocked, so you won't type while playing notes - if you have special keys/mods, those will still work. A work-around for this is to jump to a different layer with KC_NOs before (or after) enabling music mode. | 62 | The music mode maps your columns to a chromatic scale, and your rows to octaves. This works best with ortholinear keyboards, but can be made to work with others. All keycodes less than `0xFF` get blocked, so you won't type while playing notes - if you have special keys/mods, those will still work. A work-around for this is to jump to a different layer with KC_NOs before (or after) enabling music mode. |
diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c index ddb93c885..34a011b0c 100644 --- a/keyboards/planck/keymaps/default/keymap.c +++ b/keyboards/planck/keymaps/default/keymap.c | |||
@@ -16,10 +16,6 @@ | |||
16 | 16 | ||
17 | #include "planck.h" | 17 | #include "planck.h" |
18 | #include "action_layer.h" | 18 | #include "action_layer.h" |
19 | #include "eeconfig.h" | ||
20 | #ifdef AUDIO_ENABLE | ||
21 | #include "audio.h" | ||
22 | #endif | ||
23 | 19 | ||
24 | extern keymap_config_t keymap_config; | 20 | extern keymap_config_t keymap_config; |
25 | 21 | ||
diff --git a/keyboards/preonic/keymaps/default/keymap.c b/keyboards/preonic/keymaps/default/keymap.c index a05117c9e..491f4ae85 100644 --- a/keyboards/preonic/keymaps/default/keymap.c +++ b/keyboards/preonic/keymaps/default/keymap.c | |||
@@ -16,10 +16,6 @@ | |||
16 | 16 | ||
17 | #include "preonic.h" | 17 | #include "preonic.h" |
18 | #include "action_layer.h" | 18 | #include "action_layer.h" |
19 | #include "eeconfig.h" | ||
20 | #ifdef AUDIO_ENABLE | ||
21 | #include "audio.h" | ||
22 | #endif | ||
23 | 19 | ||
24 | enum preonic_layers { | 20 | enum preonic_layers { |
25 | _QWERTY, | 21 | _QWERTY, |
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index baa364eec..8e8570d26 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c | |||
@@ -555,7 +555,10 @@ ISR(TIMER1_COMPA_vect) | |||
555 | note_position++; | 555 | note_position++; |
556 | bool end_of_note = false; | 556 | bool end_of_note = false; |
557 | if (TIMER_1_PERIOD > 0) { | 557 | if (TIMER_1_PERIOD > 0) { |
558 | end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1)); | 558 | if (!note_resting) |
559 | end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1)); | ||
560 | else | ||
561 | end_of_note = (note_position >= (note_length)); | ||
559 | } else { | 562 | } else { |
560 | end_of_note = (note_position >= (note_length)); | 563 | end_of_note = (note_position >= (note_length)); |
561 | } | 564 | } |