noisybox.net

Infinity footpedal external for Pd

Last updated: July 16th, 2014

infinity pedal

About

The VEC Electronics Corporation make a nice sturdy USB footcontroller, traditionally used by transcriptionists to reverse/play/pause/forward audio. These pedals generally retail for $50-60USD and are easily found through online shops. When I found the Infinity IN-USB-1 (local link) for $4.99 at the local Goodwill, I instantly thought it could be repurposed as a nice foot/stomp controller for Pd.

I purchased it, brought it home, searched around for ways to read it, experimented and failed to use HCS's HID and then decided to just write my own external + abstraction. I hate reinventing the wheel, but when the other wheels don't fit it's sometimes a necessity.

The original version in 2009 used a hacky scheme to read the usb device as a file.  Something (in the kernel?) changed and this hacky approach stopped working.  A rewrite was issued in summer 2014 and uses libhidapi for a more robust HID interaction.  Around this time, the code was also migrated to github.

Download

The code can be found in this GitHub repository:

https://github.com/breedx2/infinity-footpedal

Images

Since this is a software project, there really isn't much to show. The following are images of the pedal itself, the help patch, and a short demo video.

screenshot screenshot screenshot screenshot <demo vid tbd>

Description

Features:

How to build:

Note: I've discovered that libc < 2.9 may complain about pipe2(). If so, edit infinity_pedal.c and change:
pipe2(pfd, O_NONBLOCK);
to:
pipe(pfd);
or better still, give me a patch that solves this at build-time. :)

Troubleshooting

If you have difficulty, first make sure the device shows up in lsusb:

Bus 001 Device 005: ID 05f3:00ff PI Engineering, Inc.

If it does, at least the pedal is recognized. You can then try the readpedal program (included) to troubleshoot. Make sure your permissions are correct and that you can read the device. If readpedal works but Pd can't find it, make sure that your Pd path is correct and the binary external has been installed.

How does it work?

The quick and dirty explanation (or the code speaks for itself):

The first instance of [infinity_pedal] causes a thread to be started. This thread performs blocking reads on the device, specified as the first creation argument. Subsequent instances of the [infinity_pedal] are simply registered in the list of objects to be dispatched. When pedal data is available from the reading thread, it sends outputs to the outlets of each of the registered Pd objects. Only those outlets whose state has changed will have data sent to them. A mutex is used in order to protect the list of registered Pd objects from changing while the pedal state is being dispatched. When the final Pd object instance has been deleted, the reading thread is sent a message (via pipe) to terminate.

More

Like all software projects, this one has its shortcomings:

And credit/mention is required for the following resources/links:

If you'd like to contribute to this project and make it more better, please fork the repo and submit a pull request...or contact me!