Terug

Max Les 5 – OSC Mobile Device

Downloads

In this lesson you will learn how to bridge your Mobile Phone to Max/MSP so that you can use the sensors on your phone as controllers for Max.

Step 1 – Download : Max OSC Module

Download the Max Module from the link above from gitHub. Once you are on the page click on the download zip link:

Step 2 – Download app on your phone : for Android or for iPhone

Setup

Once you have downloaded the Module and installed the App you can get started.

Get your computers IP Address:

On a Mac: Open System Preferences/Network. Under Status you should see the IP Address.
On Windows: Select Start > Settings > Network & internet > Wi-Fi and then select the Wi-Fi network you’re connected to. Under Properties, look for your IP address listed next to IPv4 address.

Put your computers IP address in the Zig Sim App

Select the Sensors you want to use from your phone

In the image you see there are 3 sensors selected (Accelerometer, Gravity and Gyroscope)

Select the Sensors on the Max Module and turn On

Select your phone type, then the sensors and finally turn it On.

Troubleshooting

If all went well you should start seeing data coming into your Max Module which are from the selected sensors. If not then check the following:
– Your computer AND your phone are on the same WiFi Network.
– You entered the correct (Local) IP address of your computer into your phone.
– Your settings on your phone look like the images above.

Opdracht 5-1

Lets use our phones Gravity Sensor to control the playback speed and direction of our jit.playlist.

  1. Connect your phone to Max/MSP. Make sure you are getting data from your Gravity sensor. In particular we will use the X plane. When you tilt your phone forward 90 degrees then backward 90 degrees (on the x-axis) you should see the numbers go from Maximum to Minimum. On my phone that Max is 1.0 and the Min is -1.0. Others might be 10.0 to -10.0.

  2. Scale your output. The rate of playback goes from 1.0 (normal speed forward) to -1.0 (normal speed backward). So if your Sensor already goes between 1.0 and -1.0 then skip this step. Otherwise create a scale object like the following and connect it to the 4th output from the module : scale 10. -10. 1. -1.
    note: If your output already goes between 1.0 and -1.0 then skip this step!

  1. Create a jit.playlist + jit.pwindow with 1 video, start the video and keep it in a loop.

  2. Drag a message box above the playlist and inside it type : rate $1.

  3. Connect the Gravity X-Axis to the message box, and the output of the message box to the jit.playlist

If all goes well you should be able to tilt your mobile phone forward and backward to scrub through the playing video.

Save your patcher as Opdracht 5-1 and bring it to your lesson.

Opdracht 5-2

Lets now use our mobile phone as a drum machine.

  1. Open a new patcher with your OSC Module. Connect your phone to Max/MSP (make sure you put the correct IP address and both devices are connected to the same WiFi).
    For this example I will use the X-Axis and Y-Axis (outputs 7 & 8) of the Gravity sensor and the Light sensor on my phone. Go to the Zig Sim app and turn on the Gravity and Light sensors in the OSC Module.

  2. Lets setup an Audio Playlist with our sounds. I will use only sounds from the Resources Library on the Left-Side of the Patcher window. playlist~ works very similar to jit.playlist, please follow the Lesson on Audio Playlist to learn this object in depth.

  1. I will use the X & Y Gravity axis as triggers, therefore I will use a few If-Statements to trigger sounds.
    I know that my X-Axis data goes between 1.0 and -1.0, I can use this to trigger 2 sounds, one when I tilt forward and one when I tilt backwards. Therefore I will make the following If-statement first: if $f1 < -0.5 then 1
    NOTE: Notice that I use the variable $f1 instead of $i1. The f stands for float and the i stands for integer.

  1. The second If-Statement should read if $f1 > 0.5 then 2. Both If-statements trigger a sound in the playlist, as you can see, the first If triggers sound 1 and the second triggers sound 2, both connected to the 4th output which is the gravity X-axis.

Please notice the change object as discussed in Les 4.

  1. Now lets connect two sounds to the Y-axis. Make two If-statements that trigger sound 3 and 4 in the same way except connected to the 5th output which is the gravity Y-axis.

  2. Finally we will add a last sound using a different method to show how Max can solve the same problem in many ways. The Light sensor sends an integer between 0 and 8, 0 being darkness and 8 being bright. When I put my hand over the light sensor it should send a 0. First, connect the Light Sensor (last output) to a change, then make a sel 0 object, this way when it received a 0 it will send a bang. Next, make a message box with the number 5 in it. This way, when I cover my phone and a 0 is sent it bangs the number 5 into the playlist, playing sound 5 in the playlist.

If all goes well, your patch should look like this:

Save your patcher as Opdracht 5-2 and bring it to your lesson.