-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathBlip.fs
89 lines (76 loc) · 1.64 KB
/
Blip.fs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
######################################################
##
## Blip:
##
## A set of reusable sound effects for video games
## based around generating raw 8-bit samples for
## the Audio port.
##
## John Earnest
##
######################################################
: square 4 / / 2 mod 128 * ;
: noise 4 / / 2 mod RN @ 96 mod 32 + * ;
: saw 4 / swap over mod swap 127 swap / * ;
: square-note 2000 for i over square AU ! next drop ;
: noise-note 2000 for i over noise AU ! next drop ;
: saw-note 2000 for i over saw AU ! next drop ;
:const C-3 245 :const C$3 231 :const D-3 218
:const D$3 206 :const E-3 194 :const F-3 183
:const F$3 173 :const G-3 163 :const G$3 154
:const A-3 145 :const A$3 137 :const B-3 130
:data scale-3 C-3 C$3 D-3 D$3 E-3 F-3 F$3 G-3 G$3 A-3 A$3 B-3
#######################################################
##
## Effects
##
#######################################################
: scratch
250 for RN @ 96 mod AU ! next
1750 for 0 AU ! next
;
: bounce
2000 for
i dup 23 / 50 + square AU !
next
;
: dunk
2000 for
i 2000 over - 23 / 50 + square AU !
next
;
: brap
0 2000 for
RN @ 32 mod if RN @ 4 mod + then dup AU !
next drop
;
#######################################################
##
## Demos
##
#######################################################
: main
brap
50 for sync next
halt
;
(
:data instr square-note noise-note saw-note
: note
RN @ 12 mod scale-3 + @
RN @ 3 mod instr + @ exec
;
:data effects scratch bounce dunk note
: effect
RN @ 4 mod effects + @ exec
;
: main
loop
keys key-a and if
effect
loop sync keys key-a and while
then
sync
again
;
)