0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-23 14:25:10 +00:00
uxn/projects/examples/devices/audio.usm
2021-05-15 09:44:20 +01:00

80 lines
1.9 KiB
Text

( dev/audio )
@timer $1
@progress $1
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|0100 ( -> )
( theme )
#00ff .System/r DEO2
#0f0f .System/g DEO2
#0ff0 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
( setup synth )
#1202 .Audio0/adsr DEO2
;saw .Audio0/addr DEO2
#0100 .Audio0/length DEO2
#ff .Audio0/volume DEO
BRK
@on-frame ( -> )
( incr ) .timer LDZ #01 ADD .timer STZ
( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ]
( get note )
;melody #00 .progress LDZ ADD2 LDA
( play note )
DUP .Audio0/pitch DEO
( erase last note )
#20 .Screen/color DEO
( draw note )
#00 SWP #0004 MUL2 #0100 SUB2 .Screen/y DEO2
#00 .progress LDZ #0008 MUL2 .Screen/x DEO2
;dot .Screen/addr DEO2
#21 .Screen/color DEO
( incr ) .progress LDZ #01 ADD #1f AND .progress STZ
#00 .timer STZ
BRK
@dot [ 003c 7eff 7e3c 0000 ]
@saw [
0003 0609 0c0f 1215 181b 1e21 2427 2a2d
3033 3639 3b3e 4143 4649 4b4e 5052 5557
595b 5e60 6264 6667 696b 6c6e 7071 7274
7576 7778 797a 7b7b 7c7d 7d7e 7e7e 7e7e
7f7e 7e7e 7e7e 7d7d 7c7b 7b7a 7978 7776
7574 7271 706e 6c6b 6967 6664 6260 5e5b
5957 5552 504e 4b49 4643 413e 3b39 3633
302d 2a27 2421 1e1b 1815 120f 0c09 0603
00fd faf7 f4f1 eeeb e8e5 e2df dcd9 d6d3
d0cd cac7 c5c2 bfbd bab7 b5b2 b0ae aba9
a7a5 a2a0 9e9c 9a99 9795 9492 908f 8e8c
8b8a 8988 8786 8585 8483 8382 8282 8282
8182 8282 8282 8383 8485 8586 8788 898a
8b8c 8e8f 9092 9495 9799 9a9c 9ea0 a2a5
a7a9 abae b0b2 b5b7 babd bfc2 c5c7 cacd
d0d3 d6d9 dcdf e2e5 e8eb eef1 f4f7 fafd ]
@melody [
54 52 54 4f 4b 4f 48 ff
54 52 54 4f 4b 4f 48 ff
54 56 57 56 57 54 56 54
56 52 54 52 54 50 54 ff ]