Different number sources using Max
This patch shows different ways to receive and generate numerical values using MaxMSP.
This patch shows different ways to receive and generate numerical values using MaxMSP.
This example shows how to create a “theremin” where the mouse position controls pitch and amplitude of a cycle~ with the x and y position respectively.
In this example, the horizontal location of the mouse in the screen is used to determine whether to send a bang or not. The mouse moving from one side of the screen, passing the mid point to the other side of the screen, causes a bang to be sent to the gswitch2 object.
In this example, you can play notes by pressing the mouse on the kslider object, and when you release the mouse, the notes will be turned off. When the mouse button is released, that fact is reported by a 0 from the left outlet of the mousestate object.
This example shows 2 approaches, using 2 different objects, to send a 0 value when mouse is pressed and a 255 value when mouse button is released. One object that does respond to both mousedown and mouseup events is lcd. Another is mousestate.
In digital images, each pixel contains color information (such as values describing intensity of red, green, and blue) and also contains a value for its opacity known as its ‘alpha’ value. An alpha value of 1 means totally opaque, and an alpha value of 0 means totally transparent. This value can be used for blending images, or for making all or part of an image totally transparent.
To translate numbers that occupy a particular range into an equivalent set of numbers in a different range, one common and useful technique is "linear mapping". The term "mapping" refers to making conceptual connections between elements of one domain and elements of another, and "linear" mapping refers to using a mapping function that is a straight line––that is, such that numbers in one domain are mapped to an exactly equivalent position in the new domain. This is a very common and useful operation in media programming.
Here are three ways of generating MIDI notes. Admittedly they don't result in very interesting music, but they show ways how numbers can be converted for usage as pitch information.