-
Notifications
You must be signed in to change notification settings - Fork 55
Sounder
HASUMI Hitoshi edited this page Sep 3, 2022
·
8 revisions
| Feature | Version |
|---|---|
| Sounder | 0.9.18+ |
PRK can not only make a beep sound but also play music.
As of 0.9.18, Piezoelectric sounder is supported by Sounder class.
require "sounder"
sounder = Sounder.new(2) # A pin number that connecs to the sounder
sounder.play "c d e f g a b < c"This plays "Do Re Mi Fa So La Ti Do"
It creates a new song but doesn't play it.
sounder.compile "c e g f e f d c"You can also pass variable-length arguments like this:
sounder.compile "c e g f", "e f d c"It plays the last played (compiled) song.
sounder.replayA wrapper method for Sounder#compile and Sounder#replay.
As in, it accepts variable-length arguments of String.
sounder.play "c e g f", "e f d c"See Examles.
The list of preset songs:
| Name |
|---|
| beepo |
| pobeep |
| beepbeep |
| oneup |
sounder.play :beeposounder = Sounder.new(2)
sounder.play "T200 L8 O5 e16. r32 e r e r c e r g r4. > g"You can add your song to the list:
sounder = Sounder.new(2)
sounder.add_songs :mario, "T200 L8 O5 e16. r32 e r e r c e r g r4. > g"
sounder.play :mariosounder = Sounder.new(2)
kbd.before_report do
if kbd.key_pressed?
sounder.play :beepo
sounder.lock
else
sounder.unlock
end
endsounder.lock and sounder.unlock are for preventing another playback while playing.
See Music Macro Language.
- Getting started
- Keyboard features
- Keycodes (ja)
- Mouse (ja)
- Layers and mode key (ja)
- Debounce
- Composite key
- Split-type keyboard
- Keyscan matrix
- Num Lock, Caps Lock and Scroll Lock
- Useful methods that make you free
- BIOS mode
- Other features
- Examples
- Development
- Contribute to the Wiki
- FAQ