[ Launch: timbre.js pendulums pluck ] 5893561 by enjalot
[ Launch: timbre.js pendulums ] 5893516 by enjalot
[ Launch: timbre.js play midi dots ] 5893390 by enjalot
[ 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/5893561 to your computer and use it in GitHub Desktop.
timbre.js pendulums pluck
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 pendulums pluck","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},"synth.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"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/IIYRBoU.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 midx = tributary.sw/2; | |
var xwidth = 200; | |
var midy = tributary.sh/2; | |
var xr = 27; | |
var yr = 45; | |
var r = 24; | |
var startNote = 42; | |
var octave = 0; | |
var noteOffset = 3; | |
midis = [64, 63, 64, 63, 64, 59, 62, 60, 57].reverse() | |
var notes = midis.map(function(d,i) { | |
return { | |
note: d | |
} | |
}) | |
var msec = timbre.timevalue("bpm100 l8"); | |
var env = T("perc", {a:109, r:500}); | |
var synth = T("PluckGen", {env:env, mul:0.25}).play(); | |
function playNote(note) { | |
synth.noteOn(note, 100) | |
synth.play() | |
} | |
//playNote(60) | |
tributary.init = function(g) { | |
g.append("line").attr({ | |
x1: midx - xwidth - r, | |
y1: 0, | |
x2: midx - xwidth - r, | |
y2: tributary.sh | |
}).style({ | |
stroke: "#000" | |
}) | |
g.append("line").attr({ | |
x1: midx + xwidth + r, | |
y1: 0, | |
x2: midx + xwidth + r, | |
y2: tributary.sh | |
}).style({ | |
stroke: "#000" | |
}) | |
g.selectAll("circle") | |
.data(notes) | |
.enter() | |
.append("circle") | |
.attr({ | |
cx: function(d,i,j) { return midx }, | |
cy: function(d,i,j) { return 49 + i * yr }, | |
r: r, | |
fill: function(d,i,j) { return color(i) } | |
}).on("mouseover", function(d,i) { | |
playNote(d.note) | |
}) | |
} | |
tributary.run = function(g,t) { | |
var theta = Math.PI / 9; | |
var freq = 3; | |
var lr = -0.999 | |
var rr = 0.999 | |
function wave(i) { | |
return Math.sin(freq * t + i * theta); | |
} | |
g.selectAll("circle") | |
.attr({ | |
cx: function(d,i) { | |
d.wave = wave(i); | |
var x = midx + xwidth * wave(i); | |
return x | |
} | |
}) | |
.each(function(d,i) { | |
if(wave(i) < lr && !d.lastL) { | |
playNote(d.note - octave) | |
d3.select(this).attr("fill", "#fff") | |
d.lastL = true | |
} | |
if(wave(i) > lr && !d.lastR) { | |
d.lastL = false; | |
d3.select(this).attr("fill", color(i)) | |
} | |
if(wave(i) > rr && !d.lastR) { | |
playNote(d.note + octave) | |
d3.select(this).attr("fill", "#fff") | |
d.lastR = true | |
} | |
if(wave(i) < rr && !d.lastL) { | |
d3.select(this).attr("fill", color(i)) | |
d.lastR = false; | |
} | |
}) | |
} | |
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
var mml0, mml1; | |
/* | |
var master = synth; | |
var mod = T("sin", {freq:2, add:3200, mul:800, kr:1}); | |
master = T("eq", {params:{lf:[800, 0.5, -2], mf:[6400, 0.5, 4]}}, master); | |
master = T("phaser", {freq:mod, Q:2, steps:4}, master); | |
master = T("delay", {time:"BPM60 L16", fb:0.65, mix:0.25}, master); | |
mml0 = "t60 l4 v6 q2 o3"; | |
mml0 += "[ [g < b0<d0f+2>> d <a0<c+0f+2>>]8 "; | |
mml0 += "f+ <a0<c+0f+2>>> b<<b0<d0f+2>> e<g0b2> e<b0<d0g2>> d<f0a0<d2>>"; | |
mml0 += ">a<<a0<c0e2>> d<g0b0<e2>> d<d0g0b0<e2>> d<c0e0a0<d2>> d<c0f+0a0<d2>>"; | |
mml0 += "d<a0<c0f2>> d<a0<c0e2>> d<d0g0b0<e2>> d<c0e0a0<d2>> d<c0f+0a0<d2>>"; | |
mml0 += "| e<b0<e0g2>> f+<a0<c+0f+2>>> b<<b0<d0f+2>> e<<c+0e0a2>> e<a0<c+0f+0a2>>"; | |
mml0 += "eb0<a0<d>e0b0<d0g>> a0<g2.> d0a0<d2.> ]"; | |
mml0 += "e<b0<e0g2>> e<a0<d0f0a2>> e<a0<c0f2>> e<<c0e0a2>> e<a0<c0f0a2>>"; | |
mml0 += "eb0<a0<d>e0b0<d0g>> a0<g2.> d0a0<d2.>"; | |
mml1 = "t60 v14 l4 o6"; | |
mml1 += "[ r2. r2. r2. r2."; | |
mml1 += "rf+a gf+c+ >b<c+d >a2. f+2.& f+2.& f+2.& f+2.< rf+a gf+c+ >b<c+d >a2.<"; | |
mml1 += "c+2. f+2. >e2.&e2.&e2."; | |
mml1 += "ab<c ed>b< dc>b< d2.& d2d"; | |
mml1 += "efg acd ed>b <d2.& d2d"; | |
mml1 += "| g2. f+2.> bab< c+de c+de>"; | |
mml1 += "f+2. c0e0a0<c2.> d0f+0a0<d2. ]"; | |
mml1 += "g2. f2.> b<cf edc edc>"; | |
mml1 += "f2. c0e0a0<c2.> d0f0a0<d2."; | |
/* | |
T("mml", {mml:[mml0, mml1]}, synth).on("ended", function() { | |
this.stop(); | |
}).set({buddies:master}).start(); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment