Git Product home page Git Product logo

jack-example-tools's People

Contributors

0evsg avatar 7890 avatar adiknoth avatar camille-sound4 avatar dehnhardt avatar dmanam avatar dvzrv avatar elboulangero avatar erikd avatar falktx avatar fjapinteric avatar fps avatar karllinden avatar kimjeongyeon avatar krasjet avatar luzpaz avatar mildsunrise avatar nedko avatar pauldavisthefirst avatar petern avatar rncbc avatar schnitzeltony avatar sletz avatar smiszym avatar tiny69712 avatar tmatth avatar torbenh3 avatar trebmuh avatar valentindavid avatar x42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jack-example-tools's Issues

Evaluate correct naming for internal clients (which are not drivers)

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?

Add build system

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.

alsa_in broken with Kinect, works with jack2 version

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.

New release for Homebrew formula

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!

Add README, license file and contribution guidelines

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.

Use semantic versioning

Hello,

could you please adopt semantic versioning rather than current version 1? It would help packagers. Thanks.

Reporting a vulnerability

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

Consistency for tabs vs spaces

Per most files there is use of tabs, so lets use that.

iodelay.cpp looks awful

Opening ticket as reminder to do this later.

Add CI for macOS and Windows

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).

  • macOS (#72)
  • Windows

Compare and merge jack2 example-clients and tools

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:

  • example-clients/capture_client.c <--> jack2/example-clients/capture_client.c #12
  • example-clients/impulse_grabber.c <--> jack2/example-clients/impulse_grabber.c #13
  • example-clients/inprocess.c <--> jack2/example-clients/inprocess.c #36
  • example-clients/latent_client.c <--> jack2/example-clients/latent_client.c #14
  • example-clients/metro.c <--> jack2/example-clients/metro.c #15
  • example-clients/midiseq.c <--> jack2/example-clients/midiseq.c #16
  • example-clients/midisine.c <--> jack2/example-clients/midisine.c #17
  • example-clients/showtime.c <--> jack2/example-clients/showtime.c #18
  • example-clients/simple_client.c <--> jack2/example-clients/simple_client.c #19
  • tools/alsa_in.c <--> jack2/tools/alsa_in.c #20
  • tools/alsa_out.c <--> jack2/tools/alsa_out.c #21
  • tools/connect.c <--> jack2/tools/connect.c #22
  • tools/evmon.c <--> jack2/tools/evmon.c #23
  • tools/freewheel.c <--> jack2/tools/freewheel.c #24
  • tools/iodelay.c <--> jack2/tests/iodelay.cpp #25
  • tools/ipload.c <--> jack2/tools/ipload.c #26
  • tools/ipunload.c <--> jack2/tools/ipunload.c #27
  • tools/midi_dump.c <--> jack2/tools/midi_dump.c #28
  • tools/monitor_client.c <--> jack2/tools/monitor_client.c #29
  • tools/netsource.c <--> jack2/tools/netsource.c #37
  • tools/property.c <--> jack2/tools/property.c #30
  • tools/samplerate.c <--> jack2/tools/samplerate.c #31
  • tools/session_notify.c <--> jack2/tools/session_notify.c #32
  • tools/transport.c <--> jack2/tools/transport.c #33
  • tools/tw.c <--> jack2/tools/tw.c #34
  • tools/wait.c <--> jack2/tools/wait.c #35

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.

Features relying on jack_net can not be built using pipewire-jack

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).

compilation error

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.