Hi, just found out about audacity and I love the program. I’d like to use a USB HID Joystick or Gamepad to control Audacity. For example, I’d like to program buttons for “play”, “record” and “play loop”, perhaps the direction pad for increasing or decreasing the selection for the current track. I know that I can perhaps bind the USB joystick to keyboard keys, but I’d like to do this natively so that the command is sent to audacity regardless of which program is selected?
For example, if I’m using audacity, but my currently selected program is an internet browser, if I press the space bar, the input is sent to the internet browser, not to audacity. I’d like for the USB joystick/gamepad controller to be bound to the focus of the audacity program.
Is this possible and where would I find resources/documentation to get started?
I’d like to contribute anyway I can. My background is in embedded hardware and software design and I have designed several USB devices. My website is at http://www.engscope.com, with some of the projects that I’ve created. I discovered audacity while trying to improve my guitar playing. The goal is to make a device that can control audacity’s selection cursor, loop, play and record. These are very common controls for guitar pedals. I’d like to build a USB device that does all these things exclusively for audacity. I can make the hardware portion of the project as it is the area of my expertise, but I don’t even know if this is possible within audacity. Of course, binding this to audacity’s keyboard shortcuts is very easy to do, but I’d like to do this through a joystick drivers (such as hid.dll on Windows). This will of course allow you to record/play/loop even while looking at tabs or other reference material.
If this can be done with a plugin, or if some programming is required on the open source itself, I’d definitely would love to contribute.
So the idea is that when Audacity is running, you can use any standard USB HID but it will only talk to Audacity? Or that the user must use your HID, which does nothing unless Audacity is running?
It seems to me we are not at the first step yet, which would be for Audacity to work with standards- based HID’s when it has focus. The current solution to that lack of support is of course to map keystrokes on the device using third-party software, or use an expensive DAW pedal like http://www.xtempozone.com/uses/#stage .
Would you want to write a patch that helps with the “first step”? If we achieve the first step, is another more extensible solution for Audacity to support global shortcuts (that work whatever app has focus) and keyboard media keys?
We know already that wxwidgets (the GUI toolkit that Audacity uses) only supports global shortcuts in Windows. Cross-platform issues might make your original idea difficult too. Do you have experience on Mac or Linux?
I’ve done projects on Windows mostly and some Linux, I unfortunately do not own a MAC machine. My priority would be to have this work on a Windows machine, though if it works on Linux, that would be a plus.
I can definitely look into creating a plugin that can bind HID buttons to Audacity functions. The focus issue would be nice to have, but it would be a low priority. I’d love to help, but documentation is a little scarce.
From a software perspective, the HID API can be accessed on Windows through hid.dll and on Linux through input.h. However, I wouldn’t even know where to start to invoke the functions in Audacity. If you can point to the direction for anything helpful, that would be great (especially an example). It seems like you have already pointed out that wxwidgets is the way to go as far as accessing functions within Audacity through a plugin. Is there an example of a plugin project that shows how functions are accessed? All I can find on the wiki is http://wiki.audacityteam.org/wiki/Developing_On_Windows and some very scarce information about wxwidget (something about wxwidget still a proof-of-concept, source: http://wiki.audacityteam.org/wiki/Creating_your_own_Plug-in#wxWidgets_Plug-In).
Currently looking at the AutoHotKey program to send commands when Audacity is not in focus. It seems like Audacity ignores all keys or commands sent to it if the focus is not on the program. Is this an intentional behavior or is this due to wxWidgets? I have not yet looked at the source code yet, however, AutoHotKey covers just about every possible binding possible so if it can be made to work with Audacity, that would save a ton of programming.
As a side note, the out of focus command implementation of VLC is very nicely done. Perhaps such key binding for global variables can be implemented for Audacity in the future? This will allow keyboard bindings to send commands to Audacity without having the program selected.
The implementation uses two columns for key bindings, one for when the program is in focus, and another “global” column. The shortcuts under the global column automatically binds to a function, even when VLC is not in focus.
Well the request is for global shortcuts. I think such a feature can benefit many people who are using the program, especially since it is possible to implement it from a cross-platform point of view, just like VLC. How the global shortcuts are used can be platform independent. I’ll take a look at the source when I have time to see why the events are being consumed when Audacity is not in focus or when it is minimized. Thanks.
I see. QT or GTK+ would be much more mainstream, and perhaps a larger programmer base.
I’ve looked a bit into mod-pipe-script. It seems like using the “MenuCommand” might be the way to go. However, some of the commands such as “play/stop” implemented on the space button is is not listed on a menu (just to name one). How would such commands be invoked?