|
| 1 | +# Lua Auproc Documentation |
| 2 | + |
| 3 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 4 | +## Contents |
| 5 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 6 | + |
| 7 | + * [Overview](#overview) |
| 8 | + * [Module Functions](#module-functions) |
| 9 | + * [auproc.new_audio_mixer()](#auproc_new_audio_mixer) |
| 10 | + * [auproc.new_midi_mixer()](#auproc_new_midi_mixer) |
| 11 | + * [auproc.new_midi_receiver()](#auproc_new_midi_receiver) |
| 12 | + * [auproc.new_midi_sender()](#auproc_new_midi_sender) |
| 13 | + * [auproc.new_audio_sender()](#auproc_new_audio_sender) |
| 14 | + * [auproc.new_audio_receiver()](#auproc_new_audio_receiver) |
| 15 | + * [Connector Objects](#connector-objects) |
| 16 | + * [Processor Objects](#processor-objects) |
| 17 | + * [processor:activate()](#processor_activate) |
| 18 | + * [processor:deactivate()](#processor_deactivate) |
| 19 | + * [processor:close()](#processor_close) |
| 20 | + |
| 21 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 22 | +## Overview |
| 23 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 24 | + |
| 25 | +This package provides basic [Lua] audio processor objects to be used for realtime audio and |
| 26 | +midi processing. The provided processor objects can be used in conjunction with Lua packages |
| 27 | +that are implementing the [Auproc C API] e.g. [LJACK](https://github.com/osch/lua-ljack) |
| 28 | +or [lrtaudio](https://github.com/osch/lua-lrtaudio). |
| 29 | + |
| 30 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 31 | +## Module Functions |
| 32 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 33 | + |
| 34 | +* <a id="auproc_new_audio_mixer">**` auproc.new_audio_mixer(audioIn[, audioIn]*, audioOut, mixCtrl) |
| 35 | + `**</a> |
| 36 | + |
| 37 | + Returns a new audio mixer object. The audio mixer object is a |
| 38 | + [processor object](#processor-objects). |
| 39 | + |
| 40 | + * *audioIn* - one or more [connector objects](#connector-objects) of type *AUDIO IN*. |
| 41 | + * *audioOut* - [connector object](#connector-objects) of type *AUDIO OUT*. |
| 42 | + * *mixCtrl* - optional sender object for controlling the mixer, must implement |
| 43 | + the [Sender C API], e.g. a [mtmsg] buffer. |
| 44 | + |
| 45 | + The mixer can be controlled by sending messages with the given *mixCtrl* object to the mixer. |
| 46 | + Each message should contain subsequent pairs of numbers: the first number, an integer, |
| 47 | + is the number of the *audioIn* connector (1 means *first connector*), the second number |
| 48 | + of each pair, a float, is the amplification factor that is applied to the corresponding |
| 49 | + input connector given by the first number of the pair. |
| 50 | + |
| 51 | + |
| 52 | + See also [ljack/example06.lua](https://github.com/osch/lua-ljack/blob/master/examples/example06.lua). |
| 53 | + |
| 54 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 55 | + |
| 56 | +* <a id="auproc_new_midi_mixer">**` auproc.new_midi_mixer(midiIn[, midiIn]*, midiOut, mixCtrl) |
| 57 | + `**</a> |
| 58 | + |
| 59 | + * *midiIn* - one or more [connector objects](#connector-objects) of type *MIDI IN*. |
| 60 | + * *midiOut* - [connector object](#connector-objects) of type *MIDI OUT*. |
| 61 | + * *mixCtrl* - optional sender object for controlling the mixer, must implement |
| 62 | + the [Sender C API], e.g. a [mtmsg] buffer. |
| 63 | + |
| 64 | + The mixer can be controlled by sending messages with the given *mixCtrl* object to the mixer. |
| 65 | + Each message should contain subsequent triplets of integers: the first integer |
| 66 | + is the number of the *midiIn* connector (1 means *first connector*), the second integer |
| 67 | + of each triplet is the source channel (1-16) that is to be mapped and the third integer is |
| 68 | + the new channel number (1-16) that the source channel events are mapped to or may be |
| 69 | + 0 to discard events for the given source channel. |
| 70 | + |
| 71 | + See also [ljack/example07.lua](https://github.com/osch/lua-ljack/blob/master/examples/example07.lua). |
| 72 | + |
| 73 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 74 | + |
| 75 | +* <a id="auproc_new_midi_receiver">**` auproc.new_midi_receiver(midiIn, receiver) |
| 76 | + `**</a> |
| 77 | + |
| 78 | + Returns a new midi receiver object. The midi receiver object is a |
| 79 | + [processor object](#processor-objects). |
| 80 | + |
| 81 | + * *midiIn* - [connector object](#connector-objects) of type *MIDI IN*. |
| 82 | + |
| 83 | + * *receiver* - receiver object for midi events, must implement the [Receiver C API], |
| 84 | + e.g. a [mtmsg] buffer. |
| 85 | + |
| 86 | + The receiver object receivers for each midi event a message with two arguments: |
| 87 | + - the time of the midi event as integer value in frame time |
| 88 | + - the midi event bytes, an [carray] of 8-bit integer values. |
| 89 | + |
| 90 | + The midi receiver object is subject to garbage collection. The given port object is owned by the |
| 91 | + midi receiver object, i.e. the port object is not garbage collected as long as the midi receiver |
| 92 | + object is not garbage collected. |
| 93 | + |
| 94 | + See also [ljack/example03.lua](https://github.com/osch/lua-ljack/blob/master/examples/example03.lua). |
| 95 | + |
| 96 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 97 | + |
| 98 | +* <a id="auproc_new_midi_sender">**` auproc.new_midi_sender(midiOut, sender) |
| 99 | + `**</a> |
| 100 | + |
| 101 | + Returns a new midi sender object. The midi sender object is a |
| 102 | + [processor object](#processor-objects). |
| 103 | + |
| 104 | + * *midiOut* - [connector object](#connector-objects) of type *MIDI OUT*. |
| 105 | + |
| 106 | + * *sender* - sender object for midi events, must implement the [Sender C API], |
| 107 | + e.g. a [mtmsg] buffer. |
| 108 | + |
| 109 | + The sender object should send for each midi event a message with two arguments: |
| 110 | + - optional the frame time of the midi event as integer value. If this value is not given, |
| 111 | + the midi event is sent as soon as possible. If this value refers to a frame time in the |
| 112 | + past, the event is discarded. |
| 113 | + - the midi event bytes as [carray] of 8-bit integer values. |
| 114 | + |
| 115 | + The caller is responsible for sending the events in order, i.e. for increasing the frame |
| 116 | + time, i.e. the frame time of the subsequent midi event must be equal or larger then the frame |
| 117 | + time of the preceding midi event. |
| 118 | + |
| 119 | + The midi sender object is subject to garbage collection. The given connector object is owned |
| 120 | + by the midi sender object, i.e. the connector object is not garbage collected as long as the |
| 121 | + midi sender object is not garbage collected. |
| 122 | + |
| 123 | + See also [ljack/example04.lua](https://github.com/osch/lua-ljack/blob/master/examples/example04.lua). |
| 124 | + |
| 125 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 126 | + |
| 127 | +* <a id="auproc_new_audio_sender">**` auproc.new_audio_sender(audioOut, sender) |
| 128 | + `**</a> |
| 129 | + |
| 130 | + Returns a new audio sender object. The audio sender object is a |
| 131 | + [processor object](#processor-objects). |
| 132 | + |
| 133 | + * *audioOut* - [connector object](#connector-objects) of type *AUDIO OUT*. |
| 134 | + |
| 135 | + * *sender* - sender object for sample data, must implement the [Sender C API], e.g. a [mtmsg] buffer. |
| 136 | + |
| 137 | + The sender object should send for each chunk of sample data a message with one or two arguments: |
| 138 | + - optional the frame time of the sample data as integer value in frame time. If this |
| 139 | + value is not given, the samples are played as soon as possible. |
| 140 | + - chunk of sample data, an [carray] of 32-bit float values. |
| 141 | + |
| 142 | + The caller is responsible for sending the events in order, i.e. for increasing the frame |
| 143 | + time. The chunks of sample data may not overlap, i.e. the frame time of subsequent sample |
| 144 | + data chunks must be equal or larger then the frame time of the preceding sample data chunk |
| 145 | + plus the length of the preceding chunk. |
| 146 | + |
| 147 | + The audio sender object is subject to garbage collection. The given connector object is owned |
| 148 | + by the audio sender object, i.e. the connector object is not garbage collected as long as the |
| 149 | + audio sender object is not garbage collected. |
| 150 | + |
| 151 | + See also [ljack/example05.lua](https://github.com/osch/lua-ljack/blob/master/examples/example05.lua). |
| 152 | + |
| 153 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 154 | + |
| 155 | +* <a id="auproc_new_audio_receiver">**` auproc.new_audio_receiver(audioIn, receiver) |
| 156 | + `**</a> |
| 157 | + |
| 158 | + Returns a new audio receiver object. The audio receiver object is a |
| 159 | + [processor object](#processor-objects). |
| 160 | + |
| 161 | + * *audioIn* - [connector object](#connector-objects) of type *AUDIO IN*. |
| 162 | + |
| 163 | + * *receiver* - receiver object for audio samples, must implement the [Receiver C API], |
| 164 | + e.g. a [mtmsg] buffer. |
| 165 | + |
| 166 | + The receiver object receivers for each audio sample chunk a message with two arguments: |
| 167 | + - the time of the audio event as integer value in frame time. |
| 168 | + - the audio sample bytes, an [carray] of 32-bit float values. |
| 169 | + |
| 170 | + The audio receiver object is subject to garbage collection. The given connector object is owned by the |
| 171 | + audio receiver object, i.e. the connector object is not garbage collected as long as the audio receiver |
| 172 | + object is not garbage collected. |
| 173 | + |
| 174 | + See also [ljack/example08.lua](https://github.com/osch/lua-ljack/blob/master/examples/example08.lua). |
| 175 | + |
| 176 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 177 | +## Connector Objects |
| 178 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 179 | + |
| 180 | +Connector objects have to be provided by the package that implements the [Auproc C API]. |
| 181 | +They can be used to connect [processor objects](#processor-objects) with each other. |
| 182 | + |
| 183 | +Connector objects can be of type AUDIO or MIDI and can be used for either INPUT or OUTPUT direction. |
| 184 | + |
| 185 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 186 | +## Processor Objects |
| 187 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 188 | + |
| 189 | +Processor objects are Lua objects for processing realtime audio data. They must be implemented |
| 190 | +in C using the [Auproc C API]. |
| 191 | + |
| 192 | +This packages includes the following procesor objects. The implementations can be seen as examples |
| 193 | +on how to implement procesor objects using the [Auproc C API]. |
| 194 | + |
| 195 | + * [audio mixer](#auproc_new_audio_mixer), implementation: [audio_mixer.c](../src/audio_mixer.c). |
| 196 | + * [midi mixer](#auproc_new_midi_mixer), implementation: [midi_mixer.c](../src/midi_mixer.c). |
| 197 | + * [midi reveicer](#auproc_new_midi_receiver), implementation: [midi_receiver.c](../src/midi_receiver.c). |
| 198 | + * [midi sender](#auproc_new_midi_sender), implementation: [midi_sender.c](../src/midi_sender.c). |
| 199 | + * [audio sender](#auproc_new_audio_sender), implementation: [audio_sender.c](../src/audio_sender.c). |
| 200 | + * [audio receiver](#auproc_new_audio_receiver), implementation: [audio_receiver.c](../src/audio_receiver.c). |
| 201 | + |
| 202 | +The above builtin processor objects are implementing the following methods: |
| 203 | + |
| 204 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 205 | + |
| 206 | +* <a id="processor_activate">**` processor:activate() |
| 207 | + `** </a> |
| 208 | + |
| 209 | + Activates the processor object. A activated processor object is taking part in realtime audio |
| 210 | + processing, i.e. the associated *processCallback* is periodically called in the realtime |
| 211 | + thread. |
| 212 | + |
| 213 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 214 | + |
| 215 | +* <a id="processor_deactivate">**` processor:deactivate() |
| 216 | + `** </a> |
| 217 | + |
| 218 | + Deactivates the processor object. A deactivated processor object can be activated again |
| 219 | + by calling [processor:activate()](#processor_activate). |
| 220 | + |
| 221 | + |
| 222 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 223 | + |
| 224 | +* <a id="processor_close">**` processor:close() |
| 225 | + `** </a> |
| 226 | + |
| 227 | + Closes the processor object. A closed processor object is invalid and cannot be used |
| 228 | + furthermore. |
| 229 | + |
| 230 | + |
| 231 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 232 | + |
| 233 | + |
| 234 | +End of document. |
| 235 | + |
| 236 | +<!-- ---------------------------------------------------------------------------------------- --> |
| 237 | + |
| 238 | +[Lua]: https://www.lua.org |
| 239 | +[auproc]: https://luarocks.org/modules/osch/auproc |
| 240 | +[auproc_cairo]: https://luarocks.org/modules/osch/auproc_cairo |
| 241 | +[auproc_opengl]: https://luarocks.org/modules/osch/auproc_opengl |
| 242 | +[mtmsg]: https://github.com/osch/lua-mtmsg#mtmsg |
| 243 | +[carray]: https://github.com/osch/lua-carray |
| 244 | +[light userdata]: https://www.lua.org/manual/5.4/manual.html#2.1 |
| 245 | +[Receiver C API]: https://github.com/lua-capis/lua-receiver-capi |
| 246 | +[Sender C API]: https://github.com/lua-capis/lua-sender-capi |
| 247 | +[Auproc C API]: https://github.com/lua-capis/lua-auproc-capi |
0 commit comments