Comments

1 comment

  • Avatar
    Paddy Keane

    ok, got working over localhost. ( was just not working in codepen.io ). anyone interested in code

    <html>

    <head>

    <script>

    varmidi = null; // global MIDIAccess object

    functiononMIDIMessage( event ) {

    varstr = "MIDI message received at timestamp " + event.timeStamp + "[" + event.data.length + " bytes]: ";

    for (vari=0; i<event.data.length; i++) {

    str += "0x" + event.data[i].toString(16) + " ";

    }

    console.log( str );

    }

    functionstartLoggingMIDIInput( midiAccess, indexOfPort ) {

    midiAccess.inputs.forEach( function(entry) {entry.onmidimessage = onMIDIMessage;});

    }

    functiononMIDISuccess( midiAccess ) {

    console.log( "MIDI ready!" );

    midi = midiAccess; // store in the global (in real usage, would probably keep in an object instance)

    for (varentryofmidiAccess.inputs) {

    varinput = entry[1];

    console.log( "Input port [type:'" + input.type + "'] id:'" + input.id +

    "' manufacturer:'" + input.manufacturer + "' name:'" + input.name +

    "' version:'" + input.version + "'" );

    }

    for (varentryofmidiAccess.outputs) {

    varoutput = entry[1];

    console.log( "Output port [type:'" + output.type + "'] id:'" + output.id +

    "' manufacturer:'" + output.manufacturer + "' name:'" + output.name +

    "' version:'" + output.version + "'" );

    }

    startLoggingMIDIInput(midi), null

    }

    functiononMIDIFailure(msg) {

    console.log( "Failed to get MIDI access - " + msg );

    }

    functiononLoadHandler(){

    navigator.requestMIDIAccess().then( onMIDISuccess, onMIDIFailure );

    }

    </script>

    </head>

    <bodyonload="onLoadHandler()">

    MONOGRAM TEST

    </body>

    </html>
    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk