Re: [LAD] Tutorial for programming with JACK

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <kallipygos@...>
Cc: <Linux-audio-dev@...>
Date: Wednesday, February 22, 2012 - 11:30 am

Hi kallipygo,

I can not answer all of your questions, but Harry may jump in and answer
them.

On 02/22/2012 10:56 AM, kallipygos@inbox.lv wrote:

Yes, kind of.

More precisely: you actually only ask JACK for a pointer.
"Where can I read the audio-data from" -> reply: an array starting at
this memory address. similar for write.

> If so then why callback func

No.

> Why not

What's confusing you is that there is no dedicated 'read/write'. You
only ask: where to read from and where to write to.

Those pointers are valid during the whole process callback function.
You usually query them at the start of the process function.

The data that resides in the outputBuffer memory-area (float array) is
/written back/ at the end of each process callback.

(Actually, JACK uses a "zero-copy" approach which makes it rather fast
and efficient: JACK prepares a float[] array for your application to
write _output_ audio to. You ask where that float-array is and write
audio data to it. The next jack-client in the graph will be pointed to
exactly the same memory as _input_. -- although in reality the
implementation is a bit more complicated..)

> How can i detect (list) - all available ports:channels ?

jack_get_ports()

the source of 'jack_lsp' is a good example:
https://github.com/jackaudio/tools/blob/master/lsp.c

> How to automatic connect my client i/o ports to jackd ?

Be very careful with that. Most applications should not do this, but let
the user connect ports: either manually or automatically using
studio/session patchbay tools.

In a studio: the playback1/2 outputs may correspond to a sub-woofer or
be connected to something where you don't want any JACK client to send
audio by default.. Speakers have been killed by auto-connecting JACK
applications.

That being said:
jack_connect(c, jack_port_name(src_port), jack_port_name(dst_port))
but disable it by default or ask the user if s/he wishes to auto-connect
ports,..

> jack_lsp -t

> 32 bit float - does JACK work with other sample formats ?
theoretically yes, practically no.

You can change the data-format for the whole JACK system. It requires
recompiling jack and adapting all jack-clients. e.g. "video-jack" does
that it uses fixed-size RGB videoframes instead of "32bit float"

> mono - is it possible operate with interleaved stereo stream ?
no

> audio - what else as audio ?

JACK as we know it officially only supports audio and MIDI.

but in principle it can any data: control information, video,..

> What about stereo stream ?

yes.

> outputPort = jack_port_register ( client,

One usually uses a for loop and an array of ports:
outputPort[0], outputPort[1]

> If so, then how to write data and sync both seperate(d) channels?

Neither with separate ports.
The First sample is outputPort[0] is played at the same time as the
first sample in outputPort[N].

Some example code to de-interleave N-channel audio:
https://github.com/erikd/sndfile-tools/blob/master/src/jackplay.c

With JACK, two channel (stereo) audio is no different than forty-two
channel sound (or 5.1 or whatever).

One of the big features of jack is its simple interface. There's exactly
ONE format for audio: 32bit float mono channels. No interleaving, no
16/24 bit conversions, no overflow/clipping inside the JACK graph
(floats can go beyond -1.0 .. +1.0).

Clipping is done as last step before the audio goes back to the device.
Bit-dithering [if necessary and wanted] happens inside the server
back-end that interfaces with the audio-device.

Cheers!
robin
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[LAD] Tutorial for programming with JACK, Kris Calabio, (Thu Feb 16, 11:38 pm)
Re: [LAD] Tutorial for programming with JACK, Harry van Haaren, (Sat Feb 18, 2:45 pm)
Re: [LAD] Tutorial for programming with JACK, Kris Calabio, (Fri Feb 17, 2:17 pm)
Re: [LAD] Tutorial for programming with JACK, Robin Gareus, (Fri Feb 17, 3:13 pm)
Re: [LAD] Tutorial for programming with JACK, Neil C Smith, (Sat Feb 18, 11:26 am)
Re: [LAD] Tutorial for programming with JACK, Bill Gribble, (Fri Feb 17, 2:22 pm)
Re: [LAD] Tutorial for programming with JACK, Harry van Haaren, (Wed Feb 22, 1:18 pm)
Re: [LAD] Tutorial for programming with JACK, Joan Quintana, (Fri Feb 24, 10:12 am)
Re: [LAD] Tutorial for programming with JACK, Robin Gareus, (Fri Feb 24, 5:08 pm)
Re: [LAD] Tutorial for programming with JACK, Joan Quintana, (Mon Feb 27, 12:31 am)
Re: [LAD] Tutorial for programming with JACK, Emanuel Rumpf, (Thu Mar 8, 8:41 am)
Re: [LAD] Tutorial for programming with JACK, Paul Davis, (Thu Mar 8, 1:19 am)
Re: [LAD] Tutorial for programming with JACK, Harry van Haaren, (Fri Feb 24, 4:52 pm)
Re: [LAD] Tutorial for programming with JACK, Joan Quintana, (Fri Feb 24, 5:46 pm)
Re: [LAD] Tutorial for programming with JACK, Iain Duncan, (Sat Feb 25, 10:34 pm)
Re: [LAD] Tutorial for programming with JACK, Robin Gareus, (Fri Feb 24, 5:06 pm)
Re: [LAD] Tutorial for programming with JACK, Robin Gareus, (Wed Feb 22, 11:30 am)
Re: [LAD] Tutorial for programming with JACK, Patrick Shirkey, (Thu Feb 16, 11:49 pm)
Re: [LAD] Tutorial for programming with JACK, Kris Calabio, (Fri Feb 17, 12:00 am)
Re: [LAD] Tutorial for programming with JACK, Joel Roth, (Sat Feb 18, 11:06 pm)
Re: [LAD] Tutorial for programming with JACK, Patrick Shirkey, (Fri Feb 17, 12:10 am)