[SOLVED] Capturing MODEP Output with jack_capture?

Is there a proper way to use jack_capture in a MODEP context?

Been thinking about ways to record the output of my jamming with a MODEP pedalboard (sounds like @loopmasta has the same idea). Though there are some loopers which do work as LV2 plugins within MODEP (e.g. SooperLooper and Loopor), it doesn’t sound like they can bounce any audio to file. Would be cool, though.

It then hit me that @Giedrius had mentioned jack_capture in a thread about #Zynthian, with @C0d3man. Though it may not have any interface in MOD UI, it could still work well from the CLI. So, installed from git, no complaint whatsoever. Ran the jack_capture command and it complained that no session was running:

Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
>>> jack_client_open() failed, status = 0x11

Then tried jack_server_control which gave me a bunch of stuff ending with:

parameter name = auto-save
parameter id = s
parameter short decs = Save/restore netmaster connection state when restarted
parameter long decs = Save/restore netmaster connection state when restarted
parameter value = 0
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Unknown source port in attempted (dis)connection src_name [port1] dst_name [jackrec:input1]

Now, jack_capture stopped complaining. Was even able to produce audio files…

>>> Warning. Could not set higher priority for a SCHED_OTHER process using setpriority().
>>> Recording to "jack_capture_01.wav". Press <Return> or <Ctrl-C> to stop.
>>> Please wait while writing all data to disk. (shouldn't take long) 
   |"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""|
00:|                                                                 |
01:|                                                                 |
Buffer: 4.03s./4.03s    Time: 0.10m.   DHP: [ ]  Overruns: 0  Xruns: 0
Finished.

But they’re empty. So, Jack (or, at least, jack_capture) isn’t using the right audio port or something?
Would really be neat if we could record our jams.

Hi @Enkerli

I know this problem, too. This (maybe) caused by a dual installation of jackd: one installation by system (located at /usr (e.g. /usr/bin/jackd)) and one “self-made” located at /usr/local. If you call a binary which is linked against the “self-made” jackd but uses the system-jackd-libraries you get this error.

What you can try (if you have installed a jackd by yourself):

  1. Look if a system installed jackd exists: ls /usr/bin/jackd => If there are no dependencies to other packages try to uninstall
  2. Alternativly: try to change the order of looking for libraries:

export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"

or (for a first try):
LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}" jack_capture

Hope that helps!

Regards, Holger

1 Like

Nice lead!

Thanks a lot for the help, Holger! (And for those Zynthian recipes!)

Getting somewhere, but still not to the point where things work.

So, no jackd in /usr/bin/j*. Did try both setting the variable momentarily and exporting it so it sticks. Same issue.

Cannot connect to server socket err = No such file or directory

This is with a “stock install” of MODEP apart from a few LV2 folders added directly to /usr/local/modep/.lv2 without doing an install (and, of course, apart from jack_capture itself).

Also tried with another MODEP card, which has all sorts of things installed, and it has the exact same problem in jack_capture but sudo jack_server_control claims that:

`default' server already active

(Why does it use a backtick? Sheesh!)

Running jack_server_control doesn’t cause this “server already active” error, but then jack_capture still records silence.

My impression is that setting the right port with jack_capture -p might help but my attempts have been in vain (jack_capture -c 2 -p system:capture* and jack_capture --channels 2 --port system:playback* both record silence and all my attempts at finding the right port fail:

Warning, no port(s) with name "hw:playback*".

(Tried with all sorts of combinations of pcm:, pisound:, alsa:, hw:, etc. Just shooting in the dark, here.)

Ha! Got it!
On a whim, did sudo jack_capture (instead of running it as the default pi user)… and it worked!
Actually, the first couple of times, the signal was way too loud (even though headphones plugged on the pisound didn’t sound too loud, even at full blast). Added compression with a negative -10dB makeup, and it produced an appropriate result.
(This is on a plain install of the MODEP card with a few plugins copied directly into /usr/local/modep/.lv2 and jack_capture installed from Github).
Was using two tweaked presets from TAL Noize Mak3r: “BS Juicy Bass TUC” and “LD Mellow Organ”. Controlling with a WX-11 wind controller (setting filter cutoff to respond to CC#2).
Honestly, it’s way too much fun. Will surely spend long hours jamming with this setup, recording continuously. Of course, uncompressed audio takes a lot of room but Jack Capture does support compressed format and this is a 64GB SD card.

Here’s the output of Jack Capture, for reference. (Much more extensive than my non-sudo attempts.)

sudo jack_capture
Jack: JackClient::SetupDriverSync driver sem in flush mode
Jack: JackLinuxFutex::Connect name = jack_sem.0_default_jack_capture
Jack: Clock source : system clock via clock_gettime
Jack: JackLibClient::Open name = jack_capture refnum = 10
Jack: jack_set_graph_order_callback ext_client 1c1f470 client 1c1f470 
Jack: JackClient::Activate
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: JackClient::kBufferSizeCallback buffer_size = 256
Jack: JackClient::Init : period = 5333 computation = 100 constraint = 5333
Jack: JackPosixThread::AcquireRealTimeImp priority = 5
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 2
Jack: JackClient::kActivateClient name = jack_capture ref = 10 
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 4
Jack: JackClient::kGraphOrderCallback
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 4
Jack: JackClient::kGraphOrderCallback
Jack: JackClient::PortRegister ref = 10 name = jack_capture:input1 type = 32 bit float mono audio port_index = 31
Jack: JackClient::PortRegister ref = 10 name = jack_capture:input2 type = 32 bit float mono audio port_index = 32
Jack: WaitGraphChange...
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 4
Jack: JackClient::kGraphOrderCallback
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 4
Jack: JackClient::kGraphOrderCallback
Jack: JackClient::Connect src = mod-monitor:out_1 dst = jack_capture:input1
Jack: WaitGraphChange...
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 4
Jack: JackClient::kGraphOrderCallback
Jack: JackClient::Connect src = mod-monitor:out_2 dst = jack_capture:input2
Jack: WaitGraphChange...
>>> Recording to "jack_capture_01.wav". Press <Return> or <Ctrl-C> to stop.
Jack: JackClient::ClientNotify ref = 10 name = jack_capture notify = 18
   |"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""|
00:|----------------------------------------------------*            |
01:|--------------------------------------------------------*        |
>>> Please wait while writing all data to disk. (shouldn't take long) 
   |"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""|8
00:|-----------------------------------------------------------------!
01:|---------------------------------------------------------------* |
Buffer: 4.03s./4.03s    Time: 0.43m.   DHP: [ ]  Overruns: 0  Xruns: 0
Jack: jack_client_close
Jack: JackClient::Close ref = 10
Jack: JackClient::Deactivate
Jack: JackClient::Deactivate res = 0
Jack: JackPosixThread::Kill
Jack: JackSocketClientChannel::Stop
Jack: JackPosixThread::Kill
Jack: JackClientSocket::Close
Jack: JackClientSocket::Close
Jack: JackLibClient::~JackLibClient
Jack: JackShmReadWritePtr1::~JackShmReadWritePtr1 9
Jack: Succeeded in unlocking 432 byte memory area
Jack: JackLibGlobals Destroy 1c12c78
Jack: ~JackLibGlobals
Jack: no message buffer overruns
Jack: JackPosixThread::Stop
Jack: JackPosixThread::ThreadHandler : exit
Jack: JackShmReadWritePtr::~JackShmReadWritePtr 1
Jack: Succeeded in unlocking 1240 byte memory area
Jack: JackShmReadWritePtr::~JackShmReadWritePtr 0
Jack: Succeeded in unlocking 82287136 byte memory area
Jack: jack_client_close res = 0
Finished.
1 Like

This were also a problem with my first steps with Jack on the Raspi… I am currently working only as root on the system, because it makes no sense for me to use a dedicated user with less rights. So I was implicitly thinking everyone does this also :wink:

Regards, Holger

1 Like

Makes a lot of sense, especially when it’s not plugged into Ethernet (and there’s nobody with bad intentions within WiFi range). Might be something @Giedrius could add to instructions.

Would be neat to have a simple transport in MOD UI, to turn Jack Capture on and off. Or maybe through MIDI, OSC, HID…

2 Likes

Added a short note to MODEP’s docs about running as root.

You could customize the button behavior for this, if you’d figure out which commands would have to be executed.

1 Like

Ha! Good point! Hadn’t thought of it, to be honest. That single Button is really a neat feature.
The commands should be easy enough.
Sounds like the best way might actually be with send_osc. Since jack_capture has a “time machine” mode, that could work pretty well.
Tried it with two SSH sessions, one with sudo jack_capture -O 7777 -tm and the other for two send_osc commands:

  1. send_osc 7777 /jack_capture/tm/start
  2. send_osc 7777 /jack_capture/tm/stop

Works exactly as expected. These could then be added to button scripts (personally, would be fine having them as scripts for single-click toggle: click the button once to start, click again to stop).

The trick, then, would be to start jack_capture at boot. Tried adding the following command to /etc/rc.local:

sudo jack_capture -O 7777 -tm

Couldn’t find the files it produced, if any. Then added -fp /home/pi/timemach to that command and it started producing a bunch of tiny files right away, before getting the start command.

Does sound like it’s close to a solution, but just not quite.

Could be really very neat, especially with the timemachine mode, which would make it like the “capture” mode in Ableton. As Peter Kirn recently said:

So, there’s a funny mystery to the universe: the moment you hit the record button, all your creative ideas go away. Also, if you aren’t recording, you’ll suddenly play something ingenious – and then immediately forget it.

“Capture” is a way around this – it listens in on any connected MIDI input on armed/monitored tracks. Just played something on the keyboard you like? Hit the Capture button, and it turns instantly into a clip – no recording needed. (You can do this from Push, too; it seems inevitable that a Push 3 will have a dedicated button, but for now the Record and New buttons will do.)

Can imagine my “MODEP box” as the audio equivalent. Not sure how long a buffer would make sense but there’s something really neat about the idea.

(At the same time, maybe buffering all the time is a really bad idea for the SD card. But cards are cheap enough now that it’s fun to experiment.)

(Edit: come to think of it, maybe it makes most sense to click first to “arm” jack_capture. Will try that.)

1 Like

(As a followup, now that @vedranius is interested in using jack_capture…)
Eventually gave up on the easy transport idea. It might be easy to solve but it wasn’t very obvious to me where to go from there and it wasn’t that important at that point in time. Now that my MODEP setup is getting more airtime (jam sessions, Raspberry Jams, mini-Maker Faire…), recording the output can provide some value. Will probably go back to this fairly soon.

The timing would be great if @thetechnobear releases something with MEC for pisound. The connection between MODEP and MEC isn’t very obvious but focusing on my pisound setups has to do with both.

Hey @Enkerli, today I’m trying to record via jack_capture and it works.
But for now it works only if I start it in command line.

I’ve tried adding it as “sudo jack_capture” under buttons script and it would only make a 88KB file and that’s it.
Tried with “sudo screen jack_capture” and it won’t even start.
I’m sure that I’m doing something wrong but not sure how to write this script to do two things:

  1. pressed button once > starts recording
  2. pressed button twice > stops recording

Also, I’d like to make a HTTP/FTP web page that would be accessible locally when user goes to that IP address, and then have an list of all files/recording in that folder and ability to download them.
Any thoughts how to do that?
I don’t want to do it via SSH or similar, because it needs to be the easiest way to access, download files.
And even playing them in a browser would be nice!

Thanks!

(Sorry for the delay.)
Haven’t been able to simplify the method. Kept using SSH… because it works.
Would love a MODEP card image set up in such a way that there’s actually some UI for jack_capture (including the button). For some reason, it hasn’t worked for me outside of SSH. No idea why. Sorry, IANAC.

I am working on adding a recording button to the MODEP UI. This thread is gold for the backend functionality I was struggling with.

I am posting progress here if anyone wants to subscribe and/or collaborate.

AND

I started doing some streaming of this implementation on Twitch, I’ll be developing this entire feature Live on Twitch. You can follow here for notifications on when I go LIVE.

3 Likes

I like this idea of having a UI to see the files and playback in browser with download links too.

I think from a UX perspective, I would like to double press to start and stop recording AND add a blinking red recording light on the Pisound to indicate recording is in progress.

I get that this would mess with the ability to 1 press = x pedal board, 2 presses = y pedal board but I think that can be worked around with some type of long pressing etc.

Basically a UX refactor for how the button behaves when recording mode is supported and enabled.

2 Likes

Im not best in coding, but I can for sure help you out with anything needed.
Please, feel free to ping me whenever. :blush:

Sadly, I didnt had time to get more into how to enable recording, but I see that youve got far :blush:

Also, streaming your process is great idea too!

1 Like

Just had to install Patchbox so I wiped my install of jack_capture and ran into fatal error: sndfile.h: No such file or directory on the make and did an apt search sndfile and found that libsndfile1 was already installed, after some more reading, I tried apt install libsndfile1-dev and that resolved this error.

Then I got an undefined reference to __atomic_load_8’` error which I resolved in https://github.com/kmatheussen/jack_capture/pull/38.

And now I am back up and running with jack_capture!

I think we need to get jack_capture added to Patchbox OS out of the box.

1 Like

I agree.
We need a way to record easily an output from MODEP that’s being filtered by it.
I’ve done tests with Audacity and I couldn’t get it working at all…

1 Like

@Giedrius @Enkerli
is there any update on this?
It would be great if some option has being added for recording MODEP output inside the MODEP GUI or via button for start.
Or some sort of HTML server that can be accessed to start/stop recording and download them.
Thanks!

1 Like