MouseX and MouseY turn cursor position into live control signals, making a synth playable in real time
MouseX.kr(min,max) and MouseY.kr(min,max) are control-rate UGens that output the cursor’s horizontal and vertical screen position rescaled to the given range. Feeding them into a UGen’s arguments makes the synth respond to mouse movement, so one line of code becomes a live performable instrument. The tutorial’s flagship example maps MouseX to frequency and MouseY to amplitude, simulating a Theremin. Because the mapping is just an argument, any parameter (filter cutoff, playback rate, pan) can be put under mouse control. The mouse is the simplest live controller available before adding MIDI or OSC.
Examples
{SinOsc.ar(freq: MouseX.kr(300,2500), mul: MouseY.kr(0,1))}.play; // instant Theremin {PlayBuf.ar(1,~buf1, MouseY.kr(0.5,3), loop:1)}.play; // mouse-scrubbed rate
Assessment
Write a one-line synth where horizontal mouse position sweeps a filter cutoff and vertical position controls amplitude, then perform a short gesture with it.