{
   "ancestor_list" : [],
   "description" : "Experiments in metering and mapping a synth using sendreply.kr and Level-Indicator.",
   "name" : "OceanTracker",
   "author" : "Scott L Simon",
   "code" : "//this block evaluate first.  Synth add and arrays initialize...\r\n\r\n(\r\n~ocean = Array.new(8);\r\n~oceanz = Array.new(8);\r\n\r\n\r\nSynthDef.new(\\ocean,{\r\n\r\n\tvar sig, mod;\r\n\tsig = BrownNoise.ar(0.15!2);\r\n\tmod = SinOsc.kr(0.2, 3pi/2).exprange(0.001,1);\r\n\tsig = sig * mod;\r\n\tsig = sig +(GVerb.ar(sig, 200,5) * 0.2);\r\n\tSendReply.kr(Impulse.kr(20), '/ocean', mod, 1);\r\n\tSendReply.kr(Impulse.kr(20), '/ocean2', sig, 1);\r\n\tOut.ar(0, sig);\r\n}).add;\r\n)\r\n\r\n\r\n\r\n//the OSC defs to read the sendReplies and put them into the array.  Evaluate this...\r\n\r\n(\r\nOSCdef.new(\\tracker,{\r\n\targ msg;\r\n\t//~ocean.postln;\r\n\t~ocean.add( msg[3]);\r\n\r\n\tif(~ocean.size>=8,{\r\n\t\t\t~ocean.pop;\r\n\t\t});\r\n\r\n\t\t~ocean.addFirst(msg[3]);\r\n\r\n}, '/ocean');\r\n\r\n\r\n\r\n\r\nOSCdef.new(\\tracker2,{\r\n\targ msg;\r\n\t//~oceanz.postln;\r\n\t~oceanz.add( msg[3]);\r\n\r\n\tif(~oceanz.size>=8,{\r\n\t\t\t~oceanz.pop;\r\n\t\t});\r\n\r\n\t\t~oceanz.addFirst(msg[3]);\r\n\r\n}, '/ocean2');\r\n)\r\n\r\n//start the synth.\r\nx = Synth(\\ocean);\r\n\r\n//evaluate the GUI / metering.  Shows 2 rows of metering one of the Sine wave as an envelope and the other the Noise as it is scaled.\r\n\r\n(\r\nvar indicators, indicators2, updateIndicators, updateIndicators2, test;\r\n\r\n\r\n\r\n// create window\r\nvar window = Window.new(\"OceanData\",360@420).front.onClose_({ updateIndicators.stop });\r\nq = window.addFlowLayout; // add flowLayout\r\n\r\n// create and customize 8 Level indicators\r\n\r\nindicators = Array.fill(8, {LevelIndicator(window,40@200)});\r\nq.nextLine;\r\nindicators2 = Array.fill(8, {LevelIndicator(window,40@200)});\r\n\r\nindicators.do { arg item;\r\n  item.warning_(0.8).critical_(0.9).background_(Color.green(0.4)).drawsPeak_(true);\r\n\titem.meterColor = Color.blue(0.9,0.4);\r\n};\r\n\r\nindicators2.do { arg item;\r\n\titem.warning_(0.8).critical_(0.9).background_(Color.white(0.1,0.5)).drawsPeak_(true);\r\n};\r\n\r\n// update the indicators with a routine\r\nupdateIndicators = fork{loop{\r\nindicators.do{ arg item, i; {\r\n\r\nvar value = ~ocean[i];  // read value\r\nitem.value_(value);\r\nitem.peakLevel_(value);\r\n\r\n}.defer();  // schedule in the AppClock\r\n};\r\n0.1.wait;\r\n}};\r\n\r\nupdateIndicators2 = fork{loop{\r\n  indicators2.do{ arg item, i; {\r\n\r\n    var value = ~oceanz[i]*5;\r\n\r\n    item.value_(value);\r\n    item.peakLevel_(value);\r\n\r\n  }.defer();  // schedule in the AppClock\r\n  };\r\n\r\n  0.1.wait;\r\n}};\r\n\r\n//get rid of everything at the same time.\r\nCmdPeriod.doOnce({ window.close });\r\nwindow.onClose_({ x.free });\r\n\r\n/*CmdPeriod.doOnce({ window.close });\r\nwindow.onClose_({ CmdPeriod.run});*/\r\n)\r\n\r\n/*Fieldsteel's Synthdef used - with a couple of additions.\r\nSome of the metering modded from Koutsomichalis.*/",
   "is_private" : null,
   "id" : "1-5bm",
   "labels" : [
      "synthesis",
      "mapping",
      "metering"
   ]
}
