-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNOTES
97 lines (75 loc) · 3.91 KB
/
NOTES
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
90
91
92
93
94
95
96
97
Channel architecture:
any number of inputs. Each input can be routed to any number of FX sends,
either post- or pre-fade.
Mono inputs are converted to stereo when sent, and the stereo return's gain
is given in the fx chain's specification. Each fx chain has a return gain,
an optional input gain, and a number of ladspa effects each with their
own parameters.
All values (gain, pans, fx params) have an optional ctrl channel name
in brackets. This specifies a control channel which can change the value.
Control channels have a name, an input (diamond variable, midi cc, OSC??)
and a mapping to get the value to 0-1 range. The 0-1 value is mapped
to the final range when set in the controlled Value.
A single physical control input can control multiple control channels,
so (say) midi cc 15 on midi channel 1 can control several gains and pans.
Todo:
* effects chains
* get output buffer from output effect
Data flows for control data:
In source and main threads:
Data arrives at source, which is polling.
Source works out which controller(s) (Ctrls) need updating with it.
Data arrives at Ctrl, which performs range conversions in->0/1->out,
and adds new data to its ring buffer
In process thread:
Process calls poll in all ctrls
if data in ring buffer, ctrl pulls data and sets target in all
the values it controls
Values update periodically to bring them closer to target
Channels/Effects get() values to work with.
Audio data flow (in process thread):
for each effect: zero effect input buffers
for each channel: (mixChannels calls mix)
mix the channel into the stereo buffers
if there is a send,
for mono pre-fade send, add left channel to
given input in given chain
for stereo pre-fade send, add channels to given
inputs in given chain
for mono post-fade send, add either left or right
tmp channel to given input in given chain
for stereo post-fade send, add tmp channels to given
inputs in given chain
for each chain:
input buffers should all be filled, and if not will be zero
for each effect:
ensure all ports connected to buffers (done at parsing)
run effect
output buffers should now have data
apply pan and gain to output buffers and add to output.
Monitoring injects data directly into the Value, so that Values
without controls can be changed in the monitor.
The monitor uses two ring buffers - one is fed with MonitorData
blocks, containing data for all channels, in process(). It is
read by the main thread and written by the processing thread. The
other contains MonitorCommand structures, and is written by the
main thread and read by the processing thread.
How effect chains work:
Each chain has a pair of named inputs, which are mono buffers,
given the special names LEFT and RIGHT.
The outputs of a chain are 2 pointers to some output buffers within
owned effects. They have associated gain/pan values.
chains are sets of effects, stored as both a map (so we can
get the effect) and a vector (so we can run them in order added).
Each effect has a unique name within the chain (not its effect
name) so we can ID multiple instances of the same effect uniquely
Each output port in the effect owns a buffer to write to. These
are zeroed on initialisation.
When a chain runs, the inputs should have been filled by sends.
Each effect runs in the order they were added.
Each effect reads its inputs - which can come from a chain input
or the output of another effect - and runs, writing to its output
buffer.
It may be necessary to give all effects a buffer for each input,
if we need to set gains. But hopefully effects will handle this
internally.