Terug

Les 5 – Max Objects / Opdracht

Max/MSP jit.playlist

In last lesson you learned the audio playlist and started using the jit.playlist for videos. Here we will look a bit further at jit.playlist to see what options we have.

We will create a playlist that is controlled via the Arduino and that syncronizes video and arduino elements.

Summary: You will have 3 inputs and 2 output. Inputs (switch, potmeter & LDR); Outputs (Servo & LED). The potmeter will select which video gets played from the playlist of 4. Your LDR (light sensor) will control the playback rate AND the turning of your servo motor. Your switch will turn play/pause the video.

  1. Build the following on your Arduino

  2. In Max load your Max/Arduino Module

  3. Make a jit.playlist with 4 videos; connect the jit.pwindow and test it out with a numberbox.

  4. Potmeter: first scale the output of the potmeter from 0 1023 to 1 4. This way when you turn the potmeter it only gives out results from 1 to 4 correspoinding to your 4 videos. Save the output of the scale into the right-inlet of a message box and connect the message box into the playlist.

  5. Switch: Next lets make the switch bang the correct video into the playlist and pause it when we are not pressing the switch. IMPORTANT: This is a good moment to use the change object, do you see why?. we will use the sel object to bang the potmeters message box (left-inlet) when it gets a 1 and then a pause message when it gets 0.

  6. LDR: Next let the LDR control the playback speed/rate. First scale the output of the LDR from 0 127 to 0.0 2.0. The output of the scale needs to go into the playlist as a message, therefore we connect the scale outlet into a message box with a variable ($1) so that the playlist receives the message rate x.xx which is changing depending on the LDR’s output.

note:

At this point you should have a working system for playing videos controlled by the potmeter, the switch and the LDR. Next lets attach the LED and the Servo motor.

  1. Servo: You will need a seperate scale object for the potmeter that goes from 0 1023 to 90 180. Plug the output into a servo pin and turn that pin to Servo

* note: there are continuous motors and position specific motors. This example is with continuous motors but we understand if you only have a specific position motor, as long as there is a rational movement of the servo.

  1. Take the output of the switch and plug it directly into the LED pin. The 1/0 from the pin will also turn on/off the LED. I prefer to do this after the change object so that I the stream of data (in this case 1 or 0) is clean as early as possible.

Opdracht

On the Arduino build the following:
Inputs: 2 Switches, potmeter; Outputs: Servo, LED

On Max you will create a jit.playlist with 4 videos and a jit.pwindow to see the result.

You will create a system where pressing and holding the switch bangs a random number between 1-4 into the playlist to play that random video. When you release the switch it will stop the video. The same switch will turn on and off an LED.

You will scale the output of the Potmeter to result in values between 0.0 and 1.0 and use this to control the playback rate/speed of the video.

You will again use the output of the Potmeter, scale the output between 90 and 180 and save the output of the scale into a message box (without banging it yet, only saving the number there).

You will use the output of the second switch. If it is pressed you will send the value stored in the last message box to the servo. When you release the switch you will send a 90 to the servo (stopping it).