Poly~ Tutorial 2 : Sending notes to each instances.

Hi, this is the second tutorial of poly~object. In this tutorial, we will try controlling each instance individually. Source code (.maxpat) is uploaded here on github and we will use 2/main.maxpatand 2/sub-2.maxpat today.

Preparing instances

First, let’s see the essential point of the instance of poly~. Please open sub-2.maxpat.

sub-2.maxpat

As you can see, most objects are common except thispoly~and in. If you are also unfamiliar with out~, please check the previous article.

So, how do you think inobject works? Yes, it is similar to out~ object or inlet object. It works as the inlet of poly~object. In other words, in emits what each instance gets from outside the instance. in works only inside poly~.

What about thispoly~? This object is REALLY IMPORTANT especially when we control huge amount of instances and want to reduce the use of computational resources. But in this patch, thispoly~ is used only to get the index of each instance. When bang is sent to thispoly~, it emits index number of each instance starting from 1.

Therefore, if there’s no input from in 1, sub-2.maxpatcreates sine wave and its frequency is the multiple of 440 based on the instance index.

Controlling instances.

Then, let’s see main.maxpat.

main.maxpat

If you are ready, turn on the audio. You will hear the sound and see 3 waves on spectroscope~like this.

From now, we’ll control each instance. We have to take 2 steps in order to control individually.

  1. Select target instance to control.
  2. Send message.

For step 1. we need to send a target X message to specify the target instance. Click 1 on tab.

Now, poly~ received target 1message and all incoming messages will be sent to 1st instance of sub-2.maxpat. Then, scroll number box next to the tab. This is step 2. Now you hear the different sound.

Change the target and frequency more so that each pitch gets different sound. Let’s change each frequency to 261.6, 329.6, and 392 to get C major!

This is how to control the instances individually.

Open instance

If you want to see what is going on the each instance, sending open Xmessage to poly~ is a good way to do it.

Opening each instance.