How to use the midi.noteOff function in midi

To help you get started, we’ve selected a few midi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github michaelnew / web-piano / js / app.js View on Github external
velocity = data[2];
	// with pressure and tilt off
	// note off: 128, cmd: 8
	// note on: 144, cmd: 9
	// pressure / tilt on
	// pressure: 176, cmd 11:
	// bend: 224, cmd: 14
	// log('MIDI data', data);
	switch(type){
		case 144: // noteOn message
			if (velocity > 0) {
				MIDI.noteOn(0, note, velocity, 0);
				piano.toggleKey(note, true);
				beatVisualizer.triggerNearestNodeOnChannel(note, currentNumericBeat + percentAccumulator);
			} else {
				MIDI.noteOff(0, note, 0);
				piano.toggleKey(note, false);
			}
			break;
		case 128: // noteOff message
			MIDI.noteOff(0, note, 0);
			piano.toggleKey(note, false);
			// noteOff(note, velocity);
			break;
	}
if (channel != 8 && channel != 14) {
		console.log('data', data, 'cmd', cmd, 'channel', channel);
	}
	// logger(keyData, 'key data', data);
}
github michaelnew / web-piano / js / app.js View on Github external
beatVisualizer = new BeatVisualizer(stage, function(note) {
		// TODO: make this depend on the selected instrument
		if (currentBeatSound < 3) {
			MIDI.noteOn(currentBeatSound, note, 50, 0);
			MIDI.noteOff(currentBeatSound, note, .2);
		}
	});
github michaelnew / web-piano / js / app.js View on Github external
document.onkeyup = function (e) {
	e = e || window.event;

	//console.log("keyup fired " + e.keyCode);
	var note = keyCodeToNote(e.keyCode);
	MIDI.noteOff(0, note, 0);

	piano.toggleKey(note, false);

	var temp = triggeredKeyCodes.slice();
	triggeredKeyCodes = [];
    for (var i = 0, kc; kc = temp[i]; i++) {
		if (note != kc) {
			triggeredKeyCodes.push(kc);
		}
	}
};
github michaelnew / web-piano / js / app.js View on Github external
piano = new PianoVisualizer(stage, function(note, on) {
		if (on) {
			MIDI.noteOn(0, note, 50, 0);
			beatVisualizer.triggerNearestNodeOnChannel(note, currentNumericBeat + percentAccumulator);
		} else {
			MIDI.noteOff(0, note, 0);
		}
	});