-
Notifications
You must be signed in to change notification settings - Fork 0
/
sound
22 lines (17 loc) · 981 Bytes
/
sound
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
sinc sound synthesis
(based on http://slack.net/~ant/bl-synth)
The first difference of a band-limited step is a sinc function (or at least, is closely approximated by same).
So we first generate a bunch of values of the sinc function, at high (near-CPU) resolution. Then, for each offset within one audio sample, we go along and make the table of summed groups, like this:
sinc (not): 0 0 0 1 1 1 0 1 1 1 0 0
offset 0/4: 1 3 2
offset 1/4: 2 3 1
offset 2/4: 3 3
offset 3/4: 0 3 3
Then we just have to keep live a record of all the currently active steps.
Shutdown sequence (needed because abuf is shared):
While running we have [1, 1]
Core wants to exit, sets !C -> [0, 1]
Core spins on !A
Audio sees !C, fills audio with silence and sets !A -> [0, 0]
Core sees !A, exits (and abuf is destroyed)
Audio continues writing silence and thread eventually exits