-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoutput.fs
47 lines (39 loc) · 1.15 KB
/
output.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
[IFUNDEF] 2PI
include constants.fs
[ENDIF]
\ setup timestamp; unit will be samples.
variable sample_clock
0 sample_clock !
\ setup channels
variable lchan 0.0e lchan f!
variable rchan 0.0e rchan f!
\ sample clock (timestamp) and channel routines here
: t sample_clock @ ;
: lcget lchan f@ ;
: lcset lchan f! ;
: rcget rchan f@ ;
: rcset rchan f! ;
: clear_channels
0.0e lcset 0.0e rcset ;
: t+ 1 sample_clock +! \ advance the clock
clear_channels
reset-phasor-count ;
\ sending out mono or stereo
: scale_output
BIT_DEPTH f* f>s ;
: panmix ( sig pan -- ) \ will send out to global L and R channels
fabs fsqrt fdup 1e fswap f- frot fdup frot
f* lcget f+ lcset
f* rcget f+ rcset ;
: sendout-32 ( fval -- )
scale_output dup dup dup
0xff and emit \ send 1st byte (least-significant)
8 >> 0xff and emit \ send 2nd byte (16-bit most-significant)
16 >> 0xff and emit \ send 3rd byte (24-bit most-significant)
24 >> 0xff and emit ; \ send 4th byte (32-bit most-significant)
: sendout-16 ( fval -- )
scale_output dup
0xff and emit
8 >> 0xff and emit ;
: stereo_out ( sig sig -- )
lcget sendout-32 rcget sendout-32 ;