Am working with JZZ.js and JZZ.synth.OSC. Very impressed so far, and learning a lot.
Am able to get it to play messages, but not to stop, or to accept any subsequent messages.
Docs say that all of the helper functions can be applied to the Midi-out port object. But it does not appear to work.
Why would port.allNotesOff(0); or port.stop() not affect anything?
I'm sure my question reveals my beginner-ness. I appreciate any help you can offer.
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>A familiar tune...</title>
<script src='javascript/JZZ.js'></script>
<script src='javascript/JZZ.synth.OSC.js'></script>
</head>
<body>
<button style="font-size : 48px; height:100px; width:90%" onclick='play();'>Play</button>
<button style="font-size : 48px; height:100px; width:90%" onclick='stop();'>Stop</button>
<script><!--
JZZ.synth.OSC.register('Web Audio');
JZZ({sysex:true}).or('Cannot start MIDI engine!')
.and(function(){ console.log(this.info()); });
var port = JZZ().openMidiOut().or(function(){alert('Cannot open MIDI port!');});
function stop() {
port.send(JZZ.MIDI.allNotesOff(0));
// port.stop(); none of the 'helpers' do anything
}
function play() {
JZZ.util.iosSound();
port.noteOn(0, 'e4', 30).wait(300).noteOff(0, 'e4')
.noteOn(0, 'a3', 30).wait(300).noteOff(0, 'a3')
.noteOn(0, 'c4', 30).wait(150).noteOff(0, 'c4')
.noteOn(0, 'd4', 30).wait(150).noteOff(0, 'd4')
.noteOn(0, 'e4', 30).wait(300).noteOff(0, 'e4')
.noteOn(0, 'a3', 30).wait(300).noteOff(0, 'a3')
.noteOn(0, 'c4', 30).wait(150).noteOff(0, 'c4')
.noteOn(0, 'd4', 30).wait(150).noteOff(0, 'd4')
.noteOn(0, 'e4', 30).wait(300).noteOff(0, 'e4')
.noteOn(0, 'a3', 30).wait(300).noteOff(0, 'a3')
.noteOn(0, 'c4', 30).wait(150).noteOff(0, 'c4')
.noteOn(0, 'd4', 30).wait(150).noteOff(0, 'd4')
.noteOn(0, 'e4', 30).wait(300).noteOff(0, 'e4')
.noteOn(0, 'a3', 30).wait(300).noteOff(0, 'a3')
.noteOn(0, 'c4', 30).wait(150).noteOff(0, 'c4')
.noteOn(0, 'd4', 30).wait(150).noteOff(0, 'd4')
.noteOn(0, 'e4', 100).wait(900).noteOff(0, 'e4')
;
}
--></script>
</body>
</html>