waveforms
This commit is contained in:
parent
235dcdeb74
commit
052956ad54
Binary file not shown.
After Width: | Height: | Size: 541 B |
Binary file not shown.
After Width: | Height: | Size: 471 B |
Binary file not shown.
After Width: | Height: | Size: 505 B |
Binary file not shown.
After Width: | Height: | Size: 451 B |
Binary file not shown.
After Width: | Height: | Size: 580 B |
|
@ -254,61 +254,10 @@ as we mentioned above, we can think of the sample data as the equivalent of spri
|
|||
|
||||
they have to be in program memory, they have a specific length, and we can refer to them by labels.
|
||||
|
||||
the audio.channels.tal example in the uxn repository, has several of them, all of them 256 bytes long:
|
||||
the piano.tal example in the uxn repository, has several of them, all of them 256 bytes long:
|
||||
|
||||
```
|
||||
@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
|
||||
@tri
|
||||
8082 8486 888a 8c8e 9092 9496 989a 9c9e
|
||||
a0a2 a4a6 a8aa acae b0b2 b4b6 b8ba bcbe
|
||||
c0c2 c4c6 c8ca ccce d0d2 d4d6 d8da dcde
|
||||
e0e2 e4e6 e8ea ecee f0f2 f4f6 f8fa fcfe
|
||||
fffd fbf9 f7f5 f3f1 efed ebe9 e7e5 e3e1
|
||||
dfdd dbd9 d7d5 d3d1 cfcd cbc9 c7c5 c3c1
|
||||
bfbd bbb9 b7b5 b3b1 afad aba9 a7a5 a3a1
|
||||
9f9d 9b99 9795 9391 8f8d 8b89 8785 8381
|
||||
7f7d 7b79 7775 7371 6f6d 6b69 6765 6361
|
||||
5f5d 5b59 5755 5351 4f4d 4b49 4745 4341
|
||||
3f3d 3b39 3735 3331 2f2d 2b29 2725 2321
|
||||
1f1d 1b19 1715 1311 0f0d 0b09 0705 0301
|
||||
0103 0507 090b 0d0f 1113 1517 191b 1d1f
|
||||
2123 2527 292b 2d2f 3133 3537 393b 3d3f
|
||||
4143 4547 494b 4d4f 5153 5557 595b 5d5f
|
||||
6163 6567 696b 6d6f 7173 7577 797b 7d7f
|
||||
@sin
|
||||
8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad
|
||||
b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7
|
||||
d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4
|
||||
f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe
|
||||
fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6
|
||||
f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb
|
||||
d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3
|
||||
b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683
|
||||
807d 7a77 7471 6e6b 6865 625f 5c59 5653
|
||||
504d 4a47 4542 3f3d 3a37 3532 302e 2b29
|
||||
2725 2220 1e1c 1a19 1715 1412 100f 0e0c
|
||||
0b0a 0908 0706 0505 0403 0302 0202 0202
|
||||
0102 0202 0202 0303 0405 0506 0708 090a
|
||||
0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225
|
||||
2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
|
||||
5053 5659 5c5f 6265 686b 6e71 7477 7a7d
|
||||
@piano
|
||||
@piano-pcm
|
||||
8182 8588 8d91 959b a1a6 aaad b2b5 b8bd
|
||||
c1c7 cbd0 d5d9 dde1 e5e5 e4e4 e1dc d7d1
|
||||
cbc5 bfb8 b2ac a6a2 9c97 928d 8884 807c
|
||||
|
@ -325,9 +274,81 @@ the audio.channels.tal example in the uxn repository, has several of them, all o
|
|||
6f71 7477 7776 7370 6c65 5e56 4e48 423f
|
||||
3d3c 3b3a 3a39 3838 3839 393a 3c3e 4146
|
||||
4a50 575b 6064 686a 6e70 7274 7677 7a7d
|
||||
|
||||
@violin-pcm
|
||||
8186 8d94 9ba0 a3a7 acb1 b5bc c2c7 cacc
|
||||
cecf d0d1 d3d5 d8db dee1 e3e5 e6e5 e5e3
|
||||
dfdc d7d0 c8c2 bbb2 a99f 968c 847c 746e
|
||||
675f 5851 4b43 3e3a 3533 312e 2c2b 2826
|
||||
2422 2122 2327 2d34 3c44 4c57 5f68 7075
|
||||
7b80 8487 8789 8a8c 8d90 9397 999c 9ea0
|
||||
a2a2 a2a0 9c97 9491 8f8e 908f 918f 8e88
|
||||
827a 726a 6058 5047 423f 3f40 4245 4748
|
||||
4949 4746 4545 4a4f 5863 717f 8b9a a6b1
|
||||
b8be c1c1 bfbd bab5 b1af acac aeb1 b7bc
|
||||
c2c9 cfd3 d5d4 d3d3 d1ce cbc6 c0ba b3ab
|
||||
a39a 8f85 7b72 6c67 6462 605f 5e5d 5b58
|
||||
5550 4d49 4848 4949 4a4d 5052 5558 5b5e
|
||||
6164 686c 7074 7677 7979 7a7b 7b7a 7977
|
||||
7473 6f6e 6b69 696b 6f72 7576 7574 716b
|
||||
655d 554e 4742 3f3f 4045 4b52 5a62 6b74
|
||||
|
||||
@sin-pcm
|
||||
8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad
|
||||
b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7
|
||||
d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4
|
||||
f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe
|
||||
fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6
|
||||
f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb
|
||||
d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3
|
||||
b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683
|
||||
807d 7a77 7471 6e6b 6865 625f 5c59 5653
|
||||
504d 4a47 4542 3f3d 3a37 3532 302e 2b29
|
||||
2725 2220 1e1c 1a19 1715 1412 100f 0e0c
|
||||
0b0a 0908 0706 0505 0403 0302 0202 0202
|
||||
0102 0202 0202 0303 0405 0506 0708 090a
|
||||
0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225
|
||||
2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
|
||||
5053 5659 5c5f 6265 686b 6e71 7477 7a7d
|
||||
|
||||
@tri-pcm
|
||||
8082 8486 888a 8c8e 9092 9496 989a 9c9e
|
||||
a0a2 a4a6 a8aa acae b0b2 b4b6 b8ba bcbe
|
||||
c0c2 c4c6 c8ca ccce d0d2 d4d6 d8da dcde
|
||||
e0e2 e4e6 e8ea ecee f0f2 f4f6 f8fa fcfe
|
||||
fffd fbf9 f7f5 f3f1 efed ebe9 e7e5 e3e1
|
||||
dfdd dbd9 d7d5 d3d1 cfcd cbc9 c7c5 c3c1
|
||||
bfbd bbb9 b7b5 b3b1 afad aba9 a7a5 a3a1
|
||||
9f9d 9b99 9795 9391 8f8d 8b89 8785 8381
|
||||
7f7d 7b79 7775 7371 6f6d 6b69 6765 6361
|
||||
5f5d 5b59 5755 5351 4f4d 4b49 4745 4341
|
||||
3f3d 3b39 3735 3331 2f2d 2b29 2725 2321
|
||||
1f1d 1b19 1715 1311 0f0d 0b09 0705 0301
|
||||
0103 0507 090b 0d0f 1113 1517 191b 1d1f
|
||||
2123 2527 292b 2d2f 3133 3537 393b 3d3f
|
||||
4143 4547 494b 4d4f 5153 5557 595b 5d5f
|
||||
6163 6567 696b 6d6f 7173 7577 797b 7d7f
|
||||
|
||||
@saw-pcm
|
||||
8282 8183 8384 8685 8888 8889 8a8b 8c8c
|
||||
8e8e 8f90 9092 9193 9494 9596 9699 9899
|
||||
9b9a 9c9c 9c9d 9ea0 a1a0 a2a2 a3a5 a4a6
|
||||
a7a7 a9a8 a9aa aaac adad aeae b0b0 b1b3
|
||||
b2b4 b5b5 b6b7 b9b8 b9bb babc bdbc bdbe
|
||||
bfc1 bfc1 c3c1 c4c5 c5c6 c6c7 c9c7 cbca
|
||||
cbcc cdcd cfcf d2d0 d2d2 d2d5 d4d5 d6d7
|
||||
d8d8 d9dc d9df dadf dce1 dde5 dce6 dceb
|
||||
cb1f 1b1e 1c21 1c21 1f23 2025 2127 2329
|
||||
2529 2829 2a2b 2b2e 2d2f 302f 3231 3234
|
||||
3334 3536 3836 3939 3a3b 3b3d 3e3d 3f40
|
||||
4042 4242 4444 4646 4748 474a 4a4b 4d4c
|
||||
4e4e 4f50 5052 5252 5554 5557 5759 5959
|
||||
5b5b 5c5d 5d5f 5e60 6160 6264 6365 6566
|
||||
6867 6969 6a6c 6c6d 6d6e 706f 7071 7174
|
||||
7475 7576 7777 797a 7a7c 7b7c 7e7d 7f7f
|
||||
```
|
||||
|
||||
=> https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/examples/devices/audio.channels.tal audio.chanels.tal source code
|
||||
=> https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/examples/demos/piano.tal piano.tal source code
|
||||
|
||||
and what do these numbers mean?
|
||||
|
||||
|
@ -335,22 +356,27 @@ in the context of varvara, we can understand them as multiple unsigned bytes (u8
|
|||
|
||||
a "playhead" visits each of these numbers during a specific time, and uses them to set the amplitude of the sound wave.
|
||||
|
||||
for example, in the case of the saw sample, if we look at it as single bytes instead of shorts, we can see that it consists in a series of numbers going from 00 to fd, increasing by 03 at a time:
|
||||
the following images show the waveform of each one of these samples. when we loop them we get a tone based on that shape!
|
||||
|
||||
```
|
||||
@saw ( as single bytes )
|
||||
00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d
|
||||
( etc )
|
||||
```
|
||||
piano-pcm:
|
||||
=> ./img/screenshot_uxn-waveform_piano.png piano sample waveform
|
||||
|
||||
the sound wave will have the shape of a ramp going up over time.
|
||||
violin-pcm:
|
||||
=> ./img/screenshot_uxn-waveform_violin.png violin sample waveform
|
||||
|
||||
and if we loop it, we would have a ramp going up, and then returning quickly to 00, multiple times: i.e. a "sawtooth" shape.
|
||||
sin-pcm:
|
||||
=> ./img/screenshot_uxn-waveform_sin.png sin sample waveform
|
||||
|
||||
tri-pcm:
|
||||
=> ./img/screenshot_uxn-waveform_tri.png tri sample waveform
|
||||
|
||||
saw-pcm:
|
||||
=> ./img/screenshot_uxn-waveform_saw.png saw sample waveform
|
||||
|
||||
similar to how we have dealt with sprites and with the file device above, in order to set a sample in the audio device, we just have to write its address and its length:
|
||||
|
||||
```
|
||||
;saw .Audio0/addr DEO2 ( set sample address )
|
||||
;saw-pcm .Audio0/addr DEO2 ( set sample address )
|
||||
#0100 .Audio0/length DEO2 ( set sample length )
|
||||
```
|
||||
|
||||
|
@ -382,7 +408,7 @@ in theory, the following program should play our sample at that frequency, or no
|
|||
|
||||
( main program )
|
||||
|0100
|
||||
;saw .Audio0/addr DEO2 ( set sample address )
|
||||
;saw-pcm .Audio0/addr DEO2 ( set sample address )
|
||||
#0100 .Audio0/length DEO2 ( set sample length )
|
||||
|
||||
#3c .Audio0/pitch DEO ( set pitch as middle C )
|
||||
|
@ -448,7 +474,7 @@ the following program has now the five components we need in order to play a sou
|
|||
|
||||
( main program )
|
||||
|0100
|
||||
;saw .Audio0/addr DEO2 ( set sample address )
|
||||
;saw-pcm .Audio0/addr DEO2 ( set sample address )
|
||||
#0100 .Audio0/length DEO2 ( set sample length )
|
||||
#ffff .Audio0/adsr DEO2 ( set envelope )
|
||||
#ff .Audio0/volume DEO ( set maximum volume )
|
||||
|
|
Loading…
Reference in New Issue