Software » Max/MSP

Ruby Jitter Example

Since JRuby for Max runs on Java, it can access any of Cycling '74's Java APIs. So you can do things like access the Java Jitter API. Here's an example of how to modify a Jitter matrix using Ruby.

This example requires JRuby for Max.

  1. Copy the text in this box (it's the patcher source code)
  2. In Max's menu, go to File → New from Clipboard
  3. Lock the patcher to interact with it

If all goes well, you should see this patcher and no errors in the Max window. Click the 3 buttons in the order indicated. You can click the last button multiple times to flip the matrix back and forth.

How does it work? Here's the Ruby code, annotated:

Also note the [sprintf] object in the Max patcher. This is needed to call the Ruby jit_matrix() method. sprintf wraps the Jitter matrix name in quotes to convert it to a String. Otherwise it would be interpreted as an undefined variable name.