diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 49 |
1 files changed, 49 insertions, 0 deletions
| @@ -377,6 +377,55 @@ You can currently send 4 hex digits with your OS-specific modifier key (RALT for | |||
| 377 | 377 | ||
| 378 | Enable the backlight from the Makefile. | 378 | Enable the backlight from the Makefile. |
| 379 | 379 | ||
| 380 | ## Driving a speaker - audio support | ||
| 381 | |||
| 382 | Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any keyboard that allows access to the C6 port, you can hook up a simple speaker and have it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes. | ||
| 383 | |||
| 384 | The audio code lives in [quantum/audio/audio.h](/quantum/audio/audio.h) and in the other files in the audio directory. It's enabled by default on the Planck [stock keymap](/keyboard/planck/keymaps/default/keymap.c). Here are the important bits: | ||
| 385 | |||
| 386 | ``` | ||
| 387 | #include "audio.h" | ||
| 388 | ``` | ||
| 389 | |||
| 390 | Then, lower down the file: | ||
| 391 | |||
| 392 | ``` | ||
| 393 | float tone_startup[][2] = { | ||
| 394 | ED_NOTE(_E7 ), | ||
| 395 | E__NOTE(_CS7), | ||
| 396 | E__NOTE(_E6 ), | ||
| 397 | E__NOTE(_A6 ), | ||
| 398 | M__NOTE(_CS7, 20) | ||
| 399 | }; | ||
| 400 | ``` | ||
| 401 | |||
| 402 | This is how you write a song. Each of these lines is a note, so we have a little ditty composed of five notes here. | ||
| 403 | |||
| 404 | Then, we have this chunk: | ||
| 405 | |||
| 406 | ``` | ||
| 407 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
| 408 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
| 409 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
| 410 | float tone_plover[][2] = SONG(PLOVER_SOUND); | ||
| 411 | float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); | ||
| 412 | |||
| 413 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
| 414 | float goodbye[][2] = SONG(GOODBYE_SOUND); | ||
| 415 | ``` | ||
| 416 | |||
| 417 | Wherein we bind predefined songs (from [audio/song_list.h](/audio/song_list.h)) into named variables. This is one optimization that helps save on memory: These songs only take up memory when you reference them in your keymap, because they're essentially all preprocessor directives. | ||
| 418 | |||
| 419 | 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: | ||
| 420 | |||
| 421 | ``` | ||
| 422 | PLAY_NOTE_ARRAY(tone_plover, false, 0); // Signature is: Song name, repeat, rest style | ||
| 423 | ``` | ||
| 424 | |||
| 425 | This is inside one of the macros. So when that macro executes, your keyboard plays that particular chime. | ||
| 426 | |||
| 427 | "Rest style" in the method signature above (the last parameter) specifies if there's a rest (a moment of silence) between the notes. | ||
| 428 | |||
| 380 | ## MIDI functionalty | 429 | ## MIDI functionalty |
| 381 | 430 | ||
| 382 | This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile. | 431 | This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile. |
