Skip to content

Reference library > Control > MouseY

MouseY

MouseY()

Outputs the normalised cursor Y position, from 0 to 1. Currently only supported on macOS.

Examples

#-------------------------------------------------------------------------------
# Using the MouseY position to change the frequency of an oscillator.
#-------------------------------------------------------------------------------
frequency = MouseY() * 1000
osc = TriangleOscillator(frequency)
osc.play()
#-------------------------------------------------------------------------------
# A simple wobbling synthesiser controlled using the mouse. When the mouse is 
# clicked, as detected by MouseDown(), an LFO is activated and affects the 
# oscillator's frequency. MouseX position changes the rate of the LFO. MouseY 
# position changes the upper frequency limit, affecting pitch.
#-------------------------------------------------------------------------------
rate = MouseX() * 10
upper_limit = MouseY() * 1500
lfo = SineLFO(rate, 100, upper_limit)
frequency = If(MouseDown(), lfo, 100)
osc = TriangleOscillator(frequency)
osc.play()

Last update: 2024-02-02
Created: 2023-12-03