JuliaAudio / JACKAudio.jl

Access Audio I/O using the JACK Audio Connection Kit from Julia
Other
27 stars 7 forks source link

WIP: Upgrade to julia 1.0 #10

Open garrison opened 4 years ago

garrison commented 4 years ago

I would be very interested to see this package work on modern versions of julia, so I attempted updating it myself. I did not see the discussion in #6 before I started this. Right now on my system it gets as far as complaining that it cannot find libjack, which is much further than it got previously.

garrison commented 4 years ago

BTW, it is only now that I see (via SampledSignals.jl) that there is also PortAudio.jl. If that is indeed the recommended way now it would be nice to link that from the README. In particular, I am left wondering: is it able to achieve as low latency as JACKAudio.jl?

ssfrr commented 4 years ago

I unfortunately don't have time to maintain this package any more, so I just added a note saying as much to the README. Sorry to waste your time - thanks for looking into this!

I think the best path forward is to add JACK support to PortAudio.jl. Please see this issue.

PortAudio.jl is also in a bit of an in-between state right now but at least it's pretty close to working. The master branch works for most folks, but there are a few issues I need to work out before doing a release.

PortAudio.jl uses a read/write interface exposed by the underlying libportaudio library. This necessarily introduces an extra block of latency relative to implementing the JACK callback directly. The problem is that implementing the callback directly in Julia is a problem because you can't call into the Julia runtime from a different thread. You end up needing to be super careful about how the callback is written (which is what I tried with JACKAudio.jl). Then changes in the Julia compiler can end up causing segfaults because something that didn't allocate memory before starts needing to allocate.

Another approach is to implement the callback in C and then pass data to Julia via a ringbuffer. This is what PortAudio.jl used to do, using RingBuffers.jl. This ends up adding the extra block of latency, so at that point you might as well just use libportaudio's built-in blocking read/write API, which is what the new master branch of PortAudio.jl does.

So long story short, if you're interested in getting JACK working in Julia, the best way would be to help get libportaudio compiling with the right flags to support JACK. Latency won't be quite as good or reliable as a static C program using JACK directly, but this thread reported being able to get down to around 10ms round-trip latency.