Message Principles

Sending messages is the main function of GeoSonix. They can be sent by any of cursors, triggers or curves (although each is used somewhat differently). Messages can also be sent to GeoSonix to alter its generation of messages.

While a script is running you can verify what messages are being sent or received by looking in the "Messages" section of the inspector.

All types of objects can send automessages, These are sent spontaenously at regular intervals, but only when the transport is running.
In addition to automessages, triggers send a message each tme a cursor "collides" with them.
In addition to automessages, ,urves can have "beat points" defined on them which cause the curve to send a message each time a cursor collides with a beat point on the cursor's curve. Beat points can be defined to occur at regular intervals and patterns somewhat like a step sequencer. Cursors don't activate beat points on other curves.

Cursors move along curves, and although by themselves only can generate automessages, they are important in that they can cause the triggers and curves to send their messagses.

Messages are defined as normal Javascript functions in the Script tab of the inspector. Each object has a property called "msgFunction" that is the name of the funtion it calls when triggered. This can be set in the property inspector in the "Msg Function" field. An object may have a function name defined but it has no effect unless there is a valid function by that name in the script. New cursor object have a defined function name of "cursorMessage" but you can change it as needed. The same is true for the default function names for triggers and curves.

The Patchbay

The patchbay provides a way to indirectly refer to ports in messages using the names of virtual ports that you define. This allows you to change the MIDI or OSC address to which a score's messages are sent without editing all messages in the score. It also lets you write scripts that can be reused with different synths without having to make any change to the script.

The patchbay is accessble from the GeoSonix File menu with the sequence File-Patchbay... . The Patchbay looks like this:

patchbay


The dropdown lists in the MIDI section allow you to choose from the currently abailble MIDI ports on your system. No equvalent is list possibe for OSC. The system address and port number must be typed in directly. Note that 127.0.0.1 refers to the computer on which GeoSonix is currently running. You will need to look up or assign the appropriate port number for where you want the messages to go. For example the setting shown for vOsc1 (127.0.0.1:57120) will direct messages to the default port of Supercollider on your local system.

The aliases can be any string of letters and numbers that you choose, but must not start with a number and must not contain any spaces. The names VMidi1, etc are the default names, and generally it is most convenient to retain these as it may make it easier for you to share scores and scripts with other users.

A the bottom of the Patchbay dialog, a field is provided to define one MIDI in-port. The dropdown list will show the names of available ports on your system. It is also possible for you to assign the port number GeoSonix will listen for OSC messages. This can be entered in the Messages tab of the Inspector. Note that for OSC it is not necessary to assign the system address itself, just the port number, as the address will always be the UDP network address of your computer, or 127.0.0.1 if the sender is also on your computer.

It is necessary to exit from GeoSonix and restart it to cause the new patchbay settings to take effect. Patchbay assignments are saved on your system and the most recently prevailing settings are restored in the next session.

Message Parameters

In defining message behavior it is important to be able to access properties defining the state of the score at the moment the message is to be sent. The state of the score includes the location and properties of every object in the score, and global properties of the score. Most important are the properties of the object itself that generated the message. For example what the message does may be made to depend on things like the object location, the color of the pixel in image behind the object, the distanct to some other object, the velocity of the object, or many other things.

Geosonix Object Properties

In GX2 most object properties can be set and read directly as Javascript properties of the object Objects in the score can be referred to using their id using the _obj(id) function. To use the value of a property refer to it with the _obj(id) function and the name of the property.

For example to print the x coordinate of object 99 use:

print( _obj(99).x );

To set the a property you can assign to it as if it were a variable. For example to set the x position of object 99 to 3.22 use:

_obj(99).x = 3.22;

To set the message function assign the name of the function to it as a string:

_obj(99).msgFunction = "myFunction";

In the message function of an object you can refer to that object with the Javascript "this" operator. For example the following is a message function called "myMessage" that will print the coordinates of that object each time the object is triggered.

function myMessageFunction() { print(print(thix.x, this.y, this.z); }

Each time "myMessage" is called the object's properties at that instant will be used. In GX2 this technique is used to access object properties in messages, replacing the special named properties used in the old style messages. (and is much more efficient)

You can use object properties similarly to change the properties of the message object. This example sets a trigger's size to be equal to the absolute value of its x coordinate:

function myMessageFunction() { this.triggerSize = 1+abs(this.x); }

The following is a list of objects and the property you have access to and the data type of the values returned. Note that some properties that all properties can be read (accessed), but not all can be written.

Properties and Methods Shared by All Objects

The following score properties may be used for any object:

The following method (i.e.. function call) may be used for any object:

Properties and Methods of Trigger Objects

The following properties and methods may be used with trigger objects:

Properties and Methods of Cursor Objects

The following properties and methods may be used with cursor objects:

Properties and Methods of Curve Objects

The following score parameters may be used in the definition of messages sent by cursors:

The following methods (i.e.. function calls) may be used for curves: