Terug

Creative Coding Les 4

Kennistoets Creative Coding

Jullie gaan een looplicht maken. Dit zijn lampjes die ombeurten aan en uit gaan(het lijkt dus alsof het licht zich verplaatst, het licht ‘loopt.’)
Het werkt als volgt: Zodra de drukknop ingedrukt wordt gaan de lampjes ‘lopen’ van links naar rechts. Met behulp van de potmeter bepaal je de snelheid waarmee de lampjes elkaar afwisselen.

  1. Sluit het volgende stroomschema aan op je Arduino:.
  2. Bouw in Max een patch waarmee het volgende wordt gerealiseerd:

    A) Als je de button op je Arduino indrukt wordt er, om de zoveel tijd, in Max een BANG gestuurd.

    B) De snelheid waarmee de BANGs gestuurd worden, wordt beïnvloed door de potmeter die op de Arduino zit aangesloten.
    Let op! de waarde van de potmeter schaal je van 0 – 1024 naar 100 – 1000.

    C) Elke BANG die je bij stap A stuurt moet worden opgeteld, met een teller die tot maximaal 4 kan tellen.
    Hierdoor krijg je als het ware vier stappen: 1,2,3,4.

    D) Bij iedere stap zorg je dat er een ander lampje brandt. De lampkes moeten van links naaar rechts ‘lopen.’

    E) Maak een aanpassing waardoor de lampjes constant heen en weer lopen. Dus van links naar rechts en weer terug, zolang de button op je Arduino is ingedrukt.

New Max Objects

playlist~

playlist~ lets you organize sets of soundfiles and play them back. When you write ‘playlist~’in an object box, it will give you a visual representation where you can drag-drop sound files.

There is an audio sample library in Max: in the left side of your patcher window, click the music note icon. Then there is the range of sound files’ lengths (e.g. 600 samples, 275 ms, etc) on the left that you can click and drag on the vertical line.

ezdac~

ezdac~ is an audio on/off button. You can get it either by writing ‘ezdac~’ on an object box, or click the + icon on the top of the patcher window, click ‘audio’ tab, and then click a speaker icon.
Connect the first outlet of the playlist to the left inlet of ezdac~ and the second outlet to the right inlet of ezdac~ which corresponds to the left and right channels.

send, receive

send and receive make it possible to send any kind of message without patch cords. The names given for send and receive have to be the same in order to work, and you can give any name. Make a patch like below and try to send and receive a number and a message.

subpatch p

In an object box, write ‘p‘ and give a name you want after a space, then you will see that a new window opens. This is a subpatch. In here you can write a patch that you would like to separate or hide from the rest of the codes.

You can create inlet and outlet in the subpatch: inside the subpatch drag those inlet/outlet icons in + menu on top, then you can see that there are now an inlet and an outlet in the subpatch where you can make a connection with other objects.

Create an automatic sample player with a button

  1. Now put some sound samples into the playlist~ and make 3 message boxes and write 1, 2, and pause in each box. Connect the output of the message boxes to the first inlet of playlist~. Activate ezdac~ and push each message box and see what happens.

  2. Put a message box underneath the playlist~ and connect 4th outlet of the playlist~ to the right inlet of the message box. Again try to play the samples and see what happens in the message box.

  3. Now we are going to make the playlist~ automatically triggered when a sample is played. As it gives ‘done’ message from the 4th outlet, we are using sel(selector) to select ‘done’ message. When ‘done’ message is received, then sel gives a bang to counter that counts from 1 to 4 in sequence whenever it receives a bang. Connect the first outlet of the counter to the playlist~ first inlet. In this way the next sample is automatically triggered.

  4. Let’s replace the long patch cord with the send/receive. We remove the counter for now.

  5. Create a subpatch called buttonPlay, and inside the subpatch, make one outlet.

  6. In the subpatch we are making a start button using a toggle button that will initialize the sample player. As soon as the toggle is pressed, 2 things happen: 1) sel recognizes 1 or 0, where 1 will give a bang to delay with 10 milliseconds, 2) it opens the gate and the gate will send the value coming from the second inlet, which is the delayed bang. This 10 milliseconds delay will give a brief stop between each sample.
    After the bang you see the familiar counter here.

  7. Now connect the buttonPlay output to the first inlet of playlist~. So far the subpatch doesn’t work automatically but only once when the toggle is pressed. We need a trigger when a sample is played, as we saw above.

  8. Now we are going to put the receive musicTrigger in the subpatch. The bang from the receive object will trigger the delay direcly. Also we add a pause message in the subpatch, so that when the toggle is off then the player is paused.

Huiswerk – replace or attach video playlist

Try to make a sample player for videos. The objects for the video playlist is jit.playlist, and jit.pwindow will show the video file. Try to build it by heart so that you can get familiar with the use of objects.