Stream Array-Reader/Control-Law
Posted: Thu Sep 24, 2020 9:37 pm
Following from the discussions in this thread, here are some modules which can be used to implement custom control-laws, transfer-curves, etc. within mono, mono4, or poly audio streams, by using a float array as a look-up table.
The principle is the same for all them: The stream input value determines which value(s) to fetch from the float array. Lookup is interpolated so that output values "glide" smoothly from one array element to the next. The valid range of input values is set by "min" and "max" properties, which then spans all of the entries in the array, no matter the size of the array (i.e. the minimum input value looks up the first item in the array, and the maximum input value looks up the last item in the array).
Input values are constrained internally so that you can't fall off the ends of the array. Output values are not constrained at all - it is assumed that the Array only contains valid output values.
There are three versions, all implemented in optimised assembly...
- Sample rate: Lookup happens at every single sample. Can be used mono, mono4, or poly.
- Hopped: Lookup happens every 16 samples (look inside for how to change the hop interval).
- Note On: Strictly for poly streams; lookup only happens at the start of a new note (kinda!).
Where further optimisations might be possible (e.g. for pure mono use), this is noted within the code inside the modules.
The principle is the same for all them: The stream input value determines which value(s) to fetch from the float array. Lookup is interpolated so that output values "glide" smoothly from one array element to the next. The valid range of input values is set by "min" and "max" properties, which then spans all of the entries in the array, no matter the size of the array (i.e. the minimum input value looks up the first item in the array, and the maximum input value looks up the last item in the array).
Input values are constrained internally so that you can't fall off the ends of the array. Output values are not constrained at all - it is assumed that the Array only contains valid output values.
There are three versions, all implemented in optimised assembly...
- Sample rate: Lookup happens at every single sample. Can be used mono, mono4, or poly.
- Hopped: Lookup happens every 16 samples (look inside for how to change the hop interval).
- Note On: Strictly for poly streams; lookup only happens at the start of a new note (kinda!).
Where further optimisations might be possible (e.g. for pure mono use), this is noted within the code inside the modules.