P5.sound: Connecting an Oscillator to a Gain

I’m unsure how the p5 gain node works with an oscillator connecting to it, I’m not having any luck using either connect() or setInput().

The following just ignores the gain node:

var osc;
var gain;

function setup() {
  createCanvas(400, 400);
	gain = new p5.Gain();
	gain.connect();
	osc = new p5.Oscillator('sawtooth');
	osc.connect(gain);
	osc.amp(0);
	osc.start();
}

function draw() {
  background(220);
	osc.freq(60 + mouseX * 2);
	gain.amp(map(mouseY,0,height,0,1), 0.1);
}

function mousePressed() {
	osc.amp(1, 0.1);
}

function mouseReleased() {
	osc.amp(0, 0.1);
}

Any help appreciated!