music is the soul - the web is the platform fowa london 2014

47
Music is the Soul The Web is the Platform @sydlawrence @wemakeawesomesh

Upload: syd-lawrence

Post on 01-Dec-2014

369 views

Category:

Technology


1 download

DESCRIPTION

The slides accompanying my talk at the Future of Web Apps 2014 in London. A whistle stop tour of the experimental audio apis available in the browser, and some vendor APIs to accompany web based audio / music.

TRANSCRIPT

Page 1: Music is the Soul - The Web is the Platform FOWA London 2014

Music is the Soul The Web is the Platform

@sydlawrence @wemakeawesomesh

Page 2: Music is the Soul - The Web is the Platform FOWA London 2014
Page 3: Music is the Soul - The Web is the Platform FOWA London 2014

DISCLAIMER There are no GIFs

@sydlawrence @wemakeawesomesh

Page 4: Music is the Soul - The Web is the Platform FOWA London 2014

DISCLAIMER There are no GIFs

@sydlawrence @wemakeawesomesh

Page 5: Music is the Soul - The Web is the Platform FOWA London 2014

Audio Playback Audio Metadata

Audio Analysis Audio Filters

Audio Synthesis Web MIDI

@sydlawrence @wemakeawesomesh

Page 6: Music is the Soul - The Web is the Platform FOWA London 2014

Audio Playback We are literally swimming in music

@sydlawrence @wemakeawesomesh

Page 7: Music is the Soul - The Web is the Platform FOWA London 2014

Alright, not literally

Page 8: Music is the Soul - The Web is the Platform FOWA London 2014

Simple MP3 Playback

@sydlawrence @wemakeawesomesh

var audio = new Audio(); audio.src = 'mysong.mp3'; audio.play();

Page 9: Music is the Soul - The Web is the Platform FOWA London 2014

Soundcloud Playback

@sydlawrence @wemakeawesomesh

SC.stream('/tracks/6049255', function(sound){ sound.play(); });

https://developers.soundcloud.com/

Page 10: Music is the Soul - The Web is the Platform FOWA London 2014

rdio Playback

@sydlawrence @wemakeawesomesh

var player = document.getElementById('rdio'); player.rdio_play('http://rd.io/x/QUxMDDdzOP0/');

http://www.rdio.com/developers/

Page 11: Music is the Soul - The Web is the Platform FOWA London 2014

Deezer Playback

@sydlawrence @wemakeawesomesh

DZ.player.playTracks([82230030]);

http://developers.deezer.com/

Page 12: Music is the Soul - The Web is the Platform FOWA London 2014

Spotify Playback

@sydlawrence @wemakeawesomesh

Computer says no

Emeddable widget only

https://developer.spotify.com/

Page 13: Music is the Soul - The Web is the Platform FOWA London 2014

Toma.hk Playback

@sydlawrence @wemakeawesomesh

var track = window.tomahkAPI.Track( 'Never Gonna Give You Up','Rick Astley', { disabledResolvers: ['spotify'] } ); $('body').append(track.render()); track.play();

http://toma.hk/api.html

Page 14: Music is the Soul - The Web is the Platform FOWA London 2014

Audio Metadata “Get me all the songs by Rick Astley”

@sydlawrence @wemakeawesomesh

Page 15: Music is the Soul - The Web is the Platform FOWA London 2014

http://developer.echonest.com/api/v4/artist/songs ?api_key=<YOUR_API_KEY> &name=rick+astley &format=jsonp &callback=JSONP_CALLBACK

the echonest

@sydlawrence @wemakeawesomesh

http://developer.echonest.com/

Page 16: Music is the Soul - The Web is the Platform FOWA London 2014

http://api.musicgraph.com/api/v2/artist/e41999c6-a6b5-11e0-b446-00251188dd67/tracks ?api_key=<YOUR_API_KEY>

Music Graph

@sydlawrence @wemakeawesomesh

https://developer.musicgraph.com/

Page 17: Music is the Soul - The Web is the Platform FOWA London 2014

https://cXXXXXXX.web.cddbp.net/webapi/xml/1.0/ !<QUERIES> <LANG>eng</LANG> <AUTH> <CLIENT>XXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</CLIENT> <USER>XXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</USER> </AUTH> <QUERY CMD="ALBUM_SEARCH"> <TEXT TYPE=“ARTIST">rick astley</TEXT> </QUERY> </QUERIES>

gracenote

@sydlawrence @wemakeawesomesh

https://developer.gracenote.com/

Page 18: Music is the Soul - The Web is the Platform FOWA London 2014

gracenote

@sydlawrence @wemakeawesomesh

SUPER SIMPLE* *sarcasm

Page 19: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Audio Analysis When just simply playing

music isn’t enough

Page 20: Music is the Soul - The Web is the Platform FOWA London 2014

AudioContext

@sydlawrence @wemakeawesomesh

AudioContext

Source Destination?

Page 21: Music is the Soul - The Web is the Platform FOWA London 2014

AudioContext Buffer

@sydlawrence @wemakeawesomesh

var audioBuffer = null; window.AudioContext = window.AudioContext || window.webkitAudioContext; var context = new AudioContext(); !var request = new XMLHttpRequest(); request.open('GET', 'mysound.mp3', true); request.responseType = 'arraybuffer'; !request.onload = function() { context.decodeAudioData(request.response, function(buffer) { audioBuffer = buffer; }, onError); }; request.send();

Page 22: Music is the Soul - The Web is the Platform FOWA London 2014

AudioContext Playback

@sydlawrence @wemakeawesomesh

// creates a sound source var source = context.createBufferSource(); !

// tell the source which sound to play source.buffer = audioBuffer; !

// connect the source to the context's destination source.connect(context.destination); source.start(0);

Page 23: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

FFT

A fast Fourier transform (FFT) is an efficient algorithm to compute the

discrete Fourier transform (DFT) of an input vector. Efficient means

that the FFT computes the DFT of an n-element vector in O(nlog n)

operations in contrast to the O(n2) operations required for computing

the DFT by definition.

Page 24: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

FFT

Page 25: Music is the Soul - The Web is the Platform FOWA London 2014

FFT

@sydlawrence @wemakeawesomesh

SUPER SIMPLE* *sarcasm

Page 26: Music is the Soul - The Web is the Platform FOWA London 2014

FFT

@sydlawrence @wemakeawesomesh

Page 27: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Page 28: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

dancer.js

var dancer = new Dancer(); !

dancer.load(audio); !

dancer.bind( 'update', function() { var magnitude = this.getFrequency(startF, endF); });

http://jsantell.github.io/dancer.js/

Page 29: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Here’s something I made earlier

wmas.it/musicviz/ripple/

Page 30: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Audio Filters Let’s pretend we are super star DJS

Page 31: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Setup the audio node

var audioContext = new webkitAudioContext; !

var gainNode = audioContext.createGain(); !

gainNode.connect(audioContext.destination);

Page 32: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Set up the filter// create the filter var lowPassFilter = audioContext.createBiquadFilter(); lowPassFilter.frequency.value = frequency; !// create the wave shaper var waveShaper = audioContext.createWaveShaper(); !// connect the bits together var waveShaper.connect(lowPassFilter); lowPassFilter.connect(audioContext.destination); !// create the curve array and set it to the shaper var wsCurve = new Float32Array(22050); // .. add floats to the curve waveShaper.curve = wsCurve;

Page 33: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Add the filter to the audiogainNode.connect(lowPassFilter);

Page 34: Music is the Soul - The Web is the Platform FOWA London 2014

Audio Filters

@sydlawrence @wemakeawesomesh

SUPER SIMPLE* *sarcasm

Page 35: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Here’s something I made earlier*

wmas.it/vineboard !

!

*I didn’t make it, @skattyadz & @robhampson did

Page 36: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Audio Synthesis Now we can pretend

we are musicians

Page 37: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Tone Synthesis

var context = new webkitAudioContext(), oscillator = context.createOscillator(); !

oscillator.type = 0; // sine wave oscillator.frequency.value = 2000; oscillator.connect(context.destination); oscillator.noteOn && oscillator.noteOn(0);

Page 38: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Tone Synthesis

http://codepen.io/sydlawrence/pen/lruEy

Page 39: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Here’s something I made earlier*

somakeit.github.io/potzy !

!

*I didn’t make it, @Benjie & @MichDdev did

Page 40: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Web MIDI Let’s use instruments with the web

Page 41: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

What is MIDI? !

MIDI is just a messaging protocol

You can send MIDI messages and receive MIDI messages

They consist of channel, key and velocity

Page 42: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

It is experimental! Behind a flag in chrome

OR Install a browser pluginhttp://jazz-soft.net/doc/Jazz-Plugin/

Page 43: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Request MIDI Accessnavigator.requestMIDIAccess().then(success,error); !

var success = function(midi) { inputs = midi.inputs(); outputs = midi.outputs(); }; !

var error = function() { console.log('oops'); };

Page 44: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Send & Receive MIDIinput.onmidimessage = function(e) { var message = e.data; // [ channel, key, velocity ] }; !

output.send( [ channel, key, velocity ] );

Page 45: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Web MIDI

SUPER SIMPLE* *NO SARCASM!!!!!

Page 46: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Here’s something I made earlier

wmas.it/midi

Page 47: Music is the Soul - The Web is the Platform FOWA London 2014

@sydlawrence @wemakeawesomesh

Thank you for listening