Writing Jack driver

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Writing Jack driver

Pierre C

        Hello everybody.

        I have designed an ethernet audio device. It can stream audio to/from a
PC with a configurable number of channels / sample bits / sample rate. It
uses UDP packets.
        It works quite well and I want to write a Jack driver for it.

        Where do I start ? I have grokked the driver sources (dummy_driver.*) in
the Jack sources ; it doesn't look horrendously complicated but I would
appreciate if someone could point me in the right direction.

        I thought about writing a Jack client application, but the main point
which gives me problems is the audio clock. The clock is in the device, so
the PC must be slaved to it. It sends periodic packets to the PC with a
sample clock count ; it also sends how much data there is in the onbard
buffers. So :

        - Should I write a client application or a soundcard driver ?
        - How do I synchronize Jack with the onboard clock which is inside the
device ?

        Thanks for your help !

        Pierre

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Writing Jack driver

Jussi Laako
Hi,

> - Should I write a client application or a soundcard driver ?

I think you should write a driver (aka backend).

> - How do I synchronize Jack with the onboard clock which is inside the
> device ?

You generate jack processing cycle with a timestamp each time get packet.


        - Jussi

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Writing Jack driver

David-71
In reply to this post by Pierre C
On Sat, 04 Nov 2006 19:29:04 +0100
Listmail <[hidden email]> wrote:

>
> Hello everybody.
>
> I have designed an ethernet audio device. It can stream audio
> to/from a PC with a configurable number of channels / sample bits /
> sample rate. It uses UDP packets.
> It works quite well and I want to write a Jack driver for it.
>
> Where do I start ? I have grokked the driver sources
> (dummy_driver.*) in the Jack sources ; it doesn't look horrendously
> complicated but I would appreciate if someone could point me in the
> right direction.
>
> I thought about writing a Jack client application, but the
> main point which gives me problems is the audio clock. The clock is
> in the device, so the PC must be slaved to it. It sends periodic
> packets to the PC with a sample clock count ; it also sends how much
> data there is in the onbard buffers. So :
>
> - Should I write a client application or a soundcard driver ?
> - How do I synchronize Jack with the onboard clock which is
> inside the device ?

You said your device works, so you certainly have written a piece of
software for your PC, no ? Is it enslaved to the onboard clock ? If
so, it could use it to time jackd.

I am no expert, this needs confirmation.

--
David


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Writing Jack driver

Pierre C
In reply to this post by Jussi Laako


> I think you should write a driver (aka backend).

        Alright.

> You generate jack processing cycle with a timestamp each time get packet.

        OK ; so instead of Jack calling my code (the usual way) it's my driver  
calling Jack ?

        Please tell me if I understood correctly :

        If my device sends audio capture (record) data, I just needs a thread  
that waits for a data packet, and when received, runs a Jack cycle on the  
received data, gets Jack playback samples and sends them.

        However if the ADCs are not activated to save bandwidth, i will have a  
thread that :
        - keeps a local sample counter Clocal which is incremented by packet size  
each time a playback packet is sent

then the thread :
blocks on a socket waiting for device packets
when a packet arrives,
        run a jack cycle to process the capture data if present
        check the sample clock count Cdevice in the packet
        while Clocal < Cdevice :
                ask jack for data to play, send packet, increment Clocal

        I was thinking about complicated stuff but... I just realized I need only  
one thread. Is this it ?
        Can you tell me if this is the right thing to do then I start coding.

> You said your device works, so you certainly have written a piece of
> software for your PC, no ? Is it enslaved to the onboard clock ? If
> so, it could use it to time jackd.

        Yes, right now it runs through a Python driver which takes samples on  
stdin. I use XMMS with alsa output into a FIFO from whic the driver reads.
        This was really easy to develop and debug, thanks to Python, but of  
course latency is very high, and well, it's not shall we say  
"professionnal" !
        So I will use Jack.

        In case you wonder here's the prototype :
        http://audio.peufeu.com/
        It looks messy, but it works. The only specification for channel count  
and sample rate is (audio data bandwidth) <= (network bandwidth)... FPGAs  
are pretty flexible.



        Thanks !

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Writing Jack driver

Stéphane Letz

Le 5 nov. 06 à 09:28, Listmail a écrit :

>
>
>> I think you should write a driver (aka backend).
>
> Alright.
>
>> You generate jack processing cycle with a timestamp each time get  
>> packet.
>
> OK ; so instead of Jack calling my code (the usual way) it's my  
> driver
> calling Jack ?
>
> Please tell me if I understood correctly :
>
> If my device sends audio capture (record) data, I just needs a thread
> that waits for a data packet, and when received, runs a Jack cycle  
> on the
> received data, gets Jack playback samples and sends them.
>
> However if the ADCs are not activated to save bandwidth, i will  
> have a
> thread that :
> - keeps a local sample counter Clocal which is incremented by  
> packet size
> each time a playback packet is sent
>
> then the thread :
> blocks on a socket waiting for device packets
> when a packet arrives,
> run a jack cycle to process the capture data if present
> check the sample clock count Cdevice in the packet
> while Clocal < Cdevice :
> ask jack for data to play, send packet, increment Clocal
>
> I was thinking about complicated stuff but... I just realized I  
> need only
> one thread. Is this it ?
> Can you tell me if this is the right thing to do then I start coding.

jack backends are of two different type:

- pure "callback based"  ones (like the coreaudio backend on OSX). In  
this case an external callback is used to trigger the backend.

- "thread based" ones: like dummy, alsa, freebob... In this case the  
backend has a blocking read/write behaviour and an additional thread  
is used to handle the backend cycle. Since several backends have this  
way of working, the threading code is separated in libjack/driver.c  
and jack/driver.h files.

You should probably look at the alsa or dummy backend structure and  
do the same for your backend.

Stephane





-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel