{"text": "SuperCollider classlib — 3Dj/classes/Ambisonics/AmbREnc.sc\n\nCopyright (C) Fundació Barcelona Media, October 2014 [www.barcelonamedia.org] Author: Andrés Pérez López [contact@andresperezlopez.com] original Copyright (C) IEM 2005, Christopher Frauenberger [frauenberger@iem.at] This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3\n\n```supercollider\nAmbREnc {\n *ar { |in, elev=0, norm='N3D'|\n ^ in * this.kr(elev,norm);\n }\n\n *kr { |elev|\n\n }\n}\n\nAmbREnc1 : AmbREnc{\n classvar .\n\nAlgaSpinRoutine {\n *waitFor { | condition, func, breakCondition, interval = 0.01, maxTime = 5 |\n if(condition.class != Function, {\n \"waitFor only accepts a function as condition\".error;\n ^nil;\n });\n\n if(func.class != Function, {\n \"waitFor only accepts a function as func\".error;\n ^nil;\n });\n\n if(condition.value, { ^func.value });\n\n if(breakCondition == nil, { breakC"} {"text": "(condition.value, { ^func.value });\n\n if(breakCondition == nil, { breakCondition = { false } });\n\n //Spin around condition, once true, execute func\n fork {\n var accumTime = 0;\n var break = false;\n\n while( { condition.value.not }, {\n if(breakCondition.value, { condition = { true }; break = true; });\n interval.wait;\n accumTime = accumTime + interval;\n if(maxTime != nil, {\n if(accumTime >= maxTime, {\n (\"AlgaSpinRoutine: exceeded maximum wait time: \" ++ maxTime).error;\n condition = { true }; break = true;\n });\n });\n });\n\n if(break.not, { func.value });\n }\n }\n}\n```"} {"text": "SuperCollider schelp — AlgaLib/HelpSource/Classes/Alga.schelp\n\nAlga\nlive coding environment focused on the interpolation between sonic nodes\nCategory: Alga\nSee also: Classes/AlgaNode, Classes/AlgaPattern, Classes/AlgaSynthDef, Classes/AlgaPatch, Classes/AlgaServerOptions, Classes/AlgaProxySpace\n\n\nNote:\nFor Alga to work correctly, it is required to install the AlgaUGens plugin extensions. To do so, download the AlgaUGens zip file from\nhttps://github.com/vitreo12/AlgaUGens/releases/tag/v1.2.0 and extract it\nto your\n```supercollider\nPlatform.userExtensionDir\n```\n\nAlga is a new live coding environment whose focus is on describing dynamic connections between nodes. By linking AlgaNodes together, it is possible to create a fluid, complex network of sonic interactions. What makes Alga different from other environments is its interpolation capabilities. In fact, the nature of the connections between AlgaNodes arises from continuous processes of interpolation between the current states of the system and future ones, over specified windows of time.\nAlgaNode's sister class, AlgaPattern, represents\nthe polyphonic counterpart to this paradigm.\n\nCheck out the AlgaNode and AlgaPattern help files for examples on usage.\n\n## boot\nBoot Alga on a specified Server. If not specified, Server.default will be used."} {"text": " boot\nBoot Alga on a specified Server. If not specified, Server.default will be used.\n- onBoot:\nExecute a Function on boot.\n- server:\nThe Server to boot Alga on.\n- algaServerOptions:\nAn instance of AlgaServerOptions to boot the server with. If not specified, a default one will be created.\n- clock:\nThe Clock for the internal AlgaScheduler. If not specified, a default TempoClock will be created.\n\n## forceBoot\nSame as\n```supercollider\nboot\n```\n, quitting all booted servers first.\n\n## fBoot\nAlias for\n```supercollider\n forceBoot\n```\n.\n\n## quit\nQuit Alga.\n- onQuit:\nExecute a Function on quit.\n- server:\nThe Server to quit Alga from.\n\n## startup\nAdd a startup file to be executed while Alga is booting.\n\n## maxIO\nChange the maximum number of IO connections between AlgaNodes. This requires the initSynthDefs method to re-compile all the necessary AlgaSynthDefs. The default value is 8.\n- value:\nThe new value. Must be an Integer.\n\n## maxEnvPoints\nChange the maximum number of points allowed for an Env used as\n```supercollider\ninterpShape\n```\n of a module.\n- value:\nThe new value. Must be an Integer.\n\n## disableNodeOrdering\nDisable the automatic node ordering. This is an expensive operation for\n```supercollider\nsclang\n```\n the more complex a network becomes.\n\n## init"} {"text": "ive operation for\n```supercollider\nsclang\n```\n the more complex a network becomes.\n\n## initSynthDefs\nForce the recompilation of all AlgaSynthDefs necessary for Alga's runtime. This needs to be executed only once anytime the value of maxIO changes. Before boot, Alga already checks that everything is correct.\n\n## synthDescLib\nReturn Alga's SynthDescLib.\n\n## readAllDefs\nRead all the AlgaSynthDefs in the path recursively. These must have been stored with the\n```supercollider\nwrite\n```\n,\n```supercollider\nwriteDefFile\n```\n,\n```supercollider\nload\n```\n or\n```supercollider\nstore\n```\n methods.\n\n## readAlgaSynthDefs\nAlias for\n```supercollider\nreadAllDefs\n```\n.\n\n## readDef\nRead a single AlgaSynthDef or all the AlgaSynthDefs in the path non-recursively. These must have been stored with the\n```supercollider\nwrite\n```\n,\n```supercollider\nwriteDefFile\n```\n,\n```supercollider\nload\n```\n or\n```supercollider\nstore\n```\n methods.\n\n## readAlgaSynthDef\nAlias for\n```supercollider\nreadDef\n```\n.\n\n## addInterpShape\nAdd an Env to the specific Server where Alga has been booted on. These are represented as Buffers on the server, and this operation speeds up any usage of a speficic envelope shape, as it would have already been sent to"} {"text": " operation speeds up any usage of a speficic envelope shape, as it would have already been sent to the server.\n\n## removeInterpShape\nRemove the specific Env from the server where Alga has been booted on. This would free the accompanying Buffer.\n\n## interpShapes\nGet the list of Envs on the specific Server where Alga has been booted on.\n\n## interpolateTempo\nInterpolate the\n```supercollider\ntempo\n```\n of the Clock that Alga is using over to a new value. This will affect all the nodes on the Alga instance.\n- tempo:\nThe new tempo\n- time:\nThe time in seconds that the interpolation process will take\n- shape:\nAn optional Env to determine the shape of the interpolation.\n- delta:\nSpecify the resolution of the tempo change: how often should the tempo value be updated?\n- schedInSeconds:\nSpecify if the\n```supercollider\nsched\n```\n argument should be considered in seconds instead of beats / bars.\n- sched:\nWhen the interpolation should be triggered\n- server:\nThe server used for the specific Alga instance.\n\n```supercollider\n(\nAlga.boot({\n a = AP((\n def: { SinOsc.ar * EnvPerc.ar(release: 0.1 * \\tempo.kr(1)) },\n tempo: Pfunc { Alga.clocks[Server.default].tempo.reciprocal }\n )).play(chans: 2)\n})\n);\n\n//10 times faster\nAlga.interpTempo(tempo: 10, time: 5)\n\n//U"} {"text": "\n//10 times faster\nAlga.interpTempo(tempo: 10, time: 5)\n\n//Using a shape\nAlga.interpTempo(tempo: 3, time: 8, shape: Env([0, 1, 0, 1], [1, 2, 3]))\n```\n\n## interpTempo\nAlias for\n```supercollider\ninterpolateTempo\n```"} {"text": "SuperCollider patch — AlgaLib/Tests/TestSystemClockSched.scd\n\n```supercollider\nAlga.boot(clock:SystemClock)\n\na = AN({RLPF.ar(WhiteNoise.ar) * \\amp.ar(0.5)}).play;\n\n(\na.it = 4;\n\nfork {\n var sched = 5;\n a.from(0, \\amp, sched:sched);\n sched.wait;\n \"starting\".postln;\n a.it.wait;\n \"end\".postln;\n}\n)\n```"} {"text": "SuperCollider patch — AlgaLib/Tests/old/Test3.scd\n\n```supercollider\nAlga.boot\n\na = AlgaNode({\\in.ar(0)}).ft_(2)\nb = AlgaNode({\\in.ar(0)})\n//c = AlgaNode({\\in.ar(0)})\n\na >> b\nb >> a\n//c >> a\n\na.replace({\\in.ar(0)})\n\ns.plotTree\n\nCmdPeriod.run()\n\nAlga.boot\n\na = AN({SinOsc.ar(\\f.ar(1)*440)}, fadeTime:2)\nb = AN({SinOsc.ar(\\f.ar(1)*440)})\n\na.play\n\nb >>.f a\n\n//a >>.f b\n\na.ft = 1\nb.replace({SinOsc.ar(\\f.ar(1)*2000)})\nb.longestFadeTime\n\na.ft = 1\nb.replace({DC.ar(1)})\n```"} {"text": "SuperCollider schelp — AmbIEM/HelpSource/Classes/Room2D.schelp\n\nRoom2D\nRoom simulation (early reflections)\nCategory: Libraries>AmbIEM, UGens>Multichannel>Ambisonics\nSee also: Overviews/AmbIEM\n\n\n\n## new\n\n- room:\n\n## refs8polar\nReturns first 8 reflections of a point source as polar coordinates in relation to a listener output format is [phi1, dist1, phi2, dist2....]\n\n- px:\n\n- py:\n\n- lx:\n\n- ly:\n\n## refs8\nReturns first 8 reflections of a point source; coords are px, py,\noutput format is [ x1, y1, x2, y2, ... x8, y8] for easier use as UGen.\n\n- px:\n\n- py:\n\n## room\n\nExamples:\n\n```supercollider\nr = Room2D.new\nr.room = [0, 0, 8, 5]\n\na = Point(2, 3); // point to be mirrored\nr.refs8(a.x, a.y).clump(2).printAll;\n\nr.refs8polar(a.x, a.y, 0, 0).printAll;\n```"} {"text": "SuperCollider patch — AudacityLabels/FreieWortwahl/FreieWortwahlMore.scd\n\n```supercollider\n~stop.value;\n\n// von auszen neue \"verben\" einführen geht so:\n~verben['?'] = { |liste| liste.do({ |x| x.put(\\rate, rrand(2.0, 2.2)) }) };\n~sage.value(\"the missile knows greater at all times ?\");\n\n// mit weniger mickey mousing:\n~verben['?'] = { |liste| liste.do({ |x| x.put(\\rate, rrand(1.0, 1.2)) }) };\n~sage.value(\"the missile knows greater at all times ?\");\n\n// oder nur das letzte\n~verben['?'] = { |liste| liste.last.put(\\rate, rrand(1.0, 1.2)); liste };\n~sage.value(\"the missile knows greater at all times ?\");\n\n// zufällige reihenfolge und manche rückwärts\n(\n~verben['%'] = { |liste|\n liste = liste.scramble;\n liste.do { |x| if(0.3.coin) { x[\\rate] = (x[\\rate] ? 1.0).neg }};\n liste\n};\n);\n\n~sage.value(\"the missile knows greater at all times %\");\n~sage.value(\"the missile knows greater at all times % ?\");\n\n// jedes wort im takt\n(\n~verben['*='] = { |liste|\n liste.do { |x|\n var dt ="} {"text": "\n~verben['*='] = { |liste|\n liste.do { |x|\n var dt = TempoClock.default.timeToNextBeat(1).postln;\n x.play;\n x[\\wort].post; \" \".post;\n dt.wait; //1.wait;\n };\n []\n}\n);\n\n~stop.();\n~sage.value(\"the missile knows greater at all times *=\");\n\n/*\n(\n~verben['*=='] = { |liste|\nvar zeitDieWirHaben = TempoClock.default.timeToNextBeat(2);\nvar totalNormalDur = liste.sum { |x| x[\\dur] ? 0 };\nvar rate = totalNormalDur / zeitDieWirHaben;\n\"rate: \".post; rate.postln;\nliste.do({ |x| x.put(\\rate, rate) });\nliste\n};\n);\n*/\n\n~verspreche.value(\"the missile knows *= * greater at all times *= *\");\n~stop.value;\n~kanaele[\\standard][\\inhalt]\n\n// ~verspreche.value(\"ergebnis alleine n liebe zwergenaufstand kriegsfall\");\n\n~sage.value(\"the missile knows % greater at all times .\");\n~sage.value(\"it obtain a deviation ? where where where ** it isn't . \");\n~stop.value;\n~labels[\\obtains].copy.play;\n~labels.dict.keys; // alle wörter\n\n// nur mal so als Beispiel: ein effekt (geht noch nicht ganz so wie"} {"text": "\n// nur mal so als Beispiel: ein effekt (geht noch nicht ganz so wie man möchte)\n\n(\nSynthDef(\\raum, { |out, gate = 1|\n var input = In.ar(out, 2);\n var env = EnvGen.kr(Env.asr(0.01, 1, 0.1), gate);\n var sig = GVerb.ar(input.sum * env, Rand(4, 11), revtime: Rand(0.4, 0.5), damping:Rand(0.1, 0.8));\n sig = Limiter.ar(sig, 0.5);\n DetectSilence.ar(sig, doneAction: 2);\n ReplaceOut.ar(out, sig + (0.8 * input))\n}).add;\n\n~verben['*uhu'] = { |liste|\n var on = (type: \\on, instrument: \\raum, addAction: \\addToTail, dur: 0);\n var off = on.copy.put(\\type, \\off);\n liste = liste.drop(-1).add(on).add(liste.last).add(off);\n liste.collect { |x| x[\\wort] }.postln;\n liste\n};\n);\n\n~sage.value(\"all times *uhu knows greater\");\n\n~sage.value(\"the the the insn't missile *uhu knows greater at uhu all times *uhu *\");\n\n// alles zusammen:\n\n~verspreche.value(\"the missile *uhu knows greater ? at *uhu all times uhu *\");\n```"} {"text": "SuperCollider schelp — BBCut/HelpSource/Classes/CutBuf1.schelp\n\nCutBuf1 —\nBBCut2 buffer playback, efficient but inflexible\nCategory: Libraries>BBCut>Cut synths\nSee also: Overviews/BBCut\n\n\n\nPlayback for a buffer, using a single fixed PlayBuf UGen with jump in playback position- cheap for CPU but no enveloping, so it may click, and no individual parameters for different grains are supported.\n\n## new\n\n- bbcutbuf:\nAn instance of BBCutBuffer representing the buffer to be cut-up.\n\n- offset:\nA parameter to be passed to any cut playback position determining routine. The default chooseoffset method is in BBCutBuffer and the parameter is a single number from 0.0 to 1.0 giving the chance of a jump to a random event in the source.\n\nExamples:\n\n```supercollider\n(\nvar sf, clock;\n\nclock= ExternalClock(TempoClock(2.1));\n\nclock.play;\n\nRoutine.run({\n\nsf= BBCutBuffer(Platform.resourceDir +/+ \"sounds/break.aiff\",8);\n\ns.sync; //this forces a wait for the Buffer to load\n\n//0.3.coin chance of random offset starting position for cut playback\nBBCut2(CutBuf1(sf,0.3), BBCutProc11.new).play(clock);\n});\n\n)\n```"} {"text": "SuperCollider schelp — BBCut/HelpSource/Classes/StatBalNormStream.schelp\n\nStatBalNormStream —\nStream class implementing Charles Ames' method of statistical feedback\nCategory: Libraries>BBCut>Cut procedures\nSee also: Overviews/BBCut, Classes/StatBalProc, Classes/StatBalProc2\n\nStream class implementing Charles Ames' method of statistical feedback.\nThis class implements all the full possibilities of the method as presented in \"Statistics and Compositional Balance\" by Charles Ames. This includes\na normalisation step. Charles Ame's original seems incorrect, so I've added my own\nnormalisation that maintains the sum of statistics as precisely zero. There is a touch of\ncontroversy here; Charles has communicated to me personally that he doesn't consider\ncomputer music his field any more, so his comments on my correction are unavailable. At\nsome point a deeper mathematical analysis should help to resolve this.\n\nSome normalisation step is necessary for situations where a weight may be zero for some\ntime. Otherwise, the statistics will force unrealistic catchup when that weight becomes non zero again.\nNote that the set of weights, heterogeneity and accenture of a given test can be updated at any point.\nYou could even change the set of states as long as the number of them remained the same.\nSee StatBalStream for the simplified version without any controversial normalisation.\nThe Pstatbalnorm class is also provided for use with Patterns classes.\n\nReferences (all Ames, Char"} {"text": "atbalnorm class is also provided for use with Patterns classes.\n\nReferences (all Ames, Charles):\n\n- \"Statistics and Compositional Balance\" Perspectives of New Music 1989\n- \"A Catalogue of Sequence Generators\" Leonardo Music Journal 1992\n- \"Quantifying Musical Merit\" Interface: Journal of New Music Research 1992\n\n## new\n\n- states:\nAn array of the states to return\n- weights:\nAn array of weightings, one for each state. Weights may be zero.\n- heterogeneity:\nany positive float. Whilst weightings will be approached in the long term, how quickly\nthis occurs relative to serialism and the tolerance within which a running histogram of results fluctuates\ndepends on the ratio of heterogeneity to accent (by default 1).\n\nHeterogeneity 0.0 gives fully deterministic results, like serialism. Increasing heterogeneity increases the\nshuffling of order of appearance of states, that is, less predictability in the short term.\n\nIf heterogenity is really large then floating point problems will eventually occur.\n- length:\nNumber of calls to next before returning nil for sequence end. Default is inf for forever.\n\n## next\nGet the next state.\n\n## reset\nRestart the stream.\n\nExamples:\n\n```supercollider\n( //compare to weighted randomness, with heterogeneity 1.0, and change of weights halfway\nvar sbns;\nvar weights;\n\nweights= [0.6,0.3,0.1,0.0];\n\nsbns= StatBalNormStream"} {"text": "0.6,0.3,0.1,0.0];\n\nsbns= StatBalNormStream.new([0,1,2,3],weights,1.0);\n\n20.do({arg i;\n\"wchoose \".post;[0,1,2,3].wchoose(weights).post; \" statbal \".post;sbns.next.postln;\n});\n\nweights=[0.6,0.0,0.1,0.3];\n\n\"HALFWAY\".postln;\n\nsbns.weights_(weights);\n\n20.do({arg i;\n\"wchoose \".post;[0,1,2,3].wchoose(weights).post; \" statbal \".post;sbns.next.postln;\n});\n)\n```"} {"text": "SuperCollider classlib — BBCut/classes/core/BBCutQuantise1.sc\n\nThis file is part of The BBCut Library. Copyright (C) 2001 Nick M.Collins distributed under the terms of the GNU General Public License full notice in file BBCutLibrary.help\n\n```supercollider\n//BBCutQuantise1 07/1/05 by N.M.Collins\n\n//master quantise for all blocks, 16th triplet\n\n//swing test always based on proximity to 0.25\n\nBBCutQuantise1 {\n var <>swing;\n var <>phrasetotal;\n\n *new{arg swing=0.25;\n\n ^super.new.swing_(swing).phrasetotal_(0.0);\n }\n\n value {arg block;\n var copyiois,pos,lastpos, keptindices;\n\n //startpos= block.phrasepos;\n\n //block.length;\n\n copyiois= block.cuts.copy;\n keptindices=Array.fill(copyiois.size,{false});\n\n //add on to phrasetotal one at a time seeing where they fall on quantise grid\n\n pos= phrasetotal;\n\n lastpos=pos;\n\n copyiois.do({arg cut,i;\n var nextpos,quantpos,roundpos,swingadd, ioi;\n\n ioi=cut[0];\n\n nextpos= pos+ioi;\n\n quantpos= (nextpos%0.5);\n\n swingadd= if(abs(quantpos-0.25)<0.125,1,0);\n\n roundpos= nextpos.round(0.5);\n\n if(roundpos>"} {"text": "<0.125,1,0);\n\n roundpos= nextpos.round(0.5);\n\n if(roundpos>nextpos, {roundpos= roundpos-(swingadd*(0.5-swing));}, {roundpos= roundpos+(swingadd*swing);});\n\n if(roundpos>(lastpos+0.0001),{\n ioi=roundpos-lastpos;\n copyiois[i][0]= ioi;\n copyiois[i][1]= ioi;\n lastpos=roundpos;\n keptindices[i]=true;\n },{copyiois[i]=0;});\n\n pos=nextpos;\n });\n\n //remove any 0.0 length iois\n\n //lastpos gives revised length\n block.length= lastpos-phrasetotal;\n block.cuts= copyiois.select({arg val,i; keptindices[i]});\n\n if(block.length<0.001,{\"this shouldn't be zero?\".postln});\n\n //trust length works out, else no sweat\n //\n //end of phrase, must add up to correct amount here if possible\n if((block.currphraselength-0.001) < (block.phrasepos + block.length),{\n\n //reset for new phrase\n phrasetotal=0.0;\n });\n\n }\n\n}\n```"} {"text": "SuperCollider schelp — BlumBox/HelpSource/Classes/BlumFollowPower.schelp\n\nBlumFollowPower\nStereo power analysis\nCategory: Libraries>Blumlein Box>Analyses, UGens>Analysis\n\n\nMeasure the power of a stereo signal.\n\n## ar, kr\n\n- in:\nThe stereo input, an array: [L, R]\n\n- size:\nNumber of samples for Hilbert window (i.e. FFT size) or running sum. See RunningSum and HilbertW for more info.\n\nNote: For instantaneous analysis, size must be a power of two! \n\n- method:\n\n```supercollider\n\\instant\n```\n for instantaneous analysis or\n```supercollider\n\\average\n```\n for time-averaged analysis\n\nReturns:\nSignal power\n\nExamples:\n\n```supercollider\n(\n~powerTest = {\n var in, out;\n var freqLFO, ampLFO;\n var instant, average;\n var makeUpDelay;\n var size = 2048;\n var halfSize = (size / 2).asInteger;\n\n freqLFO = LFNoise2.kr(72).range(0.9, 1.1);\n ampLFO = SinOsc.kr(0.5).range(0.01, 0.5);\n\n // Sinusoids\n in = SinOsc.ar([440 * freqLFO, 330 * freqLFO]);\n // in = SinOsc.ar([220, 0]); // Fully L\n // in = SinOsc.ar([0, 220]"} {"text": ".ar([220, 0]); // Fully L\n // in = SinOsc.ar([0, 220]); // Fully R\n\n // Note how power changes using only one channel of the stereo input!\n\n // Noise\n // in = PinkNoise.ar([1.0, 1.0]);\n\n // apply amplitude LFO\n in = in * ampLFO;\n\n // Instant and average output\n instant = BlumFollowPower.ar(in, method: \\instant);\n average = BlumFollowPower.ar(in, method: \\average);\n\n // match delay of instant and average for comparison\n makeUpDelay = ((halfSize * SampleDur.ir) - ControlDur.ir);\n average = DelayN.ar(average, makeUpDelay, makeUpDelay);\n\n // Select one: ompare instant vs average\n // out = average;\n out = instant;\n // out = (instant.neg + average); // difference between instantaneous and average\n\n // write analysis to post window\n out.poll(label: \"analyzed\");\n\n // listen to source\n in\n}.play\n)\n```"} {"text": "SuperCollider classlib — Clothesline/Classes/Clothesline.sc\n\n```supercollider\nArrange code on a timed clothesline\n----,---;------,---------,---,-----\n\n- score elements are uniquely identified by their file name\n- each element has init/play/stop/free sections that are called as necessary\n- code outside these sections is ignored but can be used to live code\n- each element may maintain its own environment\n\n*/\n\nClothesline {\n\n var reader, <>fileNameEnding=\"-score\";\n var verbose = true, <>tolerant = true;\n var changedAction;\n\n var scheduleIndex;\n\n *new {\n ^super.new.init\n }\n\n init {\n score = IdentityDictionary.new;\n currentTime = 0;\n scheduleIndex = {:x, x<-(0..)};\n reader = ClotheslineReader;\n // for reliability, we capture the environment here\n capturedCurrentEnvironment = currentEnvironment;\n capturedCurrentEnvironment[\\clothesline] = this; // access self\n }\n\n // file reading\n\n addScore { |path, callInContext = true|\n var event = reader.parseScore(path);\n var name;\n if(event.notNil) {\n name = path.basename;\n name = name.replace(fileNameEnding ++ \".scd\","} {"text": " name = path.basename;\n name = name.replace(fileNameEnding ++ \".scd\", \"\");\n name = name.asSymbol;\n if(callInContext) { this.addCallContextToEvent(event) };\n this.put(name, event);\n }\n }\n\n addAllScores { |path, callInContext = true|\n var paths;\n if(path.endsWith(\"/\").not) { path = path ++ \"/\" };\n path = \"%*%.scd\".format(path, fileNameEnding);\n paths = path.pathMatch;\n if(paths.isEmpty) { \"No files found in this path: \\n'%'\".format(path.cs).warn };\n paths.do { |path| this.addScore(path, callInContext) };\n }\n\n // scheduling\n // aliases allow to add the same file multiple times.\n\n sched { |name, startTime, endTime, alias|\n var isRunning, shouldBeRunning, end;\n var event;\n\n if(tolerant) {\n if(startTime > endTime) {\n end = endTime;\n endTime = startTime;\n startTime = end;\n }\n };\n\n // later we can optimize this a little to schedule a bunch and then do the play update\n this.doWithPlayUpdate {\n event = if(alias.isNil) { this.getEvent(name) } { this.getAliasEvent(name, alias) };\n event[\\startTime] = startTime;\n event[\\endTime] = endTime;\n event[\\indexInSchedule] = event"} {"text": "ime;\n event[\\endTime] = endTime;\n event[\\indexInSchedule] = event[\\indexInSchedule] ?? { scheduleIndex.next };\n this.updateBreakpoints;\n };\n\n changedAction.value(this, [event], \\scheduled);\n\n ^event\n\n }\n\n getEvent { |name|\n var event, err;\n err = \"event with name '%' not found (maybe forgot to add '%'?)\";\n event = score[name];\n if(event.isNil) { Error(err.format(name, fileNameEnding)).throw };\n ^event\n }\n\n getAliasEvent { |name, alias|\n var event, err;\n err = \"event with name '%' not found (maybe forgot to add '%'?)\";\n event = score[alias];\n if(event.isNil) {\n event = score[name];\n if(event.isNil) { Error(err.format(name, fileNameEnding)).throw };\n event = event.copy;\n event[\\sourceName] = name;\n event[\\name] = alias;\n event[\\indexInSchedule] = scheduleIndex.next;\n if(event[\\callContext].notNil) { this.addCallContextToEvent(event) };\n this.put(alias, event);\n };\n ^event\n }\n\n addCallContextToEvent { |event|\n event[\\callContext] = Environment(parent: capturedCurrentEnvironment, know: true)\n "} {"text": "callContext] = Environment(parent: capturedCurrentEnvironment, know: true)\n }\n\n addMissingEndTimes { |arrays|\n var last = arrays.lastIndex;\n arrays.size.do { |i|\n var endTime = arrays[i][2];\n if(endTime.isNil) {\n endTime = if(i == last) { arrays[i][1] + 1.0 } { arrays[i+1][1] };\n arrays[i] = arrays[i].instill(2, endTime)\n }\n }\n }\n\n schedAllArrays { |arrays|\n this.addMissingEndTimes(arrays);\n arrays.do { |each|\n if(each.size < 3) { Error(\"scheduling data format is wrong: %\".format(each)).throw };\n this.sched(*each)\n }\n }\n\n // access\n\n at { |name|\n ^score[name]\n }\n\n put { |name, event|\n var prevEvent = score[name];\n var hotSwap = false;\n var doc;\n\n if(prevEvent.notNil) {\n hotSwap = this.eventIsPlaying(prevEvent, currentTime);\n if(hotSwap) { this.stopScore(name) };\n if(event[\\startTime].isNil) { event[\\startTime] = score[name][\\startTime] };\n if(event[\\endTime].isNil) { event[\\endTime] = score[name][\\endTime] };\n };\n event[\\name] = name;\n score[name] = event;\n\n if(hotSwap)"} {"text": " };\n };\n event[\\name] = name;\n score[name] = event;\n\n if(hotSwap) { this.playScore(name) };\n\n if(verbose) {\n if(prevEvent.notNil) {\n \"replaced event '%' from path %\".format(name, event[\\path]).postln\n } {\n \"added event '%' from path %\".format(name, event[\\path]).postln\n }\n };\n\n doc = Document.allDocuments.detect { |x| x.path == event[\\path] };\n if(doc.notNil) { this.linkDocumentToEvent(doc, event) };\n }\n\n // TODO: to make playScore part of the public interface,\n // we need to know if an event is really playing and wasn't stopped by cmd-.\n\n playScore { |...names|\n var events = this.getEvents(names);\n events = events.reject { |event| this.eventIsPlaying(event, currentTime) };\n this.playEvents(events);\n }\n\n stopScore { |...names|\n var events = this.getEvents(names);\n events = events.select { |event| this.eventIsPlaying(event, currentTime) };\n this.stopEvents(events);\n }\n\n restartScore { |...names|\n var events = this.getEvents(names);\n this.stopEvents(events);\n this.playEvents(events);\n }\n\n playEvents { |events|\n events = this.sortEvents(events, \\startTime);\n events.do { |event|"} {"text": " events = this.sortEvents(events, \\startTime);\n events.do { |event|\n event[\\runningTask].stop;\n event[\\runningTask] = fork {\n this.updateEventIfNeeded(event);\n this.callInContext({\n event[\\INIT].value;\n event[\\PLAY].value;\n }, event);\n event[\\runningTask] = nil;\n changedAction.value(this, events, \\started);\n }\n };\n\n if(events.notEmpty) {\n if(verbose) {\n \"started: %\".format(this.sortEvents(events, \\name, \\zzz) .collect { |e| e[\\name] }).postln\n };\n };\n }\n\n stopEvents { |events|\n events = this.sortEvents(events, \\endTime);\n events.do { |event|\n var task;\n event[\\runningTask].stop;\n event[\\runningTask] = fork {\n this.updateEventIfNeeded(event);\n this.callInContext({\n event[\\STOP].value;\n event[\\FREE].value;\n }, event);\n event[\\runningTask] = nil;\n changedAction.value(this, events, \\stopped);\n };\n };\n\n if(events.notEmpty) {\n if(verbose) {\n \"stopped: %\".format(this.sortEvents(events, \\name, \\zzz).collect { |e| e[\\name] }).postln\n };\n };\n"} {"text": "name, \\zzz).collect { |e| e[\\name] }).postln\n };\n };\n\n }\n\n // helpers\n\n callInContext { |func, event|\n var callContext = event[\\callContext];\n if(callContext.notNil) {\n callContext.use(func)\n } {\n func.value\n }\n }\n\n needsUpdate { |event|\n ^File.mtime(event[\\path]) != event[\\modificationTime]\n }\n\n updateEventIfNeeded { |event|\n var newEvent, path;\n if(this.needsUpdate(event)) {\n path = event[\\path];\n newEvent = reader.parseScore(path);\n if(newEvent.notNil) {\n event.putAll(newEvent);\n } {\n \"file update failed: %\".format(path).throw\n }\n }\n }\n\n // schedule information\n\n firstEventScheduled {\n ^this.scheduledEvents.minItem { |e| e[\\startTime] }\n }\n\n lastEventScheduled {\n ^this.scheduledEvents.maxItem { |e| e[\\endTime] }\n }\n\n firstStartTime {\n var event = this.firstEventScheduled;\n ^event !? { event[\\startTime] }\n }\n\n lastEndTime {\n var event = this.lastEventScheduled;\n ^event !? { event[\\endTime] }\n }\n\n lastTime {\n ^max(this.lastEndTime ? 0, defaultBreakpoints.l"} {"text": "Time {\n ^max(this.lastEndTime ? 0, defaultBreakpoints.last)\n }\n\n eventIsScheduled { |event|\n ^event[\\startTime].notNil\n }\n\n eventIsCurrent { |event, time|\n var start = event[\\startTime];\n var end = event[\\endTime];\n if(start.isNil or: { end.isNil }) { ^false };\n ^this.timeIsInRange(time, start, end)\n }\n\n eventIsPlaying { |event, time|\n time = time ? currentTime;\n if(this.isInSoloMode) {\n ^event[\\name] == currentSolo and: { this.eventIsCurrent(event, time) }\n };\n if(event[\\muted] == true) { ^false };\n ^this.eventIsCurrent(event, time)\n }\n\n eventIsMuted { |event|\n ^event[\\muted] == true\n }\n\n timeIsInRange { |atTime, startTime, endTime|\n ^startTime.notNil and: { atTime >= startTime }\n and: {\n endTime.isNil or: { atTime < endTime }\n }\n }\n\n scheduledEvents {\n ^score.select(this.eventIsScheduled(_)).values\n }\n\n eventsThatPlayAt { |time|\n var events = this.scheduledEvents;\n ^events.select { |e| this.eventIsPlaying(e, time) }\n }\n\n eventsCurrentAt { |time|\n var events = this.scheduledEvents;\n "} {"text": " }\n }\n\n eventsCurrentAt { |time|\n var events = this.scheduledEvents;\n ^events.select { |e| this.eventIsCurrent(e, time) }\n }\n\n sortEvents { |events, sortKey, default = inf|\n var f = { |e| e[sortKey] ? default };\n if(events.isNil) { ^nil };\n ^events.sort { |a, b| f.(a) < f.(b) }\n }\n\n namesDo { |names, func|\n if(names.asArray.isEmpty) {\n score.do(func);\n ^this\n };\n names.do { |name|\n var event = score[name];\n if(event.isNil) { \"no event for this name: %\".format(name).warn; ^this };\n func.value(event)\n }\n }\n\n getScoreAsSortedArray { |sortKey = \\indexInSchedule|\n ^this.sortEvents(this.scheduledEvents, sortKey)\n }\n\n getPlayingEvents {\n ^this.eventsThatPlayAt(currentTime)\n }\n\n getEvents { |names|\n var events = Array.new;\n this.namesDo(names, { |event| events = events.add(event) });\n ^events\n }\n\n // muting and solo\n\n mute { |...names|\n this.doWithPlayUpdate({\n this.namesDo(names, {|event| event[\\muted] = true })\n })\n }\n\n unmute { |...names|\n "} {"text": "event| event[\\muted] = true })\n })\n }\n\n unmute { |...names|\n this.doWithPlayUpdate({\n this.namesDo(names, { |event| event[\\muted] = nil })\n })\n }\n\n toggleMute { |...names|\n this.doWithPlayUpdate({\n this.namesDo(names, { |event|\n event[\\muted] = if(event[\\muted] == true) { nil } { true }\n })\n })\n }\n\n solo { |name|\n this.doWithPlayUpdate({ currentSolo = name })\n }\n\n unsolo {\n this.doWithPlayUpdate({ currentSolo = nil })\n }\n\n toggleSolo { |name|\n if(this.isInSoloMode) { this.unsolo } { this.solo(name) }\n }\n\n isInSoloMode {\n ^currentSolo.notNil\n }\n\n removeEventFromSchedule { |event|\n event[\\startTime] = nil;\n event[\\endTime] = nil;\n }\n\n clear {\n this.doWithPlayUpdate({\n score.do { |event|\n this.removeEventFromSchedule(event)\n };\n this.updateBreakpoints;\n changedAction.value(this, [], \\cleared);\n })\n }\n\n doWithPlayUpdate { |func|\n var nowRunning, shouldBeRunning;\n nowRunning = this.getPlayingEvents;\n func.value;\n shouldBeRunning = this.getPlaying"} {"text": ".getPlayingEvents;\n func.value;\n shouldBeRunning = this.getPlayingEvents;\n this.stopEvents(nowRunning difference: shouldBeRunning);\n this.playEvents(shouldBeRunning difference: nowRunning);\n }\n\n // navigation\n\n jumpTo { |time|\n var shouldRun, runningNow;\n\n if(time.isNil) { \"nowhen to jump to (time is nil)\".postln; ^this };\n\n runningNow = this.eventsThatPlayAt(currentTime);\n shouldRun = this.eventsThatPlayAt(time);\n\n this.stopEvents(runningNow difference: shouldRun);\n this.playEvents(shouldRun difference: runningNow);\n\n currentTime = time;\n\n }\n\n jumpBy { |delta|\n this.jumpTo(currentTime + delta)\n }\n\n moveTo { |time, previousTime|\n this.jumpTo(time)\n }\n\n // breakpoints\n\n defaultBreakpoints_ { |array|\n defaultBreakpoints = array.collect { |x| x.asFloat };\n this.updateBreakpoints;\n }\n\n jumpToNextBreakpoint {\n this.jumpTo(this.getNextBreakpoint(currentTime))\n }\n\n jumpToPreviousBreakpoint {\n this.jumpTo(this.getPreviousBreakpoint(currentTime) ? 0)\n }\n\n getNextBreakpoint { |time|\n var i;\n ^breakpoints !? {\n i = breakpoints.indexOfGreaterThan(time);\n i !? { breakpoint"} {"text": " {\n i = breakpoints.indexOfGreaterThan(time);\n i !? { breakpoints[i] }\n }\n }\n\n getPreviousBreakpoint { |time|\n var i;\n ^breakpoints !? {\n i = breakpoints.indexOfGreaterThan(time);\n ^if(i.isNil) {\n if(time == breakpoints.last) {\n breakpoints.clipAt(breakpoints.lastIndex - 1)\n } {\n breakpoints.last\n }\n } {\n breakpoints.clipAt(i - 2)\n }\n }\n }\n\n updateBreakpoints {\n var b = defaultBreakpoints.as(IdentitySet);\n [\\startTime, \\endTime].do { |key|\n score.do { |event|\n var val = event[key];\n val !? { b.add(val.asFloat) };\n }\n };\n breakpoints = b.as(Array).sort\n }\n\n // playing\n\n isPlaying { ^player.isPlaying }\n stop { player.stop; player = nil; }\n pause { if(player.isNil) { \"not playing\".warn } { player.pause }}\n resume { if(player.isNil) { \"not playing\".warn } { player.resume } }\n\n play { |startTime = 0, endTime = inf, clock, timeStep = 0.1|\n this.stop;\n player = Task {\n var next, dt;\n this.jumpTo(startTime);\n while {\n next = this.getNextBreakpoint(currentTime);\n currentTime < end"} {"text": "Time);\n while {\n next = this.getNextBreakpoint(currentTime);\n currentTime < endTime\n } {\n dt = if(next.notNil) { min(next - currentTime, timeStep) } { timeStep };\n this.moveTo(currentTime + dt, currentTime);\n dt.wait;\n };\n\n }.play(clock);\n ^player\n\n }\n\n // code access\n // sometimes this may open the wrong document, maybe due to an issue in SCIDE\n // the paths are correct, mostly it works ...\n\n openDocument { |name|\n var event = score[name];\n var path, doc;\n var updateFunc;\n\n if(event.notNil) {\n path = event[\\path];\n if(path.notNil) {\n doc = Document.open(path);\n this.linkDocumentToEvent(doc, event);\n doc.front;\n } {\n \"no path in event:\\n%\".format(event).warn;\n }\n } {\n \"no score event for that name: '%'\".format(name).warn\n };\n ^doc\n }\n\n closeDocument { |name|\n var event = score[name];\n var doc;\n if(event.notNil) {\n doc = event[\\document];\n if(doc.notNil) {\n doc.close;\n event[\\document] = nil;\n };\n } {\n \"no score event for that name: '%'\".format(name).warn\n }\n }\n\n switchDocument { |name, prev|\n var event = score[name];\n var oldEvent = score[prev];\n // this check is"} {"text": "|\n var event = score[name];\n var oldEvent = score[prev];\n // this check is needed because if they happen to be the same\n // there is some race condition in the IDE\n if(event[\\path] != oldEvent[\\path]) {\n this.closeDocument(prev);\n };\n this.openDocument(name)\n }\n\n // still missing, if you hand-open document after score is scheduled, this won't do\n // also: when clearing the schedule, the document functions need to be unlinked\n\n linkDocumentToEvent { |doc, event|\n event[\\document] = doc;\n if(event[\\callContext].notNil) {\n doc.toFrontAction = {\n currentEnvironment = event[\\callContext];\n };\n doc.endFrontAction = {\n // this may override an environment that was hand-pushed\n // in the meantime. think about this later\n currentEnvironment = capturedCurrentEnvironment;\n };\n if(verbose) {\n \"linked score event '%' envir to open document '%'\".format(event[\\name], doc.title).postln;\n };\n };\n doc.onClose_({ event[\\document] = nil });\n }\n\n postTimeline {\n var lineLength = 80;\n \"\\n\\n\".postln;\n { |i| (i+1).asString.padLeft(10, \".\") }.dup(lineLength div: 10).join.postln;\n score.values.do { |e|\n e.use {\n var t0 = ~startTime * 10 - 1;\n var t1 = ~endTime -"} {"text": "use {\n var t0 = ~startTime * 10 - 1;\n var t1 = ~endTime - ~startTime * 10 - 1;\n \"-> % (from: % to: % (dur: %)\".format(~name, ~startTime, ~endTime, ~endTime - ~startTime).postln;\n t0.do { |i| \" \".post }; \"|\".post;\n t1.do { |i| \".\".post }; \"|\".post;\n \"\".postln;\n };\n };\n \"\\n\\n\".postln;\n }\n\n codeAsString {\n var stream = CollStream(String.new);\n breakpoints.do { |time|\n var startingEvent, endingEvent, makeParentheses, nothingToDo, hasStarts, hasEnds;\n startingEvent = this.scheduledEvents.select { |event| event[\\startTime] == time };\n endingEvent = this.scheduledEvents.select { |event| event[\\endTime] == time };\n\n hasStarts = startingEvent.notEmpty;\n hasEnds = endingEvent.notEmpty;\n\n if(hasStarts or: hasEnds) { stream << \"// %\\n\".format(time.asTimeString) };\n if(hasStarts and: hasEnds) { stream << \"(\\n\" };\n if(startingEvent.notEmpty) {\n stream << \"Clothesline.default.playScore(%);\\n\".format(startingEvent.collect { |event| event[\\name].asCompileString }.join(\", \"))\n "} {"text": "vent.collect { |event| event[\\name].asCompileString }.join(\", \"))\n };\n if(endingEvent.notEmpty) {\n stream << \"Clothesline.default.stopScore(%);\\n\".format(endingEvent.collect { |event| event[\\name].asCompileString }.join(\", \"))\n };\n if(hasStarts and: hasEnds) { stream << \")\" };\n stream << \"\\n\\n\";\n };\n ^stream.collection\n }\n\n codeDoc { |title = \"clothesline score\"|\n ^Document.new(title, this.codeAsString, capturedCurrentEnvironment)\n }\n\n}\n\nContinuousClothesline : Clothesline {\n\n var .\n*/\n\n// Just use a different class to mark an array as being a ClusterArg\nM[slot] : Array {\n\n asClusterArg {\n ^ClusterArg(this.as(Array))\n }\n\n printOn { arg stream;\n if (stream.atLimit, { ^this });\n stream << \"M[ \" ;\n this.printItemsOn(stream);\n stream << \" ]\" ;\n }\n\n}\n\n+ Array {\n\n asClusterArg { }\n\n}\n```"} {"text": "SuperCollider classlib — Conductor/classes/CV/TV.sc\n\n```supercollider\n \n *new { | v | ^super.new(NoSpec, v) }\n\n draw { |win, name =\">\"| \n var tv = TextField(win, ~sliderRect.value)\n .font_(Font(\"Helvetica\", 12) )\n .string_(value)\n ; \n this.connect(tv);\n ^tv\n }\n \n connect { | view | ^TVSync(this, view) }\n \n}\n```"} {"text": "SuperCollider schelp — Connection/HelpSource/Classes/MethodSlot.schelp\n\nMethodSlot\n(put short description here)\nCategory: Undocumented classes\nSee also: Classes/SomeRelatedClass, Reference/SomeRelatedStuff, etc.\n\n\n(put long description here)\n\n## makeUpdateFunc\n(describe method here)\n\n- reciever:\n(describe argument here)\n\n- methodName:\n(describe argument here)\n\n- argOrder:\n(describe argument here)\n\nReturns: (describe returnvalue here)\n\n## prNew\n(describe method here)\n\nReturns: (describe returnvalue here)\n\n## new\n(describe method here)\n\n- obj:\n(describe argument here)\n\n- method:\n(describe argument here)\n\n- ...: argOrder\n(describe argument here)\n\nReturns: (describe returnvalue here)\n\n## connectionTraceString\n(describe method here)\n\n- what:\n(describe argument here)\n\nReturns: (describe returnvalue here)\n\n## init\n(describe method here)\n\n- inObject:\n(describe argument here)\n\n- inMethodName:\n(describe argument here)\n\n- argOrder:\n(describe argument here)\n\nReturns: (describe returnvalue here)\n\n## updateFunc\n(describe method here)\n\nReturns: (describe returnvalue here)\n\n## reciever\n(describe method here)\n\nReturn"} {"text": ": (describe returnvalue here)\n\n## reciever\n(describe method here)\n\nReturns: (describe returnvalue here)\n\n## update\n(describe method here)\n\n- object:\n(describe argument here)\n\n- changed:\n(describe argument here)\n\n- ...: args\n(describe argument here)\n\nReturns: (describe returnvalue here)\n\n## methodName\n(describe method here)\n\nReturns: (describe returnvalue here)\n\nExamples:\n\n```supercollider\n(some example code)\n```"} {"text": "SuperCollider classlib — CuePlayer/GUI/ClockFaceCP.sc\n\n```supercollider\nClockFaceCP {\n var inc, <>bounds, isPlaying = false, clock, timeString;\n\n *new{ \n arg window, starttime = 0, tempo = 1, inc = 0.1, bounds = Rect(0, 0, 209, 20);\n ^super.newCopyArgs(window, starttime, tempo, inc, bounds).init;\n }\n\n init {\n cursecs = starttime;\n this.digitalGUI;\n }\n\n play {\n var start;\n clock = TempoClock.new(tempo);\n start = clock.elapsedBeats;\n clock.sched(inc, {\n this.cursecs_(clock.elapsedBeats - start + starttime, false);\n inc;\n });\n isPlaying = true;\n }\n\n cursecs_ {arg curtime, updateStart = true;\n var curdisp;\n cursecs = curtime;\n curdisp = curtime.asTimeString;\n curdisp = curdisp[0 .. (curdisp.size-3)];\n updateStart.if({starttime = cursecs});\n {timeString.string_(curdisp)}.defer;\n }\n\n stop {\n starttime = cursecs;\n clock.clear;\n clock.stop;\n isPlaying = false;\n }\n\n digitalGUI { var initialValue;\n initialValue = \"00:00:00:0\";\n timeString = GUI.staticText.new(window, bounds)\n ."} {"text": ":00:00:0\";\n timeString = GUI.staticText.new(window, bounds)\n .string_(initialValue)\n .font_(Font(\"Arial\", 20))\n .align_(\\center)\n .stringColor_(Color.white);\n }\n\n}\n```"} {"text": "SuperCollider classlib — DataNetwork/core/SystemOverwrites/3.4/extWiiMote.sc\n\n```supercollider\n // this will be in the main distro from the next release (3.5)...\n *devicesMap{\n ^(\n wii_mote: [\n \\ax, \\ay, \\az, \\ao,\n \\bA, \\bB, \\bOne, \\bTwo,\n \\bMinus, \\bHome, \\bPlus, \\bUp, \\bDown, \\bLeft, \\bRight,\n \\led1, \\led2, \\led3, \\led4,\n \\battery\n ],\n wii_nunchuk: [\n \\nax, \\nay, \\naz, \\nao, \\nsx, \\nsy, \\nbZ, \\nbC\n ],\n wii_classic: [\n \\cbX, \\cbY, \\cbA, \\cbB, \\cbL, \\cbR, \n \\cbZL, \\cbZR,\n \\cbUp, \\cbDown, \\cbLeft, \\cbRight,\n \\cbMinus, \\cbHome, \\cbPlus,\n \\csx1, \\csy1, \\csx2, \\csy2,\n \\caleft, \\caright\n ]\n )\n }\n}\n```"} {"text": "SuperCollider schelp — Ease/HelpSource/Classes/EaseInCirc.schelp\n\nEaseInCirc —\nCircular ease-in\nCategory: Ease\nSee also: Overviews/EaseOverview\n\n\nEasing equation for a circular (sqrt(1-t^2)) ease-in, accelerating from zero velocity.\n\nUse value, *value, *kr or *ar, all with a Float argument t between 0.0 and 1.0. If t is below or above this range the output will be undefined.\n\n## value\n\n- t:\na Float between 0.0 and 1.0.\n\nExamples:\n\n\na= EaseInCirc.new\na.value(0.5)\n\n{|t| EaseInCirc.(t/99)}.dup(100).plot\n\ns.boot\n{SinOsc.ar(EaseInCirc.kr(Line.kr(0, 1, 2, doneAction:2)).exprange(500, 1000), 0, 0.1)}.play"} {"text": "SuperCollider patch — FPLib/Examples/FRP/counter.scd\n\n```supercollider\n(\n\n~but1 = Button();\n~but2 = Button();\n~text = StaticText();\n\nw = Window(bounds:Rect(200,200,200,200)).layout_(\n HLayout( ~but1, ~but2, ~text )\n ).front;\n\n//network\nENdef(\\x, {\n //inputs\n var but1E = ~but1.enIn;\n var but2E = ~but2.enIn;\n\n var counter = but1E.collect{ { |x| x - 1 } }\n .merge( but2E.collect{ { |x| x + 1 } } )\n .injectF(0);\n\n ~text.enSink( counter.collect{ |x| [\\string_, x] } );\n\n}).start;\n)\n```"} {"text": "SuperCollider patch — FPLib/Examples/FRP/sumWithLastValue.scd\n\nsum with last value recursive expressions\n\n```supercollider\n//sum with last value\n//recursive expressions\n/*\n\nfrp in haskell can express mutually recursive values\nThis allows a value to depend on it's own past value:\n\nreactive-banana\nsum to the last value:\n\ne2 = (+) <$> b <@> e1\nb = stepper 0 e2\n\nunfortunatelly this cannot be done this way in SuperCollider so\n\nf <$> sig <@> es\n\nmust be changed to\n\nf.liftRecSampled({sig}, es)\n\n{sig} will delay execution of sig\n\n*/\n(\n//Setup GUI\nvar nb1 = NumberBox();\nvar nb2 = NumberBox();\n\nw = Window(bounds:Rect(200,200,200,100)).layout_(\n HLayout( StaticText().string_(\"In:\"), nb1, StaticText().string_(\"Out:\"), nb2 )\n );\n\n//Setup Event Network\n//network\nENdef(\\x, {\n var sumSig, sum;\n\n //in\n var nb1ES = nb1.enIn;\n\n sum = (_+_).liftRecSampled({sumSig}, nb1ES);\n sumSig = sum.hold(0);\n\n //out\n nb2.enSinkValue( sum );\n\n}).start;\n\nw.front;\n)\n```"} {"text": "SuperCollider classlib — FileLog/MultiFilePlayerGui.sc\n\n```supercollider\n var sliderSpec;\n var updFunc;\n var \"]]);\n gotoF = Button.new(w, Rect( 0, 0, 48, 20 )).states_([[\"go to\"]]);\n file = NumberBox.new( w, Rect( 0, 0, 45, 20)).value_( 0 );\n stamp = StaticText.new( w, Rect( 0, 0, 195, 20)).background_( Color.white );\n\n slider = Slider.new( w, Rect( 0, 0, 200, 20));\n\n w.front;\n\n sliderSpec = [0,fp.indexFile.length,\\linear,1].asSpec;\n\n updFunc = { |v| v.postln; };\n\n playB.action = { |but| if ( but.value == 1 ){ playTask.play; }{ playTask.pause } };\n nextB.action = { updFunc.value( fp.next ); this.updateLoc };\n resetB.action = { fp.reset; playTask.reset; this.updateLoc };\n goto.action = { f"} {"text": " { fp.reset; playTask.reset; this.updateLoc };\n goto.action = { fp.goToLine( line.value ); this.updateLoc; };\n\n nextFB.action = { fp.openFile( fp.curid + 1 ); this.updateLoc };\n prevFB.action = { fp.openFile( fp.curid - 1 ); this.updateLoc };\n gotoF.action = { fp.openFile( file.value ); this.updateLoc; };\n\n /*\n slider.action = { |sl|\n var lmval,lval;\n lval = sliderSpec.map( sl.value );\n lmval = fp.lineMap.array.indexInBetween( lval ).floor;\n if ( ( (sl.value) - sliderSpec.unmap( fp.lineMap.at( lmval ) ) ) < 0.1 ){\n fp.goToLine( lmval ); \n }{\n fp.goToLine( (lval/linedist).floor; );\n };\n this.updateLoc;\n };\n */\n\n this.setPlayTask;\n }\n\n estimateLine { \n var cl,dist; \n if ( fp.indexFile.lineMap.size < 2 ){\n // get at least one increase in lines and reset to the old line id:\n cl = fp.indexFile.currentLine; fp.indexFile.next; fp.indexFile.goToLine( cl ); \n };\n linedist = (fp.indexFile.lineMap.at(1) - fp.indexFile.lineMap.at(0) );"} {"text": "xFile.lineMap.at(1) - fp.indexFile.lineMap.at(0) );\n }\n\n updateLoc { \n defer{\n file.value_( fp.curid );\n line.value_( fp.currentLine );\n if ( fp.indexFile.lineMap.at( fp.curid ).notNil ){\n slider.value = sliderSpec.unmap( \n fp.indexFile.lineMap.at( fp.curid ) );\n };\n };\n this.updateStamp;\n }\n\n updateStamp {\n defer{ stamp.string_( fp.readIndexLine( fp.curid ).first ); };\n }\n\n setPlayTask{ |func,dt = 0.1|\n updFunc = func ? updFunc;\n playTask = Task.new( { var val; \n while ( { (val = fp.next).notNil },{\n updFunc.value( val ); \n this.updateLoc;\n dt.value.wait;\n });\n playB.value = 0;\n } );\n }\n\n}\n```"} {"text": "SuperCollider classlib — GameLoop/Classes/EntityRepresentation.sc\n\n```supercollider\n *new { arg repManager, collisionFunc;\n ^super.newCopyArgs(repManager, collisionFunc)\n }\n\n init{ var latency;\n /* initialize data */\n /* this.getData; */\n position = entity.position;\n radius = entity.radius;\n speed = entity.velocity.norm;\n\n collisionFunc = collisionFunc ?? {{}};\n\n //Do transformation in case there is a camera\n position = this.cameraTransform(entity);// + entity.worldCenter;\n }\n\n/* public */\n\n update { arg entity, message;\n switch (message[0])\n {\\preUpdate}\n { var transPosition;\n transPosition = this.cameraTransform(entity);\n this.preUpdate(entity, transPosition);\n }\n {\\update}\n {this.getData}\n {\\attach}\n {this.attach(entity) }\n {\\remove}\n {this.remove;}\n {\\detach}\n {this.detach(message)}\n {\\collision}\n {this.collision(message)};\n }\n\n attach{ arg entity;\n if (attached.isNil or:{attached.not},\n { attached = true;\n this.storeEntity(entity);\n this.init; }\n );\n }\n\n add{\n this.addAll;\n }\n\n remove{\n repManager.remove(this);\n attached = false;\n }\n\n/* private"} {"text": "ove{\n repManager.remove(this);\n attached = false;\n }\n\n/* private */\n\n detach{ arg message;\n if (attached and:{message[1] == this}, {attached = false; this.remove;});\n }\n\n cameraTransform{arg entity;\n if (Camera2D.active,\n {^(Camera2D.instance.applyTransformation(entity))},\n {^position}\n );\n }\n\n preUpdate{ arg entity, transposition;\n position = transposition + entity.worldCenter;\n }\n\n getData{\n position = entity.position - entity.worldCenter;\n radius = entity.radius;\n speed = entity.velocity.norm;\n }\n\n addAll{ arg delay = 0;\n if(entity.queuedForAddition,\n {this.addRepresentation},\n {this.addEntityAndRepresentation(delay)}\n );\n }\n\n addEntityAndRepresentation{ arg delay;\n entity.queuedForAddition_(true);\n Routine{\n if(delay.notNil) {delay.wait};\n if (entity.active.not){entity.add};\n this.addRepresentation;\n }.play;\n }\n\n addRepresentation{\n repManager.add(this);\n }\n\n storeEntity{ arg item;\n entity = item;\n }\n\n colliding{\n ^entity.colliding;\n }\n\n dt{\n ^entity.dt;\n }\n\n collision{ arg message;\n /* message should have a list at [1] with the colliding with entities*/\n collisionF"} {"text": "{ arg message;\n /* message should have a list at [1] with the colliding with entities*/\n collisionFunc.value(this, entity, message[1]);\n }\n\n}\n```"} {"text": "SuperCollider classlib — GraphicalModule/Classes/GMStyle.sc\n\n```supercollider\n classvar thisDefault;\n\n var listeners,\n\n thisMainColor,\n thisSecondColor,\n\n thisOutlineColor,\n thisOutlineSize = 3,\n\n thisBackColor,\n thisBackgroundColor,\n\n thisBeatColor,\n\n thisDisabledColor,\n thisFontColorDisabled,\n thisSelectedColor,\n\n thisBorderSize = 4,\n thisBorderColor,\n thisSecondBorderSize = 0,\n thisSecondBorderColor,\n thisThirdBorderSize = 0,\n thisThirdBorderColor,\n\n thisHelpersColor,\n\n thisFont,\n thisFontColor,\n\n thisValueFontColor,\n thisHighlightColor;\n\n *new {\n ^super.new.init\n }\n\n *initClass {\n thisDefault = this.new();\n }\n\n *default {\n ^thisDefault\n }\n\n *default_ { |aGMStyle|\n thisDefault = aGMStyle;\n }\n\n init {\n listeners = List(0);\n\n thisMainColor = Color(0.75, 0, 0.333);\n thisSecondColor = Color(0.5, 0, 0.111);\n thisOutlineColor = Color(1, 1, 1);\n\n thisBackColor = Color(1, 0, 0.25);\n thisBackgroundColor = Color(0, 0, 0);\n\n thisBeatColor = Color(0, 1, 1, 0.5);\n\n thisFontCol"} {"text": ", 0);\n\n thisBeatColor = Color(0, 1, 1, 0.5);\n\n thisFontColorDisabled = Color(0.25, 0.25, 0.25);\n thisDisabledColor = Color(0.5, 0.5, 0.5);\n\n thisBorderColor = Color(0.666, 0, 0.125);\n thisSecondBorderColor = Color(0.333, 0, 0.0625);\n thisThirdBorderColor = Color(0, 0, 0);\n\n thisHelpersColor = Color(1, 1, 1, 0.25);\n\n thisFont = Font.default.deepCopy.size_(24);\n thisFontColor = Color(0, 0, 0);\n\n thisSelectedColor = Color(0.75, 0, 0.333);\n\n thisValueFontColor = Color(1, 1, 1);\n thisHighlightColor = Color(1, 1, 1, 0.5);\n }\n\n borderSize {\n ^thisBorderSize\n }\n\n borderSize_ { |aNumber|\n thisBorderSize = aNumber;\n this.refreshListeners;\n }\n\n secondBorderSize {\n ^thisSecondBorderSize\n }\n\n secondBorderSize_ { |aNumber|\n thisSecondBorderSize = aNumber;\n this.refreshListeners;\n }\n\n thirdBorderSize {\n ^thisThirdBorderSize\n }\n\n thirdBorderSize_ { |aNumber|\n thisThirdBorderSize = aNumber;\n this.refreshListeners;\n }\n\n borderColor {\n ^"} {"text": " = aNumber;\n this.refreshListeners;\n }\n\n borderColor {\n ^thisBorderColor\n }\n\n borderColor_ { |aColor|\n thisBorderColor = aColor;\n this.refreshListeners;\n }\n\n secondBorderColor {\n ^thisSecondBorderColor\n }\n\n secondBorderColor_ { |aColor|\n thisSecondBorderColor = aColor;\n this.refreshListeners;\n }\n\n thirdBorderColor {\n ^thisThirdBorderColor\n }\n\n thirdBorderColor_ { |aColor|\n thisThirdBorderColor = aColor;\n this.refreshListeners;\n }\n\n mainColor {\n ^thisMainColor\n }\n\n mainColor_ { |aColor|\n thisMainColor = aColor;\n this.refreshListeners;\n }\n\n secondColor {\n ^thisSecondColor\n }\n\n secondColor_ { |aColor|\n thisSecondColor = aColor;\n this.refreshListeners;\n }\n\n backColor {\n ^thisBackColor\n }\n\n backColor_ { |aColor|\n thisBackColor = aColor;\n this.refreshListeners;\n }\n\n backgroundColor {\n ^thisBackgroundColor\n }\n\n backgroundColor_ { |aColor|\n thisBackgroundColor = aColor;\n this.refreshListeners;\n }\n\n outlineSize {\n ^thisOutlineSize\n }\n\n out"} {"text": "freshListeners;\n }\n\n outlineSize {\n ^thisOutlineSize\n }\n\n outlineSize_ { |aNumber|\n thisOutlineSize = aNumber;\n this.refreshListeners;\n }\n\n outlineColor {\n ^thisOutlineColor\n }\n\n outlineColor_ { |aColor|\n thisOutlineColor = aColor;\n this.refreshListeners;\n }\n\n beatColor {\n ^thisBeatColor\n }\n\n beatColor_ { |aColor|\n thisBeatColor = aColor;\n this.refreshListeners;\n }\n\n disabledColor {\n ^thisDisabledColor\n }\n\n disabledColor_ { |aColor|\n thisDisabledColor = aColor;\n this.refreshListeners;\n }\n\n selectedColor {\n ^thisSelectedColor\n }\n\n selectedColor_ { |aColor|\n thisSelectedColor = aColor;\n this.refreshListeners;\n }\n\n helpersColor {\n ^thisHelpersColor\n }\n\n helpersColor_ { |aColor|\n thisHelpersColor = aColor;\n this.refreshListeners;\n }\n\n font {\n ^thisFont\n }\n\n font_ { |aFont|\n thisFont = aFont;\n this.refreshListeners;\n }\n\n fontColor {\n ^thisFontColor\n }\n\n fontColor_ { |aColor|\n thisFontColor = aColor;\n this.refreshListeners;\n }\n\n "} {"text": "olor|\n thisFontColor = aColor;\n this.refreshListeners;\n }\n\n fontColorDisabled {\n ^thisFontColorDisabled\n }\n\n fontColorDisabled_ { |aColor|\n thisFontColorDisabled = aColor;\n this.refreshListeners;\n }\n\n valueFontColor {\n ^thisValueFontColor\n }\n\n valueFontColor_ { |aColor|\n thisValueFontColor = aColor;\n this.refreshListeners;\n }\n\n highlightColor {\n ^thisHighlightColor\n }\n\n highlightColor_ { |aColor|\n thisHighlightColor = aColor;\n this.refreshListeners;\n }\n\n // Private methods, used to refresh Views automatically\n addListener { |aGMView|\n listeners.add(aGMView);\n }\n\n removeListener { |aGMView|\n listeners.removeAt(\n listeners.indexOf(aGMView));\n }\n\n refreshListeners {\n listeners.do({ |view|\n view.refresh;\n });\n }\n}\n```"} {"text": "SuperCollider schelp — Hilbert/HelpSource/Overviews/Hilbert-Overview.schelp\n\nThe Hilbert Transform Library\nVarious implementations of the Hilbert Transform and related functions.\nCategory: Libraries>Hilbert\n\n# Introduction\nThe Hilbert Transform is offered in various forms:\n\n##HilbertW - via Weaver's Third Method.\n##HilbertH - via Weaver's Second Method, known as Hartley Phasing.\n##HilbertPDN - via Hartley Phasing, expressed as a 12th-order Phase Differencing Network.\n\nThese WritingUGens#Pseudo-UGens#pseudo-UGens return https://ccrma.stanford.edu/~jos/st/In_Phase_Quadrature_Sinusoidal.html##phase-quadrature outputs in a form suitable for use as an https://ccrma.stanford.edu/~jos/st/Analytic_Signals_Hilbert_Transform.html##analytic signal . Each form offers separate pseudo-UGens for returning just the real or imaginary output independently by appending Re or Im, respectively, to the class name. E.g., HilbertWRe & HilbertWIm.\n\nAdditionally, each class includes further Hilbert related transforms and analyses:\n\n- Phase Rotation\n- https://en.wikipedia.org/wiki/Single-sideband_modulation##Single-Sideband Modulation (SSB) \n- Instantaneous Amplitude Analys"} {"text": "Single-Sideband Modulation (SSB) \n- Instantaneous Amplitude Analysis\n- Instantaneous Phase Analysis\n\n# Further Reading\n\nAnsari, R. “IIR Discrete-Time Hilbert Transformers.” Acoustics, Speech and Signal Processing, IEEE Transactions On, vol. 35, no. 8, 1987, pp. 1116–1119.\n\nHutchins, B. “Calculation of the Poles of 90° Phase Difference Networks [after Weaver]”\nin Musical Engineer's Handbook: Musical Engineering for Electronic Music. Ithaca, NY: Electronotes. 1975. http://electronotes.netfirms.com/MEHCh6aPart.PDF, accessed 2017-08-08.\n\nHutchins, B. “The Design of Wideband Analog 90° Phase Differencing Networks without Large Spread of Capacitor Values”, Electronotes, Special Issue G, No. 168, http://electronotes.netfirms.com/EN168-90degreePDN.PDF, accessed 2017-08-08.\n\nPicinbono, B. “On Instantaneous Amplitude and Phase of Signals.” Signal Processing, IEEE Transactions On, vol. 45, no. 3, 1997, pp. 552–560.\n\nSchüssler, H., and W. Steffen. “Halfband Filters and Hilbert Transformers.” C"} {"text": "., and W. Steffen. “Halfband Filters and Hilbert Transformers.” Circuits, Systems and Signal Processing, vol. 17, no. 2, 1998, pp. 137–164.\n\nSmith, J.O. “Analytic Signals and Hilbert Transform Filters”, in Mathematics of the Discrete Fourier Transform (DFT) with Audio Applications, Second Edition, https://ccrma.stanford.edu/~jos/st/Analytic_Signals_Hilbert_Transform.html, online book, 2007 edition, accessed 2017-08-08.\n\nWeaver, Donald. “A Third Method of Generation and Detection of Single-Sideband Signals.” Proceedings of the IRE, vol. 44, no. 12, 1956, pp. 1703–1705.\n\nUS Patent 1,666,206, Modulation System, April 17, 1928, United States Patent and Trademark Office."} {"text": "SuperCollider classlib — JITLibExtensions/classes/Dispatch.sc\n\n```supercollider\n var <>envir, <>public=true;\n\n value { arg key, obj;\n if(this.sendsTo(key))\n {\n if(obj.isKindOf(Function) and: { obj.isClosed.not }) {\n (Char.bullet ++ \" only closed functions can be sent\").postln;\n ^this\n };\n\n this.dispatch(key, obj)\n }\n }\n sendsTo { ^public }\n\n dispatch { ^this.subclassResponsibility(thisMethod) }\n}\n\nPublic : EnvirDispatch {\n\n var <>sendingKeys, <>listeningKeys;\n var <>addresses, <>channel, <>nickname;\n var <>action, <>logSelf=true, basicSafety=true;\n classvar 8125) { \"message too large to publish\".postln; ^this };\n addresses.do { arg addr; addr.sendBundle(nil, b) };\n }\n\n // in future: use a function to allow more flexibility.\n\n sendsTo { arg key;\n ^public and: { sendingKeys.notNil } and:\n {\n sendingKeys === \\all\n or:\n { sendingKeys.includes(key) }\n }\n }\n listensTo { arg key;\n ^public and: { listeningKeys.notNil } and:\n {\n listeningK"} {"text": " arg key;\n ^public and: { listeningKeys.notNil } and:\n {\n listeningKeys === \\all\n or:\n { listeningKeys.includes(key) }\n }\n }\n\n avoidTheWorst { arg obj;\n var str;\n if(basicSafety.not or: { obj.isKindOf(Symbol).not }) { ^true };\n str = obj.asString;\n ^str.find(\"unixCmd\").isNil\n and: { str.find(\"systemCmd\").isNil }\n and: { str.find(\"File\").isNil }\n and: { str.find(\"Pipe\").isNil }\n and: { str.find(\"Public\").isNil }\n }\n\n}\n```"} {"text": "SuperCollider classlib — JITLibExtensions/classes/extBufEnvir.sc\n\n```supercollider\n toBuffer { arg buffer;\n var numChannels, numFrames, coll;\n if(this.at(0).isArray) {\n numChannels = this.size;\n numFrames = this[0].size;\n coll = this.lace;\n } {\n numChannels = 1;\n numFrames = this.size;\n coll = this;\n };\n// buffer.server.makeBundle(nil, {\n buffer.numFrames_(numFrames).numChannels_(numChannels).alloc(buffer.setnMsg(0, coll));\n // buffer.sendCollection(this);\n // doesn't work yet, because of the way makeBundle works.\n// });\n }\n\n}\n\n+ SimpleNumber {\n toBuffer { arg buffer;\n this.asArray.toBuffer(buffer)\n }\n}\n\n+ String {\n toBuffer { arg buffer;\n buffer.allocRead(this)\n }\n}\n\n+ Nil {\n toBuffer { arg buffer;\n buffer.numFrames_(0).numChannels_(1).alloc\n }\n\n}\n```"} {"text": "SuperCollider classlib — JITLibExtensions/classes/GUI/ProxyMeter/PrePostView.sc\n\n```supercollider\n *initClass {\n preCol = Color.yellow(1.0, 0.4);\n postCol = Color.green(0.7, 0.4);\n preSatCol = Color.red(1, 0.4);\n satCol = Color.red(1, 0.6);\n\n swapXYFunc = { |bounds, rect|\n var newtop = bounds.height - rect.left;\n Rect(rect.top, newtop, rect.height, rect.width.neg);\n };\n }\n\n *new { |parent, bounds|\n ^super.new.init(parent, bounds);\n }\n\n *forMonitor { |monitorGui|\n var sliderZone = monitorGui.zone.children[0];\n var slider = sliderZone.children[1];\n\n ^this.new(sliderZone, slider.bounds);\n }\n\n init { |parent, bounds|\n\n uv = UserView(parent, bounds);\n uv.background_(Color(1,1,1,0));\n uv.acceptsMouse_(false);\n\n // horizontal for now:\n uv.drawFunc = { |uv|\n var bounds = uv.bounds;\n var maxwid = bounds.width - 4;\n var height = bounds.height - 4;\n var satPreLeft, satLeft, nextRect;\n\n var isVertical = swapXYFunc.notNil\n and: {"} {"text": ", nextRect;\n\n var isVertical = swapXYFunc.notNil\n and: { bounds.height > bounds.width };\n\n Pen.color_(preCol);\n nextRect = Rect(2,2, preAmp * maxwid, height);\n if (isVertical) { nextRect = swapXYFunc.(bounds, nextRect) };\n Pen.addRect(nextRect);\n Pen.fill;\n\n if (preAmp > 1.0) {\n Pen.color_(preSatCol);\n satPreLeft = (1 - (preAmp - 1).clip(0, 1)) * maxwid;\n nextRect = Rect( satPreLeft, 2, maxwid, height);\n if (isVertical) { nextRect = swapXYFunc.(bounds, nextRect) };\n Pen.addRect(nextRect);\n Pen.fill;\n };\n\n if (postAmp > 0) {\n Pen.color_(postCol);\n nextRect = Rect(2,2, postAmp * maxwid, height);\n if (isVertical) { nextRect = swapXYFunc.(bounds, nextRect) };\n Pen.addRect(nextRect);\n Pen.fill;\n\n if (postAmp > 1.0) {\n Pen.color_(satCol);\n satLeft = (1 - (postAmp - 1).clip(0, 1)) * maxwid;\n nextRect = Rect( satLeft, 2, maxwid, height);\n if (isVertical) { nextRect = swapXYFunc.(bounds, nextRect) };\n Pen.addRect(nextRect);\n Pen."} {"text": ".(bounds, nextRect) };\n Pen.addRect(nextRect);\n Pen.fill;\n };\n };\n };\n }\n\n setAmps { |pre = 0, post = 0|\n preAmp = pre.sqrt; postAmp = post.sqrt;\n uv.refresh;\n }\n\n remove { this.setAmps(0,0) }\n}\n```"} {"text": "SuperCollider classlib — JITMIDIKtl/JSBKtl.sc\n\nadc & haho - joystickbox inherit the rest from PocketFader\n\n```supercollider\n\nJSBKtl : PFKtl { \n \n init { // make sure we reach top and bottom \n // - the joysticks often only reach 15 - 105.\n ^super.init.valRange_([20, 100]);\n }\n *makeDefaults { \n\n // just one bank of joysticks\n defaults.put(this, \n ( // upper row, left to right\n js1X: '0_0', js2X: '0_2', js3X: '0_4', js4X: '0_6', \n js1Y: '0_1', js2Y: '0_3', js3Y: '0_5', js4Y: '0_7', \n \n js5X: '0_8', js6X: '0_10', js7X: '0_12', js8X: '0_14',\n js5Y: '0_9', js6Y: '0_11', js7Y: '0_13', js8Y: '0_15'\n )\n );\n }\n}\n```"} {"text": "SuperCollider schelp — MathLib/HelpSource/Classes/Matrix.schelp\n\nMatrix\nan ordered 2-dimensional array of numbers\nCategory: Math, Linear Algebra, Libraries>MathLib>Matrix\nSee also: Classes/Spherical, Classes/Point, Classes/Polar\n\n\n\nMatrices are a 2-dimensional Array whose slots may only contain (at the moment 'real' ) numbers. Their shape is fully described by the number of rows and columns(cols). Each element can be adressed by 2 indices (row,col), where row (col) ranges between 0 and rows-1 (cols-1). For a lesson on matrices, read your math books from school. Or this reference if you like it the hard way:\n http://www.ee.ic.ac.uk/hp/staff/dmb/matrix/intro.html#Intro \n\nArray2D\nMatrix uses an array-of-rows–notation. This is the same concept as found in Array2D. As a subclass of Array, Matrix responds to far more methods than given in this helpfile. Be aware of strange results when using them. This is meant to support only the basic matrix manipulations. Most of this is not designed for realtime action. Too slow, not optimized.\n\nPart of MathLib, a diverse library of mathematical functions.\n\n## newClear\nCreate a new Matrix of shape (rows, cols) filled with zeros.\nMatrix.newClear(3,3).postln; \n\n\nrows\n\n\ncols\n\n## with\nCreate a new Matrix whose rows are filled with the given subarrays.\n\nMatrix.with"} {"text": "\n## with\nCreate a new Matrix whose rows are filled with the given subarrays.\n\nMatrix.with([[1,2,3],[4,5,6],[7,8,9]]).postln; \n\n\narray\n\n## withFlatArray\nCreate a new Matrix from a 1-dimensional array of shape (rows , cols).\nMatrix.withFlatArray(3,3,[1,2,3,4,5,6,7,8,9]).postln; \n\n\nrows\n\n\ncols\n\n\narray\n\n## newIdentity\nCreate a new identity matrix of shape (n,n).\nMatrix.newIdentity(3).postln; \n\n\nn\n\n## newDiagonal\n\nCreate a new square https://en.wikipedia.org/wiki/Diagonal_matrix##diagonal matrix .\n\n```supercollider\nMatrix.newDiagonal(Array.series(8)); // Integer\nMatrix.newDiagonal(Array.series(8.0)); // Float\n```\n\n- diagonal:\n\nAn array of values with which to fill the diagonal.\n\n## newDFT\nCreate a new discrete Fourier transform matrix of shape (n,n).\nMatrix.newDFT(3).postln; \n\n\nn = 51; // DFT size\n\n// Make a sinusoidal test signal (3 partials: 1st, 3rd and 10th)\nx = Matrix.withFlatArray(n, 1, n collect: { |i| sin(2pi*i/(n - 1)) + sin(6pi*i/(n - 1)) + sin(20pi*i/(n - 1)) })\n\n// Calculate Fou"} {"text": "pi*i/(n - 1)) + sin(20pi*i/(n - 1)) })\n\n// Calculate Fourier transform\ny = Matrix.newDFT(n)*x\n\n// Plot spectrum\ny.flat.abs.plot(discrete: true)\n\n// Recover original signal from Fourier transform\nz = Matrix.newIDFT(n)*y\nz.flat.real.plot;\nx.flat.plot;\n\n\nn\n\n## newIDFT\nCreate a new inverse discrete Foutier transform matrix of shape (n,n).\nMatrix.newIDFT(3).postln; \n\n\n// Show discrete Fourier transform is unitary\nn = 3;\n(Matrix.newDFT(n)*Matrix.newIDFT(n)).real.postln;\n\n\nn\n\n## fill\nfill the matrix by evaluating function.\nfunction is passed two arguments: row, col\n\n\nrows\n\n\ncols\n\n\nfunction\n\n## mul\n\na = [[1,2],[3,4]];\nb = [[1,2],[1,2]];\n\nMatrix.mul(a,b);\n\n\nArrayA\n\n\nArrayB\n\n## rows\nReturns: the number of rows\n\n## cols\nReturns: the number of columns\n\n## shape\nReturns: the number of rows and columns as array [rows, cols]\n\n## postmln\npost the matrix as 2D representation.\n\n\nMatrix.withFlatArray(3,3,[1,2,3,4,5,6,7,8,9]).postln;\nMatrix.withFlatArray(3,3,[1,2,3,4,5,6,7,8,9]"} {"text": ".withFlatArray(3,3,[1,2,3,4,5,6,7,8,9]).postmln;\n\n## doRow\nevaluate function for each element of row;\nfunction is passed two arguments: item, col\n\n\nrow\n\n\nfunction\n\n## doCol\nevaluate function for each element of col;\nfunction is passed two arguments: item, row\n\n\ncol\n\n\nfunction\n\n## doMatrix\nevaluate function for each element ;\nfunction is passed three arguments: item, row,col;\n\n\nfunction\n\n## colsDo\nIterate over the columns. Each column will be passed to func in turn.\n\n```supercollider\na = Matrix.newIdentity(4);\na.colsDo({ |item, i| format(\"Col %: \", i).post; (item * i).postln;});\n```\n\n## rowsDo\nIterate over the rows. Each row will be passed to func in turn.\n\n```supercollider\na = Matrix.newIdentity(4);\na.rowsDo({ |item, i| format(\"Row %: \", i).post; (item * i).postln;});\n```\n\n## Changing Matrices\n\n## put\nput a single element at (row, col)\n\n\nrow\n\n\ncol\n\n\nvalue\n\n## putRow\nput a row of elements at (row)\n\nMatrix.newClear(3,3).putRow(0,[2,4,6]).postln \n\n\nrow\n\n\nvalues\n\n## putCol\nput a column of elements at (col)\n\nMatrix.newClear(3,3).putCol(1,[2,4,6]).postln \n\n\ncol\n\n\nvalues\n"} {"text": "3,3).putCol(1,[2,4,6]).postln \n\n\ncol\n\n\nvalues\n\n## fillRow\nfill a row by evaluating function for each element;\nfunction is passed two arguments: row, col.\n\n\nrow\n\n\nfunction\n\n## fillCol\nfill a column by evaluating function for each element;\nfunction is passed two arguments: row, col.\n\n\ncol\n\n\nfunction\n\n## exchangeRow\nexchange two rows\n\n\nrowA\n\n\nrowB\n\n## exchangeCol\nexchange two cols\n\n\ncolA\n\n\ncolB\n\n## Return Arrays\n\n## at\n\n\nrow\n\n\ncol\n\n## get\n\n\nrow\n\n\ncol\n\nReturns: element at (row,col)\n\n## getRow\n\n\nrow\n\nReturns: an array from row\n\n## getCol\n\n\ncol\n\nReturns: an array from column\n\n## getDiagonal\nReturns: an array from the diagonal elements\n\n## asArray\nReturns: an array of rows\n\n## flat\nReturns: a one slot array of all elements\n\n## Return Matrices\n\n## fromRow\n\n\nrow\n\nReturns: a new matrix from row\n\n## fromCol\n\n\ncol\n\nReturns: a new matrix from column\n\n## getSub\nget a sub-matrix from within matrix.\n\n- rowStart:\nRow index to begin copying.\n\n- colStart:\nColumn index to begin copying.\n\n- rowLength:\nThe number of elements to copy from each row.\n\n- colHeight:\nThe number of elements to copy from each column.\n\nReturns: a new matrix\n\n## addRow\nadd a row (values) to the matrix and return.\nreceiver is unchanged.\n\n\n"} {"text": "## addRow\nadd a row (values) to the matrix and return.\nreceiver is unchanged.\n\n\nvalues\n\n## addCol\nadd a column (values) to the matrix and return.\nreceiver is unchanged.\n\n\nvalues\n\n## insertRow\ninsert a row (values) in matrix and return.\nreceiver is unchanged.\n\n\ncol\n\n\nvalues\n\n## insertCol\ninsert a column (values) in matrix and return.\nreceiver is unchanged.\n\n\nrow\n\n\nvalues\n\n## removeRow\n\n\nrow\n\nReturns: a new matrix without row\n\n## removeCol\n\n\ncol\n\nReturns: a new matrix without column\n\n## collect\n\n\nfunction\n\nReturns: a new matrix by evaluating function for each element.\nfunction is passed three arguments: item, row, col.\n\n## sub\n\n\nrow\n\n\ncol\n\nReturns: a submatrix that results from matrix by crossing out row and col\n\n## flop\nReturns: the transpose of matrix\n\n## adjoint\nReturns: the adjoint or adjugate of a square matrix\n\n## inverse\nReturns: the inverse of a square matrix\n\n## gram\nReturns: the gram matrix\n(the transpose of matrix multiplied with matrix)\n T^t * T\n\n## pseudoInverse\nReturns: the pseudoInverse of a matrix\n\n## *\nReturns: the result of matrix multiplication: matrix * matrix2\nmatrix.cols must equal matrix2.rows\n\nmultiplication with aNumber for each element\n\n## +\nReturns: (matrix + matrix2)\nmatrix must have the same shape as matrix2\n\nsummation with aNumber for each element\n\n## -\nReturns: (matrix - matrix2)\n"} {"text": "2\n\nsummation with aNumber for each element\n\n## -\nReturns: (matrix - matrix2)\nmatrix must have the same shape as matrix2\n\nsubtraction with aNumber for each element\n\n## center\n\n\nmean\n\nReturns: a matrix centred around the mean vector (which will be calculated for you if not supplied)\n\n## thresh2\nBilateral thresholding.\n\n- thresh:\n\nWhen the\n```supercollider\ninput.abs < thresh\n```\n, the output is forced to\n```supercollider\n0\n```\n.\nShould be a positive value.\n\n- adverb:\n\nOptional, for processing Collections. See Adverbs.\n\n```supercollider\n(\nvar m = Matrix.with(Array.rand(9, -9, 9).clump(3));\nvar t = m.thresh(3);\nvar t2 = m.thresh2(3);\n\" original\".postln; m.postmln;\n\" thresh\".postln; t.postmln;\n\" thresh2\".postln; t2.postmln;\n\"\";\n)\n```\n\n## Return Characteristic Values\n\n## sum\nReturns: the sum of all elements\n\n## sumRow\n\n\nrow\n\nReturns: the sum of all elements of desired row\n\n## sumCol\n\n\ncol\n\nReturns: the sum of all elements of desired column\n\n## sumRows\n\n\nfunction\n\nReturns: an array giving the sum for every row\n\n## sumCols\n\n\nfunction\n\nReturns: an array giving the sum for every column\n\n## grammian\nReturns: the grammian of a matrix\n(determinant of the gram matrix)"} {"text": " grammian\nReturns: the grammian of a matrix\n(determinant of the gram matrix)\n\n## mean\nReturns: the mean array, calculated over the rows\n\n## cov\n\n\nmean\n\nReturns: the sample covariance, if rows represent observations\n\n## covML\n\n\nmean\n\nReturns: the Maximum-Likelihood covariance estimate, if rows represent observations and the distribution is assumed to be Gaussian\n\n## Return Characteristic Values of Square Matrices\n\n## det\nReturns: the determinant\n\n## cofactor\n\n\nrow\n\n\ncol\n\nReturns: the cofactor to element (row, col)\nthis is the determinant of the matrix.sub(row, col) mutiplied with (-1)**(row+col)\n\n## trace\nReturns: the trace of matrix:\n(sum of the diagonal elements)\n\n## norm\nReturns: the euclidean norm of matrix\n( sqrt( tr [ A*A(T) ] ) )\n\n## Testing\n\n## isSquare\nReturns: true for (n x n) - matrices\n\n## isSingular\nReturns: true if determiant is zero\n\n## isRegular\nReturns: true if determiant is Non-zero\n\n## isSymmetric\nReturns: true if matrix is symmetric\n\n## isAntiSymmetric\nReturns: true if matrix is antisymmetric\n\n## isPositive\nReturns: true if matrix is strictly positive\n\n## isNonNegative\nReturns: true if matrix is positive / non negative (zeros allowed)\n\n## isNormal\n"} {"text": "gative\nReturns: true if matrix is positive / non negative (zeros allowed)\n\n## isNormal\nReturns: true if matrix is normal\n\n## isZero\nReturns: true for a zero matrix\n\n## isIntegral\nReturns: true if matrix is integral\nAn Integral matrix is one whose elements are all integers.\n\n## isIdentity\nReturns: true if matrix is an identity matrix\n(the diagonal elements are all 1; the nondigonal elements are all zero)\n\n## isDiagonal\nReturns: true if matrix is diagonal\na(i,j)=0 unless i=j.\n\n## isOrthogonal\nReturns: true if matrix is orthogonal\n(the matrix multiplied with its transpose is an identity matrix)\n\n## isIdempotent\nReturns: true if matrix is idempotent\n(the squared matrix equals itself)\n\n## ==\nReturns: true if matrix equals matrix2\n\n## Unary Operators: matrix.uop\n\n## neg\n\n## bitNot\n\n## abs\n\n## ceil\n\n## floor\n\n## frac\n\n## sign\n\n## squared\n\n## cubed\n\n## sqrt\n\n## exp\n\n## reciprocal\n\nReturns: new matrices.\n\n## Binary Operators\nusage: matrix bop aNumber\nor: aNumber bop matrix\n\n## /\n\n## div\n\n## %\n\n## **\n\n## min\n\n## max\n\nReturns: new matrices\n\n# Authors\n\n- sc.solar(at)studiobeige.de (Original author)\n- Till Bovermann"} {"text": "SuperCollider classlib — MathLibTests/TestMathLib.sc\n\n```supercollider\nThese tests are for \"miscellaneous\" mathlib functions that don't have their own class.\n*/\nTestMathLib : UnitTest {\n \n test_correlation {\n var x, y, n, p;\n \n n = 1000000;\n \n // Uncorrelated\n x = {10.0.sum3rand}.dup(n);\n y = {10.0.sum3rand}.dup(n);\n p = corr(x, y);\n this.assert(p.abs < 0.002, \"corr() on uncorrelated data should give near-zero value (this test may [rarely] fail by chance)\");\n // Correlated\n x = {10.0.sum3rand}.dup(n);\n y = x.deepCopy;\n p = corr(x, y);\n this.assert(p == 1.0, \"corr() on perfectly correlated data == 1\");\n // Anticorrelated\n x = {10.0.sum3rand}.dup(n);\n y = x.collect(0.0 - _);\n p = corr(x, y);\n this.assert(p == -1.0, \"corr() on perfectly anticorrelated data == -1\");\n \n \n n = 50000; // spearmanRho is much slower than corr so let's use slightly smaller data\n \n // Uncorrelated\n x = {10.0.sum3rand}.dup(n);\n y = {10.0.sum3rand}.dup(n);\n p = spearmanRho(x, y);\n this.assert(p.abs < 0.012, \"spearmanRho() on uncorrelated data should give near-zero value (this"} {"text": " 0.012, \"spearmanRho() on uncorrelated data should give near-zero value (this test may [rarely] fail by chance)\");\n // Correlated\n x = {10.0.sum3rand}.dup(n);\n y = x.deepCopy;\n p = spearmanRho(x, y);\n this.assert(p == 1.0, \"spearmanRho() on perfectly correlated data == 1\");\n // Anticorrelated\n x = {10.0.sum3rand}.dup(n);\n y = x.collect(0.0 - _);\n p = spearmanRho(x, y);\n this.assert(p == -1.0, \"spearmanRho() on perfectly anticorrelated data == -1\");\n \n }\n \n test_princomp {\n var x, y, n, p, d;\n \n n = 100000;\n \n // Correlated\n x = {10.0.sum3rand}.dup(n);\n y = x.deepCopy;\n p = pc1([x, y].flop);\n this.assert(p[0] == p[1], \"pc1() on perfectly correlated data gives a vector pointing along [+1, +1] or [-1, -1]\");\n // Anticorrelated\n x = {10.0.sum3rand}.dup(n);\n y = x.collect(0.0 - _);\n p = pc1([x, y].flop);\n this.assert(p[0] == (0.0 - p[1]), \"pc1() on perfectly anticorrelated data gives a vector pointing along [+1, -1] or [-1, +1]\");\n // A specific bimodal distrib\n d = n.collect{ if(0.5.coin){"} {"text": "1]\");\n // A specific bimodal distrib\n d = n.collect{ if(0.5.coin){[-2, -0.5]}{[2, 0.5]}.collect{|v| v + 0.95.sum3rand} };\n // GNUPlot.new.scatter(d);\n p = pc1(d);\n this.assertArrayFloatEquals(p.abs, [ 0.97016356074164, 0.24245103350099 ], \"pc1() on a specific bimodal distribution\", 0.01);\n }\n}\n```"} {"text": "SuperCollider schelp — Maths/HelpSource/Maths.schelp\n\nMaths —\nFunction Generator\nSee also: Maths2\nCategory: UGens>Generators>Deterministic\n\n\nA Faust implementation of the MakeNoise Maths EuroRack module. Creates a logarithmic to exponential curve function that can be triggered or can oscillate. The function starts at 0, goes to 1, and returns to 0 on each iteration or loop.\n\nThe Maths.scx file must be in the Extensions folder for this to work. If you downloaded the quark, you should move this file.\n\nFor a pure SC implementation of the same algorithm, use Maths2, which is completely interoperable and should give mostly identical output. (Right now the EOC and EOR triggers are not exactly the same - Maths outputs single sample triggers. Maths two correctly outputs PWM oscillators.)\n\nThe source code for the Faust implementation of the UGen is provided and can be compiled for SC, PD, Max, or other environments.\n\nThe UGen outputs a 3 channel signals:\n\nChannel[0] is the audio rate function.\n\nChannel[1] is a pulse width oscillator at the front edge of the function (Front of Cycle - FOC). The oscillator is 1 while the function is rising and 0 while it is falling or not active. (This is currently a simple trigger in the Maths, and PWM in the Maths2.)\n\nChannel[2] is the end-of-rise (EOR) pulse width oscillator. It is 1 when the function is falling and 0 when the function is rising or not active. (This is"} {"text": "th oscillator. It is 1 when the function is falling and 0 when the function is rising or not active. (This is currently a simple trigger in the Maths, and PWM in the Maths2.)\n\nAudio Rate Only!\n\n## ar\n\n- riseDur:\nDuration of the signal's rise from 0.001 to 10 minutes.\n\n- fallDur:\n\nDuration of the signal's fall from 0.001 to 10 minutes.\n\n- logExp:\n\n0 is a logarithmic curve, 1 is an exponential curve. 0.5 is linear.\n\n- loop:\n\nIf 1, the function loops. If 0, the function does not loop. The cycle will start over upon receiving a value of 1.\n\n- plugged:\n\n0 is normal operation, using internal cycle to create the input. When \"plugged\" it only reactions to tiggers coming from the trig input.\n\n- trig:\n\nAn input trigger will trigger the function to happen once if loop is set to 0.\n\nExamples:\n\nMaths outputs 3 signals. The function, FOC and EOR:\n\n```supercollider\n{Maths.ar(0.05, 0.15, 0.8)}.plot(1)\n```\n\nBoth FOC and EOR are 0 when the function is 0:\n\n```supercollider\n{Maths.ar(0.05, 0.15, 0.8, 0, 1, Impulse.ar(3))}.plot(1)\n```\n\nMouseX and MouseY control the rise and fall durations of the function. MouseButton triggers the cycle to end. Lifting the MouseButton trigger the cycle to start over:\n\n```supercollider\na = {LFTri.ar(100+(1000*Maths."} {"text": " over:\n\n```supercollider\na = {LFTri.ar(100+(1000*Maths.ar(MouseX.kr, MouseY.kr, 0.2, 1-MouseButton.kr(lag:0.001))[0]), 0, 0.1)}.play //notice how I am taking the [0]th channel of the Maths and ignoring the other outputs\n```\n\nThe same thing but with no looping, just MouseButton triggers:\n\n```supercollider\na = {LFTri.ar(100+(1000*Maths.ar(MouseX.kr, MouseY.kr, 0.2, 0, 1, MouseButton.kr(lag:0.001))[0]), 0, 0.1)}.play\n```\n\nChanging the shape of the envelope from Log to Exponential has significant influence over the sound:\n\n```supercollider\na = {LFTri.ar(100+(1000*Maths.ar(MouseX.kr, MouseY.kr, SinOsc.ar(0.2, 0).range(0,1), 1-MouseButton.kr(lag:0.001))[0]), 0, 0.1)}.play\n```\n\nA Maths can also be used to trigger a Maths. Here we have a complex percussion sound made by using the trigger out of one Maths to trigger a second, nonlooping Maths.\n\n```supercollider\n(\na = {\n var sig, mathsA, foc, mathsB, sig1, noise;\n\n #mathsA, foc = Maths.ar(0.001, MouseX.kr, 0.9, 1-MouseButton.kr(0,1, 0.001));\n\n sig = L"} {"text": "r, 0.9, 1-MouseButton.kr(0,1, 0.001));\n\n sig = LFTri.ar(100+(2000*mathsA), 0, 0.1);\n mathsB = Maths.ar(0.001, min(0.1, MouseX.kr), 0.9, 0, 1, foc)[0];\n noise = mathsB*WhiteNoise.ar(0.1);\n\n sig1 = LFTri.ar(20+(mathsB*1400), 0, 0.1);\n\n (sig+sig1+noise).dup;\n}.play\n)\n```\n\nThe same idea, but using the EOR.\n\n```supercollider\n(\na = {\n var sig, mathsA, foc, eor, mathsB, sig1, noise;\n\n #mathsA, foc, eor = Maths.ar(0.5, MouseX.kr, 0.5, 1-MouseButton.kr(0,1, 0.001));\n\n sig = LFTri.ar(100+(2000*mathsA), 0, 0.1);\n mathsB = Maths.ar(0.001, min(0.1, MouseX.kr), 0.9, 0, 1, eor)[0];\n noise = mathsB*WhiteNoise.ar(0.1);\n\n sig1 = LFTri.ar(20+(mathsB*1400), 0, 0.1);\n\n (sig+sig1+noise).dup\n}.play\n\n)\n```\n\nRise and Fall can each be up to 600 seconds:\n\n```supercollider\na = {LFTri.ar(50+(1000*Maths.ar(10, 10, 0.5, 1)[0]), 0, 0.1)}.play //notice how I am taking the"} {"text": "10, 10, 0.5, 1)[0]), 0, 0.1)}.play //notice how I am taking the [0]th channel of the Maths and ignoring the [1]st channel.\n```\n\nAn external Audio or Control rate signal can be used is an input to the Slew inside Maths:\n\n```supercollider\na = {LFTri.ar(100+(1000*Maths.ar(MouseX.kr, MouseY.kr, 0.2, 1, 0, 1, LFPulse.ar(2))[0]), 0, 0.1)}.play\n```\n\nThis is a fun way to make different shaped noise curves:\n\n```supercollider\n(\na = {\n var dur;\n\n dur = 0.1;\n\n LFTri.ar(100+(1000*Maths.ar(dur/2, dur/2, 0.99, 1, 0, 1, LFNoise0.ar(1/dur).range(0,1))[0]), 0, 0.1)\n}.play\n)\n```"} {"text": "SuperCollider classlib — McldUnitTests/TestKMeansRT.sc\n\n```supercollider\n dataFromLanguageTest { |d, numclust, senddatafunc, analysebufferfunc|\n // Simple factory method to poke a KMeansRT with values from the language, and check what the buffer looks like afterwards.\n var s=Server.default, thebuf, thesynth, c, subtots;\n thebuf = Buffer.alloc(s, numclust, d+1);\n 0.1.wait;\n s.sync;\n thesynth = Synth(\"testmcldugens_kmeansrt%d\".format(d), ['buf', thebuf, 'k', numclust]);\n 0.1.wait;\n s.sync;\n senddatafunc.value(thesynth);\n 0.1.wait;\n s.sync;\n thebuf.loadToFloatArray(action: { |data|\n data = data.clump(d+1);\n // equiv to \"c = k.centroids\":\n c = data.collect{|frame| frame[..d-1]};\n subtots = data.collect{|frame| frame.last};\n\n analysebufferfunc.value(c, subtots);\n \n thebuf.free;\n thesynth.free;\n });\n }\n\n test_kmeansrt {\n var k, p, c, range, rescaled, testsIncomplete=0;\n this.bootServer;\n SynthDef('testmcldugens_kmeansrt1d', { |buf=0, input=0, k=5, t_gate=0"} {"text": "_kmeansrt1d', { |buf=0, input=0, k=5, t_gate=0, t_reset=0, learn=1|\n KMeansRT.kr(buf, input, k, t_gate, t_reset)\n }).add;\n SynthDef('testmcldugens_kmeansrt2d', { |buf=0, input=#[0,0], k=5, t_gate=0, t_reset=0, learn=1|\n KMeansRT.kr(buf, input, k, t_gate, t_reset)\n }).add;\n SynthDef('testmcldugens_kmeansrt3d', { |buf=0, input=#[0,0,0], k=5, t_gate=0, t_reset=0, learn=1|\n KMeansRT.kr(buf, input, k, t_gate, t_reset)\n }).add;\n SynthDef('testmcldugens_kmeansrt4d', { |buf=0, input=#[0,0,0,0], k=5, t_gate=0, t_reset=0, learn=1|\n KMeansRT.kr(buf, input, k, t_gate, t_reset)\n }).add;\n\n [1,2,3,4].do{|d|\n var thebuf, thesynth;\n\n testsIncomplete = testsIncomplete + 1;\n this.dataFromLanguageTest(d, 2, { |thesynth|\n p = [{-2}.dup(d), {2}.dup(d)];\n \"Sending fuzzybinary data to KMeansRT (takes about 10 secs)...\".postln;\n 1000."} {"text": "zybinary data to KMeansRT (takes about 10 secs)...\".postln;\n 1000.do{\n thesynth.set('t_gate', 1, 'input', p.choose + {0.5.sum3rand}.dup(d));\n 0.01.wait;\n };\n }, { |c, subtots|\n c.sortBy(0);\n c = (p-c).flat.abs;\n this.assertArrayFloatEquals(c, 0.0, \n \"clustering %D fuzzybinary data should approximately recover the true centroids\".format(d), 0.1);\n testsIncomplete = testsIncomplete - 1;\n });\n\n [1,2,3,4].do{|numclust|\n testsIncomplete = testsIncomplete + 1;\n this.dataFromLanguageTest(d, numclust, { |thesynth|\n p = {100.0.rand}.dup(d);\n 100.do{\n thesynth.set('t_gate', 1, 'input', p);\n 0.01.wait;\n };\n }, { |c, subtots|\n this.assertArrayFloatEquals(c.flat, p.dup(c.size).flat, \n \"clustering constant data should give centroids at the constant value (%D, k=%)\".format(d, numclust));\n testsIncomplete = testsIncomplete - 1;\n });\n //////\n testsIncomplete = testsIncomplete + 1;\n this.dataFromLanguageTest(d, numclust, { |thesynth|\n range = {{100.0.rand}.dup.integrate}.dup(d"} {"text": "hesynth|\n range = {{100.0.rand}.dup.integrate}.dup(d).flop;\n 100.do{\n thesynth.set('t_gate', 1, 'input', d.collect{|whichd| 1.0.rand.linlin(0,1,range[0][whichd], range[1][whichd])});\n 0.01.wait;\n };\n }, { |c, subtots|\n rescaled = c.collect{ |acent| (acent - range[0]) / (range[1] - range[0]) }.flat;\n this.assert(rescaled.every{|val| (val>=0) and: {val<=1}},\n \"clustering range-limited data should give centroids within that range (%D, k=%)\".format(d, numclust));\n testsIncomplete = testsIncomplete - 1;\n });\n };\n };\n \n // Wait for async tests\n this.wait{testsIncomplete==0};\n } // end test_kmeansrt\n\n test_kmeansrt_nolearn {\n var d=5, numclust=7, origdata, buf, s=Server.default, thesynth, testsIncomplete=1;\n this.bootServer;\n\n origdata = {100.0.rand}.dup(numclust * (d+1));\n buf = Buffer.loadCollection(s, origdata, d+1);\n 0.2.wait;\n s.sync;\n\n thesynth = {\n Line.kr(0,0,1,doneAction:2);\n KMeansRT.kr(buf, {PinkNoise.kr}.dup(d),"} {"text": ");\n KMeansRT.kr(buf, {PinkNoise.kr}.dup(d), numclust, gate:1, reset:0, learn:0);\n }.play(s);\n 0.2.wait;\n s.sync;\n 1.0.wait;\n \n buf.loadToFloatArray(action: {|data|\n this.assertArrayFloatEquals(data, origdata,\n \"data buffer should be unaffected by use of KMeansRT.kr(learn=0)\");\n testsIncomplete = testsIncomplete - 1;\n });\n \n // Wait for async tests\n this.wait{testsIncomplete==0};\n } // end test_kmeansrt_nolearn\n\n} // end class TestKMeansRT\n```"} {"text": "SuperCollider schelp — MethodController/HelpSource/Classes/FuncSpec.schelp\n\nFuncSpec\na Spec that can be anything\nCategory: MethodControllerQuark\n\n\nA Spec is basically an Object that translates data ( map/unmap), secures that the data fits a specification (constrain).\nThis Spec holds functions to enact these duties.\n\n## new\nCreates a FuncSpec\n\n- mapFunc:\na Function to be called on map\n\n- unmapFunc:\na Function to be called on unmap\n\n- constrainFunc:\na Function to be called on constrain\n\n- defaultFunc:\na Function to be called on default\n\nReturns: a FuncSpec\n\nThe instance methods are the most important of ControlSpec\n\nExamples:\n\nA simple example that could be also with a ControlSpec\n\n```supercollider\n(\na = FuncSpec({|a|(a*10).debug(\"map 0-1 to 0-10\")}\n ,{|a|(a/10).debug(\"unmap 0-10 to 0-1\")}\n ,{|a|a.clip(0,10).debug(\"constrain between 0-10\")}\n ,0\n);\na.map(0.5);\na.unmap(5);\na.constrain(-1000);\na.default;\n)\n```"} {"text": "SuperCollider classlib — Modality-toolkit/Modality/Classes/HID/HIDMKtlDevice.sc\n\n```supercollider\n classvar showAllDevices = false, % type: %\".format(\n mktl, el.name.cs, el.value.asStringPrec(3), el.type).postln\n };\n\n mktl.elementsDict.keysValuesDo { |elemKey, elem|\n var theseElements;\n\n var elid = elem.elemDes"} {"text": "mKey, elem|\n var theseElements;\n\n var elid = elem.elemDesc[\\hidElementID];\n var page = elem.elemDesc[\\hidUsagePage];\n var usage = elem.elemDesc[\\hidUsage];\n\n var hidElemFunc = { |val, hidElem|\n if (enabled) { elem.deviceValueAction_( val ); };\n if(traceRunning) { traceFunc.value(elem) }\n };\n\n var hidElem, hidElems;\n\n // device specs should primarily use usage and usagePage,\n // only in specific instances - where the device has bad firmware\n // use elementIDs which will possibly be operating system dependent\n\n if ( elid.notNil ) { // filter by element id\n hidElem = source.elements.at( elid );\n } { // filter by usage and usagePage\n // HIDFunc.usage( { |v| el.deviceValueAction_( v ) },\n // usage, page, \\devid, devid );\n hidElems = source.findElementWithUsage( usage, page );\n if (hidElems.size > 1) {\n \"%: hidElems.size is % - should not be > 1!\\n\"\n .postf(mktl, hidElems.size);\n \"taking first of :\".postln(hidElems);\n hidElems.printAll;\n };\n hidElem = hidElems.first;\n };\n if (hid"} {"text": "ll;\n };\n hidElem = hidElems.first;\n };\n if (hidElem.isNil) {\n \"%: in % no hidElem was found for elemKey % !\\n\"\n .postf(mktl, thisMethod, elemKey.cs);\n ^this\n };\n\n // we have a valid element, so use it\n hidElemDict.put(elemKey, hidElem);\n hidElemFuncDict.put(elemKey, hidElemFunc);\n hidElem.action = hidElem.action.addFunc(hidElemFunc);\n };\n }\n\n enableElement { |elemKey|\n var hidElem = hidElemDict[elemKey];\n var funcToAdd = hidElemFuncDict[elemKey];\n var hidElemAction = hidElem.action;\n\n // only add once, so remove first, then add\n hidElem.action = hidElemAction\n .removeFunc(funcToAdd)\n .addFunc(funcToAdd);\n }\n\n disableElement {|elemKey|\n var hidElem = hidElemDict[elemKey];\n var funcToRemove = hidElemFuncDict[elemKey];\n var hidElemAction = hidElem.action;\n hidElem.action = hidElemAction.removeFunc(funcToRemove);\n }\n\n // not elegant to write global enabling into each element.\n // there should be a simpler global way.\n enable { |"} {"text": " // not elegant to write global enabling into each element.\n // there should be a simpler global way.\n enable { |elemKeys|\n (elemKeys ? hidElemDict.keys).do { |elem|\n this.enableElement(elem);\n }\n }\n\n disable { |elemKeys|\n (elemKeys ? hidElemDict.keys).do { |elem|\n this.disableElement(elem);\n }\n }\n\n send { |key, val|\n var mktlElem, elemDesc, hidElem;\n mktlElem = mktl.elementsDict[ key ];\n if (mktlElem.isNil) {\n ^this\n };\n elemDesc = mktlElem.elemDesc;\n if ( elemDesc.isNil ){\n ^this\n };\n\n hidElem = hidElemDict[key];\n if (hidElem.notNil) {\n hidElem.value = val;\n };\n }\n\n // no cases yet in MKtlDesc folder\n sendSpecialMessage { |msgs|\n \"% not implemented yet, no cases yet in MKtl descs.\\n\"\n .postf(thisMethod);\n }\n}\n```"} {"text": "SuperCollider patch — Modality-toolkit/Modality/DeviceExamples/Uc4_RelSet_example.scd\n\nTest relative setting on UC4: on the device, select grp1, then go into edit mode: hold \\shift, press \\edit_setup select enc1 on knob 1, change ctlmode to Ccr2, hold until running bars go away -> all encoders are now relative then test here:\n\n```supercollider\n// Test relative setting on UC4:\n\n// on the device, select grp1,\n// then go into edit mode: hold \\shift, press \\edit_setup\n// select enc1 on knob 1, change ctlmode to Ccr2,\n// hold until running bars go away -> all encoders are now relative\n\n// then test here:\nm = MKtl(\\uc4, \"*uc4\");\nm.trace;\nm.gui;\n\n// add a spec to uc4, for relative use:\n// ccr2 is up 58 ... 63 down / 65 .. 70 up,\n// so use this for good resolution on gui elements\nm.addSpec(\\knRel, [56, 72, \\lin, 1, 64]);\nm.elAt(\\kn, \\1).do(_.deviceSpec_(m.getSpec(\\knRel)));\n\n~ckeys = [\\a, \\b,\\c, \\d, \\e, \\f];\n~ckeys.do (Spec.add(_, \\amp));\nm.specs;\n// a silly sound\nNdef(\\a, {\n (VarSaw.ar((1..6) * 48.midicps, 0, 0.1)\n * ~"} {"text": " (VarSaw.ar((1..6) * 48.midicps, 0, 0.1)\n * ~ckeys.collect(_.kr(0)).lag(0.1)).mean;\n}).play;\n\nNdef(\\a).gui(6);\n\n// make the action fot the encoders:\n// - moving knob above 0 will raise level in rel steps,\n// - below middle will lower it\n\n~ckeys = Ndef(\\a).controlKeys;\nm.elAt(\\kn, \\1).action = { |el|\n RelSet(\n Ndef(\\a),\n ~ckeys[el.indexInGroup].postln,\n ((el.value - 0.5) * 0.06).postln,\n \\amp\n )\n};\n\n// now try that it works by moving knobs\n// ...\n// then set Ndef to random values\nNdef(\\a).set(* ~ckeys.collect ([_, 1.0.linrand]).flat);\n\n// and move knobs again, should continue smoothly\n// from where they are now.\n```"} {"text": "SuperCollider schelp — Modality-toolkit/Modality/HelpSource/Tutorials/Creating_Named_Groups.schelp\n\nCreating Named Groups\nOrganize alternative groups of elements in an MKtl for particular purposes\nCategory: Libraries>Modality, Tutorials\nSee also: Overviews/Modality, Classes/MKtl, Classes/MKtlElement, Classes/MKtlElementGroup, Reference/MKtl_description_files\n\n# Background\nMKtl objects contain a hierarchical organisation of their interaction elements in MKtl.elementsGroup. This group contains and defines every element once, and one can access every element directly by its element key, or by its hierarchical address. At times multiple ways of grouping and naming these elements make sense, and MKtl supports multiple such orders.\n\nThe examples below show that for two simple cases.\n\n# Examples\n\n```supercollider\n// make a nanokontrol2\nn = MKtl(\\nk, \"korg-*ol2\");\nn.gui;\nn.trace;\n\n// the logical organization of elements and their direct names:\nn.postElements;\n\n// it contains five transport buttons in a group called \\tr:\nn.elementGroup;\nn.elAt(\\tr);\n\n// as these buttons are unique and have names,\n//they could also be accessible by that name directly:\nn.elAt(\\tr, \\play);\n// not there yet -\nn.elAt(\\play);\n// add them to namedDict\nn.elAt(\\tr, [\\play, \\stop, \\rew, \\fwd, \\rec]"} {"text": "\nn.elAt(\\tr, [\\play, \\stop, \\rew, \\fwd, \\rec]).do { |el| n.addNamed(el.elemDesc.key, el); };\nn.namedDict.keys;\n// and now this access works:\nn.elAt(\\stop);\n```\n\nThe nanokontrol is actually structured like a mixer, so rather than grouping sliders, knobs and buttons in separate groups, one could also make a group of each of the 8 mixer channels, with each containing a knob, a slider and 3 buttons.\n\n```supercollider\n(\n// nested - the top group is \\mix,\ny = MKtlElementGroup(\\mix, n,\n 8.collect { |i|\n // inner group is a list of 8 channels, index 0-7\n MKtlElementGroup(i, n,\n // note the assocs which are needed for access by name later!\n [ \\kn -> n.elAt(\\kn, i),\n \\sl -> n.elAt(\\sl, i),\n \\bt_S -> n.elAt(\\bt, 0, i),\n \\bt_M -> n.elAt(\\bt, 1, i),\n \\bt_R -> n.elAt(\\bt, 2, i)\n ]\n )\n };\n);\nn.addNamed(\\mix, y);\n);\n\n// access variants\nn.elAt(\\mix);\n// index 0 is channel 1...\nn.elAt(\\mix, 0, 0);\nn.elAt(\\mix, 0, \\bt_R);\nn.elAt(\\mix, 0, \\bt_R);\n\n// same example, but make symbolic names for the channels as"} {"text": "At(\\mix, 0, \\bt_R);\n\n// same example, but make symbolic names for the channels as well,\n// and put the buttons in a nested group\n(\ny = MKtlElementGroup(\\mix, n,\n 8.collect { |i|\n var chanName = (\"ch_\" ++ (i + 1)).asSymbol;\n chanName -> MKtlElementGroup(chanName, n,\n [ \\kn -> n.elAt(\\kn, i),\n \\sl -> n.elAt(\\sl, i),\n\n \\bt -> MKtlElementGroup(\\bt, n,\n [\\S, \\M, \\R].collect { |key|\n key -> n.elAt(\\bt, key, i)\n }\n )\n ]\n )\n };\n);\nn.addNamed(\\mix, y);\n);\n\n// access variants\nn.namedDict[\\mix];\nn.elAt(\\mix);\n\n// and now access by name and index works at every level:\nn.elAt(\\mix, 'ch_1');\nn.elAt(\\mix, 0);\nn.elAt(\\mix, 'ch_1', \\bt);\nn.elAt(\\mix, 'ch_1', \\bt, \\S);\nn.elAt(\\mix, 'ch_1', \\bt, 0);\nn.elAt(\\bt, 0, 0);\n```"} {"text": "SuperCollider patch — Modality-toolkit/Modality/MKtlDescriptions/icontrols/icon-icontrols-102.desc.scd\n\n```supercollider\n/*\n\nThis is for the older version of the iCon iControls,\nwhich registers as \"iCON iControl V1.02\".\n\n// tests:\nMKtlDesc.loadDescs;\nm.free; m = MKtl(\\ic, \"*icontrols-102\"); m.trace.gui;\n\nm.elAt.action = { |el| el.name.postln };\nm.elementsDict.size;\nm.postElements;\n*/\n\n(\ndeviceName: \"iCON iControl V1.02\",\n\nidInfo: (deviceName: \"iCON iControl V1.02\", srcPortIndex: 0, destPortIndex: 0),\n\nstatus: (\n linux: \"unknown\",\n osx: \"tested and working, adc, 2016-05-05.\",\n win: \"unknown\"),\n\nprotocol: \\midi,\ndeviceType: \\faderbox,\nelementTypes: [\\fader, \\knob, \\button],\n\ndeviceInfo: (\n vendorURI: \"http://icon-global.com/product/icontrols/\",\n manualURI: \"http://support.icon-global.com/hc/en-us/articles/216201337-iControls\",\n // description: \"\",\n // features: [],\n notes: \"\"\n // hasScribble: false\n),\n\nelementsDes"} {"text": " \"\",\n // features: [],\n notes: \"\"\n // hasScribble: false\n),\n\nelementsDesc: (\n elements: [\n (\n key: \\bt,\n shared: (elementType: \\pad, midiChan: 0, spec: \\midiBut),\n elements: #[\n [ 16, 17, 18, 19, 20, 21, 22, 23, 48 ],\n [ 8, 9, 10, 11, 12, 13, 14, 15, 49 ]\n ].collect { |xs, row|\n (\n elements: xs.collect { |note, col|\n (\n key: col, midiNum: note, groupType: \\noteOnOffBut,\n shared: (\n groupType: \\noteOnOffBut,\n \\style: (row: row+2, column: 3 + (col*2))\n )\n );\n }\n )\n }\n ),\n (\n key: \\sl,\n shared: (\n midiMsgType: \\cc, elementType: \\slider,\n midiNum: 13, spec: \\midiCC),\n elements: (0..8).collect { |i, n| (\n midiChan: i,\n \\style: (row: 1, column: 4+(i*2))\n ) }\n ),\n (\n key: \\kn,\n shared: (midiMsgType: \\cc, elementType: \\knob,\n midiChan: 0, spec: \\midiCC),\n elements: ((16..23)++[12]).collect { |i, n| (\n midiNum: i,\n \\style: (row: 0, column: 4+(n*2))\n ) }\n ),\n (\n key: \\tr,\n shared: ("} {"text": ": 4+(n*2))\n ) }\n ),\n (\n key: \\tr,\n shared: (elementType: \\pad, midiChan: 0, groupType: \\noteOnOffBut, spec: \\midiBut),\n elements: [\n ( key: \\rew, midiNum: 91, shared: ( \\style: (row: 0, column: 0) ) ),\n ( key: \\play, midiNum: 94, shared: ( \\style: (row: 0, column: 1) ) ),\n ( key: \\fwd, midiNum: 92, shared: ( \\style: (row: 0, column: 2) ) ),\n ( key: \\cycle, midiNum: 86, shared: ( \\style: (row: 1, column: 0) ) ),\n ( key: \\stop, midiNum: 93, shared: ( \\style: (row: 1, column: 1) ) ),\n ( key: \\rec, midiNum: 95, shared: ( \\style: (row: 1, column: 2) ) )\n ]\n )\n ]\n)\n);\n```"} {"text": "SuperCollider patch — Modality-toolkit/Modality/MKtlDescriptions/qunexus/keith-mcmillen-qunexus_port2.desc.scd\n\n```supercollider\n/*\n\nGeneral QuNexus info:\nThe QuNexus has 3 input ports, which have three separate desc files.\nIts general info in is \"keith-mcmillen-qunexus.parentDesc.scd\".\n\nThis file is for Port 2 = portIndex 1.\nThis port is for the MIDI Expander in/output for connecting external MIDI hardware.\nNOTE: One never needs to make an MKtl from this desc,\nit is only for information purposes.\n\n// For an example how to connect an external device thru a MIDI port, see:\n\"Connecting external MIDI devices\".openHelpFile;\n*/\n\n(\n///////// GENERIC INFORMATION COPIED TO ALL QUNEXUS DESC FILES: ///////\nparentDesc: \"keith-mcmillen-qunexus\",\n\n///////// SPECIFIC INFORMATION for this port and config: ///////\n\nelementTypes: [],\ndeviceType: \\externalMidiPort,\n\nstatus: (\n linux: \"unknown\",\n osx: \"tested desc only, without ext. device, looks ok. 2016-03-17, adc\",\n win: \"unknown\"),\n\nidInfo: (deviceName: \"QuNexus\", srcPortIndex: 1, destPortIndex"} {"text": " (deviceName: \"QuNexus\", srcPortIndex: 1, destPortIndex: 1),\nportName: \"Port 2\",\n\n// port is for connecting external MIDI, so elementsDesc is empty.\nelementsDesc: (\n elements: []\n)\n\n);\n```"} {"text": "SuperCollider patch — ModalityWorkshop/modalities-sonic-expression/4_Buttons.scd\n\nButtons Buttons can be used in various ways... most buttons have a default state (off), and a state when they are pressed (on).\n\n```supercollider\n/// Buttons\n\n// Buttons can be used in various ways...\n\n// most buttons have a default state (off), and a state when they are pressed (on).\n\nk = MKtl( 'lpd80' );\nk.gui;\n\ns.boot;\n\nk.reset;\n\nMIDIIn.noteOnZeroAsNoteOff_( false );\n\n// ---------------- on - off --------------\n\n// the simplest version is just on-off\n\nNdef( \\testSynth, { |on=0| SinOsc.ar( 440, 0, on * 0.5 ) } );\nNdef( \\testSynth ).play;\n\nk.elementAt( \\pad, \\on, 1 ).action = { arg el; Ndef( \\testSynth ).set( \\on, 1 ) };\n\nk.elementAt( \\pad, \\off, 1 ).action = { arg el; Ndef( \\testSynth ).set( \\on, 0 ) };\n\n// --------------- toggle -------------\n\n// next one up is a toggle:\nk.reset;\n\n~buttonState = 0;\n\nk.elementAt( \\pad, \\on, 1 ).action = { arg el; ~buttonState = (~buttonState + 1).mod(2); Ndef( \\testSynth ).set( \\on, ~buttonState ); };\n\n// clean up:\nk"} {"text": "testSynth ).set( \\on, ~buttonState ); };\n\n// clean up:\nk.reset;\nNdef( \\testSynth ).stop;\n\n// ------------- multistate ----------\n\n// a toggle presents two different states that the button can be in, you can also have more states, advancing to the next state each time you press the button:\n\nNdef( \\testSynth, { |select=0| Select.ar( select, [ SinOsc.ar( 440, 0, 0.1 ), Saw.ar( 440, 0.1 ), Pulse.ar( 440, 0.5, 0.1 ), WhiteNoise.ar( 0.1 ), PinkNoise.ar(0.1) ] ) } );\nNdef( \\testSynth ).play;\n\n~buttonMultiState = 0;\nk.elementAt( \\pad, \\on, 1 ).action = { arg el; ~buttonMultiState = (~buttonMultiState + 1).mod(5); Ndef( \\testSynth ).set( \\select, ~buttonMultiState ); };\n\n// clean up:\nk.reset;\n\nNdef( \\testSynth ).stop;\n\n// ----------- tracking multiple clicks ----------\n\n// You can also make actions dependent on multiple clicks on the same button, e.g. different actions for a double-click or triple-click, or use the time between clicks as a control value, or make a difference between a soft click before a hard one, and vice versa (if the button is sensitive to how hard you press it).\n\n// the code below records the time between clicks, and for every click that is within a maximum time of a previous click (0.2), it record"} {"text": "s the time between clicks, and for every click that is within a maximum time of a previous click (0.2), it records the time between the clicks (clickDeltas), the number of clicks, and the velocity of the clicks.\n\n(\n~multiclick = IdentityDictionary.new;\n~multiclick.put( \\clicks, 0 );\n~multiclick.put( \\clickDeltas, List.new );\n~multiclick.put( \\clickTimes, IdentityDictionary.new );\n~multiclick.put( \\clickVals, IdentityDictionary.new );\n~multiclick.put( \\clickActions, IdentityDictionary.new );\n~multiclick.put( \\maxClickDelta, 0.4 );\n(\n~multiclick.put( \\timeOut, Task( {\n var clickcount, action;\n ~multiclick[\\maxClickDelta].wait; \"timeout\".postln;\n // value of multiclick\n clickcount = ~multiclick[\\clicks];\n // put an action based on the result of the multiclick here:\n // [clickcount, ~multiclick[\\clickVals], ~multiclick[ \\clickTimes ], ~multiclick[ \\clickDeltas ] ].postln;\n action = ~multiclick[ \\clickActions ].at( clickcount );\n if ( action.notNil ){ action.value( ~multiclick[\\clickVals], ~multiclick[ \\clickDeltas ] ); };\n // reset variables:\n ~multiclick.put( \\clicks, 0 );\n ~"} {"text": "); };\n // reset variables:\n ~multiclick.put( \\clicks, 0 );\n ~multiclick.put( \\clickTimes, IdentityDictionary.new );\n ~multiclick.put( \\clickVals, IdentityDictionary.new );\n ~multiclick.put( \\clickDeltas, List.new );\n} ) );\n);\n);\n\n(\nk.elementAt( \\pad, \\on, 1 ).action = { arg el;\n var thisTime = Process.elapsedTime;\n// if ( ~multiclick[ \\clicks ] > 0 ){ ~multiclick };\n if ( ~multiclick[ \\clicks ] > 0 ){\n ~multiclick[ \\clickDeltas ].add( thisTime - ~multiclick[ \\clickTimes ][ ~multiclick[ \\clicks ] ] )\n };\n ~multiclick[ \\clicks ] = ~multiclick[\\clicks] + 1;\n ~multiclick[ \\clickTimes ].put( ~multiclick[\\clicks], thisTime );\n ~multiclick[ \\clickVals ].put( ~multiclick[\\clicks], el.value );\n ~multiclick[\\timeOut].stop.reset.play;\n ~multiclick.put( \\lastTime, thisTime );\n ~multiclick[\\clicks].postln;\n};\n);\n\n(\nNdef( \\testSynth, { |amp=1,on=1|\n var trig = Impulse.kr( \\rate.kr(1) );\n var seq"} {"text": "1|\n var trig = Impulse.kr( \\rate.kr(1) );\n var seq = Demand.kr( trig, 0, Dseq( \\dseq.kr( [0,0,0] ), inf ) );\n SinOsc.ar( seq.exprange( 100, 1000 ), mul: on * amp * EnvGen.kr( Env.perc, trig, timeScale: \\dur.kr(0.5) ) );\n} );\n);\nNdef( \\testSynth ).play;\n\n~multiclick[ \\clickActions ].put( 1, { |vals,deltas| [ 1, vals, deltas ].postln; Ndef( \\testSynth ).set( \\amp, vals.at(1) ); } );\n~multiclick[ \\clickActions ].put( 2, { |vals,deltas| [ 2, vals, deltas.asArray ].postln; Ndef( \\testSynth ).set( \\dur, deltas.first * 2, \\rate, ( deltas.first * 3 ).reciprocal ) } );\n~multiclick[ \\clickActions ].put( 3, { |vals,deltas| [ 3, vals.asArray, deltas ].postln; Ndef( \\testSynth ).setn( \\dseq, vals.asArray ); } );\n\n// ------------------ buttons in relationship to each other --------------\n\n// You could extend the concept above to button presses on different buttons, so creating \"key-combos\", like in games where you have special actions dependent on using a specific control-sequence.\n\n// -------------- modal control, a"} {"text": " you have special actions dependent on using a specific control-sequence.\n\n// -------------- modal control, a button press selects a mode for another control --------\n\n// You can also use buttons to select between different modes of control, or to shift control from one controller to another.\n```"} {"text": "SuperCollider classlib — MultiTouchPad/Classes/GUI/MultiTouchPad.sc\n\n```supercollider\n\n *initClass\n {\n responder = OSCFunc({|msg| this.processOSC(msg) }, \"/tuio/2Dobj\");\n responder.disable;\n fingersDict = Dictionary.new;\n activeBlobs = List.new;\n guiOn = false;\n isRunning = false;\n stopFunc = { this.stop; };\n device = 0;\n }\n\n *setDevice\n {|argDevice|\n\n argDevice.switch\n (\n \\internal, { device = 0; },\n \\external, { device = 1; },\n { \"argDevice must be \\\\internal for internal trackpad and \\\\external for external trackpad.\".error; }\n );\n }\n\n *start\n {|force|\n\n if(isRunning == false or: { force == \\force; },\n {\n if(force == \\force, { responder.disable; }); //in case...\n\n \"killall tongsengmod\".unixCmd\n ({|res|\n\n if(res == 0,\n {\n \"A dangling tongsengmod process was found and terminated.\".postln;\n });\n\n pid = (progpath +/+ \"tongsengmod localhost\" + NetAddr.langPort.asString + device.asString).unixCmd\n ({|res|\n\n if(res == 127,\n {\n \"tongsengmod executable not found. See help.\".error;\n });\n });\n "} {"text": " \"tongsengmod executable not found. See help.\".error;\n });\n });\n });\n\n responder.enable;\n isRunning = true;\n },\n {\n \"MultiTouchPad is already active and running. Try MultiTouchPad.start(\\\\force)\".error;\n });\n ShutDown.add(stopFunc);\n }\n\n *stop\n {\n if(isRunning,\n {\n responder.disable;\n (\"kill -1\" + pid.asString).unixCmd;\n isRunning = false;\n },\n {\n responder.disable; //in case\n \"killall tongsengmod\".unixCmd;\n \"MultiTouchPad isn't running.\".error;\n });\n }\n\n *processOSC\n { |msg|\n\n var toRemove = List.new;\n var curID = msg[2];\n var xys = msg[4..6];\n\n if(msg[1] == 'alive',\n {\n\n activeBlobs = msg[2..];\n fingersDict.keys.do\n ({|item|\n\n if(activeBlobs.includes(item).not,\n {\n toRemove.add(item);\n });\n });\n\n toRemove.do\n ({|item|\n\n fingersDict.removeAt(item);\n untouchAction.value(item);\n if(guiOn, { { guiWin.refresh; }.defer; });\n });\n\n activeBlobs.do\n ({|item|\n\n if(fingersDict.at(item).isNil,\n {\n "} {"text": "do\n ({|item|\n\n if(fingersDict.at(item).isNil,\n {\n fingersDict.put(item, -1); //-1 means xy not initialized\n });\n });\n\n ^this;\n });\n\n if(msg[1] == 'set',\n {\n if(fingersDict.at(curID).isNil, { \"MultiTouchPad: bug? this should never happen.\".postln; });\n if(fingersDict.at(curID) == -1, { touchAction.value(curID, xys); });\n fingersDict.put(curID, xys);\n setAction.value(curID, xys);\n if(guiOn, { { guiWin.refresh; }.defer; });\n ^this;\n });\n }\n\n *gui\n {\n var view;\n guiWin = Window(\"MultiTouchPad\", Rect(100, 100, 525, 375)).onClose_({ guiOn = false; });\n view = UserView(guiWin, guiWin.view.bounds).background_(Color.white).resize_(5);\n view.drawFunc_\n ({\n var fItem;\n\n fingersDict.keys.do\n ({|key|\n\n fItem = fingersDict.at(key);\n Pen.color = Color.red;\n Pen.fillOval\n (\n Rect\n (\n guiWin.view.bounds.width * fItem[0],\n guiWin.view.bounds.height * fItem[1],\n 20 * fIt"} {"text": "],\n guiWin.view.bounds.height * fItem[1],\n 20 * fItem[2],\n 20 * fItem[2]\n )\n );\n });\n });\n guiOn = true;\n guiWin.front;\n }\n\n *resetActions\n {\n touchAction = {};\n untouchAction = {};\n setAction = {};\n }\n}\n```"} {"text": "SuperCollider patch — NTMI/NTMI_AI_sc_setup/1_prefs/historical_2bUpdated/ntmi_prefs_raspi_seoul2021.scd\n\n```supercollider\n/*\nThis is the prefs file for the korea exhibition 2021:\n- different raspis known by name load different ndefs on startup.\n\n*/\n\nq.userName = unixCmdGetStdOut(\"whoami\").select(_.isAlphaNum).asSymbol;\nq.hostName = {\n Platform.case(\\osx, {\n unixCmdGetStdOut(\"hostname\").split($-).first.select(_.isAlphaNum).asSymbol;\n },\n // works on raspi, hope on linux and windows too?\n {\n unixCmdGetStdOut(\"hostname\").select(_.isAlphaNum).asSymbol;\n });\n};\n\nq.startNdefs = (\n adcpi64: [ 'bleepo', 'pulselet', 'rjkChaos', 'revFB', ],\n adc: [ 'bleepo', 'pulselet', 'rjkChaos', 'revFB', ],\n ntmpi_01: [ 'allArm', 'granbuf', 'moogSing', 'xFMSH', ],\n ntmpi_02: [ 'bleepo', 'pulselet', 'robTron', 'xf-bufFun' ],\n ntmpi_03: [ 'cat', 'filterFB', 'varsawFB', 'pulselet', ],\n ntmpi_04:"} {"text": " 'filterFB', 'varsawFB', 'pulselet', ],\n ntmpi_04: [ 'dog', 'formSing', 'revFB', 'xf-ringMod' ],\n ntmpi_05: [ 'envelo', 'kiteHi', 'rjkChaos', 'frya' ],\n);\n\n(\n'name': 'raspi', // <- user name here\n'numChans': 2,\n'serverSetup': \"serverBasic2.scd\",\n'hasGui': false,\n\n// the 4 sounds to load into the slots\n// 'defaultActives': [ 'allArm', 'dog', 'cat', 'revFB' ],\n\n'defaultActives': q.startNdefs[q.hostName],\n\ninfluxPresets: [ 3, 12, 37, 42, 45, 86, \\diagL ],\n// the preset key/name to set it to\ninfluxPreset: 3,\n\n// these are just filenames with collections of funcs for now\neffects: [ \"allFX.scd\" ],\n\n// the slotNames to put into q.mFX\nmfxSlotNames: [\n '00_in', '0OnePolBal', '0_DBComp', '0_comp', '0_gate', '0freqBal',\n '1comby', '1holz', '1ixiDist',\n '3AdCVerb', '3ring', '3thrasher',\n '4ixiVerb', '5HPF', '5LPF',\n '6roto', '7Delay',\n '9endFilt', '9monofy', '9stereofy',\n 'ampFin' ],\n'finalSetup': \"~"} {"text": " '9monofy', '9stereofy',\n 'ampFin' ],\n'finalSetup': \"~/ntmi/finalSetup.scd\",\n\n)\n```"} {"text": "SuperCollider patch — NTMI/NTMI_AI_sc_setup/3_interfaces/2_volSteps.scd\n\n```supercollider\nMFdef(\\ndefVolStep).add(\\step, { |ndef, step = 1|\n var acceleration = step.abs ** 1.0;\n var stepsize = 0.01; // 100 steps from 0 to 1\n var ampspec = \\amp.asSpec;\n \"% ndefVolStep %\\n\".postf(ndef, step);\n ndef.vol = ampspec.map(ampspec.unmap(ndef.vol) + (step * acceleration * stepsize))\n});\n```"} {"text": "SuperCollider patch — NTMI/NTMI_AI_sc_setup/3_interfaces/optionals/nUFO/1c_nUFO_imupad_abs.scd\n\n```supercollider\n/***\nIMU AND PADS can do absolute and relative influx:\n\n// this switches them to absolute\nNTMI.nUFO.setRel;\nNTMI.nUFO.setAbs;\n\nNTMI.nUFO.debugOn = false;\nNTMI.nUFO.debugOn = true;\n\nThe main funcs of imu and pads use that name to look up which\nfunction to run, see below.\n***/\n\nNTMI.nUFO.debugOn = false;\n\n// available influx modes:\nNTMI.nUFO.influxModes = [\\setRel, \\setAbs];\n\n// when loading, keep if already set, else default to setRel\nNTMI.nUFO.influxMode = NTMI.nUFO.influxMode ? \\setRel;\n// same with\nNTMI.nUFO.zoom = NTMI.nUFO.zoom ? 1;\n\n// ///////////////////////////////////////////////////////////////\n// //// I M U\n// ///////////////////////////////////////////////////////////////\n\nMKtl(\\nUFO).collAt(\\imu).action = {\n // trigger the action only once when array from imu comes in,\n // not several times for every input value\n MF"} {"text": "\n // trigger the action only once when array from imu comes in,\n // not several times for every input value\n MFdef(\\nUFOImuFunc).value;\n};\n\n// set the first 9 values of the inphlux from the imu params:\nNTMI.inphlux.addHalo(\\imuNames, NTMI.inphlux.inNames.keep(9));\n\nMFdef(\\nUFOImuFunc).add(\\makeCalibVals, {\n var imuInvalsBi = MKtl(\\nUFO).elAt(\\imu9).value.unibi;\n var calibImuValsBi = imuInvalsBi - NTMI.nUFO.zero.imu;\n NTMI.nUFO.rawImuBiValues = imuInvalsBi;\n NTMI.nUFO.calibImuValsBi = calibImuValsBi;\n NTMI.nUFO.calibImuVals = calibImuValsBi.biuni;\n});\n\nMFdef(\\nUFOImuFunc).add(\\setAbs, {\n var calibImuValsBi = NTMI.nUFO.calibImuValsBi;\n var indivZoom = NTMI.nUFO.zoom;\n var keysvals = NTMI.inphlux.getHalo(\\imuNames).collect { |name, i|\n var value = calibImuValsBi[i];\n [name, value * indivZoom]\n }.flat;\n\n // \"*** imufunc setAbs: \".post; keysvals.round(0.01).postl"} {"text": " // \"*** imufunc setAbs: \".post; keysvals.round(0.01).postln;\n NTMI.inphlux.set(*keysvals);\n}, false);\n\nMFdef(\\nUFOImuFunc).add(\\set, {\n if (NTMI.nUFO.debugOn) {\n \"nUFOImuFunc - NTMI.nUFO.influxMode: %\\n\".postf(NTMI.nUFO.influxMode);\n };\n MFdef(\\nUFOImuFunc).at(NTMI.nUFO.influxMode).value\n});\n\n/*\nNTMI.nUFO.debugOn = true;\n*/\n\n///////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////\n//// Caps\n///////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////\n\n(\nMFdef(\\capsToInph).orderedNames;\n\nNTMI.inphlux.addHalo(\\padNames, NTMI.inphlux.inNames.copyRange(9, 16));\n\nMFdef(\\capsToInph).add(\\setAbs, {\n // var debug = \"capsToInph setAbs\".postln;\n var influx = NTMI.inphlux;\n var padVals = NTMI"} {"text": "ostln;\n var influx = NTMI.inphlux;\n var padVals = NTMI.nUFO.padVals;\n var padInNames = NTMI.inphlux.getHalo(\\padNames);\n var indivZoom = NTMI.nUFO.zoom;\n var keysValues = padVals.collect { |padval, i|\n [ padInNames[i], padval * indivZoom]\n }.flat;\n NTMI.inphlux.set(*keysValues);\n});\n\nMFdef(\\capsToInph).disable(\\setAbs);\n\nMFdef(\\capsToInph).add(\\set, {\n if (NTMI.nUFO.debugOn) {\n \"capsToInph - NTMI.nUFO.influxMode: %\\n\".postf(NTMI.nUFO.influxMode);\n };\n MFdef(\\capsToInph).at(NTMI.nUFO.influxMode).value\n});\n\n////// this is the action that gets triggered\n////// when values come in from the ntmi -\n////// coompensate for base values,\n////// and send the final values only once.\n\nMKtl(\\nUFO).addHalo(\\capLedThresh, 0.3);\n\nNTMI.nUFO.capsin = MFunc();\nMKtl(\\nUFO).collAt('caps').action = NTMI.nUFO.capsin;\n\nNTMI.nUFO.capsin.add(\\set, { |elOrColl|\n // var de"} {"text": "NTMI.nUFO.capsin.add(\\set, { |elOrColl|\n // var debug = \"NTMI.nUFO.capsin set\".postln;\n var capLedThresh = MKtl(\\nUFO).getHalo(\\capLedThresh);\n var rawPads = MKtl(\\nUFO).elAt('cap').value;\n var calibPadVals;\n\n NTMI.nUFO.rawPads = rawPads;\n\n // NTMI.nUFO.zero.pads is the rest state of the pads\n // use it to stretch to a range of 0-1\n calibPadVals = rawPads.collect { |rawval, i|\n var zeroOffset = NTMI.nUFO.zero.pads.asArray.wrapAt(i) ? 0;\n var stretched = rawval.linlin(zeroOffset, 0.9, 0, 1);\n stretched;\n };\n\n // keep prev and new reordered and calibrated padVals here:\n NTMI.nUFO.prevPadVals = NTMI.nUFO.padVals;\n NTMI.nUFO.padVals = calibPadVals;\n\n // this func gets called from collective caps when from nUFO,\n // and from indiv element when from GUI:\n if (elOrColl.isKindOf(MKtlElement)) {\n // if from single element, set all element values,\n // to get correct differences for relative modes\n MKtl(\\nUFO).elAt('cap').do { |el, i| el.value_(rawPads[i]) };\n }"} {"text": "At('cap').do { |el, i| el.value_(rawPads[i]) };\n };\n\n ///// trigger touch to inphlux only once ...\n MFdef(\\capsToInph).value;\n\n // light up leds when pads are touched above thresh:\n fork {\n MKtl(\\nUFO).elAt(\\led, \\fr).do { |led, i|\n var newval = (rawPads[i] > capLedThresh).binaryValue;\n if (newval != led.value) {\n led.value = newval;\n 0.003.wait;\n }\n }\n }\n});\n\n);\n```"} {"text": "SuperCollider patch — NTMI/NTMI_AI_sc_setup/3_interfaces/optionals/nUFO/1z_settingsExamples.scd\n\n```supercollider\n/************* nUFO sensor modes ***\n\nThe nUFO has several modes for playing the sounds,\nwhich determine whether and how the motion sensors and pads\ninfluence the sounds:\n- move means only use the motion sensor\n- touch means use the pads as continuous sensors\n- binary means use the pads as a binary clavier\n. to switch between the active sounds presets.\n- full is move + touch,\n- binmove is move + binary.\n\nNTMI.nUFO.printInterface\n// The full choice of these modes is:\nNTMI.nUFO.allModes = [\n \\full, // move/imu, touch/pads\n \\move, // only move/imu\n \\touch, // only touch/pads\n \\binary, // pads as binary preset-switching clavier\n \\binMove, // pads as binary, plus move/imu best in setRel mode\n \\off // all\n];\n\n// The default mode choices are:\nNTMI.nUFO.modes\n-> [ 'full', 'touch', 'binary' ]\n*/\n// One choose freely which subset of allModes to use, e.g.:\nNTMI.nUFO.modes = [ 'full', 'touch', 'binary', 'binMove', 'off' ];\n\n// To set which mode to go to, use e.g.\nNT"} {"text": " 'binMove', 'off' ];\n\n// To set which mode to go to, use e.g.\nNTMI.nUFO.modeIndex = 0;\n\n// to go to specific mode, do:\nNTMI.nUFO.setModeIndex(1);\n\n// to step thru the modes, use\nNTMI.nUFO.modeStep(1); // up\nNTMI.nUFO.modeStep(-1); // down\nNTMI.nUFO.modeStep(nil); // rand\n\n/*** NTMI.nUFO.influxModes *****\n\nthe nUFO can play the influx in two different modes:\nNTMI.nUFO.influxModes.postcs;\n[ 'setRel', 'setAbs' ]\n\n- setRel means differences on the nUFO get translated\nto differences on the parameters of the playing sounds;\nthis allows multiple sources to change the sounds\nsimultaneously, in effect, polyphonic influence.\n\n- setAbs means the full state of the nUFOs sensors,\nthe current influx weights, and the sounds' last chosen presets\nwill determine the exact setting of the process parameters.\n*/\n\n// this is how to set the initial influxMode:\nNTMI.nUFO.influxMode = \\setRel;\n\n// and to switch between them when the nUFO is loaded, do:\nNTMI.nUFO.setRel; // or\nNTMI.nUFO.setAbs; // or\n\n// to set how much influence the nUFO has, use its zoom value:\nNTMI.nUFO.zoom = 0.5;\n```"} {"text": "SuperCollider patch — NTMI/NTMI_AI_sc_setup/9_demos/9_ntmi_general.scd\n\n```supercollider\n/* To Do:\ntest sections for\nrandOrb,\nbinClav,\nliveInput,\n\nin separate testdefs:\nnUFO, nanoKtl, uc4, ferrari\n*/\n\nNTMI.demos = NTMI.demos ? ();\nNTMI.demos.notDoneYet = { {\n [\n \"... ... not done yet\",\n \"... not done yet ...\",\n \"not done yet ... ...\",\n \"done yet ... ...\",\n \"yet ... ...\",\n \"... ...\",\n \"...\", \"\"\n ].do { |str|\n NTMI.g.setFrontText(str);\n 1.wait;\n }\n} };\n\nButz(\\NTMI_DEMO).clear;\nButz(\\NTMI_DEMO).add(\\showAll, { Butz.run('Tdef.all') });\nButz(\\NTMI_DEMO).add(\\Demo_GUI, { Tdef(\\NTDemo_GUI).play });\nButz(\\NTMI_DEMO).add(\\Demo_nanoKtl, { Butz.run('\\NTDemo_nanoKtl.all') });\nButz(\\NTMI_DEMO).add(\\Demo_Presets, { Tdef(\\NTDemo_Presets, NTMI.demos.notDoneYet).play });\n\nButz(\\NTMI_DEMO)."} {"text": "I.demos.notDoneYet).play });\n\nButz(\\NTMI_DEMO).add(\\Demo_Influx, { Tdef(\\NTDemo_Influx, NTMI.demos.notDoneYet).play });\nButz(\\NTMI_DEMO).add(\\Demo_MainFX, { Tdef(\\NTDemo_MainFX, NTMI.demos.notDoneYet).play });\nButz(\\NTMI_DEMO).add(\\Demo_flatcat, { Tdef(\\NTDemo_flatcat, NTMI.demos.notDoneYet).play });\n\nButz(\\NTMI_DEMO).add(\\NT_codeTest, { Tdef(\\NT_codeTest).play });\n\nMFdef(\\showPopItems).add(\\show, { |names, view, dur = 3|\n defer {\n var preBnds = view.bounds.postln;\n var length = preBnds.height;\n var listBnds = preBnds.moveBy(0, -70).height_(500);\n var listv = ListView(view.parent, listBnds).front\n .font_(NTMI.g.font);\n\n listv.items_(names).value_(view.value);\n defer ({ listv.close }, dur);\n listv\n };\n});\n\n/*\nMFdef(\\showPopItems).value(\n NdefPreset(\\bleepo).getSetNames,\n NTMI.g.main.prePops[0]\n);\nTdef(\\NT_codeTest).stop.play;\n"} {"text": ".main.prePops[0]\n);\nTdef(\\NT_codeTest).stop.play;\nTdef(\\NT_codeTest).stop;\n*/\n\n(\nTdef(\\NT_codeTest, {\n\n \"\\n\\n*** Tdef('NT_codeTest') starts!\\n\\n\".postln;\n Butz(\\NTMI).run(\\Main_NTMI);\n NTMI.g.setFrontText(\"***NT_codeTest***\");\n 4.do { |i| 0.1.wait; NTMI.slots.endAt(i) };\n 1.wait;\n\n NTMI.g.setFrontText(\"Play four sounds\");\n 4.do { |i| 1.wait; NTMI.slots.playAt(i) };\n 1.wait;\n\n NTMI.g.setFrontText(\"...and change their volumes...\");\n 8.do { |i| 0.5.wait; NTMI.ndefs.wrapAt(i).vol_(exprand(0.05, 0.5)) };\n 1.wait;\n\n NTMI.g.setFrontText(\"... and change main volume ...\");\n 4.do { |i| 0.5.wait; MFdef(\\mainVol).(exprand(0.25, 0.5)) };\n 1.wait;\n MFdef(\\mainVol).(1);\n\n (1..3).do { |i| NTMI.slots.endAt(i) };\n 4.do { |i| NTMI.ndefs.wrapAt(i).vol_(0.25) };\n NTMI.slots."} {"text": "defs.wrapAt(i).vol_(0.25) };\n NTMI.slots.playAt(0);\n\n Butz.curr = \\NTMI_DEMO;\n\n NTMI.g.setFrontText(\"Change presets on slot 1:\");\n defer {\n Butz(\\NTMI).run(\\presets);\n Window.find(\\presets).moveTo(968.0, 100.0);\n NTMI.pre.butAction(0);\n };\n 6.do { 1.wait; NTMI.pre.stepNdefInf(NTMI.ndefs[0], nil) };\n\n NTMI.g.setFrontText(\"Select sound processes:\");\n 2.do {\n 1.wait;\n NTMI.slots.stepNext(0); NTMI.slots.playAt(0);\n NTMI.pre.stepNextInf(NTMI.ndefs[0]);\n NTMI.pre.butAction(0);\n };\n\n NTMI.g.setFrontText(\"Show and simulate Influx\");\n 2.wait;\n defer {\n Butz(\\NTMI).run(\\inphlux);\n NTMI.inph.wiggle.play;\n };\n\n 2.wait;\n\n NTMI.g.setFrontText(\"Change influx inputs\");\n 4.wait;\n NTMI.g.setFrontText(\"... while presets change\");\n 6.do { 1.wait; NTMI.pre.stepNdefInf(NTMI.ndefs[0], 1) };\n\n NTMI.g.setFrontText"} {"text": "f(NTMI.ndefs[0], 1) };\n\n NTMI.g.setFrontText(\"... and with multiple sounds\\n\\n\\n\");\n NTMI.close(\\presets);\n Butz(\\NTMI).run(\\slotSounds);\n 4.do { |i| 1.wait; NTMI.slots.playAt(i) };\n\n NTMI.g.setFrontText(\"... and while sounds change\\n\\n\\n\\n\");\n 10.do {\n 4.do { |i|\n 1.wait;\n NTMI.slots.stepNext(i);\n NTMI.slots.playAt(i);\n NTMI.pre.stepNextInf(NTMI.ndefs[i]);\n }\n };\n NTMI.close(\\slotSounds);\n\n 3.wait;\n NTMI.g.setFrontText(\"Change influx weight presets\");\n 8.do {\n 1.wait;\n NTMI.inph.stepWPre;\n };\n 1.wait;\n NTMI.inph.setWPreIndex(0);\n\n 3.wait;\n NTMI.g.setFrontText(\"Change main effects\");\n Butz(\\NTMI_DEMO).run(\\mainFX);\n 8.do {\n 1.wait;\n MFdef.all.mainPreStep.value;\n };\n NTMI.inph.wiggle.stop;\n NTMI.close(\\slotSounds);\n NTMI.close(\\inphlux);\n NTMI.close(\\mainFX);\n\n NTMI.ndef"} {"text": "(\\inphlux);\n NTMI.close(\\mainFX);\n\n NTMI.ndefs.do(_.end(1));\n 1.wait;\n NTMI.g.setFrontText(\"NT_codeTest done!\");\n 3.wait;\n NTMI.g.setFrontText(\"\");\n}).clock_(AppClock);\n);\n```"} {"text": "SuperCollider patch — NTMI/NTMI_AI_sc_setup/POOL/2_process/dog.scd\n\nSOUND 1, from orig Influx Example\n\n```supercollider\n// SOUND 1, from orig Influx Example\n(\nNdef(\\dog).addSpec(\\intv, [-24, 24]);\nNdef(\\dog).addSpec(\\timescale, [0.01, 10, \\exp]);\nNdef(\\dog).addSpec(\\curve, [-10, 10]);\nNdef(\\dog).addSpec(\\ffreq, \\freq);\n\nNdef(\\dog).addSpec(\\loopnode, [0, 12]);\nNdef(\\dog).addSpec(\\dens, [10, 1000]);\nNdef(\\dog).addSpec(\\resfreq, \\freq);\nNdef(\\dog).addSpec(\\ringtime, [0.01, 1, \\exp]);\n\nNdef(\\dog, { |amp=0, freq=250, intv=19, timescale=1, curve=0, loopnode=0, dens = 10, resfreq = 500, ringtime = 0.01|\n var n = 15;\n var env = EnvGen.kr(\n Env({ 1.0.rand2 }!(n+1), {1.0.rand}!n, curve, releaseNode: n-1, loopNode: loopnode.min(n-3)),\n timeScale: timescale);\n var pitch = (env * [1, 0.33, -1] * intv).midiratio * freq;\n var form = Formant.ar(pitch, pitch.rotate(1) * 1.6"} {"text": "req;\n var form = Formant.ar(pitch, pitch.rotate(1) * 1.6, pitch.rotate(2) * 2.6);\n\n var dusty = Ringz.ar(\n Dust.ar(dens!3),\n (resfreq * LFNoise0.kr([3, 5, 7], 0.5, 1)).lag(0.3),\n ringtime)\n * ((dens ** -0.5) * (ringtime ** -0.3)\n );\n\n Splay.ar(form * dusty, level: amp * 4) ;\n});\n);\n```"} {"text": "SuperCollider patch — NTMI/NTMI_AI_sc_setup/POOL/example_startup_files/NTMI_AbsRel_workshop.scd\n\n```supercollider\n/*** example for NTMI AbsRel workshop setup ***\n\n// start oscar&xflux\nNTMI.oscar.makeServer;\n// activate flatcat simulation\ndefer ({ Tdef(\\flatcatSim).stop.play }, 1);\n\n*****/\n\n// load all supported interfaces\nNTMI.interfacesToLoad = [\n \"nUFO\",\n \"uc4\", \"mu8\",\n \"nanoKtl\",\n \"dual_analog_3_2\",\n \"dual_analog_4\",\n \"ferrari\",\n \"xtm\"\n];\n\n// now run NTMI setup:\nNTMI.run;\n```"} {"text": "SuperCollider classlib — Neutral/BaseClasses/NeutralFileWriter.sc\n\n```supercollider\n *initClass {\n this.write(\\Neutral.asClass, this.neutralExcludeSelectors);\n }\n\n *write { |class, excluding, path, ellipsisArgsOnly|\n var string = this.generateClassFileString(class, excluding, ellipsisArgsOnly);\n var existing, extDir;\n\n path = path ?? {\n extDir = Platform.userExtensionDir.standardizePath +/+ \"NeutralObjectExtensions\";\n if(pathMatch(extDir).isEmpty) { File.mkdir(extDir) };\n if(LanguageConfig.includePaths.includesEqual(extDir).not) {\n \"The extension directory is not included in LanguageConfig.includePaths. \"\n \"Please either write the extension to an included path \"\n \"or include the extension directory\".warn;\n };\n extDir +/+ \"ext\" ++ class.name ++ \".sc\"\n };\n\n if(File.exists(path)) {\n File.use(path, \"r\", { |file| existing = file.readAllString })\n };\n if(existing != string) {\n File.use(path, \"w\", { |file| file << string });\n \"NeutralizeObject: writing new class file for the % class:\\npath: %\\nRecompile another time to make it work.\"\n .format(class.name, path).warn;\n } {\n \"NeutralizeO"} {"text": " it work.\"\n .format(class.name, path).warn;\n } {\n \"NeutralizeObject: using existing correct class file for the % class.\\n\".postf(class.name)\n }\n }\n\n *neutralExcludeSelectors {\n ^#[\n \\doesNotUnderstand,\n \\class,\n \\dump,\n \\post,\n \\postln,\n \\postc,\n \\postcln,\n \\postcs,\n \\totalFree,\n \\largestFreeBlock,\n \\gcDumpGrey,\n \\gcDumpSet,\n \\gcInfo,\n \\gcSanity,\n \\canCallOS,\n\n //printing\n \\asString,\n \\asCompileString,\n\n //accessing (?)\n \\size,\n \\indexedSize,\n \\flatSize,\n\n // class membership\n \\class,\n \\isKindOf,\n \\isMemberOf,\n \\respondsTo,\n\n \\performMsg,\n \\perform,\n \\performList,\n \\functionPerformList,\n \\superPerform,\n \\superPerformList,\n \\tryPerform,\n \\multiChannelPerform,\n \\performWithEnvir,\n \\performKeyValuePairs,\n\n // copying\n \\shallowCopy, // because it calls the primitive\n\n '===',\n '!==',\n \\compareObject,\n \\instVarHash,\n \\basicHash,\n \\hash,\n \\identityHash,\n\n // inspection\n \\pointsTo,\n \\"} {"text": "\n \\hash,\n \\identityHash,\n\n // inspection\n \\pointsTo,\n \\mutable,\n \\frozen,\n \\halt,\n \\prHalt,\n \\primitiveFailed,\n \\reportError,\n \\subclassResponsibility,\n \\shouldNotImplement,\n \\outOfContextReturn,\n \\immutableError,\n \\isException,\n \\deprecated,\n \\mustBeBoolean,\n \\notYetImplemented,\n \\dumpBackTrace,\n \\getBackTrace,\n\n // printing\n \\printClassNameOn,\n \\printOn,\n \\storeOn,\n \\storeParamsOn,\n \\simplifyStoreArgs,\n \\storeArgs,\n \\storeModifiersOn,\n\n // inspection\n \\inspect,\n \\inspectorClass,\n \\inspector,\n \\crash,\n \\stackDepth,\n \\dumpStack,\n \\dumpDetailedBackTrace,\n \\freeze,\n\n // direct slot access\n \\slotSize,\n \\slotAt,\n \\slotPut,\n \\slotKey,\n \\slotIndex,\n \\slotsDo,\n \\slotValuesDo,\n \\getSlots,\n \\setSlots,\n \\instVarSize,\n \\instVarAt,\n \\instVarPut,\n\n // copy\n \\contentsCopy,\n \\deepCopy,\n \\copyImmutable,\n\n // archiving\n \\writeArch"} {"text": "deepCopy,\n \\copyImmutable,\n\n // archiving\n \\writeArchive,\n \\asArchive,\n \\initFromArchive,\n \\archiveAsCompileString,\n \\archiveAsObject,\n \\checkCanArchive,\n \\writeTextArchive,\n \\asTextArchive,\n \\getContainedObjects,\n \\writeBinaryArchive,\n \\asBinaryArchive,\n\n // help\n \\help,\n\n ]\n }\n\n *printRespondingMethodsWithArgs { |stream, class, exclude|\n var overriddenMethodSelectors = [];\n // override all methods of this and all superclasses\n class.respondingMethods.do { |method|\n var selector = method.name;\n var lastIndex = method.argNames.lastIndex - 1;\n if(exclude.includes(selector).not) {\n stream << Char.tab;\n stream << selector;\n stream << \" { \";\n if(method.argNames.size > 1) {\n stream << \"| \";\n method.argNames.drop(1).do { |x, i|\n var defaultArg = method.prototypeFrame.at(i);\n //stream << \"| \" x << \" |\";\n stream << x;\n if(defaultArg.notNil) {\n stream << \" = \" <<< x\n };\n if(i == lastIndex) { stream << \" |\" } { stream << \", \" };\n\n };\n stream << \"\\n\\t\\t^this.doesNotUnderstand(thisMethod"} {"text": ";\n stream << \"\\n\\t\\t^this.doesNotUnderstand(thisMethod.name, %)\\n\"\n .format(method.argNames.drop(1).join(\", \"));\n } {\n\n stream << \"\\n\\t\\t^this.doesNotUnderstand(thisMethod.name)\"\n };\n stream << \"\\n\\t}\\n\\n\";\n overriddenMethodSelectors = overriddenMethodSelectors.add(selector);\n }\n };\n\n stream << \"\\n\\n\\t\" << \"*overriddenMethodSelectors {\\n\\t\\t^#\" <<< overriddenMethodSelectors << \"\\n\\t}\\n\\n\";\n }\n\n *printRespondingMethods { |stream, class, exclude|\n var overriddenMethodSelectors = [];\n // override all methods of this and all superclasses\n class.respondingMethods.do { |method|\n var selector = method.name;\n if(exclude.includes(selector).not) {\n stream << Char.tab;\n stream << selector;\n stream << \" { |... args|\";\n stream << \"\\n\\t\\t^this.doesNotUnderstand(thisMethod.name, *args)\\n\";\n stream << \"\\n\\t}\\n\\n\";\n overriddenMethodSelectors = overriddenMethodSelectors.add(selector);\n }\n };\n\n stream << \"\\n\\n\\t\" << \"*overriddenMethodSelectors {\\n\\t\\t^#\" <<< overriddenMethodSelectors <"} {"text": "enMethodSelectors {\\n\\t\\t^#\" <<< overriddenMethodSelectors << \"\\n\\t}\\n\\n\";\n }\n\n *generateClassFileString { |class, excluding ([]), ellipsisArgsOnly = (true)|\n var stream, exclude, startTime;\n startTime = Main.elapsedTime;\n\n exclude = excluding.as(IdentitySet);\n\n // don't overwrite existing exclusions\n class.superclassesDo { |sclass|\n if(class != sclass and: { sclass.respondsTo(\\overriddenMethodSelectors) }) {\n exclude.addAll(class.overriddenMethodSelectors)\n }\n };\n\n // code to generate a neutral class file, the text has to be compiled then first.\n stream = CollStream.on(String.new);\n stream << \"/*\\nThis file has been automatically generated.\\n\"\n \"It overwrites all object methods that aren't necessary for introspection and basic functionality\\n*/\\n\\n\\n\";\n stream << \"\\n+ \" << class.name << \" {\\n\\n\";\n\n if(ellipsisArgsOnly) {\n this.printRespondingMethods(stream, class, exclude)\n } {\n this.printRespondingMethodsWithArgs(stream, class, exclude)\n };\n\n \"Neutral: generated string in % sec.\\n\".postf(Main.elapsedTime - startTime);\n\n stream << \"}\\n\\n\";\n ^stream.collection\n }\n\n}\n\n+ Class {\n\n respondingMethodSelectors {\n var selectors = Array."} {"text": "\n }\n\n}\n\n+ Class {\n\n respondingMethodSelectors {\n var selectors = Array.new(256); // keep the order\n this.superclassesDo { |class|\n class.methods.do { |method|\n if(selectors.includes(method.name).not) {\n selectors = selectors.add(method.name)\n }\n }\n };\n ^selectors\n }\n\n respondingMethods {\n ^this.respondingMethodSelectors.collect { |selector|\n this.findRespondingMethodFor(selector)\n }\n }\n\n}\n```"} {"text": "SuperCollider patch — PlonkSetup/protoSetup/config.scd\n\n```supercollider\n(\n// relAssetsDir: \"_assets\", // set asset directory relative to project directory\n\n// Audio Server\nserverOptions: ServerOptions()\n// .device_(\"Fireface UFX (23610321)\") // use a non-default device (OSX only)\n// .sampleRate_(48000)\n// .blockSize_(64)\n// .numBuffers_(1024)\n// .numOutputBusChannels_(2)\n// .numInputBusChannels_(2)\n// .maxNodes_(1024 * 16)\n// .memSize_(8192 * 64)\n// .numWireBufs_(1024)\n// .bindAddress_(\"0.0.0.0\") // also listen to other machines on the network\n,\nserverLatency: 0.1, // 100 ms\n\n//////////////////////////////////// files to execute\n// order is important here\nbeforeBoot: [\n {\"*** Hello Worlds\".postln}, // executing functions here works as well\n],\nafterBoot: [\n // \"dataSources/busAlloc.scd\", // bus allocation for external data sources\n // load data sources, e.g.\n // \"dataSources/sunMoon.scd\",\n // ^^ this requires q.config.filenameMoon and q.config.filenameSun,\n // see Sun and Moon Helpfiles for details.\n {\"*** Hello Worlds after boot\".postln}, // executing functions here works as well\n\n // load sounds\n // \""} {"text": " Worlds after boot\".postln}, // executing functions here works as well\n\n // load sounds\n // \"sounds/example.scd\",\n\n // high level control and sensor integration\n],\n\n)\n```"} {"text": "SuperCollider patch — Radicles/Files/DescriptionFiles/Block.scd\n\n```supercollider\n[['test2', \"test synth\"], ['test1', \"a test synth\"], ['sine', \"a simple sine oscillator\"], ['play', \"play buffer from sound file\"], ['loop', \"loop buffer from sound file\"], ['cue', \"loop sound file from disk\"], ['playpv', \"play FFT buffer of sound file\"], ['looppv', \"loop FFT buffer of sound file\"], ['playbuf', \"play or loop buffer from sound file\"], ['rec', \"record into a buffer\"], ['recpv', \"record into a FFT phase vocoder buffer\"], ['recloop', \"record in a loop into a buffer\"], ['looptr', \"play into a buffer with an impulse trigger\"], ['osc1', \"wavetable lookup oscillator\"], ['shaperSine', \"wave shaper on sine oscillator\"], ['vosc', \"wavetable oscillator sweep across wavetalbes with mouse\"], ['loopAll', \"loop all buffers from sound files\"], ['audioin', \"sound in from selected audio device\"], ['grainbuf', \"granulates a given buffer with impulse\"], ['grainfm', \"FM granulator with impulse as trigger\"], ['formletfun', \"fun formlet synth from SC examples\"], ['sinenv', \"a simple sine oscillator with adsr envelope and s&h\"], ['blipen"} {"text": "env', \"a simple sine oscillator with adsr envelope and s&h\"], ['blipenv', \"a band limited impulse oscillator with adsr envelope\"], ['blipdissenv', \"a band limited impulse oscillator (dissonance) with adsr envelope\"], ['sinekey', \"a triad of sine oscillators for chords\"], ['sinekey2', \"a triad of sine oscillators for chords\"], ['karplus', \"karplus strong algorithm: physical model of a string\"], ['sinenv2', \"a simple sine oscillator with adsr envelope\"], ['sawenv', \"a simple saw oscillator with adsr envelope and s&h\"], ['squarenv', \"a simple square wave oscillator with adsr envelope and s&h\"], ['noise', \"white noise\"], ['blip', \"test signal with impulse and decay\"], ['ravein', \"RAVE block with audio in - generation and timbre transfer\"], ['ravein2', \"RAVE block with stereo audio in - generation and timbre transfer\"], ['ravest', \"RAVE stereo block - generation and timbre transfer\"], ['ravevan', \"RAVE econder/decoder - nice for parker lines\"], ['ravenoise', \"RAVE prior/decoder - with lfnoise\"], ['ravedc', \"RAVE prior/decoder - with dc\"], ['ravenoise2', \"RAVE prior/decoder - with lfnoises with rand freqs\"], ['p"} {"text": "RAVE prior/decoder - with lfnoises with rand freqs\"], ['pravein', \"PRECUSSION - RAVE block with audio in - generation and timbre transfer\"], ['pravein2', \"PRECUSSION - RAVE block with stereo audio in - generation and timbre transfer\"], ['pravest', \"PRECUSSION - RAVE stereo block - generation and timbre transfer\"], ['pravevan', \"PRECUSSION - RAVE econder/decoder - nice for parker lines\"], ['pravenoise', \"PRECUSSION - RAVE prior/decoder - with lfnoise\"], ['pravedc', \"PRECUSSION - RAVE prior/decoder - with dc\"], ['pravenoise2', \"PRECUSSION - RAVE prior/decoder - with lfnoises with rand freqs\"], ['vravein', \"VOICE - RAVE block with audio in - generation and timbre transfer\"], ['vravein2', \"VOICE - RAVE block with stereo audio in - generation and timbre transfer\"], ['vravest', \"VOICE - RAVE stereo block - generation and timbre transfer\"], ['vravevan', \"VOICE - RAVE econder/decoder - nice for parker lines\"], ['vravenoise', \"VOICE - RAVE prior/decoder - with lfnoise\"], ['vravedc', \"DAR"} {"text": " - RAVE prior/decoder - with lfnoise\"], ['vravedc', \"DARBOUKA - RAVE prior/decoder - with dc\"], ['vravenoise2', \"VOICE - RAVE prior/decoder - with lfnoises with rand freqs\"], ['travein', \"RAVE block with audio in - generation and timbre transfer\"], ['i1ravein', \"BIRD MOTHER - RAVE block with audio in - generation and timbre transfer\"], ['i1ravein2', \"BIRD MOTHER - RAVE block with stereo audio in - generation and timbre transfer\"], ['i1ravest', \"BIRD MOTHER - RAVE stereo block - generation and timbre transfer\"], ['i1ravevan', \"BIRD MOTHER - RAVE econder/decoder - nice for parker lines\"], ['i1ravenoise', \"BIRD MOTHER - RAVE prior/decoder - with lfnoise\"], ['i1ravedc', \"BIRD MOTHER - RAVE prior/decoder - with dc\"], ['i1ravenoise2', \"BIRD MOTHER - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i2ravein', \"BIRD PLUMA - RAVE block with audio in - generation and timbre transfer\"], ['i2ravein2', \"BIRD PLUMA - RAVE block with stereo aud"} {"text": " ['i2ravein2', \"BIRD PLUMA - RAVE block with stereo audio in - generation and timbre transfer\"], ['i2ravest', \"BIRD PLUMA - RAVE stereo block - generation and timbre transfer\"], ['i2ravevan', \"BIRD PLUMA - RAVE econder/decoder - nice for parker lines\"], ['i2ravenoise', \"BIRD PLUMA - RAVE prior/decoder - with lfnoise\"], ['i2ravedc', \"BIRD PLUMA - RAVE prior/decoder - with dc\"], ['i2ravenoise2', \"BIRD PLUMA - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i3ravein', \"GUITAR ILL - RAVE block with audio in - generation and timbre transfer\"], ['i3ravein2', \"GUITAR ILL - RAVE block with stereo audio in - generation and timbre transfer\"], ['i3ravest', \"GUITAR ILL - RAVE stereo block - generation and timbre transfer\"], ['i3ravevan', \"GUITAR ILL - RAVE econder/decoder - nice for parker lines\"], ['i3ravenoise', \"GUITAR ILL - RAVE prior/decoder - with lfnoise\"], ['i3ravedc', \"GUITAR ILL - RAVE prior/decoder - with dc\"], ['i3ravenoise2', \"GUITAR ILL"} {"text": "E prior/decoder - with dc\"], ['i3ravenoise2', \"GUITAR ILL - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i4ravein', \"HUMPBACKS - RAVE block with audio in - generation and timbre transfer\"], ['i4ravein2', \"HUMPBACKS - RAVE block with stereo audio in - generation and timbre transfer\"], ['i4ravest', \"HUMPBACKS - RAVE stereo block - generation and timbre transfer\"], ['i4ravevan', \"HUMPBACKS - RAVE econder/decoder - nice for parker lines\"], ['i4ravenoise', \"HUMPBACKS - RAVE prior/decoder - with lfnoise\"], ['i4ravedc', \"HUMPBACKS - RAVE prior/decoder - with dc\"], ['i4ravenoise2', \"HUMPBACKS - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i5ravein', \"MAGNETS - RAVE block with audio in - generation and timbre transfer\"], ['i5ravein2', \"MAGNETS - RAVE block with stereo audio in - generation and timbre transfer\"], ['i5ravest', \"MAGNETS - RAVE stereo block - generation and timbre transfer\"], ['i5ravevan', \"MAGNETS - RAVE econder/dec"} {"text": "fer\"], ['i5ravevan', \"MAGNETS - RAVE econder/decoder - nice for parker lines\"], ['i5ravenoise', \"MAGNETS - RAVE prior/decoder - with lfnoise\"], ['i5ravedc', \"MAGNETS - RAVE prior/decoder - with dc\"], ['i5ravenoise2', \"MAGNETS - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i6ravein', \"MARINE MAMMALS - RAVE block with audio in - generation and timbre transfer\"], ['i6ravein2', \"MARINE MAMMALS - RAVE block with stereo audio in - generation and timbre transfer\"], ['i6ravest', \"MARINE MAMMALS - RAVE stereo block - generation and timbre transfer\"], ['i6ravevan', \"MARINE MAMMALS - RAVE econder/decoder - nice for parker lines\"], ['i6ravenoise', \"MARINE MAMMALS - RAVE prior/decoder - with lfnoise\"], ['i6ravedc', \"MARINE MAMMALS - RAVE prior/decoder - with dc\"], ['i6ravenoise2', \"MARINE MAMMALS - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i7ravein', \"MRP - RAVE block with audio in - generation and timbre transf"} {"text": "i7ravein', \"MRP - RAVE block with audio in - generation and timbre transfer\"], ['i7ravein2', \"MRP - RAVE block with stereo audio in - generation and timbre transfer\"], ['i7ravest', \"MRP - RAVE stereo block - generation and timbre transfer\"], ['i7ravevan', \"MRP - RAVE econder/decoder - nice for parker lines\"], ['i7ravenoise', \"MRP - RAVE prior/decoder - with lfnoise\"], ['i7ravedc', \"MRP - RAVE prior/decoder - with dc\"], ['i7ravenoise2', \"MRP - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i8ravein', \"OGRAN ARCHIVE - RAVE block with audio in - generation and timbre transfer\"], ['i8ravein2', \"OGRAN ARCHIVE - RAVE block with stereo audio in - generation and timbre transfer\"], ['i8ravest', \"OGRAN ARCHIVE - RAVE stereo block - generation and timbre transfer\"], ['i8ravevan', \"OGRAN ARCHIVE - RAVE econder/decoder - nice for parker lines\"], ['i8ravenoise', \"OGRAN ARCHIVE - RAVE prior/decoder - with lfnoise\"], ['i8ravedc', \"OGRAN ARCHIVE - RAVE pri"} {"text": "noise\"], ['i8ravedc', \"OGRAN ARCHIVE - RAVE prior/decoder - with dc\"], ['i8ravenoise2', \"OGRAN ARCHIVE - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i9ravein', \"OGRAN BACH - RAVE block with audio in - generation and timbre transfer\"], ['i9ravein2', \"OGRAN BACH - RAVE block with stereo audio in - generation and timbre transfer\"], ['i9ravest', \"OGRAN BACH - RAVE stereo block - generation and timbre transfer\"], ['i9ravevan', \"OGRAN BACH - RAVE econder/decoder - nice for parker lines\"], ['i9ravenoise', \"OGRAN BACH - RAVE prior/decoder - with lfnoise\"], ['i9ravedc', \"OGRAN BACH - RAVE prior/decoder - with dc\"], ['i9ravenoise2', \"OGRAN BACH - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i10ravein', \"VOICE HITTS - RAVE block with audio in - generation and timbre transfer\"], ['i10ravein2', \"VOICE HITTS - RAVE block with stereo audio in - generation and timbre transfer\"], ['i10ravest', \"VOICE HITTS - RAVE stereo block - generation and timbre"} {"text": "ravest', \"VOICE HITTS - RAVE stereo block - generation and timbre transfer\"], ['i10ravevan', \"VOICE HITTS - RAVE econder/decoder - nice for parker lines\"], ['i10ravenoise', \"VOICE HITTS - RAVE prior/decoder - with lfnoise\"], ['i10ravedc', \"VOICE HITTS - RAVE prior/decoder - with dc\"], ['i10ravenoise2', \"VOICE HITTS - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i11ravein', \"VOICE JVS - RAVE block with audio in - generation and timbre transfer\"], ['i11ravein2', \"VOICE JVS - RAVE block with stereo audio in - generation and timbre transfer\"], ['i11ravest', \"VOICE JVS - RAVE stereo block - generation and timbre transfer\"], ['i11ravevan', \"VOICE JVS - RAVE econder/decoder - nice for parker lines\"], ['i11ravenoise', \"VOICE JVS - RAVE prior/decoder - with lfnoise\"], ['i11ravedc', \"VOICE JVS - RAVE prior/decoder - with dc\"], ['i11ravenoise2', \"VOICE JVS - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i12ravein"} {"text": " prior/decoder - with lfnoises with rand freqs\"], ['i12ravein', \"VOICE VCTK - RAVE block with audio in - generation and timbre transfer\"], ['i12ravein2', \"VOICE VCTK - RAVE block with stereo audio in - generation and timbre transfer\"], ['i12ravest', \"VOICE VCTK - RAVE stereo block - generation and timbre transfer\"], ['i12ravevan', \"VOICE VCTK - RAVE econder/decoder - nice for parker lines\"], ['i12ravenoise', \"VOICE VCTK - RAVE prior/decoder - with lfnoise\"], ['i12ravedc', \"VOICE VCTK - RAVE prior/decoder - with dc\"], ['i12ravenoise2', \"VOICE VCTK - RAVE prior/decoder - with lfnoises with rand freqs\"], ['i13ravein', \"VOICE VOCALSET- RAVE block with audio in - generation and timbre transfer\"], ['i13ravein2', \"VOICE VOCALSET- RAVE block with stereo audio in - generation and timbre transfer\"], ['i13ravest', \"VOICE VOCALSET- RAVE stereo block - generation and timbre transfer\"], ['i13ravevan', \"VOICE VOCALSET- RAVE econder/decoder - nice for parker l"} {"text": "OICE VOCALSET- RAVE econder/decoder - nice for parker lines\"], ['i13ravenoise', \"VOICE VOCALSET- RAVE prior/decoder - with lfnoise\"], ['i13ravedc', \"VOICE VOCALSET- RAVE prior/decoder - with dc\"], ['i13ravenoise2', \"VOICE VOCALSET- RAVE prior/decoder - with lfnoises with rand freqs\"], ['i14ravein', \"WATER - RAVE block with audio in - generation and timbre transfer\"], ['i14ravein2', \"WATER - RAVE block with stereo audio in - generation and timbre transfer\"], ['i14ravest', \"WATER - RAVE stereo block - generation and timbre transfer\"], ['i14ravevan', \"WATER - RAVE econder/decoder - nice for parker lines\"], ['i14ravenoise', \"WATER - RAVE prior/decoder - with lfnoise\"], ['i14ravedc', \"WATER - RAVE prior/decoder - with dc\"], ['i14ravenoise2', \"WATER - RAVE prior/decoder - with lfnoises with rand freqs\"], ['mhravein', \"MARK HANSLIP - RAVE block with audio in - generation and timbre transfer\"], ['mhravein2', \"MARK HANSLIP - RAVE block with stereo audio in - generation"} {"text": "ravein2', \"MARK HANSLIP - RAVE block with stereo audio in - generation and timbre transfer\"], ['mhravest', \"MARK HANSLIP - RAVE stereo block - generation and timbre transfer\"], ['mhravevan', \"MARK HANSLIP - RAVE econder/decoder - nice for parker lines\"], ['mhravenoise', \"MARK HANSLIP - RAVE prior/decoder - with lfnoise\"], ['mhravedc', \"MARK HANSLIP - RAVE prior/decoder - with dc\"], ['mhravenoise2', \"MARK HANSLIP - RAVE prior/decoder - with lfnoises with rand freqs\"], ['dravein', \"DRUMS - RAVE block with audio in - generation and timbre transfer\"], ['dravein2', \"DRUMS - RAVE block with stereo audio in - generation and timbre transfer\"], ['dravest', \"DRUMS - RAVE stereo block - generation and timbre transfer\"], ['dravevan', \"DRUMS - RAVE econder/decoder - nice for parker lines\"], ['dravenoise', \"DRUMS - RAVE prior/decoder - with lfnoise\"], ['dravedc', \"DRUMS - RAVE prior/decoder - with dc\"], ['dravenoise2', \"DRUMS - RAVE prior/decoder - with lfnoises with rand"} {"text": "2', \"DRUMS - RAVE prior/decoder - with lfnoises with rand freqs\"], ['audioins', \"sound in from selected audio device plus next bus (stereo)\"], ['audioin2', \"sound in from selected audio device and pan2\"], ['play2', \"play buffer from sound file and pan2\"], ['loop2', \"loop buffer from sound file and pan2\"], ['impulse', \"Impulse\"], ['grainfm2', \"FM granulator with impulse as trigger\"]]\n```"} {"text": "SuperCollider patch — Radicles/Files/SynthDefFiles/Block.scd\n\n```supercollider\n[['test2', {arg freq = 400 -> [200.0,1000, \\exp, {|val| val.round}], amp\n = 0.4 -> [0,1], mul = 0.4 -> [0,0.5], harm = 3-> [1,10, {|val| val.round;}];\n Saw.ar(freq, amp);}], ['test1', {arg freq = 400 -> [200.0,1000, \\exp, {|val|\n val.round}], amp = 0.4 -> [0,1], mul = 0.4 -> [0,0.5], harm = 3-> [1,10,\n {|val|\n val.round;}];\nSinOsc.ar(freq, 0, amp);\n}], ['sine', {arg freq=440 -> [20, 20000, \\exp], phase=0 -> [-2pi, 2pi], mul=0.4 -> [0,1]; SinOsc.ar(freq,phase,mul)}], ['play', {arg rate=1 -> [0.1,10], trigger=1 -> [0,1, {|val| val.round(1)}], startPos=0 -> [0,1], mul=1 -> [0,2];\n RadPosition.kr(\\position, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos, 0);\n PlayBuf.ar(\\buffer.numChannels, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos.linlin(0"} {"text": " BufRateScale.kr(\\buffer), trigger, startPos.linlin(0,1,0, \\buffer.numFrames), 0)*mul;}], ['loop', {arg rate=1 -> [0.1,10], trigger=1 -> [0,1, {|val| val.round(1)}], startPos=0 -> [0,1], mul=1 -> [0,2];\n RadPosition.kr(\\position, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos, 1);\n PlayBuf.ar(\\buffer.numChannels, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos.linlin(0,1,0, \\buffer.numFrames), 1)*mul;}], ['cue', {arg loop=1 -> [0,1, {|val| val.round(1)}], mul=1 -> [0,2], rate=1 -> [0.1,10];\n VDiskIn.ar(\\buffer.numChannels, \\buffer, rate * \\fileRate / SampleRate.ir, loop)*mul;}], ['playpv', {arg rate=1 -> [0.1,10], offset=0 -> [0,1], numFrames=0.6 -> [0,1,\\lin, 0.1], winType=0 -> [-1,1, {|val| val.round(1)}], mul=1 -> [0,2];\n var localbuf, chain;\n localbuf = LocalBuf.new(numFrames.linexp(0,1,32,32768), \\buffer.numCh"} {"text": "new(numFrames.linexp(0,1,32,32768), \\buffer.numChannels);\n chain = PV_PlayBuf(localbuf, \\buffer.bufnum, rate, offset.linlin(0,1,0, \\buffer.numFrames),\n 0);\n IFFT(chain, winType)*mul}], ['looppv', {arg rate=1 -> [0.1,10], offset=0 -> [0,1], numFrames=0.6 -> [0,1,\\lin, 0.1], winType=0 -> [-1,1, {|val| val.round(1)}], mul=1 -> [0,2];\n var localbuf, chain;\n localbuf = LocalBuf.new(numFrames.linexp(0,1,32,32768), \\buffer.numChannels);\n chain = PV_PlayBuf(localbuf, \\buffer.bufnum, rate, offset.linlin(0,1,0, \\buffer.numFrames),\n 1);\n IFFT(chain, winType)*mul}], ['playbuf', {arg rate=1 -> [0.1,10], trigger=1 -> [0,1, {|val| val.round(1)}], startPos=0 -> [0,1], mul=1 -> [0,2], loop=1 -> [0,1, {|val| val.round(1)}];\n RadPosition.kr(\\position, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos, loop);\n PlayBuf.ar(\\buffer."} {"text": "(\\buffer), trigger, startPos, loop);\n PlayBuf.ar(\\buffer.numChannels, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos.linlin(0,1,0, \\buffer.numFrames), loop)*mul;}], ['rec', {arg recLevel=1 -> [0,2], preLevel=0 -> [0,2], fade=0.01 -> [0,0.1];\n var sig;\n sig = \\in;\n sig = sig * Env.linen(fade, (\\duration-(fade*2)), fade, 1, 'sin').kr;\n RecordBuf.ar(sig, \\buffer.bufnum, 0, recLevel, preLevel, loop: 0); }], ['recpv', {arg numChannels=1 -> [1,10, {|val| val.round(1)}], numFrames=0.6 -> [0,1,\\lin, 0.1], hop=0.5 -> [0,1], winType=0 -> [-1,1, {|val| val.round(1)}], offset=0 -> [0,1], run=1 -> [0,1, {|val| val.round(1)}], loop=0 -> [0,1, {|val| val.round(1)}], mul=1 -> [0,2], fade=0.01 -> [0,0.1];\n var sig, localbuf, chain;\n sig = \\in;\n sig = sig * Env.linen(fade, (\\duration-(fade*2)), fade, 1, 'sin').kr;\n localbuf = LocalBuf(numFrames.line"} {"text": "), fade, 1, 'sin').kr;\n localbuf = LocalBuf(numFrames.linexp(0,1,32,32768), numChannels);\n chain = FFT(localbuf, sig, hop/2, winType);\n chain = PV_RecordBuf(chain, \\buffer.bufnum, offset.linlin(0,1,0, \\buffer.numFrames), run, loop, hop, winType)*mul}], ['recloop', {arg recLevel=1 -> [0,2], preLevel=0 -> [0,2], fade=0.01 -> [0,0.1];\n var sig;\n sig = \\in;\n sig = sig * Env.asr(fade, 1, fade, 'sin').kr;\n RecordBuf.ar(sig, \\buffer.bufnum, 0, recLevel, preLevel, loop: 1); }], ['looptr', {arg rate=1 -> [0.1,10], triggerRate=1 -> [0.1,10], startPos=0 -> [0,1], mul=1 -> [0,2];\n var trigger = Impulse.kr(triggerRate);\n RadPosition.kr(\\position, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos, 1);\n PlayBuf.ar(\\buffer.numChannels, \\buffer, rate * BufRateScale.kr(\\buffer), trigger,\n startPos.linlin(0,1,0, \\buffer.numFrames), 1)*mul;}], ['osc1',"} {"text": "(0,1,0, \\buffer.numFrames), 1)*mul;}], ['osc1', {arg freq=400 -> [20,20000, \\exp], phase=0 -> [-2pi, 2pi], mul=0.5 -> [0,2]; Osc.ar(\\buffer, freq, phase, mul)}], ['shaperSine', {arg freq=440 -> [20,20000, \\exp], phase=0 -> [-2pi, 2pi], mul=0.5 -> [0,2];\n Shaper.ar(\\buffer, SinOsc.ar(freq, phase, mul), 0.5)}], ['vosc', {arg bufoffset=0 -> [0,10], freq=440 -> [20,20000, \\exp], phase=0 -> [-2pi, 2pi], mul=0.5 -> [0,2];\n var buffer, bufnum;\n buffer = \\buffer;\n bufnum = buffer[0].bufnum;\n VOsc.ar(bufoffset+MouseX.kr(bufnum, bufnum+buffer.size-1), freq, phase, mul)}], ['loopAll', {arg rate=1 -> [0.1,10], trigger=1 -> [0,1, {|val| val.round(1)}], startPos=0 -> [0,1], mul=1 -> [0,2];\n var buffer, play;\n buffer = \\buffer;\n play = buffer.collect{|item|\n PlayBuf.ar(item.numChannels, item, rate * BufRateScale.kr(item), trigger, startPos.linlin"} {"text": " item, rate * BufRateScale.kr(item), trigger, startPos.linlin(0,1,0, item.numFrames), 1)*mul;};\n play.sum/play.size;\n}], ['audioin', {arg bus=1 -> [1,8], mul= 1 -> [0,4];\n SoundIn.ar((bus.round(1)-1).max(0), mul);}], ['grainbuf', {arg rate=1 -> [0.1,10], freq= 1 -> [0.5,50], dur = 0.1 -> [0.0001, 0.1, {|val|val.round(0.0001)}], startPos=0 -> [0,1], interp=1 -> [0,4, {|val| val.round(1)}], pan= 0 -> [-1,1];\n var buffer;\n buffer = \\buffer;\n BufGrain.ar(Impulse.kr(freq), dur, \\buffer, rate, startPos, interp);\n /*GrainBuf.ar(buffer.numChannels, Impulse.kr(freq), dur, buffer[0], rate, startPos, interp, pan); */\n}], ['grainfm', {arg freq= 1 -> [0.5,50], dur = 0.1 -> [0.0001, 0.1, {|val| val.round(0.0001)}], carfreq= 440 -> [20,20000, \\exp], modFreq=200 -> [1,1000, \\exp], index= 1 -> [0.1,10], pan = 0 -> [-1,1];\n GrainFM.ar(1, Impulse.kr(freq), d"} {"text": "> [-1,1];\n GrainFM.ar(1, Impulse.kr(freq), dur, carfreq, modFreq, index, pan);\n}], ['formletfun', {arg my= 1000 -> [400,3200];\n var amp;\n amp = LFPulse.kr(0.5,0,0.5);\n Formlet.ar(Dust.ar(12,[0.05,0.05]) * amp, my * exprand(0.5,2.0), 0.005, 0.1);\n}], ['sinenv', {arg trig = 1 -> [0,1,{|val| val.round(1)}], freq=440 -> [20, 20000, \\exp], phase=0 -> [-2pi, 2pi], mul=0.4 -> [0,2], attack=0.01 -> [0.0001,0.5], decay = 0.3 -> [0.001,0.4], sustain= 0.5 -> [0.1,1], release = 1 -> [0.01,3], octMul=1 -> [0.25,4];\n var cps;\n cps = Latch.ar(freq*octMul, trig);\n SinOsc.ar(cps,phase,mul) * EnvGen.kr(Env.adsr(attack, decay, sustain, release), trig);\n}], ['blipenv', {arg trig = 1 -> [0,1,{|val| val.round(1)}], freq=440 -> [20, 20000, \\exp], numharm=0 -> [0, 200], mul=0.4 -> [0,1], attack=0.01 -> [0.0001,0.5], decay = 0.3 -> [0.001,0.4],"} {"text": ".01 -> [0.0001,0.5], decay = 0.3 -> [0.001,0.4], sustain= 0.5 -> [0.1,1], release = 1 -> [0.01,3];\n Blip.ar(freq,numharm,mul) * EnvGen.kr(Env.adsr(attack, decay, sustain, release), trig);\n}], ['blipdissenv', {arg trig = 1 -> [0,1,{|val| val.round(1)}], freq=440 -> [20, 20000, \\exp], diss=0 -> [0, 1], mul=0.4 -> [0,1], attack=0.01 -> [0.0001,0.5], decay = 0.3 -> [0.001,0.4], sustain= 0.5 -> [0.1,1], release = 1 -> [0.01,3];\n Blip.ar(freq,(diss.sqrt)*200,mul) * EnvGen.kr(Env.adsr(attack, decay, sustain, release), trig);\n}], ['sinekey', {arg key=0 -> [0, 23, {|val| val.round(1)}], oct=1 -> [0.25,4], phase=0 -> [-2pi, 2pi], mul=0.4 -> [0,1], lag = 0.01 => [0,0.1];\n var chord;\n chord = Select.kr(key, [\n ([60, 64, 67]+0).midicps*oct,\n ([60, 64, 67]+1).midicps*oct,\n ([60, 64, 67]+2).midicps*oct,\n ([60, 64, 67]+3).midicps*oct,"} {"text": "2).midicps*oct,\n ([60, 64, 67]+3).midicps*oct,\n ([60, 64, 67]+4).midicps*oct,\n ([60, 64, 67]+5).midicps*oct,\n ([60, 64, 67]+6).midicps*oct,\n ([60, 64, 67]+7).midicps*oct,\n ([60, 64, 67]+8).midicps*oct,\n ([60, 64, 67]+9).midicps*oct,\n ([60, 64, 67]+10).midicps*oct,\n ([60, 64, 67]+11).midicps*oct,\n ([60, 63, 67]+0).midicps*oct,\n ([60, 63, 67]+1).midicps*oct,\n ([60, 63, 67]+2).midicps*oct,\n ([60, 63, 67]+3).midicps*oct,\n ([60, 63, 67]+4).midicps*oct,\n ([60, 63, 67]+5).midicps*oct,\n ([60, 63, 67]+6).midicps*oct,\n ([60, 63, 67]+7).midicps*oct,\n ([60, 63, 67]+8).midicps*oct,\n ([60, 63, 67]+9).midicps*oct,\n ([60, 63, 67]+10).midicps*oct,\n ([60, 63, 67]+11).midicps*oct,\n ]);\n Mix.ar(SinOsc.ar([chord[0].lag(lag), chord[1].lag"} {"text": "ix.ar(SinOsc.ar([chord[0].lag(lag), chord[1].lag(lag), chord[2].(lag)],phase,mul/3));\n }], ['sinekey2', {arg key=0 -> [0, 23, {|val| val.round(1)}], oct=1 -> [0.25,4], phase=0 -> [-2pi, 2pi], mul=0.4 -> [0,1], lag = 0.01 => [0,0.1], inv1=0 -> [-24, 24, {|val| val.round(12)}], inv2=0 -> [-24, 24, {|val| val.round(12)}], inv3=0 -> [-24, 24, {|val| val.round(12)}];\n var chord;\n chord = Select.kr(key, [\n ([60+inv1, 64+inv2, 67+inv3]+0).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+1).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+2).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+3).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+4).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+5).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+6).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+7).midicps*oct"} {"text": " ([60+inv1, 64+inv2, 67+inv3]+7).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+8).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+9).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+10).midicps*oct,\n ([60+inv1, 64+inv2, 67+inv3]+11).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+0).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+1).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+2).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+3).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+4).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+5).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+6).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+7).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+8).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+9).midicps*oct,\n "} {"text": "60+inv1, 63+inv2, 67+inv3]+9).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+10).midicps*oct,\n ([60+inv1, 63+inv2, 67+inv3]+11).midicps*oct,\n ]);\n Mix.ar(SinOsc.ar([chord[0].lag(lag), chord[1].lag(lag), chord[2].(lag)],phase,mul/3));\n }], ['karplus', {arg trig = 1 -> [0,1,{|val| val.round(1)}], freq=440 -> [20, 20000, \\exp], decayTime = 2.0 -> [0.2,4], att = 0 -> [0,0.01], dec = 0.001 -> [0,0.1];\n var burstEnv, signalOut, delayTime;\n delayTime = freq.min(2000).reciprocal;\n delayTime = Latch.ar(delayTime, trig);\n burstEnv = EnvGen.kr(Env.perc(att, dec), trig);\n signalOut = CombL.ar(PinkNoise.ar(burstEnv), 0.1, delayTime, decayTime)}], ['sinenv2', {arg trig = 1 -> [0,1,{|val| val.round(1)}], freq=440 -> [20, 20000, \\exp], phase=0 -> [-2pi, 2pi], mul=0.4 -> [0,2], attack=0.01 -> [0.0001,0.5], decay = 0.3 -> [0.001,0.4],"} {"text": ".01 -> [0.0001,0.5], decay = 0.3 -> [0.001,0.4], sustain= 0.5 -> [0.1,1], release = 1 -> [0.01,3];\n var cps;\n cps = Latch.ar(freq, trig);\n SinOsc.ar(cps,phase,mul) * EnvGen.kr(Env.adsr(attack, decay, sustain, release), trig);\n}], ['sawenv', {arg trig = 1 -> [0,1,{|val| val.round(1)}], freq=440 -> [20, 20000, \\exp], mul=0.4 -> [0,2], attack=0.01 -> [0.0001,0.5], decay = 0.3 -> [0.001,0.4], sustain= 0.5 -> [0.1,1], release = 1 -> [0.01,3], octMul=1 -> [0.25,4];\n var cps;\n cps = Latch.ar(freq*octMul, trig);\n Saw.ar(cps,mul) * EnvGen.kr(Env.adsr(attack, decay, sustain, release), trig);\n}], ['squarenv', {arg trig = 1 -> [0,1,{|val| val.round(1)}], freq=440 -> [20, 20000, \\exp], width=0.5 -> [0, 1], mul=0.4 -> [0,2], attack=0.01 -> [0.0001,0.5], decay = 0.3 -> [0.001,0.4], sustain= 0.5 -> [0.1,1], release = 1 -> [0.01,3], octMul=1 -> [0.25,4];"} {"text": ",1], release = 1 -> [0.01,3], octMul=1 -> [0.25,4];\n var cps;\n cps = Latch.ar(freq*octMul, trig);\n Pulse.ar(cps,width,mul) * EnvGen.kr(Env.adsr(attack, decay, sustain, release), trig);\n}], ['noise', {arg mul=0.5->[0,1];\n WhiteNoise.ar(mul);\n}], ['blip', {arg freq=10 -> [0.1,30], mul=0.5->[0,1], freq2 = 1200 -> [200,2000,\\exp];\n Decay.ar(Impulse.ar(freq), 0.25, LFCub.ar(freq2, 0, 0.1)) *mul;\n}], ['audioins', {arg bus=1 -> [1,8], mul= 1 -> [0,4];\n [SoundIn.ar((bus.round(1)-1).max(0), mul),\n SoundIn.ar((bus.round(1)).max(0), mul)]\n ;}], ['audioin2', {arg bus=1 -> [1,8], mul= 1 -> [0,4], pan=0 -> [-1,1], lagTime=0.1 -> [0,1];\n Pan2.ar(SoundIn.ar((bus.round(1)-1).max(0)), pan.lag(lagTime))*mul;\n}], ['play2', {arg rate=1 -> [0.1,10], trigger=1 -> [0,1, {|val| val.round(1)}], startPos=0 -> [0,1], mul=1 -> [0"} {"text": " {|val| val.round(1)}], startPos=0 -> [0,1], mul=1 -> [0,2], pan=0 -> [-1,1], lagTime=0.1 -> [0,1];\n RadPosition.kr(\\position, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos, 0);\n Pan2.ar(PlayBuf.ar(\\buffer.numChannels, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos.linlin(0,1,0, \\buffer.numFrames), 0)*mul, pan.lag(lagTime));}], ['loop2', {arg rate=1 -> [0.1,10], trigger=1 -> [0,1, {|val| val.round(1)}], startPos=0 -> [0,1], mul=1 -> [0,2], pan=0 -> [-1,1], lagTime=0.1 -> [0,1];\n RadPosition.kr(\\position, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos, 1);\n Pan2.ar(PlayBuf.ar(\\buffer.numChannels, \\buffer, rate * BufRateScale.kr(\\buffer), trigger, startPos.linlin(0,1,0, \\buffer.numFrames), 1)*mul, pan.lag(lagTime));}], ['impulse', {arg freq = 0.125 -> [0.1,10, \\exp, {|val|\n val.round}], amp = 1"} {"text": " = 0.125 -> [0.1,10, \\exp, {|val|\n val.round}], amp = 1 -> [0,1], mul = 1 -> [0,1];\nPan2.ar(Decay.ar(Impulse.ar(freq), 0.2, WhiteNoise.ar(amp), 0), 0)*mul;\n}], ['grainfm2', {arg freq= 1 -> [0.5,50], dur = 0.1 -> [0.0001, 0.1, {|val| val.round(0.0001)}], carfreq= 440 -> [20,20000, \\exp], modFreq=200 -> [1,1000, \\exp], index= 1 -> [0.1,10], pan = 0 -> [-1,1];\n GrainFM.ar(2, Impulse.kr(freq), dur, carfreq, modFreq, index, pan);\n}]]\n```"} {"text": "SuperCollider patch — Radicles/Tests/RadTest.scd\n\nRadTest: helpers shared by the test driver (run.scd) and the per-test child (child.scd). Loaded with: (Radicles.mainPath +/+ \"Tests/RadTest.scd\").load Defines environment variables only; nothing here is compiled into the class library.\n\n```supercollider\n// RadTest: helpers shared by the test driver (run.scd) and the per-test child (child.scd).\n// Loaded with: (Radicles.mainPath +/+ \"Tests/RadTest.scd\").load\n// Defines environment variables only; nothing here is compiled into the class library.\n\n~radTestDir = PathName(thisProcess.nowExecutingPath).pathOnly;\n~radTests = ~radTests ? [];\n\n// Register a test. Used in Tests/cases/*.scd:\n// ~radTest.(\"vol-track\", setup: [\"start 2\"], cmds: [\"vol t 1 -10\"],\n// check: { Ndef('track1').get('volume') == -10 });\n// setup: commands run first, not snapshotted.\n// cmds: commands whose posted code is snapshotted. An entry may be\n// \"cmd\" or [\"cmd\", seconds] to wait a fixed time instead of the quiet-wait.\n// check: function returning true, or a String explaining the failure.\n// gui: true = needs windows; skipped where there is no GUI (cloud).\n// cloud: false = needs something the cloud build"} {"text": " true = needs windows; skipped where there is no GUI (cloud).\n// cloud: false = needs something the cloud build lacks (MIDI, a plugin that\n// needs FFTW such as Tartini); skipped where there is no GUI, like gui.\n// code: optional function run after cmds (for actions with no command,\n// e.g. moving a mixer knob from code); its posts are snapshotted too.\n// It runs inside a Routine, so it may .wait.\n// teardown: function that removes anything the test saved (presets, files);\n// runs before setup (in case an earlier run crashed) and after the check.\n// noWarnings: true = fail if Radicles posts a WARNING during the test.\n// docCheck: false = skip the document consistency check (Document Model,\n// step 1): after every command the session's document, values refreshed,\n// must equal one rebuilt from the running system; a difference fails the\n// test and names the command and the address. Use only with a reason.\n// anyOrder: true = compare each command's posted code in any order (sorted\n// before snapshotting), for commands that run at the same time, such as\n// \"(lp 1 & lp 2 & fx 1 pch)\", whose posts race.\n// known: a String naming a reported problem (e.g. \"issue #39\"). The test still\n// runs, but a failure is listed as KNOWN instead of FAIL, and a pass is\n// flagged so the marker can be removed.\n~radTest = {|name, setup, cmds, check, gui = false, code, teardown, noWarnings = false, known"} {"text": ", setup, cmds, check, gui = false, code, teardown, noWarnings = false, known, note, cloud = true, docCheck = true, anyOrder = false|\n ~radTests = ~radTests.add((\n name: name.asString,\n caseFile: ~radTestCurrentCase,\n setup: setup ? [],\n cmds: cmds ? [],\n check: check,\n gui: gui or: { cloud.not },\n code: code,\n teardown: teardown,\n noWarnings: noWarnings,\n docCheck: docCheck,\n anyOrder: anyOrder,\n known: known,\n note: note\n ));\n};\n\n// Snapshot text for a list of captured blocks:\n// [ (cmd: \"vol t 1 -10\", radpost: [..], radpostcont: [..]), ... ]\n~radTestFormat = {|blocks|\n var str = \"\";\n blocks.do{|b|\n str = str ++ \">> \" ++ b[\\cmd] ++ \"\\n\";\n [\\radpost, \\radpostcont].do{|ch|\n str = str ++ \"== \" ++ ch ++ \" ==\\n\";\n if(b[ch].isEmpty, {\n str = str ++ \"(none)\\n\";\n }, {\n b[ch].do{|s| str = str ++ ~radTestNormalise.(s) ++ \"\\n\"};\n });\n };\n str = str ++ \"\\n\";\n };\n str;\n};\n\n// Remove details that change between runs or machines without meaning anything.\n~radTestNormalise = {|s|\n s = s.asString;"} {"text": " runs or machines without meaning anything.\n~radTestNormalise = {|s|\n s = s.asString;\n // tabs and trailing spaces\n s = s.replace(\"\\t\", \" \");\n s = s.split($\\n).collect{|line| line.stripWhiteSpace.isEmpty.if({\"\"}, {\n var end = line.size - 1;\n while({ end >= 0 and: { line[end].isSpace } }, { end = end - 1 });\n line.copyRange(0, end)\n })}.join(\"\\n\");\n // Numbers measured from timing (a timed recording's length, for example) vary\n // from run to run in the 3rd decimal, so numbers with 6 or more decimals are\n // rounded to 2 decimals. Typed values (0.5, -10) are never that long.\n s = {|str|\n var out = \"\", pos = 0;\n str.findRegexp(\"-?[0-9]+\\\\.[0-9]{6,}\").do{|m|\n out = out ++ str.copyRange(pos, m[0] - 1) ++ m[1].asFloat.round(0.01).asString;\n pos = m[0] + m[1].size;\n };\n out ++ str.copyToEnd(pos)\n }.(s);\n // A timed recording's loop rate is measured from the clock, so it can differ\n // in any decimal between runs: compare it as \"measured\", not by value.\n s = {|str|\n var out = \"\", pos = 0, key = \"'triggerRate', \";\n str.findRegexp(\"'triggerRate', -?[0-9.e-]+\").do{|m|\n out = out ++"} {"text": "riggerRate', -?[0-9.e-]+\").do{|m|\n out = out ++ str.copyRange(pos, m[0] - 1) ++ key ++ \"\";\n pos = m[0] + m[1].size;\n };\n out ++ str.copyToEnd(pos)\n }.(s);\n // A load keeps a sound file's place (blkload, tload): it sets startPos to\n // where the file is, which is measured, then puts it back. A line that\n // only sets startPos is compared as \"measured\", not by value.\n s = {|str|\n var out = \"\", pos = 0;\n str.findRegexp(\"\\\\.set\\\\('startPos', [^,()]*\\\\);\").do{|m|\n out = out ++ str.copyRange(pos, m[0] - 1) ++ \".set('startPos', );\";\n pos = m[0] + m[1].size;\n };\n out ++ str.copyToEnd(pos)\n }.(s);\n // recording file names carry the date and time (27_10_2026_10_50_12)\n s = {|str|\n var out = \"\", pos = 0;\n str.findRegexp(\"[0-9]{2}_[0-9]{2}_[0-9]{4}_[0-9]{2}_[0-9]{2}_[0-9]{2}\").do{|m|\n out = out ++ str.copyRange(pos, m[0] - 1) ++ \"\";\n pos = m[0] + m[1].size;\n };\n out ++ str.copyToEnd(pos)\n }.(s"} {"text": " + m[1].size;\n };\n out ++ str.copyToEnd(pos)\n }.(s);\n // absolute paths to the Radicles folders\n [Radicles.mainPath, Radicles.libPath, Radicles.filesPath].do{|p|\n if(p.notNil, { s = s.replace(p.asString, \"<\" ++ p.asString.basename ++ \">\") });\n };\n s;\n};\n\n~radTestSnapshotPath = {|t|\n ~radTestDir +/+ \"snapshots\" +/+ t[\\caseFile] +/+ (t[\\name] ++ \".txt\");\n};\n\n~radTestResultsDir = { ~radTestDir +/+ \"results\" };\n\n~radTestReadFile = {|path|\n var f, str;\n if(File.exists(path), {\n f = File(path, \"r\"); str = f.readAllString; f.close; str;\n }, { nil });\n};\n\n~radTestWriteFile = {|path, str|\n var f;\n File.mkdir(PathName(path).pathOnly);\n f = File(path, \"w\"); f.write(str); f.close;\n};\n\n// Load every case file (registers tests). caseFilter: nil or a case file name.\n~radTestLoadCases = {|caseFilter|\n ~radTests = [];\n (~radTestDir +/+ \"cases/*.scd\").pathMatch.sort.do{|path|\n var case = PathName(path).fileName"} {"text": "\").pathMatch.sort.do{|path|\n var case = PathName(path).fileNameWithoutExtension;\n if(caseFilter.isNil or: { caseFilter.asString == case }, {\n ~radTestCurrentCase = case;\n path.load;\n });\n };\n ~radTests;\n};\n```"} {"text": "SuperCollider patch — Radicles/Tests/cases/block-presets.scd\n\nBlock presets (Document Model, step 2, PR 2): blksave and blkload, the same folders and reconciler as effect presets, a sound file or wavetable carried by name, nobuf, default, same definition only. remove every block preset a test saved (all are named radtest_*)\n\n```supercollider\n// Block presets (Document Model, step 2, PR 2): blksave and blkload, the\n// same folders and reconciler as effect presets, a sound file or wavetable\n// carried by name, nobuf, default, same definition only.\n\n// remove every block preset a test saved (all are named radtest_*)\n~radBlockPresetClean = {\n (RadUnit.presetRoot +/+ \"block/*/radtest_*.scd\").pathMatch.do{|path| File.delete(path) };\n};\n\n~radTest.(\"block-preset-save-file\",\n setup: [\"start 2\", \"blk 1 sine\", \"blkset 1 freq 330\"],\n cmds: [\"blksave 1 radtest_low\"],\n check: {\n var path = RadUnit.presetPath(\\block, \\sine, \\radtest_low), text, unit;\n text = File.exists(path).if({ File.readAllString(path) }, { \"\" });\n unit = RadUnit.readPreset(\\block, \\sine, \\radtest_low);\n case\n { text.isEmpty }"} {"text": "reset(\\block, \\sine, \\radtest_low);\n case\n { text.isEmpty } { \"no file at \" ++ path }\n { text.beginsWith(\"// Radicles unit preset · block sine · format 1 · saved \").not } { \"header: \" ++ text.keep(60) }\n { unit != (kind: \\block, def: \\sine, args: (freq: 330, phase: 0, mul: 0.4)) } { \"unit: \" ++ unit.cs }\n { true }\n },\n teardown: ~radBlockPresetClean\n);\n\n// blkload sets what differs\n~radTest.(\"block-preset-load\",\n setup: [\"start 2\", \"blk 1 sine\", \"blkset 1 freq 330\", \"blksave 1 radtest_low\", \"blkset 1 freq 500\"],\n cmds: [\"blkload 1 radtest_low\"],\n check: {\n var v = Ndef(\\block1).get(\\freq);\n (v == 330) or: { \"freq \" ++ v }\n },\n teardown: ~radBlockPresetClean\n);\n\n// default: the definition's own values\n~radTest.(\"block-preset-default\",\n setup: [\"start 2\", \"blk 1 sine\", \"blkset 1 freq 500\"],\n cmds: [\"blkload 1 default\"],\n check: {\n var v = Ndef(\\block1).get(\\freq);\n (v == 440) or: { \"freq \" ++ v }\n }\n);\n\n// a preset belongs to its definition: it loads into any block"} {"text": " ++ v }\n }\n);\n\n// a preset belongs to its definition: it loads into any block playing it,\n// and not into a block playing something else\n~radTest.(\"block-preset-other-block\",\n setup: [\"start 2\", \"blk 1 sine\", \"blk 2 sine\", \"blkset 1 freq 330\", \"blksave 1 radtest_low\"],\n cmds: [\"blkload 2 radtest_low\"],\n check: {\n var v = Ndef(\\block2).get(\\freq);\n (v == 330) or: { \"freq \" ++ v }\n },\n teardown: ~radBlockPresetClean\n);\n\n~radTest.(\"block-preset-other-def\",\n setup: [\"start 2\", \"blk 1 sine\", \"blkset 1 freq 330\", \"blksave 1 radtest_low\", \"blk 2 noise\"],\n cmds: [\"blkload 2 radtest_low\"],\n check: {\n var unit = RadUnit.readBlock(\\block2);\n (unit[\\def] == \\noise) or: { \"unit: \" ++ unit.cs }\n },\n teardown: ~radBlockPresetClean\n);\n\n// a sound file by name and Play folder: loading plays the block again with it\n~radTest.(\"block-preset-sound-file\",\n setup: [\"start 2\", [\"lp 1 marilyn1\", 2], \"blkset 1 rate 0.5\", \"blksave 1 radtest_m\", [\"lp 1 drums1\", 4]],\n cmds: [[\"blkload 1 radtest_m\", 3]],\n check: {\n var"} {"text": " 4]],\n cmds: [[\"blkload 1 radtest_m\", 3]],\n check: {\n var unit = RadUnit.readBlock(\\block1), file = RadUnit.readPreset(\\block, \\loop, \\radtest_m);\n case\n { file[\\buffer] != (play: \\marilyn1, folder: BStore.playFolder) } { \"preset: \" ++ file.cs }\n { unit[\\buffer] != (play: \\marilyn1, folder: BStore.playFolder) } { \"buffer: \" ++ unit[\\buffer].cs }\n { unit[\\args][\\rate] != 0.5 } { \"rate: \" ++ unit[\\args].cs }\n { true }\n },\n teardown: ~radBlockPresetClean\n);\n\n// nobuf: the preset's values, the block's own sound file\n~radTest.(\"block-preset-nobuf\",\n setup: [\"start 2\", [\"lp 1 marilyn1\", 2], \"blkset 1 rate 0.5\", \"blksave 1 radtest_m\", [\"lp 1 drums1\", 4]],\n cmds: [[\"blkload 1 radtest_m nobuf\", 3]],\n check: {\n var unit = RadUnit.readBlock(\\block1);\n case\n { unit[\\buffer] != (play: \\drums1, folder: BStore.playFolder) } { \"buffer: \" ++ unit[\\buffer].cs }\n { unit[\\args][\\rate] != 0.5 } { \"rate: \" ++ unit[\\args].cs }"} {"text": "][\\rate] != 0.5 } { \"rate: \" ++ unit[\\args].cs }\n { true }\n },\n teardown: ~radBlockPresetClean\n);\n\n// a wavetable by its name\n~radTest.(\"block-preset-wavetable\",\n setup: [\"start 2\", [\"blk 1 osc1 sine1harm6\", 2], \"blksave 1 radtest_t\", [\"blk 1 osc1 sine2harm2\", 2]],\n cmds: [[\"blkload 1 radtest_t\", 3]],\n check: {\n var unit = RadUnit.readBlock(\\block1);\n (unit[\\data] == \\sine1harm6 and: { unit[\\buffer] == (alloc: Block.wavetableSize) }) or: { \"unit: \" ++ unit.cs }\n },\n teardown: ~radBlockPresetClean\n);\n\n// default keeps the block's sound file\n~radTest.(\"block-preset-default-keeps-file\",\n setup: [\"start 2\", [\"lp 1 drums1\", 2], \"blkset 1 rate 0.5\"],\n cmds: [[\"blkload 1 default\", 2]],\n check: {\n var unit = RadUnit.readBlock(\\block1);\n case\n { unit[\\buffer] != (play: \\drums1, folder: BStore.playFolder) } { \"buffer: \" ++ unit[\\buffer].cs }\n { unit[\\args][\\rate] != 1 } { \"rate: \" ++ unit[\\args].cs }\n { true }\n }"} {"text": "ate] != 1 } { \"rate: \" ++ unit[\\args].cs }\n { true }\n }\n);\n\n// a modulator comes back with its own settings\n~radTest.(\"block-preset-modulated\",\n setup: [\"start 2\", \"blk 1 sine\", \"blkset 1 freq sin\", \"modblkset 1 freq [freq, 3]\",\n \"blksave 1 radtest_mod\", \"unmodblk 1 freq\"],\n cmds: [[\"blkload 1 radtest_mod\", 2]],\n check: {\n var unit = RadUnit.readBlock(\\block1), mod = unit !? { unit[\\mods] } !? {|m| m[\\freq] };\n case\n { mod.isNil } { \"no modulator: \" ++ unit.cs }\n { mod[\\type] != \\sin } { \"type: \" ++ mod.cs }\n { mod[\\args][\\freq] != 3 } { \"modulator's own settings: \" ++ mod.cs }\n { true }\n },\n teardown: ~radBlockPresetClean\n);\n\n// a recorded buffer is not a file: the preset leaves it out, and a block\n// playing one keeps it when a preset loads\n~radTest.(\"block-preset-recorded-buffer\",\n setup: [\"start 2\", \"@ 2\", [\"blk 1 loop @1\", 2], \"blkset 1 rate 0.5\", \"blksave 1 radtest_r\", \"blkset 1 rate 2\"],\n cmds: [[\"blkload 1 radtest_r\", 2]],\n check: {\n var unit = RadUnit.readBlo"} {"text": "blkload 1 radtest_r\", 2]],\n check: {\n var unit = RadUnit.readBlock(\\block1), file = RadUnit.readPreset(\\block, \\loop, \\radtest_r);\n case\n { file.isNil } { \"no preset\" }\n { file[\\buffer].notNil } { \"preset holds a buffer: \" ++ file.cs }\n { unit[\\buffer] != (rec: 1) } { \"buffer: \" ++ unit[\\buffer].cs }\n { unit[\\args][\\rate] != 0.5 } { \"rate: \" ++ unit[\\args].cs }\n { true }\n },\n teardown: ~radBlockPresetClean\n);\n\n// recording blocks and patterns have no presets\n~radTest.(\"block-preset-recording-def\",\n setup: [\"start 2\"],\n check: {\n (RadUnit.recordsDef(\\rec) and: { RadUnit.recordsDef(\\recloop) } and: { RadUnit.recordsDef(\\loop).not }\n and: { RadUnit.recordsDef(\\sine).not }) or: { \"recordsDef wrong\" }\n }\n);\n\n~radTest.(\"block-preset-pattern-refused\",\n setup: [\"start 2\", [\"pn 1 test1\", 2]],\n cmds: [\"blksave 1 radtest_p\"],\n check: {\n RadUnit.allPresets(\\block).any{|pair| pair[1] == \\radtest_p }.not or: { \"a pattern was saved\""} {"text": "{|pair| pair[1] == \\radtest_p }.not or: { \"a pattern was saved\" }\n },\n //stop the pattern before the server quits: on the Mac, a note it sends\n //while the server is quitting posts a FAILURE IN SERVER\n teardown: {\n if(Ndef(\\block1).source.notNil, { Radicles.cW.callFunc(\"st 1\"); 1.wait });\n ~radBlockPresetClean.();\n }\n);\n\n// the list of a definition's presets\n~radTest.(\"block-preset-names\",\n setup: [\"start 2\", \"blk 1 sine\", \"blksave 1 radtest_a\", \"blksave 1 radtest_b\"],\n check: {\n var names = RadUnit.presetNames(\\block, \\sine);\n (names.includes(\\radtest_a) and: { names.includes(\\radtest_b) }) or: { \"names: \" ++ names.cs }\n },\n teardown: ~radBlockPresetClean\n);\n\n// ---- keeping a recording (4 Nov 2026): blksave N name keep [file] ----\n\n// remove the recordings a test kept (named radtest_*, or the rec_ file it noted)\n~radKeepClean = {\n (RadUnit.recordingsPath +/+ \"radtest_*.wav\").pathMatch.do{|path| File.delete(path) };\n ~radKeptFile !? {|name| File.delete(RadUnit.recordingsPath +/+ name ++ \".wav\") };\n "} {"text": " File.delete(RadUnit.recordingsPath +/+ name ++ \".wav\") };\n ~radKeptFile = nil;\n ~radBlockPresetClean.();\n};\n\n// keep writes the recording to recordings/.wav, the block plays the\n// file (same values), and the preset holds the file\n~radTest.(\"block-preset-keep\",\n setup: [\"start 2\", \"@ 2\", [\"blk 1 loop @1\", 2], \"blkset 1 rate 0.5\"],\n cmds: [[\"blksave 1 radtest_k keep radtest_take\", 4]],\n check: {\n var form = (play: \\radtest_take, folder: \\recordings), unit = RadUnit.readBlock(\\block1),\n file = RadUnit.readPreset(\\block, \\loop, \\radtest_k);\n case\n { File.exists(RadUnit.recordingsPath +/+ \"radtest_take.wav\").not } { \"no file in recordings\" }\n { file.isNil } { \"no preset\" }\n { file[\\buffer] != form } { \"preset: \" ++ file.cs }\n { unit[\\buffer] != form } { \"block: \" ++ unit.cs }\n { unit[\\args][\\rate] != 0.5 } { \"rate: \" ++ unit[\\args].cs }\n { true }\n },\n teardown: ~radKeepClean\n);\n\n// without a file name: rec__