Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Equal-Loudness Contour Experience in SC
name
code content
( s.waitForBoot{ var freqs = [0] ++ Array.geom(19, 30, 1.425), strps = [$a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $q, $r, $t, $u], numDB = 34, buttW = 39, buttH = 13, strpH = buttH * numDB, margL = 0, margR = 10, margT = 10, margB = 10, windW = buttW * strps.size + margL + margR, windH = strpH + margT + margB, winPH = Window.screenBounds.width - windW / 2, winPV = Window.screenBounds.height - windH / 2; strps.size.do{ |i| (freqs[i] < 1000).if( { freqs[i] = freqs[i].round(5) }, { freqs[i] = freqs[i].round(500) } ) }; x = { |freq=0, amp=1, trig=0| SinOsc.ar( freq, 0, amp*(EnvGen.ar(Env.asr(0.08, 0.2, 0.12, \welch), trig, doneAction: 0)) ) }.play; w = Window.new("Equal-Loudness Contour Finding Tool",Rect(winPH, winPV, windW, windH)).front; strps.do{ |name, frqIdx| var frqStrp = VLayoutView(w,Rect(frqIdx*buttW + margL, margT, buttW, strpH)), thisFreq = freqs[frqIdx], dbLabelW = buttW/2, lastClickId= 0; (frqIdx == 0).if( { StaticText(frqStrp, buttW@buttH) .string_("dB") .align_(\center) .font_(Font("Arial", 9)) .stringColor_(Color.grey); name = numDB.collect{ |dbIdx| var db = (1/(2**(dbIdx/2))).ampdb.round; StaticText(frqStrp, dbLabelW@buttH) .string_(db) .align_(\center) .font_(Font("Arial", 9)) .stringColor_(Color.grey); }; }, { StaticText(frqStrp, buttW@buttH) .string_((thisFreq<1000).if({ thisFreq+"Hz" },{ (thisFreq/1000)+"kHz" })) .align_(\center) .font_(Font("Arial", 9)); name = numDB.collect{ |dbIdx| var db = (1/(2**(dbIdx/2))).ampdb.round; Button(frqStrp, buttW@buttH) .states_([ [ "", Color.grey, Color.green(1, 1-(((dbIdx)*9)/400)) ], [ db, Color.grey, Color.new(0,1,0.7, 1-(((dbIdx)*9)/400)) ] ]) .mouseDownAction_{ x.set( \freq, freqs[frqIdx].postln, \amp, db.dbamp.postln, \trig, 1 ); name[lastClickId].value = 0; } .mouseUpAction_{ x.set(\trig, 0); lastClickId = dbIdx } } } ) } } )
code description
Equal-Loudness Contour Experience in SC special thanks to James Harkins who resolved my errors in the code via the sc-users list!
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change