Skip to content

Commit 76ad432

Browse files
committed
initial commit
0 parents  commit 76ad432

30 files changed

+5602
-0
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
os: [ubuntu-latest]
11+
luaVersion: ["5.1", "5.2", "5.3", "5.4", "luajit"]
12+
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- uses: actions/checkout@master
17+
18+
- uses: leafo/gh-actions-lua@master
19+
with:
20+
luaVersion: ${{ matrix.luaVersion }}
21+
22+
- uses: leafo/gh-actions-luarocks@master
23+
24+
- name: build
25+
run: |
26+
set -e
27+
lua -v
28+
luarocks make rockspecs/auproc-scm-0.rockspec
29+
lua -e 'print(require"auproc"); print(require"auproc"._VERSION)'
30+
31+

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/build
2+
/src/sandbox.mk
3+
*.o
4+
*.so
5+
*.dll
6+
a.out

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Oliver Schmidt
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# lua-auproc
2+
[![Licence](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
3+
[![build status](https://github.com/osch/lua-auproc/workflows/build/badge.svg)](https://github.com/osch/lua-auproc/actions/workflows/build.yml)
4+
[![Install](https://img.shields.io/badge/Install-LuaRocks-brightgreen.svg)](https://luarocks.org/modules/osch/auproc)
5+
6+
<!-- ---------------------------------------------------------------------------------------- -->
7+
8+
This package provides basic [Lua] audio processor objects to be used for realtime audio and
9+
midi processing. The provided processor objects can be used in conjunction with Lua packages
10+
that are implementing the [Auproc C API] e.g. [LJACK](https://github.com/osch/lua-ljack)
11+
or [lrtaudio](https://github.com/osch/lua-lrtaudio).
12+
13+
[Lua]: https://www.lua.org
14+
[Auproc C API]: https://github.com/lua-capis/lua-auproc-capi
15+
16+
<!-- ---------------------------------------------------------------------------------------- -->
17+
18+
#### Further reading:
19+
* [Documentation](./doc/README.md#auproc-documentation)
20+
* [LJACK Examples](https://github.com/osch/lua-ljack/tree/master/examples#ljack-examples)
21+
22+
<!-- ---------------------------------------------------------------------------------------- -->
23+
24+

doc/README.md

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
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

rockspecs/auproc-scm-0.rockspec

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package = "auproc"
2+
version = "scm-0"
3+
source = {
4+
url = "https://github.com/osch/lua-auproc/archive/master.zip",
5+
dir = "lua-auproc-master",
6+
}
7+
description = {
8+
summary = "Simple audio processor objects",
9+
homepage = "https://github.com/osch/lua-auproc",
10+
license = "MIT",
11+
detailed = [[
12+
Simple audio processor objects that can be used
13+
with ljack ( https://luarocks.org/modules/osch/ljack )
14+
or lrtaudio ( https://luarocks.org/modules/osch/lrtaudio )
15+
]],
16+
}
17+
dependencies = {
18+
"lua >= 5.1, <= 5.4",
19+
}
20+
build = {
21+
type = "builtin",
22+
modules = {
23+
auproc = {
24+
sources = {
25+
"src/main.c",
26+
"src/auproc_compat.c",
27+
28+
"src/midi_sender.c",
29+
"src/midi_receiver.c",
30+
"src/midi_mixer.c",
31+
32+
"src/audio_sender.c",
33+
"src/audio_receiver.c",
34+
"src/audio_mixer.c"
35+
},
36+
defines = { "AUPROC_VERSION="..version:gsub("^(.*)-.-$", "%1") },
37+
},
38+
}
39+
}

0 commit comments

Comments
 (0)