Prototyping 19 November 2012

From XPUB & Lens-Based wiki
Revision as of 16:51, 19 November 2012 by Nan Wang (talk | contribs)

The origin and theory of the cut-up, annotated audio, essay on ubuweb.

Shuffle

Javascript doesn't include a built-in function to shuffle an array, but there are lots of "recipes" to do it.

For instance: http://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript

var shuffle = function (o) {
    for (var j,x,i=o.length; i; j=parseInt(Math.random()*i), x=o[--i], o[i] = o[j], o[j] = x);
    return o;
}

Part 1: Audio cut-up

The BBC World Service produces and releases an hourly "headlines" recording

Part 2: Headline scrambler

  • Example of "walking the tree"
  • DOM (childNodes, nodeType, nodeValue, nodeName?)
  • Recursive tree / search

random play audio code

<html> <head></head> <meta charset="utf-8" /> <style></style> <body>


<audio controls onpause="onpause()" ondurationchange="jump ()" src = "http://wsdownload.bbc.co.uk/worldservice/css/96mp3/latest/bbcnewssummary.mp3"></audio> <script> var a = document.getElementsByTagName('audio')[0] var id

function jump (){ //var a = document.getElementsByTagName('audio')[0]

   a.currentTime=Math.random()*a.duration
   a.play()
   id=setTimeout(jump,3000)

} function onpause (){ clearTimeout(id) }


</script>

</body > </html>