Record audio with the button

Hi, reviving an old idea here, though reading through the forum I couldn’t find a solution.

I’m looking to use my rpi headless and trigger recording from the the audio input to a file on a sd card using a button script?

Looks like using jack_capture is the way to go and I’ve got this working from the command line but would like to trigger recording using the button.

Reading around, sounded like starting jack_capture from the button might not be straightforward, for example :

Wondered if anyone has developed a successful approach to recording in this way?



Hey, your script could just terminate the old recording process and start a new one, to the new file. That can be done by either keeping the PID of the recording process in a temporary file in /tmp, or simply doing killall jack_capture, but it could interfere if you’re or something is running jack_capture manually while the button is being triggered.

Feel free to show what you have so far in your script, so we can provide accurate suggestions. :slight_smile:

Thanks @Giedrius, will look at that.

I’m a way off writing a script, just trying to figure it what it needs to do. For example, a few things I want to do that may live outside the script:

  • mount a USB thumbdrive at boot (bu+y editing fstab)
  • start the jack daemon (as a cron job?)
  • start /stop jack_capture (button script)

I came across this little project which looks pretty neat :

Basically does what I want, but wonder if its as easy to specify the pisound button config in the py script above, or will this likely conflict with the pisound button functionality built into patchbox os?

This one’s easy - Patchbox OS has it started by default :slight_smile:

The linked project could be helpful, the most important parts of it is starting jack_capture:

/usr/local/bin/jack_capture -O 7777 --format mp3 --mp3 --filename-prefix /home/pi/recordings/ --port system:capture_1 --port system:capture_2 --timemachine --timemachine-prebuffer 300

(looks like I had to build it from source myself, I used some time ago)

As I’ve built without mp3 support I had to start it like this:

mkdir ~/recordings
/usr/local/bin/jack_capture -O 7777 --filename-prefix /home/patch/recordings/ --port system:capture_1 --port system:capture_2 --timemachine --timemachine-prebuffer 300

Then the other important thing in the linked project are the ‘start’ and ‘stop’ messages. It’s possible to send them using a shell command too:

sudo apt install liblo-utils # First get the 'oscsend' utility installed

oscsend localhost 7777 /jack_capture/tm/start
oscsend localhost 7777 /jack_capture/tm/stop

So having these pieces, what’s remaining is to get jack_capture started in the background, possibly, and then writing 2 simple scripts to start and stop recording using oscsend and map the scripts to Pisound’s button.

Thanks @Giedrius will give that all a try, was having permissions issues when starting jack _capture with anything other than root before but will try the above. Assume 7777 after Jack _capture will resolve this though…

I’m really interested to see what can be done with this.
I’m currently planning out a tiny pedalboard with a Pi4 equipped with a Pisound and a second Pi with 7" touchscreen to run Reaper or another DAW to give me a portable recording platform with effects.
It’ll be awesome if I can also capture audio reliably on the Pisound, then I can perhaps adjust the setup to allow transferring those sound files to DAW.
I could also perhaps change my audio signal chain too.