jackaudio / jack-example-tools Goto Github PK
View Code? Open in Web Editor NEWOfficial examples and tools from the JACK project
License: GNU General Public License v2.0
Official examples and tools from the JACK project
License: GNU General Public License v2.0
This project should have contributing guidelines
It seems the (unwritten?) convention about internal clients vs. drivers appears to be, that the drivers have a jack_
prefix and the internal clients do not.
Both types of shared object files usually (on Linux) live below e.g. /usr/lib/jack/
.
With jack2 <= 1.9.20 and jack-example-tools we provide jack_inprocess.so
, jack_internal_metro.so
and jack_intime.so
. If these are not in fact drivers, they should be renamed (stripped of their jack_
prefix).
Somewhat related and more of a discussion topic:
Would it make sense to have a specific prefix for all internal clients (e.g. internal_
), so that they can be clearly distinguished?
To allow the tools and examples in this project to be built (also when included from other projects), we need to add a build system, that properly supports the detection of external dependencies, while being easy to maintain.
I propose meson for this.
I use alsa_in with my Kinect to share the microphone between Linux and my Windows VM.
Recently Arch Linux switched to using this repository for the example tools rather than the jack2 repo, and I noticed my Kinect audio was broken.
The output of the Kinect sounds like a distorted saw wave when using this version, but is fine when using the jack2 version.
I diffed the 2 files and the differences seem to be minimal (after format cleanup):
--- alsa_in_jack2.c 2022-01-28 21:33:34.016069633 +0100
+++ alsa_in_example_tools.c 2022-01-28 21:34:57.554374312 +0100
@@ -48,6 +48,7 @@
// ------------------------------------------------------ commandline parameters
+const char* alsa_device = "hw:0";
int sample_rate = 0; /* stream rate */
int num_channels = 2; /* count of channels */
int period_size = 1024;
@@ -72,7 +73,6 @@
volatile float output_offset = 0.0;
volatile float output_integral = 0.0;
volatile float output_diff = 0.0;
-volatile int running_freewheel = 0;
snd_pcm_uframes_t real_buffer_size;
snd_pcm_uframes_t real_period_size;
@@ -265,12 +265,6 @@
printf("Unable to set avail min for capture: %s\n", snd_strerror(err));
return err;
}
- /* align all transfers to 1 sample */
- err = snd_pcm_sw_params_set_xfer_align(handle, swparams, 1);
- if (err < 0) {
- printf("Unable to set transfer align for capture: %s\n", snd_strerror(err));
- return err;
- }
/* write the parameters to the playback device */
err = snd_pcm_sw_params(handle, swparams);
if (err < 0) {
@@ -319,8 +313,22 @@
/**
* The freewheel callback.
*/
-void freewheel (int starting, void* arg) {
- running_freewheel = starting;
+void freewheel (int freewheel_starting, void* ignored_arg) {
+ if( freewheel_starting ) {
+ snd_pcm_close( alsa_handle );
+ alsa_handle = 0;
+ // reset resampling parameters
+ resample_mean = 1.0;
+ static_resample_factor = 1.0;
+ resample_lower_limit = 0.25;
+ resample_upper_limit = 4.0;
+ offset_differential_index = 0;
+ offset_integral = 0;
+ } else {
+ alsa_handle = open_audiofd( alsa_device, 1, sample_rate, num_channels, period_size, num_periods);
+ if( alsa_handle == 0 )
+ exit(20);
+ }
}
/**
@@ -329,7 +337,7 @@
*/
int process (jack_nframes_t nframes, void *arg) {
- if (running_freewheel) {
+ if (alsa_handle == 0) {
JSList *node = capture_ports;
while ( node != NULL)
@@ -353,7 +361,7 @@
delay = snd_pcm_avail( alsa_handle );
- delay -= round( jack_frames_since_cycle_start( client ) / static_resample_factor );
+ delay -= round( jack_frames_since_cycle_start( client ) * static_resample_factor );
// Do it the hard way.
// this is for compensating xruns etc...
@@ -435,7 +443,7 @@
if( current_resample_factor > resample_upper_limit ) current_resample_factor = resample_upper_limit;
// Now Calculate how many samples we need.
- rlen = ceil( ((double)nframes) / current_resample_factor )+2;
+ rlen = ceil( ((double)nframes) * current_resample_factor )+2;
assert( rlen > 2 );
// Calculate resample_mean so we can init ourselves to saner values.
@@ -510,7 +518,7 @@
jack_latency_range_t range;
JSList *node;
- range.min = range.max = round(target_delay * static_resample_factor);
+ range.min = range.max = round(target_delay / static_resample_factor);
if (mode == JackCaptureLatency) {
for (node = capture_ports; node; node = jack_slist_next (node)) {
@@ -532,7 +540,7 @@
void alloc_ports( int n_capture, int n_playback ) {
- int port_flags = JackPortIsOutput;
+ int port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
int chn;
jack_port_t *port;
char buf[32];
@@ -627,9 +635,8 @@
int main (int argc, char *argv[]) {
char jack_name[30] = "alsa_in";
- char alsa_device[30] = "hw:0";
- char *server_name = NULL;
int jack_opts = 0;
+ char *server_name = NULL;
extern char *optarg;
extern int optind, optopt;
@@ -654,7 +661,7 @@
num_periods = atoi(optarg);
break;
case 'd':
- strcpy(alsa_device,optarg);
+ alsa_device = strdup (optarg);
break;
case 't':
target_delay = atoi(optarg);
@@ -751,7 +758,7 @@
printf( "selected sample format: %s\n", formats[format].name );
- static_resample_factor = (double) jack_sample_rate / (double) sample_rate;
+ static_resample_factor = (double) sample_rate / (double) jack_sample_rate;
resample_lower_limit = static_resample_factor * 0.25;
resample_upper_limit = static_resample_factor * 4.0;
resample_mean = static_resample_factor;
I'm not sure what exactly is the culprit here, but I highly suspect the lack of transfer alignment to be it.
For now I simply worked around the issue by grabbing the alsa_in binary from an older jack2 package.
Also my command line is alsa_in -j kinect -d hw:2 -p 512 -n 3 -r 16000 -q 4 -c 4
if it matters.
Hi, I'm a Homebrew maintainer and I'm working on a new Homebrew formula for jack-example-tools, as it's been separated from jack. Support for building on macOS was added in #72, and this was created/merged after the latest release. Homebrew prefers that new formulae do not have patches applied to them (an audit will fail if a new formula is patched), so it would be great to have a new release with these changes. Relevant discussion is in Homebrew/homebrew-core#99640. Thanks!
The jack2 repo tracks a bunch of man pages for the tools/example-clients.
These should be included in this repository and be installed alongside the binaries.
To allow easy collaboration, this repository requires a README.md describing the project and the license that applies, a license file and a CONTRIBUTING.md to describe the workflow for contributions in this repository.
Hello,
could you please adopt semantic versioning rather than current version 1? It would help packagers. Thanks.
Those files are meant to be in sync so that changes made to one nicely match the other.
But I see there are a few little things that are different.
Opening a ticket as a reminder to do this.
Hello!
I hope you are doing well!
We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.
Can you enable it, so that we can report it?
Thanks in advance!
PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository
See https://github.com/jackaudio/example-clients/pulls and https://github.com/jackaudio/tools/pulls
We should merge as relevant, close as wont-fix/merge otherwise.
Per most files there is use of tabs, so lets use that.
iodelay.cpp looks awful
Opening ticket as reminder to do this later.
This project should have a changelog
celt is deprecated and replaced by opus.
we should not require it to build this project.
The current github workflows only test against jack1 and jack2 on Linux.
This needs to be extended to also include macOS and Windows (using whichever combination of jack implementations is sensible there).
Some example-clients and tools in jack2 have diverted slightly from the ones in the dedicated repositories (and thus also from here) and new ones have been added.
The below list is a checklist of files that need to be consolidated. All files that have only seen non-functional changes (e.g. indentation, non code changes) are ignored:
A few more test executables are always built alongside jack2 (iodelay.c is actually from the tools repository) and should be merged into this repository as well.
Pipewire-jack provides a libjacknet.so
, but it does not actually implement jack_net (tracked upstream in: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2043).
This leads to build failures with a default build (i.e. meson build && ninja -C build
):
[72/101] Linking target example-clients/jack_net_master
FAILED: example-clients/jack_net_master
cc -o example-clients/jack_net_master example-clients/jack_net_master.p/netmaster.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group -ljacknet -Wl,--end-group
/usr/bin/ld: example-clients/jack_net_master.p/netmaster.c.o: in function `signal_handler':
/home/dave/git/audio/jack-example-tools/build/../example-clients/netmaster.c:41: undefined reference to `jack_net_master_close'
/usr/bin/ld: example-clients/jack_net_master.p/netmaster.c.o: in function `main':
/home/dave/git/audio/jack-example-tools/build/../example-clients/netmaster.c:113: undefined reference to `jack_net_master_open'
/usr/bin/ld: /home/dave/git/audio/jack-example-tools/build/../example-clients/netmaster.c:179: undefined reference to `jack_net_master_send_slice'
/usr/bin/ld: /home/dave/git/audio/jack-example-tools/build/../example-clients/netmaster.c:186: undefined reference to `jack_net_master_recv_slice'
/usr/bin/ld: /home/dave/git/audio/jack-example-tools/build/../example-clients/netmaster.c:195: undefined reference to `jack_net_master_close'
collect2: error: ld returned 1 exit status
[76/101] Linking target example-clients/jack_net_slave
FAILED: example-clients/jack_net_slave
cc -o example-clients/jack_net_slave example-clients/jack_net_slave.p/netslave.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group -ljacknet -Wl,--end-group
/usr/bin/ld: example-clients/jack_net_slave.p/netslave.c.o: in function `signal_handler':
/home/dave/git/audio/jack-example-tools/build/../example-clients/netslave.c:36: undefined reference to `jack_net_slave_close'
/usr/bin/ld: example-clients/jack_net_slave.p/netslave.c.o: in function `main':
/home/dave/git/audio/jack-example-tools/build/../example-clients/netslave.c:128: undefined reference to `jack_net_slave_open'
/usr/bin/ld: /home/dave/git/audio/jack-example-tools/build/../example-clients/netslave.c:135: undefined reference to `jack_set_net_slave_process_callback'
/usr/bin/ld: /home/dave/git/audio/jack-example-tools/build/../example-clients/netslave.c:136: undefined reference to `jack_set_net_slave_shutdown_callback'
/usr/bin/ld: /home/dave/git/audio/jack-example-tools/build/../example-clients/netslave.c:138: undefined reference to `jack_net_slave_activate'
collect2: error: ld returned 1 exit status
Currently it is only possible to build this project without the tooling relying on jacknet (i.e. meson -Djack_net=disabled build && ninja -C build
).
on ubuntustudio 20.04 / meson 0.63.1 / ninja 1.10.2.git.kitware.jobserver-1
compilation fails with following error:
[1/38] Compiling C object example-clients/jack_inprocess.so.p/inprocess.c.o
FAILED: example-clients/jack_inprocess.so.p/inprocess.c.o
ccache cc -Iexample-clients/jack_inprocess.so.p -Iexample-clients -I../example-clients -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -fPIC -MD -MQ example-clients/jack_inprocess.so.p/inprocess.c.o -MF example-clients/jack_inprocess.so.p/inprocess.c.o.d -o example-clients/jack_inprocess.so.p/inprocess.c.o -c ../example-clients/inprocess.c
../example-clients/inprocess.c:59:16: error: expected ‘;’ before ‘int’
59 | JACK_LIB_EXPORT
| ^
| ;
60 | int
| ~~~
../example-clients/inprocess.c:119:16: error: expected ‘;’ before ‘void’
119 | JACK_LIB_EXPORT
| ^
| ;
120 | void
| ~~~~
[4/38] Compiling C object example-clients/jack_intime.so.p/intime.c.o
FAILED: example-clients/jack_intime.so.p/intime.c.o
ccache cc -Iexample-clients/jack_intime.so.p -Iexample-clients -I../example-clients -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -fPIC -MD -MQ example-clients/jack_intime.so.p/intime.c.o -MF example-clients/jack_intime.so.p/intime.c.o.d -o example-clients/jack_intime.so.p/intime.c.o -c ../example-clients/intime.c
../example-clients/intime.c:125:16: error: expected ‘;’ before ‘int’
125 | JACK_LIB_EXPORT
| ^
| ;
126 | int
| ~~~
../example-clients/intime.c:155:16: error: expected ‘;’ before ‘void’
155 | JACK_LIB_EXPORT
| ^
| ;
156 | void
| ~~~~
[10/38] Compiling C++ object example-clients/jack_internal_metro.so.p/internal_metro.cpp.o
Stuff like HAVE_SAMPLERATE
and HAVE_OPUS
is not being set at the moment, leading to all optional features being disabled.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.