Skip to content

Instantly share code, notes, and snippets.

@mohayonao
Created July 5, 2012 11:50
Show Gist options
  • Save mohayonao/3053253 to your computer and use it in GitHub Desktop.
Save mohayonao/3053253 to your computer and use it in GitHub Desktop.
timbre.js - ドラック&ドロップ逆再生する
"use strict"
jQuery ->
# timbre.js - T("buffer") オブジェクトを使う
synth = T("buffer").set(loop:true, reversed:true).play()
# Chrome / Safari6 でないと動きません
ctx = new webkitAudioContext()
$body = $ document.body
$body.on "dragover", (e)->
e.preventDefault()
e.stopPropagation()
$body.on "drop", (e)->
e.preventDefault()
e.stopPropagation()
reader = new FileReader()
reader.onload = (e)->
buffer = ctx.createBuffer(e.target.result, true).getChannelData 0
synth.buffer = buffer
reader.readAsArrayBuffer e.originalEvent.dataTransfer.files[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment