[ Launch: timbre.js play midi ] 5893333 by enjalot
[ Launch: timbre.js reich ] 5893325 by enjalot
[ Launch: timbre.js reich ] 5893317 by enjalot
[ Launch: timbre.js ] 5893276 by enjalot
[ Launch: timbre.js ] 5893159 by enjalot
-
-
Save enjalot/5893333 to your computer and use it in GitHub Desktop.
timbre.js play midi dots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"timbre.js play midi dots","endpoint":"","display":"svg","public":true,"require":[{"name":"supercollider","url":"http://mohayonao.github.io/subcollider.js/builds/subcollider-min.js"},{"name":"timbre-mod","url":"https://gist.github.com/enjalot/5893275/raw/3a9f3430225510d2258381c9e6ab1506ff8bb86f/timbre-mod.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/BustcF4.png"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://mohayonao.github.io/timbre.js/ | |
//hacky modifications to make it work in tributary | |
TReset(); | |
TFactory(); | |
var svg = d3.select("svg"); | |
var color = d3.scale.category10(); | |
var xr = 47; | |
var yr = 45; | |
var notes = [72, 73, 74, 75, 76, 77, 78]; | |
var data = d3.range(7).map(function(d,i) { | |
var permuted = []; | |
for(var j = 0; j < notes.length; j++) { | |
permuted.push(notes[(j) % notes.length]+i*notes.length) | |
} | |
return permuted | |
}) | |
var msec = timbre.timevalue("bpm120 l8"); | |
function playMidi(note) { | |
var synth = T("OscGen", {wave:"sin", mul:0.25, env:T("perc", {r:msec, ar:true})}); | |
synth.noteOn(note, 100); | |
synth.play() | |
} | |
//playMidi(70); | |
svg.selectAll("g.row") | |
.data(data) | |
.enter() | |
.append("g") | |
.selectAll("circle") | |
.data(function(d) { return d }) | |
.enter() | |
.append("circle") | |
.attr({ | |
cx: function(d,i,j) { return 100 + i * xr }, | |
cy: function(d,i,j) { return 100 + j * yr }, | |
r: 20, | |
fill: function(d,i,j) { return color(i) } | |
}).on("mouseover", function(d,i) { | |
playMidi(d) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment