Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Musical Creativity in the Browser

Scott Ammon
September 02, 2020

Musical Creativity in the Browser

CascadiaJS 2020 lightning talk

Scott Ammon

September 02, 2020
Tweet

Other Decks in Programming

Transcript

  1. Web MIDI API message { "type": "midimessage", "timeStamp": "1369.3500000517815", "data":

    [144, 62, 95], "target": { "connection": "open", "id": "input-0", "name": "Arturia MiniLab mkII", "state": "connected" } }
  2. { "type": "midimessage", "timeStamp": "1369.3500000517815", "data": [144, 62, 95], "target":

    { "connection": "open", "id": "input-0", "name": "Arturia MiniLab mkII", "state": "connected" } } event that occurred Web MIDI API message
  3. { "type": "midimessage", "timeStamp": "1369.3500000517815", "data": [144, 62, 95], "target":

    { "connection": "open", "id": "input-0", "name": "Arturia MiniLab mkII", "state": "connected" } } note-on (the event type) Web MIDI API message
  4. { "type": "midimessage", "timeStamp": "1369.3500000517815", "data": [144, 62, 95], "target":

    { "connection": "open", "id": "input-0", "name": "Arturia MiniLab mkII", "state": "connected" } } note that was pressed (middle C in this case) Web MIDI API message
  5. { "type": "midimessage", "timeStamp": "1369.3500000517815", "data": [144, 62, 95], "target":

    { "connection": "open", "id": "input-0", "name": "Arturia MiniLab mkII", "state": "connected" } } velocity (how fast the key was struck) Web MIDI API message
  6. export class HiHat extends Instrument { makeShape = (velocity) =>

    { const radius = velocity * 5; this.rotationRadians += .1; const xPos = Math.cos(this.rotationRadians) * radius + 400; const yPos = Math.sin(this.rotationRadians) * radius + 400; //code removed for clarity } } Making an instrument svg
  7. export class HiHat extends Instrument { makeShape = (velocity) =>

    { // angle calculation removed for clarity return ( <div className="hiHatFixed" key={Math.random()}> <svg className="hiHat" height="100%" width="100%"> <line x1="50%" y1="50%" x2={xPos} y2={yPos}/> </svg> </div> ); } } Making an instrument svg
  8. recap MIDI - the communication protocol Web MIDI API –

    implements MIDI protocol in the browser Go forth and create!
  9. Thank You - CascadiaJS Team - W3C Audio Working Group

    (creators of the Web MIDI API) - Anyone who has lived near me and been subjected to loud noises Web MIDI API spec: https://www.w3.org/TR/webmidi/ Repos used in this presentation: https://github.com/scott-ammon