-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
\ playing sound with a passive buzzer | ||
523 constant: C | ||
554 constant: C1 | ||
587 constant: D | ||
622 constant: Eb | ||
659 constant: E | ||
698 constant: F | ||
740 constant: F1 | ||
784 constant: G | ||
831 constant: Ab | ||
880 constant: A | ||
932 constant: Bb | ||
988 constant: B | ||
1047 constant: c | ||
1109 constant: c1 | ||
1175 constant: d | ||
1245 constant: eb | ||
1319 constant: e | ||
1397 constant: f | ||
1479 constant: f1 | ||
1567 constant: g | ||
1661 constant: ab | ||
1761 constant: a | ||
1866 constant: bb | ||
1976 constant: b | ||
|
||
create: song e , e , e , c , e , g , G , c , G , E , A , B , Bb , | ||
A , G , e , g , a , f , g , e , c , d , B , c , | ||
|
||
create: tempo 6 , 12 , 12 , 6 , 12 , 24 , 24 , 18 , 18 , 18 , 12 , 12 , | ||
6 , 12 , 8 , 8 , 8 , 12 , 6 , 12 , 12 , 6 , 6 , 6 , 12 , | ||
|
||
4 constant: PIN \ d2 | ||
create: PWM_PINS PIN c, | ||
PIN GPIO_OUT gpio-mode | ||
PWM_PINS 1 pwm-init | ||
1023 pwm-duty | ||
|
||
: play ( -- ) | ||
25 0 do | ||
pwm-start | ||
song i cells + @ pwm-freq | ||
tempo i cells + @ 20 * ms | ||
pwm-stop | ||
1000 us | ||
loop ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
\ playing sound with a passive buzzer | ||
|
||
129 constant: cL | ||
139 constant: cLS | ||
146 constant: dL | ||
156 constant: dLS | ||
163 constant: eL | ||
173 constant: fL | ||
185 constant: fLS | ||
194 constant: gL | ||
207 constant: gLS | ||
219 constant: aL | ||
228 constant: aLS | ||
232 constant: bL | ||
261 constant: c | ||
277 constant: cS | ||
294 constant: d | ||
311 constant: dS | ||
329 constant: e | ||
349 constant: f | ||
370 constant: fS | ||
391 constant: g | ||
415 constant: gS | ||
440 constant: a | ||
455 constant: aS | ||
466 constant: b | ||
523 constant: cH | ||
554 constant: cHS | ||
587 constant: dH | ||
622 constant: dHS | ||
659 constant: eH | ||
698 constant: fH | ||
740 constant: fHS | ||
784 constant: gH | ||
830 constant: gHS | ||
880 constant: aH | ||
910 constant: aHS | ||
933 constant: bH | ||
|
||
create: song a , a , a , f , cH , a , f , cH , a , eH , eH , eH , fH , cH , gS , f , cH , a , aH , a , a , aH , gHS , | ||
gH , fHS , fH , fHS , aS , dHS , dH , cHS , cH , b , cH , f , gS , f , a , cH , a , cH , eH , aH , a , a , | ||
aH , gHS , gH , fHS , fH , fHS , aS , dHS , dH , cHS , cH , b , cH , f , gS , f , cH , a , f , c , a , | ||
|
||
create: tempo 500 , 500 , 500 , 350 , 150 , 500 , 350 , 150 , 1000 , 500 , 500 , 500 , 350 , 150 , 500 , 350 , 150 , | ||
1000 , 500 , 350 , 150 , 500 , 250 , 250 , 125 , 125 , 250 , 250 , 500 , 250 , 250 , 125 , 125 , 250 , | ||
125 , 500 , 375 , 125 , 500 , 375 , 125 , 1000 , 500 , 350 , 150 , 500 , 250 , 250 , 125 , 125 , 250 , | ||
250 , 500 , 250 , 250 , 125 , 125 , 250 , 250 , 500 , 375 , 125 , 500 , 375 , 125 , 1000 , | ||
|
||
4 constant: PIN \ d2 | ||
|
||
create: PWM_PINS PIN c, | ||
|
||
PIN GPIO_OUT gpio-mode | ||
PWM_PINS 1 pwm-init | ||
1023 pwm-duty | ||
|
||
: play ( -- ) | ||
66 0 do | ||
pwm-start | ||
song i cells + @ pwm-freq | ||
tempo i cells + @ ms | ||
pwm-stop | ||
20 ms | ||
i case | ||
26 of 250 ms endof | ||
34 of 250 ms endof | ||
52 of 250 ms endof | ||
60 of 250 ms endof | ||
drop | ||
endcase | ||
loop ; |