Homework 2 is about synthesizing an auditory streaming illusion using FM tones.

FM demo -- discrete tones

This page demo's the same real-time FM as FMdemo but with mouse clicks to start discrete tones.
After clicking the start button, play tones by clicking the mouse button. Move the mouse laterally to change the pitch. Helpful hint: find a spot on the page where you can move the mouse without affecting the contents of the live code editor, for example, below the buttons. Parameter ranges like these will alter the timbre space:


mouseX*0.5 => m.freq; mouseY*2.5 => index;
////////////////////////////////////////////////////
live code
global int mouseX, mouseY; global Event playNote, finishNote; SinOsc c => dac; SinOsc m => blackhole; 440 => float cf; 550 => float mf => m.freq; 200 => float index; 0.0 => float cg; fun void runFM() { while( true ) { cf + (index * m.last()) => c.freq; cg => c.gain; 1::samp => now; } } spork ~ runFM(); fun void mousePlay() { while (true) { playNote => now; 1.0 => cg; finishNote => now; 0.0 => cg; } } spork ~ mousePlay(); fun void RespondToMouseMovement() { while( true ) { mouseX*0.05 => m.freq; mouseY*0.5 => index; 10::ms => now; } } spork ~ RespondToMouseMovement(); 1::week => now;