Joystick2OSC
This tool enables to drive the encoders (Encoder, Stereo Encoder) and panners (Panner, Stereo Panner)
with a joystick as in Fig.1 to control the source trajectories as in a video game.
Technically, it is a Pure Data patch that reads data from a USB HID controllers and converts it into Open Sound Control (OSC) data compatible with the aforementioned tools.
Pure Data required libraries
The following Pure Data libraries are required for the Joystick2OSC patch to work properly:
Running the patch
To run the patch, plug your USB HID controller and follow the following steps as indicated at the top of the patch
- Click to print in the PureData console the joystick ID number,
- Report this number in the corresponding message box,
- Edit the OSC sending address,
- Enter the number of sources to control,
- Send the general bang to initialize everything,
- Turn ON the OSC messages.
Using the joystick
The patch is designed for a Playstation®-like joystick as in Fig.1, and drives the sources position in a Cartesian coordinate system (although Spherical coordinates are also transmitted through OSC). The following table shows the use of the different buttons on the joystick in Fig.1:
Button | Use |
---|---|
Left joystick |
Controls the $x$-axis (left-right) and $y$-axis (top-bottom). |
Right joystick |
Controls the $z$-axis (top-bottom). |
Start |
Resets the source at initial position $(x, y, z) = (1, 0, 0)$. |
Select |
Selects the source to control in a circular way. For example, if there are $S$ sources to control, each time the Select button is pressed, the $i+1~\text{mod}~S$ source is selected and can be controlled with the joysticks, the $i~\text{mod}~S$ source is left at its position and recalled from there afterwards. |
L1 |
Low speed mode : the Left joystick and Right joystick drive each coordinates at a speed of $1$ m/s. The source is reset at initial position $(x, y, z) = (1, 0, 0)$ when pressing L1 . |
R1 |
High speed mode : the Left joystick and Right joystick drive each coordinates at a speed of $10$ m/s. The source is reset at initial position $(x, y, z) = (1, 0, 0)$ when pressing R1 . |
OSC messages details
The $i$-th source position in Cartesian and Spherical coordinates are sent to the OSC address set with the following syntax:
Coordinate | OSC | Min value | Max value |
---|---|---|---|
$x$ (m) | x_i |
$-\infty$ | $+\infty$ |
$y$ (m) | y_i |
$-\infty$ | $+\infty$ |
$z$ (m) | z_i |
$-\infty$ | $+\infty$ |
$r$ (m) | radius_i |
0 | $+\infty$ |
$\theta$ ($^\circ$) | azimuth_i |
-180 | 180 |
$\phi$ ($^\circ$) | elevation_i |
-90 | 90 |
It can therefore drive the controllers ot the (Encoder, Stereo Encoder) and panner (Panner, Stereo Panner) tools compiled in Cartesian or Spherical coordinate system.