Skip to content

Commit 20aed9e

Browse files
committed
docs: clean up & improve readme
docs: move section from readme to todo docs: change proejct description Signed-off-by: Christopher Arndt <[email protected]>
1 parent 6db9cc0 commit 20aed9e

File tree

4 files changed

+95
-19
lines changed

4 files changed

+95
-19
lines changed

LICENSE LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MIT License
1+
# MIT License
22

33
Copyright (c) 2022 - 2023 Christopher Arndt <[email protected]>
44

README.md

+81-15
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,108 @@
11
# jacket
22

3-
A [Nim] wrapper for the [JACK] [C API]
3+
A [Nim] wrapper for the [JACK] client side [C API] aka *libjack*.
44

55

66
## Project status
77

8-
This software is in *alpha status* and has no official release yet.
8+
This software is in *beta status*.
99

1010
The majority of JACK client APIs have been wrapped and are functional (see
1111
[examples]), but some APIs (e.g. threading) still need wrapping. Others, like
1212
the server control or the deprecated session API, will probably not be covered
13-
by these bindings. While this project is in alpha or beta stage, symbol names
14-
may still be changed and things moved around before the first public release.
15-
16-
Also, I plan to add a higher-level abstraction on top of the direct mapping
17-
from Nim procs and types to C functions and types, probably in the form of
18-
a JACK client object, which takes care of creating a JACK client instance,
19-
registering ports and setting up all the callbacks necessary for a well-behaved
20-
JACK application.
13+
by these bindings. While this project is in beta stage, symbol names may still
14+
be changed and things moved around before the first public release.
2115

2216

2317
## Installation
2418

2519
* Clone this repository.
2620
* Change into the `jacket` directory.
2721
* Run [`nimble install`] (or `nimble develop`).
28-
* Run the examples with `nim compile --run examples/<example>.nim` (some also
29-
need `--threads:on`).
22+
* Run the [examples] with `nim compile --run examples/<example>.nim`.
23+
24+
(Some examples need `--threads:on` with Nim < 2.0).
25+
26+
27+
## Usage
28+
29+
Here is a very minimal JACK client application, which just passes audio through
30+
from its single input port to its output port.
31+
32+
Any error checking and handling has been omitted for brevity's sake. See the
33+
files in the [examples] directory for more robust example code.
34+
35+
```nim
36+
import std/os
37+
import system/ansi_c
38+
import jacket
39+
40+
var
41+
jackClient: ClientP
42+
status: cint
43+
exitSignalled: bool = false
44+
inpPort, outPort: PortP
45+
type JackBufferP = ptr UncheckedArray[DefaultAudioSample]
46+
47+
proc signalCb(sig: cint) {.noconv.} =
48+
exitSignalled = true
49+
50+
proc shutdownCb(arg: pointer = nil) {.cdecl.} =
51+
exitSignalled = true
52+
53+
proc processCb(nFrames: NFrames, arg: pointer): cint {.cdecl.} =
54+
var inpbuf = cast[JackBufferP](portGetBuffer(inpPort, nFrames))
55+
var outbuf = cast[JackBufferP](portGetBuffer(outPort, nFrames))
56+
# copy samples from input to output buffer
57+
for i in 0 ..< nFrames:
58+
outbuf[i] = inpbuf[i]
59+
60+
# Create JACK Client ptr
61+
jackClient = clientOpen("passthru", NullOption.ord, status.addr)
62+
# Register audio input and output ports
63+
inpPort = jackClient.portRegister("in_1", JACK_DEFAULT_AUDIO_TYPE, PortIsInput.ord, 0)
64+
outPort = jackClient.portRegister("out_1", JACK_DEFAULT_AUDIO_TYPE, PortIsOutput.ord, 0)
65+
# Set JACK callbacks
66+
jackClient.onShutdown(shutdownCb)
67+
discard jackClient.setProcessCallback(processCb, nil)
68+
# Handle POSIX signals
69+
c_signal(SIGINT, signalCb)
70+
c_signal(SIGTERM, signalCb)
71+
# Activate JACK client ...
72+
discard jackClient.activate()
73+
74+
while not exitSignalled:
75+
sleep(50)
76+
77+
discard jackClient.clientClose()
78+
```
3079

3180

3281
## License
3382

34-
This software is released under the *MIT License*. See the [LICENSE](./LICENSE)
35-
file for more information.
83+
This software is released under the *MIT License*. See the file
84+
[LICENSE.md](./LICENSE.md) for more information.
85+
86+
Please note that the JACK client library (libjack), which this project wraps,
87+
is licensed under the [LGPL-2.1]. This wrapper does not statically or
88+
dynamically link to libjack, but only loads it via the dynamic linker at
89+
run-time.
90+
91+
Software using this wrapper is, in the opinion of its author, not considered a
92+
derivative work of libjack and not required to be released under the LGPL, but
93+
no guarantees are made in this regard and users are advised to employ
94+
professional legal counsel when in doubt.
95+
96+
97+
## Author
98+
99+
*jacket* is written by [Christopher Arndt].
36100

37101

38-
[`nimble install`]: https://github.com/nim-lang/nimble#nimble-usage
39102
[C API]: https://jackaudio.org/api/
103+
[Christopher Arndt]: mailto:[email protected]
40104
[examples]: ./examples
41105
[JACK]: https://jackaudio.org/
106+
[LGPL-2.1]: https://spdx.org/licenses/LGPL-2.1-or-later.html
107+
[`nimble install`]: https://github.com/nim-lang/nimble#nimble-usage
42108
[Nim]: https://nim-lang.org/

TODO.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
# TODO
22

3+
34
## Threading API
45

56
Still needs to be wrapped. How to handle `jack_native_thread_t` type?
67

8+
79
## Internal Clients
810

911
Jack 1 and JACK 2 are disagreeing on the signatures of the functions for
10-
loading and getting a handles for internal clients:
12+
loading and getting a handle for internal clients:
1113

1214
* https://github.com/jackaudio/jack2/blob/develop/common/jack/intclient.h#L66
1315
* https://github.com/jackaudio/headers/blob/2bfa5069718ca4f4dc091e0be845958f2d8a5ba8/intclient.h#L69
1416
* https://jackaudio.org/api/intclient_8h.html#a176a2daf66c8777eb1a845068fd7a822
17+
18+
19+
## Higher level abstraction
20+
21+
Add a higher-level abstraction on top of the direct mapping from Nim procs and
22+
types to C functions and types, in the form of a JACK client object, which
23+
takes care of creating a JACK client instance, registering ports and setting up
24+
all the callbacks necessary for a well-behaved JACK application.

jacket.nimble

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
version = "0.1.0"
44
author = "Christopher Arndt"
5-
description = "A Nim wrapper for the JACK C API"
5+
description = "A Nim wrapper for the JACK client-side C API aka libjack"
66
license = "MIT"
77

8-
srcDir = "src"
8+
srcDir = "src"
99

1010
# Dependencies
1111

0 commit comments

Comments
 (0)