To explore some basic audio functions a bit differently from the tutorials, and to explore ways to control parameters via the mouse and the lcd object, I’ve created a series of Theremin patchers:
The patchers get progressively more refined and functional, in an attempt to match the functionality of the online Theremin available through Femur Design. I’m going the first two in this post.
ThereminFun
ThereminFun is a first, basic attempt to use the mouse to send frequency and amplitude information to a sawtooth oscillator. It uses mousestate to report X and Y position info for the mouse, and whether the left mouse button is pressed or not. Mousestate has to be polled (sent a bang) to report mouse information, which is being handled by a metro object.
Mouse X position is being scaled to frequency. Mouse Y information is being scaled to amplitude. Screen parameters of 1024×768 are being used. You will have to adjust the scale input to match your screen resolution for best results. Since frequency relates to pitch exponentially, as does amplitude to loudness, an exponential curve factor of 1.006 has been added as the fifth argument to each scale object.
You can see the frequency and amplitude information being sent to the basic audio signal chain of the basic audio patcher. Frequency and amplitude values are being inserted into a list and sent to line~ objects for smooth changes.
ThereminInProgress
ThereminInProgress takes the ThereminFun patcher and adds a selector~ object with four different oscillator waveforms. Selector~ works like an audio switch object, using control messages by number to select different inputs to pass through to the output.
The basic audio output uses a live.gain~ object to change gain and provide a meter display in one object. I like the Max For Live objects for their integration and labeling features. Live.gain~ expects amplitude settings to be communicated in dB, so amplitude scaling is changed from 0. – 1. values to decibels (-70. to -0.1). Since decibel maps linear values exponentially to amplitude, no exponential curve is needed in scale. Also, since live.gain~ has an internal ramp time (set in the inspector), a line~ object is not needed.
Likewise, we can map Mouse X location to MIDI note number to avoid the exponential curve. Using floating point output arguments for scale means that we will get a more continuous floating point MIDI note number than the standard MIDI spec. Not only are floating point MIDI note numbers ok in Max, they provides a continuous pitch scale beyond the confines of equal tempered tuning. The MIDI note number is sent to a mtof object (MIDI to frequency converter) before passing to the frequency input of all oscillators.
…to be continued
Leave a Reply