?\n - chenge children's bounds to relative or something, and percentage (?)\n- Servers to separate classes\n- when updating - have a separate task (get rid of .init vs .new for widgets, control sending pace, etc) - might create more problems than solutions?\n- possible slider substitute: http://skidding.github.io/dragdealer/\n\ncreate 2 divs, parent and child, set class names according to instructions (.setAttribute), then create new dragdealer class passing parent\n\n--- done list: ---\n*/\n\nWsWindow {\n var title,
[widgetParams, function, controlSpec]\n var onAddClientFunc, <>onRemoveClientFunc;\n var onClose;\n var serverShutdownFunction;\n var 0, {cssDict.put(\\width, (bounds.width * 100).asString ++ \"%\")});\n if(bounds.height > 0, {cssDict.put(\\height, (bounds.height * 100).asString ++ \"%\")});\n // if((dict[\\kind] == \\slider) && (bounds.width < bounds.height), {\n // cssDict.put('-webkit-appearance', \"slider-vertical\");\n // }); //auto vertical slider\n };\n dict[\\background"}
+{"text": "ider-vertical\");\n // }); //auto vertical slider\n };\n dict[\\backgroundColor] !? {cssDict.put('background-color', dict[\\backgroundColor].hexString)};\n // dict['background-color-slider'] !? {cssDict.put('background-color-slider', dict['background-color-slider'].hexString)};\n dict[\\textColor] !? {cssDict.put('color', dict[\\textColor].hexString)};\n dict[\\font] !? {\n dict[\\font].size !? {cssDict.put('font-size', dict[\\font].size.asString ++ \"px\")};\n dict[\\font].name !? {cssDict.put('font-family', dict[\\font].name)};\n if(dict[\\font].italic, {cssDict.put('font-style', \"italic\")});\n if(dict[\\font].bold, {cssDict.put('font-weight', \"bold\")});\n //add text-decoration here as well - bold, italic?\n };\n dict[\\textAlign] !? {cssDict.put('text-align', dict[\\textAlign].asString)};\n\n //create string\n str = \"\";\n cssDict.keysValuesDo({|key, value, inc|\n keyString = key.asString;\n valString = value.asString;\n str = str ++ keyString ++ \":\" ++ valString ++ \";\";\n });\n dict[\\css] !? {str = str ++ d"}
+{"text": "\" ++ valString ++ \";\";\n });\n dict[\\css] !? {str = str ++ dict[\\css].asString}; //add custom css\n\n if(cssDict.size > 0, {\n ^str;\n }, {\n ^nil;\n });\n }\n\n addWidget {arg name, kind = \\button, func = {}, parameters = IdentityDictionary.new, spec = [0, 1].asSpec, sendNow=true;\n var paramsDict, id, okToAddWidget, step;\n if(name.notNil, {\n if(namesToIDs[name].isNil && name.isKindOf(SimpleNumber).not,\n {\n id = this.uniqueID.next;\n namesToIDs.put(name, id);\n okToAddWidget = true;\n },{\n warn( format(\n \"Widget assigned to name % already exists or you're trying to use SimpleNumber as id, not adding\\n\", name));\n okToAddWidget = false;\n });\n }, {\n id = this.uniqueID.next;\n okToAddWidget = true;\n });\n\n if(okToAddWidget, {\n paramsDict = IdentityDictionary.new(know: false);\n paramsDict.put(\\kind, kind);\n if(parameters.isKindOf(Dictionary), {\n paramsDict = paramsDict.putAll(parameters);\n });\n //here params\n kind.switch(\n \\slider, {\n // paramsDict.put(\\min, 0);\n // paramsDict.put(\\"}
+{"text": ", {\n // paramsDict.put(\\min, 0);\n // paramsDict.put(\\max, 1);\n // paramsDict.put('slider-value', spec.unmap(spec.default));\n // paramsDict.put(\\step, \\any);\n paramsDict.put(\\vertical, (paramsDict[\\bounds].width1\n dimsNorm = elements.collect{|elem|\n if("}
+{"text": " element dimensions normalized 0>1\n dimsNorm = elements.collect{|elem|\n if( elem.isKindOf(WsLayout) or: elem.isKindOf(WsWidget),\n { elem.bounds.notNil.if(\n { //\"returning a dimension of bound \".post; // debug\n (loKind == \\vert).if({elem.bounds.height},{elem.bounds.width}) },\n { //\"returning unspecified dimension\".postln; // debug\n 'unspecified' }\n );\n },{ elem } // assumed to be either nil or a Number\n );\n };\n\n // assign layouts or widgets with nil (unspecified) width to a width of\n // 1/numNonNilItems and rescale other items accordingly in case a\n // layout with unspecified width is forced to 0 width by nilSize = 0\n\n nonNilDims = dimsNorm.select({|dim| dim.notNil}); // numbers and 'unspecified's\n // postf(\"nonNilDims: %\\n\",nonNilDims);\n\n unKnownDimSize = nonNilDims.size.reciprocal; // size assigned to unspecified dimension\n // postf(\"unKnownDimSize: %\\n\",unKnownDimSize);\n\n nonNilDims = nonNilDims.replace('unspecified', unKnownDimSize);\n // postf(\"nonNilDims: %\\n\", nonNilDims);\n\n if(nonNilDims.sum > 1,\n { // dimensions"}
+{"text": "\", nonNilDims);\n\n if(nonNilDims.sum > 1,\n { // dimensions are rescaled\n // \"rescaling element dimension\".postln;\n nonNilDims = nonNilDims.normalizeSum; // rescale all down to sum to 1\n dimsAbs = dimsNorm.collect({ |item, i| var dim;\n item.isNil.if(\n { dim = 0 },\n { dim = nonNilDims[counter];\n counter = counter +1; }\n );\n dim\n })\n },{\n var numNils;\n freeSpace = 1 - nonNilDims.sum;\n numNils = dimsNorm.occurrencesOf(nil);\n nilSize = if(( numNils > 0) and: (freeSpace > 0), {freeSpace / numNils},{0});\n dimsAbs = dimsNorm.collect({ |item, i|\n var dim;\n item.isNil.if(\n { dim = nilSize },\n { dim = nonNilDims[counter];\n counter = counter +1; }\n );\n dim\n });\n });\n\n // convert to absolute page widths\n dimsAbs = dimsAbs * (loKind == \\vert).if({parBoundsRect.height},{parBoundsRect.width});\n\n // postf( \"dimensions norm:%\\ndimensions abs :%\\navailable free space:%\\nnilSize: %\\n\",\n // dimsNorm, dimsAbs, freeSpace, nilSize);\n\n // place the widgets\n nextX ="}
+{"text": " dimsNorm, dimsAbs, freeSpace, nilSize);\n\n // place the widgets\n nextX = parBoundsRect.left;\n nextY = parBoundsRect.top;\n\n elements.do{ |elem, i|\n var myBounds, myWidth, myHeight;\n\n // postf(\"\\niterating through: %, next x/y: %/%\\n\", elem, nextX, nextY); //debug\n\n (elem.isKindOf(WsLayout) or: elem.isKindOf(WsWidget)).if{\n // a widget or another layout\n switch( loKind,\n \\vert, {\n myHeight = dimsAbs[i];\n myWidth = elem.bounds.notNil.if( {\n // postf(\"multiplying elem width: % by parent width: %\\n\",\n // elem.bounds.width, parBoundsRect.width);\n elem.bounds.width * parBoundsRect.width\n },{ parBoundsRect.width }\n );\n },\n \\horiz, {\n myWidth = dimsAbs[i];\n myHeight = elem.bounds.notNil.if(\n { elem.bounds.height * parBoundsRect.height },\n { parBoundsRect.height }\n );\n }\n );\n\n // ignoring original xy for now\n myBounds = Rect(nextX, nextY, myWidth, myHeight);\n\n case\n {elem.isKindOf(WsLayout)} {\n this.buildLayout(elem, myBounds);\n elem.bounds_(myBounds); // for intro"}
+{"text": "buildLayout(elem, myBounds);\n elem.bounds_(myBounds); // for introspection\n }\n { elem.isKindOf(WsWidget) } {\n // postf(\"placing a WsWidget: % at bounds: %\\n\", elem, myBounds); // debug\n elem.bounds_(myBounds);\n elem.addToPage;\n };\n };\n\n switch( loKind,\n \\vert, {nextY = nextY + dimsAbs[i]},\n \\horiz, {nextX = nextX + dimsAbs[i]}\n )\n };\n }\n}\n\n// TODO: figure out how to separate out methods for irrelevant sub-classes\n// e.g. textColor for WsCheckBox\n\nWsWidget {\n var ws, \");//convert newline for html\n thisString = thisString.replace(\"\\t\", \" \");//convert newline for html\n if(ws.guiObjects[id][0][\\innerHTML].isNil, {\n ws.guiObjects[id][0].put(\\innerHTML, thisString);\n }, {\n ws.guiObjects[id][0][\\innerHTML] = thisString;\n });\n ws.updateWidget(id, \\innerHTML);\n }\n\n string {\n ^ws."}
+{"text": ";\n });\n ws.updateWidget(id, \\innerHTML);\n }\n\n string {\n ^ws.guiObjects[id][0][\\innerHTML];\n }\n\n remove {\n ws.removeWidget(id);\n }\n}\n\nWsSimpleButton : WsWidget {\n\n *new {|wsWindow, bounds|\n ^super.new.add(wsWindow, bounds, \\button, sendNow: true);\n }\n\n // doesn't send to page, just inits the object\n *init { |wsWindow, bounds|\n ^super.new.add(wsWindow, bounds, \\button, sendNow: false);\n }\n}\n\nWsButton : WsWidget {\n var bounds, WWW (WebSo"}
+{"text": ": WsLayout {}\n\n// this class starts/stops node OSC <-> WWW (WebSockets) bridge\n// provides sendMsg functionality\n// does NOT provide OSC responders, these are implemented by individual WsWindows\nWsWindowServer {\n var doOnShutDown; // {|this|}\n var printSentMessages = false;\n\n classvar <>oscRootPath = \"/sockets\";\n classvar nodePath; //to be detected on first run\n classvar runInTerminal = false; //for debugging\n classvar 0}, {\n this.prSendMsg(*queuedMessages.pop);\n });\n messageQueueIsEmpty = true;\n //send queued messages here\n }\n\n sendMsg {|...args|\n if(messageQueueIsEmpty, {\n if(pid.notNil, {\n "}
+{"text": "args|\n if(messageQueueIsEmpty, {\n if(pid.notNil, {\n this.prSendMsg(*args);\n }, {\n format(\"%(%) is not running\", this.class.name, port).warn;\n });\n }, {\n queuedMessages.add(args);\n });\n }\n\n prSendMsg {|...args| //this will not check for the queue\n scSendNetAddr.sendMsg(*args);\n if(printSentMessages, {\n this.class.name.post; \" oscMessage: \".post;\n args.postln;\n });\n }\n\n free {\n if(pid.notNil, {\n this.kill(false);\n }, {\n \"% doesn't seem to be running.\\n\".postf(this.class.name);\n });\n }\n\n cleanup { //triggered on exit\n // \"Cleaning up.\".postln;\n // responders.do(_.free);\n ShutDown.objects.remove(shutdownFunc);\n // shutdownFunc = nil;\n allWsWindowServers.removeAt(port);\n allWsWindows.do(_.free); //free all associated wswindowservers\n scSendNetAddr ?? {onFailure !? {onFailure.()}}; //if we didn't receive OSC port, that means we failed to start\n }\n}\n\n// helper class for managing IDs\nWsWindowUniqueID {\n var [\\acn, \\n3d], // atk, mpegH\n \\ambix->[\\acn, \\sn3d], // ambix\n \\fuma->[\\fuma, \\fuma] // fuma\n ]);\n }\n\n *format {\n ^formatDict[\\atk]\n }\n\n *ordering {\n ^formatDict[\\atk][0]\n }\n\n *normalisation {\n ^formatDict[\\atk][1]\n }\n\n *setSpeedOfSound { |mps|\n var mpsAsFloat;\n\n mpsAsFloat = mps.asFloat;\n /*\n TODO: run initializations necessary when changing speedOfSound\n after resources have already been allocated at a different speedOfSound\n */\n speedOfSound = mpsAsFloat;\n ^mpsAsFloat\n }\n\n *setRefRadius { |radius|\n var radiusAsFloat = radius.asFloat;\n\n /*\n TODO: run initializations necessary when changing refRadius\n after resources have already been allocated at a different refRadius\n */\n refRadius = radiusAsFloat;\n ^radiusAsFloat\n }\n\n *"}
+{"text": "adius\n */\n refRadius = radiusAsFloat;\n ^radiusAsFloat\n }\n\n *setThresh { |threshold|\n var threshAbs = threshold.abs;\n\n thresh = threshAbs;\n ^thresh\n }\n\n *setDefaultOrder { |order|\n var orderAsInteger = order.asInteger;\n\n /*\n TODO: run initializations necessary when changing order\n after resources have already been allocated at a different order\n */\n defaultOrder = orderAsInteger;\n ^orderAsInteger\n }\n\n // testing / confirmation\n\n // full 3D only\n *detectOrder { |size|\n var perfectSqrt = size.perfectSqrt;\n\n if(perfectSqrt.isNil, {\n \"Could not detect order from % coefficients\".format(size).throw\n }, {\n ^(perfectSqrt - 1)\n })\n }\n\n *confirmOrder { |size, order = (AtkHoa.defaultOrder)|\n ^(this.detectOrder(size) == order)\n }\n}\n```"}
+{"text": "SuperCollider schelp — atk-sc3/HelpSource/Classes/FoaPanB.schelp\n\nFoaPanB —\nFirst Order Ambisonic (FOA) panner\nCategory: Libraries>Ambisonic Toolkit>UGens>FOA>Encoder, UGens>Multichannel>Ambisonics, UGens>Multichannel>Panners\nSee also: Classes/FoaEncode\n\n\nEncode a monophonic input to a First Order Ambisonic signal (B-format), as a planewave. PanB is the SuperCollider inbuilt equivalent.\n\n## ar\n\n- in:\nThe input signal.\n\n- azimuth:\nAzimuth, in radians.\n\n- elevation:\nElevation, in radians.\n\n- mul:\nOutput will be multiplied by this value.\n\n- add:\nThis value will be added to the output.\n\nFoaPanB is provided primarily as a convenience. Encoding monophonic signals via FoaEncoderMatrix#*newOmni and transformation via FoaPush is often regarded as a more idiomatic option. See Encoding-FOA#Omnidirectional%20encoder#this example.\n\nAdditionally, use of FoaProximity to generate proximity cues is also encouraged."}
+{"text": "SuperCollider schelp — atk-sc3/HelpSource/Classes/FoaSFPL.schelp\n\nFoaSFPL —\nFirst Order Ambisonic (FOA) Soundfield Pressure Level\nCategory: Libraries>Ambisonic Toolkit>UGens>FOA>Analyzer, UGens>Multichannel>Ambisonics, UGens>Analysis>Ambisonics\nSee also: Classes/FoaSFVL, Classes/FoaSFWL, Classes/FoaSFIL, Classes/FoaSFWhL, Classes/FoaWp\n\n\nReturn the Soundfield Pressure Level, SFPL, of a first order ambisonic (B-format) signal, in dB.\n\nNote:\nFoaSFPL is usually called via the convenience wrapper FoaAnalyze.\n\n## ar\n\n- in:\nThe B-format signal, an array: [w, x, y, z]\n\n- size:\nAnalysis filter kernel size.\n\nNote: For method:\n```supercollider\n'instant'\n```\n, must be a power of 2. \n\n- method:\nThe Soundfield analysis method:\n\n-\n```supercollider\n'instant'\n```\n\n-\n```supercollider\n'average'\n```\n\nPlease see discussion of method FoaAnalyze#Analysis%20method#here.\n\nExamples:\n\nPlease see various examples FoaAnalyze#examples#here."}
+{"text": "SuperCollider schelp — atk-sc3/HelpSource/Classes/FoaSpeakerMatrix.schelp\n\nFoaSpeakerMatrix —\nFirst Order Ambisonic (FOA) diametric decoder speaker matrices\nCategory: Libraries>Ambisonic Toolkit>Matrix & Kernel>Internals\nSee also: Classes/FoaDecoderMatrix\n\n\nGenerates speaker matrices required by the Ambisonic Toolkit's first order diametric decoder, FoaDecoderMatrix#*newDiametric. footnote FoaSpeakerMatrix is Heller's speaker matrix helper used to generate matricies for diamatric decoding. See: See: E. Benjamin, R. Lee, and A. Heller, \"Is My Decoder Ambisonic?,\" in Proceedings of the 125th Audio Engineering Society Convention, San Francisco, 2008. \n\nNote:\nIn normal circumstances, the user will not call FoaSpeakerMatrix directly.\n\n## new\n\n- directions:\n\nAn array of directions for half of the loudspeaker feeds for the desired decoder. Specify in radians.\n\nRank 1 arrays return pantophonic, while rank 2 arrays return periphonic. E.g.,\n\n```supercollider\n// 2D:\n~directions = [ theta0, theta1, ... thetaN ];\n```\n\n```supercollider\n// 3D:\n~directions = [ [ theta0, phi0 ], [ theta1, phi1 ], ... [ theta"}
+{"text": "\n~directions = [ [ theta0, phi0 ], [ theta1, phi1 ], ... [ thetaN, phiN ] ];\n```\n\n- k:\nThe k factor of the decoder. May be specified as a float: 0.5 to 1.0.\n\n## newPositions\n\n- positions:\nAn array of positions for half of the loudspeaker feeds for the desired decoder. Specify in cartesian coordinates.\n\n```supercollider\n// 2D:\n~positions = [ [ x0, y0 ], [ x1, y1 ], ... [ xN, yN ] ];\n```\n\n```supercollider\n// 3D:\n~positions = [ [ x0, y0, z0 ], [ x1, y1, z1 ], ... [ xN, yN, zN ] ];\n```\n\n- k:\nThe k factor of the decoder. May be specified as a float: 0.5 to 1.0.\n\n## dim\nAnswers the number of decoder dimensions: 2D or 3D.\n\n## numChannels\nAnswers the number of loudspeaker feeds (output channels).\n\n## positions\nAnswers the position of loudspeaker feeds, in cartesian coordinates.\n\n## matrix\nAnswers the speaker matrix\n\n## k\nAnswer k"}
+{"text": "SuperCollider schelp — atk-sc3/HelpSource/Classes/HoaMatrixXformer.schelp\n\nHoaMatrixXformer\nHigher Order Ambisonic (HOA) matrix transformers\nCategory: Libraries>Ambisonic Toolkit>Matrix & Kernel>HOA\nSee also: Classes/HoaXformMatrix\n\n\nGenerate matrix transformers required by the Ambisonic Toolkit's Higher Order Ambisonic (HOA) transformer, HoaXformMatrix.\n\n## newBeam\nBeamform into a Higher Order Ambisonic signal (HOA).\n\n- theta:\nAzimuth, in radians.\n\n- phi:\nElevation, in radians.\n\n- beamShape:\nKeyword argument for beam shape. See HoaMatrixDecoder#Beam%20shape#discussion here.\n\n- order:\nAmbisonic order.\n\n## newNull\nNullform into a Higher Order Ambisonic signal (HOA).\n\n- theta:\nAzimuth, in radians.\n\n- phi:\nElevation, in radians.\n\n- beamShape:\nKeyword argument for beam shape. See HoaMatrixDecoder#Beam%20shape#discussion here.\n\n- order:\nAmbisonic order.\n\n## newReflect\nMirror a Higher Order Ambisonic signal (HOA).\n\n- mirror:\nKeyword argument for reflection. See discussion below.\n\n- order:\nAmbisonic order.\n\nA variety of refle"}
+{"text": " reflection. See discussion below.\n\n- order:\nAmbisonic order.\n\nA variety of reflection transforms are offered:\n\n- keyword || mirror\n-\n```supercollider\n\\reflect\n```\n || Mirror across the origin. Equivalent to:\n```supercollider\n\\flip * \\flop * \\flap\n```\n. FOOTNOTE HOA transform equivalent to FoaXformerMatrix#*newMirrorO. \n-\n```supercollider\n\\flip\n```\n || Mirror in the y-axis. FOOTNOTE HOA transform equivalent to FoaXformerMatrix#*newMirrorY. \n-\n```supercollider\n\\flop\n```\n || Mirror in the x-axis. FOOTNOTE HOA transform equivalent to FoaXformerMatrix#*newMirrorX. \n-\n```supercollider\n\\flap\n```\n || Mirror in the z-axis. FOOTNOTE HOA transform equivalent to FoaXformerMatrix#*newMirrorZ. \n-\n```supercollider\n\\CondonShortleyPhase\n```\n || Condon-Shortley Phase. Equivalent to:\n```supercollider\n\\flip * \\flop\n```\n.\n-\n```supercollider\n\\origin\n```\n || Synonym for\n```supercollider\n\\reflect\n```\n.\n-\n```supercollider\n\\x\n```\n || Synonym for\n```supercollider\n\\flop\n```\n.\n-\n```supercollider\n\\y\n```\n |"}
+{"text": "supercollider\n\\flop\n```\n.\n-\n```supercollider\n\\y\n```\n || Synonym for\n```supercollider\n\\flip\n```\n.\n-\n```supercollider\n\\z\n```\n || Synonym for\n```supercollider\n\\flap\n```\n.\n\n## newRotateAxis\nRotate a Higher Order Ambisonic signal (HOA) around an axis.\n\n- axis:\nKeyword argument for axis of rotation. See discussion below.\n\n- angle:\nRotation angle, in radians.\n\n- order:\nAmbisonic order.\n\nRotation about one of the three cartesian axes are offered via these keywords:\n\n- keyword || axis of rotation\n-\n```supercollider\n\\x\n```\n || x-axis\n-\n```supercollider\n\\y\n```\n || y-axis\n-\n```supercollider\n\\z\n```\n || z-axis\n-\n```supercollider\n\\rotate\n```\n || Synonym for\n```supercollider\n\\z\n```\n.\n-\n```supercollider\n\\tilt\n```\n || Synonym for\n```supercollider\n\\x\n```\n.\n-\n```supercollider\n\\tumble\n```\n || Synonym for\n```supercollider\n\\y\n```\n.\n-\n```supercollider\n\\yaw\n```\n || Synonym for\n```supercollider\n\\z\n```\n.\n-\n```supercollider\n\\pitch\n```\n || Synonym for\n```supercollider\n\\y\n```\n.\n-\n```super"}
+{"text": "\n```\n || Synonym for\n```supercollider\n\\y\n```\n.\n-\n```supercollider\n\\roll\n```\n || Synonym for\n```supercollider\n\\x\n```\n.\n\n## newRTT\nCompound rotation around the z, x and y axes, applied in sequential order: rotate, tilt, tumble.\n\nNote:\nExtrinsic, \"laboratory-fixed\" axes.\n\n- rotate:\nRotation angle around z-axis, in radians.\n\n- tilt:\nRotation angle around x-axis, in radians.\n\n- tumble:\nRotation angle around y-axis, in radians.\n\n- order:\nAmbisonic order.\n\n## newYPR\nCompound rotation around the z, y' and x\" axes: yaw, pitch, roll.\n\nNote:\nMixed extrinsic (z-axis), intrinsic (y' & x\"-axes) rotations. This rotation differs from #*newRTT, which is extrinsic.\n\n- yaw:\nRotation angle around z-axis, in radians.\n\n- pitch:\nRotation angle around y'-axis, in radians.\n\n- roll:\nRotation angle around x\"-axis, in radians.\n\n- order:\nAmbisonic order.\n\n## newRotate\nCompound rotation around the cartesian axes, applied in sequential order.\n\nNote:\nExtrinsic, \"laboratory-fixed\" axes.\n\n- r1:\nRotation angle around axis-1, in radians.\n\n- r2:\nRotation angle around axis-2, in rad"}
+{"text": " axis-1, in radians.\n\n- r2:\nRotation angle around axis-2, in radians.\n\n- r3:\nRotation angle around axis-2, in radians.\n\n- axes:\n\nIndividual axes are specified via the axial keywords for #*newRotateAxis.\n\nSpecify order of rotations via concatenation. E.g., rotate, tilt, tumble:\n```supercollider\n\\zxy\n```\n\n- order:\nAmbisonic order.\n\n## newSwapAxes\nSwap two axes of a Higher Order Ambisonic signal (HOA).\n\n- axes:\nIndividual axes are specified via the axial keywords for #*newRotateAxis.\n\nSpecify swap via concatenation. E.g., swap y-axis with z-azis:\n```supercollider\n\\yz\n```\n\n- order:\nAmbisonic order.\n\n## newDominate\nApply dominance along an arbitrary axis.\n\n- gain:\nDominance gain, in dB.\n\n- theta:\nAzimuth, in radians.\n\n- phi:\nElevation, in radians.\n\n- order:\nAmbisonic order.\n\nApplies dominance along the axis defined by theta and phi.\n\nPositive values of gain increase the gain at\n```supercollider\n [theta, phi]\n```\n to +gain dB, while decreasing the gain at\n```supercollider\n [theta.neg, phi.neg]\n```\n to -gain. This simultaneously results in a distortion"}
+{"text": "theta.neg, phi.neg]\n```\n to -gain. This simultaneously results in a distortion of the image towards\n```supercollider\n [theta, phi]\n```\n. Negative values of gain invert this distortion, distorting towards\n```supercollider\n [theta.neg, phi.neg]\n```\n . The default, 0, results in no change.\n\nImaging is illustrated FoaDominateX#figure#here.\n\n## newZoom\nApply zoom along an arbitrary axis.\n\n- angle:\nDistortion angle, in radians. -pi/2 to pi/2\n\n- theta:\nAzimuth, in radians.\n\n- phi:\nElevation, in radians.\n\n- order:\nAmbisonic order.\n\nApplies zoom along the axis defined by theta and phi.\n\nZoom is a normailised dominance variant, specified in terms of a distortion angle. Positive values of angle increase gain at\n```supercollider\n [theta, phi]\n```\n, while reducing at\n```supercollider\n [theta.neg, phi.neg]\n```\n. Negative values do the inverse. The default, 0, results in no change.\n\nImaging is illustrated FoaZoomY#figure#here.\n\n## newFocus\nApply focus along an arbitrary axis.\n\n- angle:\nDistortion angle, in radians. -pi/2 to pi/2\n\n- theta:\nAzimuth, in radians.\n\n- phi:\nElevation, in radians.\n\n- order:\nAmbisonic order.\n\nApplies focus"}
+{"text": "\nElevation, in radians.\n\n- order:\nAmbisonic order.\n\nApplies focus along the axis defined by theta and phi.\n\nFocus is a normalised dominance variant, specified in terms of a distortion angle. Positive values of angle maintain gain at\n```supercollider\n [theta, phi]\n```\n, while reducing at\n```supercollider\n [theta.neg, phi.neg]\n```\n. Negative values do the inverse. The default, 0, results in no change.\n\nIn contrast with #*newZoom#zoom, gain is maintained at 0dB in the direction of distortion.\n\nImaging is illustrated FoaFocusX#figure#here.\n\n## newAsymmetry\nApply soundfield asymmetry\n\n- angle:\nDistortion angle, in radians. -pi/2 to pi/2\n\n- order:\nAmbisonic order.\n\nPositive values of angle rotate\n```supercollider\n [-pi/2, 0]\n```\n towards\n```supercollider\n [0, 0]\n```\n, and at pi/2 collapse the soundfield to a travelling wave. Negative values rotate\n```supercollider\n [pi/2, 0]\n```\n towards\n```supercollider\n [0, 0]\n```\n. The default, 0, results in no change.\n\nImaging is illustrated FoaAsymmetry#figure#here.\n\n## newBalance\nApply soundfield balance.\n\n- angle:\nDistortion angle, in radians. -pi/2 to pi/2\n\n- order:\nAmbisonic"}
+{"text": "istortion angle, in radians. -pi/2 to pi/2\n\n- order:\nAmbisonic order.\n\nA synonym for apply zoom along the y-axis.\n\nBalance is a normailised dominance variant, specified in terms of a distortion angle. Positive values of angle increase gain at\n```supercollider\n [pi/2, 0]\n```\n, while reducing at\n```supercollider\n [-pi/2, 0]\n```\n. Negative values do the inverse. The default, 0, results in no change.\n\nImaging is illustrated FoaBalance#figure#here.\n\n## Matrix & File\n\n## newFromMatrix\nTransform a Higher Order Ambisonic signal (HOA) via a directly designed spatial filter.\n\n- matrix:\nA Matrix instance.\n\n- order:\nAmbisonic order.\n\n HoaMatrix, *newFromFile\n\n## Information\n\n HoaMatrix, -info\n\n HoaMatrix, -order\n\n HoaMatrix, -set\n\n HoaMatrix, -type\n\n HoaMatrix, -op\n\n HoaMatrix, -kind\n\n HoaMatrix, -dim\n\n HoaMatrix, -numChannels\n\n HoaMatrix, -directions\n\n HoaMatrix, -numInputs\n\n HoaMatrix, -dirInputs\n\n HoaMatrix, -numOutputs\n\n HoaMatrix, -dirOutputs\n\n## Matrix\n\n HoaMatrix, -matrix\n\n HoaMatrix, -thresh2\n\n HoaMatrix, -asArray\n\n## File handling\n\n Hoa"}
+{"text": "rix, -thresh2\n\n HoaMatrix, -asArray\n\n## File handling\n\n HoaMatrix, -fileName\n\n HoaMatrix, -filePath\n\n HoaMatrix, -fileParse\n\n HoaMatrix, -writeToFile\n\n## Analysis\n\n## analyzeAverage\nReturn an average analysis of transformer amplitude and energies.\n\nReturns:\n\nAnalysis is returned in an IdentityDictionary, with the following keys:\n\n- keyword || analysis\n-\n```supercollider\n\\amp\n```\n || pressure (virtual loudspeaker sum)\n-\n```supercollider\n\\rms\n```\n || spherical harmonic energy\n-\n```supercollider\n\\energy\n```\n || virtual loudspeaker (angular) energy\n-\n```supercollider\n\\meanE\n```\n || transformer reduced energy\n-\n```supercollider\n\\matchWeight\n```\n || transformer matching weights (a Dictionary)\n\nThe required weights for HoaMatrixDecoder#Gain%20match#gain matching are returned in the\n```supercollider\n\\matchWeight\n```\n Dictionary:\n\n- keyword || analysis\n-\n```supercollider\n\\amp\n```\n || match weight for pressure (virtual loudspeaker sum)\n-\n```supercollider\n\\rms\n```\n || match weight for spherical harmonic energy\n-\n```supercollider\n\\energy\n```\n || match weight for virtual loudspeaker (angular) energy\n\nOffers a convenient way to review modifications to the soundfield.\n\nR"}
+{"text": " (angular) energy\n\nOffers a convenient way to review modifications to the soundfield.\n\nRotation:\n\n```supercollider\n// Axial rotation\n\n// specify parameters & design\n~axis = \\z\n~angle = pi/3\n~order = 3\n~xformer = HoaMatrixXformer.newRotateAxis(~axis, ~angle, ~order)\n\n// analyze average - matching weights\n~xformer.analyzeAverage.matchWeight\n```\n\nBeamforming:\n\n```supercollider\n// Beamforming\n\n// specify parameters & design\n~theta = 0.0\n~phi = 0.0\n~beamShape = \\basic\n~order = 3\n~xformer = HoaMatrixXformer.newBeam(~theta, ~phi, ~beamShape, ~order)\n\n// analyze average - matching weights\n~xformer.analyzeAverage.matchWeight\n```\n\n## analyzeDirections\n\nReturn a directional analysis of modifications to the soundfield.\n\n- directions:\n\nA single azimuth value, or an array of test directions. Specify in radians.\n\nRank 1 arrays return pantophonic, while rank 2 arrays return periphonic. E.g.,\n\n```supercollider\n// 2D:\n~testDirections = [ theta0, theta1, ... thetaN ];\n```\n\n```supercollider\n// 3D:\n~testDirections = [ [ theta0, phi0 ], [ theta1, phi1 ], ... [ thetaN, phiN ] ];\n```\n\nReturns:\n\nAnalysis is returned in an"}
+{"text": " thetaN, phiN ] ];\n```\n\nReturns:\n\nAnalysis is returned in an IdentityDictionary, with the following keys:\n\n- keyword || analysis\n-\n```supercollider\n\\amp\n```\n || pressure (virtual loudspeaker sum)\n-\n```supercollider\n\\rms\n```\n || spherical harmonic energy\n-\n```supercollider\n\\energy\n```\n || virtual loudspeaker energy\n-\n```supercollider\n\\spreadE\n```\n || energy spread (a Dictionary)\n-\n```supercollider\n\\rV\n```\n || velocity localisation vector, rV (a Dictionary)\n-\n```supercollider\n\\rE\n```\n || energy localisation vector, rE (a Dictionary)\n\nTwo measures of energy spread are offered in the\n```supercollider\n\\spreadE\n```\n Dictionary:\n\n- keyword || analysis\n-\n```supercollider\n\\cos\n```\n || roll-off to ~-3dB, in radians\n-\n```supercollider\n\\hvc\n```\n || roll-off to ~-6dB, in radians\n\nInformation regarding rV, the velocity localisation vector, is returned in the\n```supercollider\n\\rV\n```\n Dictionary:\n\n- keyword || analysis\n-\n```supercollider\n\\magnitudes\n```\n || vector magnitudes\n-\n```supercollider\n\\directions\n```\n || vector directions, in radians\n-\n```supercollider\n\\warp\n```\n || angle distortion from test directions, in radians"}
+{"text": "```supercollider\n\\warp\n```\n || angle distortion from test directions, in radians\n-\n```supercollider\n\\rEwarp\n```\n || angle distortion from rE, in radians\n-\n```supercollider\n\\xyz\n```\n || rV, in cartesian coordinates\n\nSimilarly, information regarding rE, the energy localisation vector, is returned in the\n```supercollider\n\\rE\n```\n Dictionary:\n\n- keyword || analysis\n-\n```supercollider\n\\magnitudes\n```\n || vector magnitudes\n-\n```supercollider\n\\directions\n```\n || vector directions, in radians\n-\n```supercollider\n\\warp\n```\n || angle distortion from test directions, in radians\n-\n```supercollider\n\\rVwarp\n```\n || angle distortion from rV, in radians\n-\n```supercollider\n\\xyz\n```\n || rE, in cartesian coordinates\n\nOffers detailed analysis of transformer performance.\n\nRotation:\n\n```supercollider\n// Axial rotation\n\n// specify parameters & design\n~axis = \\z\n~angle = pi/3\n~order = 3\n~xformer = HoaMatrixXformer.newRotateAxis(~axis, ~angle, ~order)\n\n//----\n// analysis\n~numTestDirections = 16\n~testDirections = Array.regularPolygon(~numTestDirections)\n\n// analyze\n~analysis = ~xformer.analyzeDirections(~testDirections)\n\n~analysis"}
+{"text": "alysis = ~xformer.analyzeDirections(~testDirections)\n\n~analysis.amp.abs.ampdb.round(0.01)\n~analysis.rms.sqrt.ampdb.round(0.01)\n~analysis.energy.sqrt.ampdb.round(0.01)\n\n~analysis.spreadE.cos.raddeg\n\n~analysis.rV.magnitudes\n~analysis.rV.directions.raddeg.round(0.1)\n~analysis.rV.warp.raddeg.round(0.1)\n~analysis.rV.rEwarp.raddeg.round(0.1)\n\n~analysis.rE.magnitudes\n~analysis.rE.directions.raddeg.round(0.1)\n~analysis.rE.warp.raddeg.round(0.1)\n```\n\nBeamforming:\n\n```supercollider\n// Beamforming\n\n// specify parameters & design\n~theta = 0.0\n~phi = 0.0\n~beamShape = \\controlled\n~order = 3\n~xformer = HoaMatrixXformer.newBeam(~theta, ~phi, ~beamShape, ~order)\n\n//----\n// analysis\n~numTestDirections = 16\n~testDirections = Array.regularPolygon(~numTestDirections)\n\n// analyze\n~analysis = ~xformer.analyzeDirections(~testDirections)\n\n~analysis.amp.abs.ampdb.round(0.01)\n~analysis.rms.sqrt.ampdb.round(0.01"}
+{"text": "ampdb.round(0.01)\n~analysis.rms.sqrt.ampdb.round(0.01)\n~analysis.energy.sqrt.ampdb.round(0.01)\n\n~analysis.spreadE.cos.raddeg\n\n~analysis.rV.magnitudes\n~analysis.rV.directions.raddeg.round(0.1)\n~analysis.rV.warp.raddeg.round(0.1)\n~analysis.rV.rEwarp.raddeg.round(0.1)\n\n~analysis.rE.magnitudes\n~analysis.rE.directions.raddeg.round(0.1)\n~analysis.rE.warp.raddeg.round(0.1)\n```\n\nNullforming:\n\n```supercollider\n// Nullforming\n\n// specify parameters & design\n~theta = 0.0\n~phi = 0.0\n~beamShape = \\controlled\n~order = 3\n~xformer = HoaMatrixXformer.newNull(~theta, ~phi, ~beamShape, ~order)\n\n//----\n// analysis\n~numTestDirections = 16\n~testDirections = Array.regularPolygon(~numTestDirections)\n\n// analyze\n~analysis = ~xformer.analyzeDirections(~testDirections)\n\n~analysis.amp.abs.ampdb.round(0.01)\n~analysis.rms.sqrt.ampdb.round(0.01)\n~analysis.energy.sqrt.ampdb.round(0.01)\n\n~analysis.spreadE.cos.rad"}
+{"text": "energy.sqrt.ampdb.round(0.01)\n\n~analysis.spreadE.cos.raddeg\n\n~analysis.rV.magnitudes\n~analysis.rV.directions.raddeg.round(0.1)\n~analysis.rV.warp.raddeg.round(0.1)\n~analysis.rV.rEwarp.raddeg.round(0.1)\n\n~analysis.rE.magnitudes\n~analysis.rE.directions.raddeg.round(0.1)\n~analysis.rE.warp.raddeg.round(0.1)\n```\n\nExamples:\n\nTBD"}
+{"text": "SuperCollider schelp — crucial-library/HelpSource/Classes/ActionButton.schelp\n\nActionButton —\na simple button with a name and an action\nCategory: Libraries>crucial>GUI\nSee also: Classes/SimpleButton, Classes/Button\n\n Sizes itself to fit the name. Nice, simple constructor saves fiddling around with a raw Button.\n\n```supercollider\n(\n ActionButton(nil,\"hit me\",{\n \"thank you\".postln\n });\n);\n\n(\n// bigger title... bigger button\n ActionButton(nil,\"hit me hit me hit me hit me hit me hit me hit me hit me hit me hit me hit me \",{\n \"THANK YOU\".postln\n });\n)\n```\n\nSimpleButton in ServerTools is basically the same thing but I wanted that library to have no dependencies on crucial.\n\n## new\n\n- layout:\n\n- title:\n\n- function:\n\n- minWidth:\nto overide the auto-sizing feature\n\n- minHeight:\ndefault is GUI.skin.buttonHeight\n\n- color:\n\n- backcolor:\n\n- font:\n\n## action\n\n- f:\n\n## init\n\n- layout:\n\n- title:\n\n- function:\n\n- minWidth:\n\n- minHeight:\n\n- color:\n\n- backcolor:\n\n- font:\n\nExamples:\n\n```supercollider\n(\n// set minimum sizes for x and y\n// longer text will still cause it to expand\nActionButton(nil,\"hit me\",{\n \"yeah baby\".p"}
+{"text": " still cause it to expand\nActionButton(nil,\"hit me\",{\n \"yeah baby\".postln\n},200,40,Color.white,Color.black);\n\n);\n\n// accepting drags by setting the view.receiveDrag handler\n// the list view by default gives an integer when dragging from it.\n// here i am making the action button accept dragged integers.\n(\nSheet({ arg f;\n\n a = SCListView(f,100@100);\n a.items = [\"a\",\"b\",\"c\"];\n\n b = ActionButton(f,\"i accept integers\",{\n \"was hit\".postln\n });\n b.view.canReceiveDragHandler = { View.currentDrag.isNumber };\n b.view.receiveDragHandler = {\n a.items[ View.currentDrag.asInteger ].postln;\n };\n})\n);\n\n// here the list view is made to export a string when dragged from.\n// the action button is accepting strings dragged to it.\n(\nSheet({ arg f;\n a = SCListView(f,100@100);\n a.items = [\"a\",\"b\",\"c\"];\n a.beginDragAction = { arg listView;\n listView.items[ listView.value ].debug(\"begin dragging\");\n };\n\n b = ActionButton(f,\"i accept strings\",{\n \"butt hit\".postln\n });\n b.view.canReceiveDrag = { View.currentDrag.isString };\n b.view.receiveD"}
+{"text": "anReceiveDrag = { View.currentDrag.isString };\n b.view.receiveDrag = {\n View.currentDrag.postln;\n };\n})\n)\n```"}
+{"text": "SuperCollider schelp — crucial-library/HelpSource/Classes/MultiTrackAudioSpec.schelp\n\nMultiTrackAudioSpec —\ndatatype specifying multiple 'audio' rate tracks\nCategory: Spec, Libraries>crucial>Spec\n\n Where a multi-channel audio format like Ambisonics is considered to be a single output (albeit with multiple speakers), a MultiTrackAudioSpec is parallel but separate tracks that might get mixed together later in the chain.\n\n## new\n\n- tracks:\n\n- numChannels:\n\n## tracks\n\n## storeArgs"}
+{"text": "SuperCollider schelp — crucial-library/HelpSource/Classes/PlayerInputProxy.schelp\n\nPlayerInputProxy —\nplaceholder for Patch inputs for a player that will be supplied later\nCategory: Libraries>crucial>Players\n\n represents an audio or control input for a player that is to be filled with a player later.\n\neg. an input to an effect.\n a potential controller/interface input\n\n```supercollider\np = Patch({ arg audio,ffreq;\n RLPF.ar(audio,ffreq)\n},[\n PlayerInputProxy.new\n]);\n```\n\nit holds the place. if the patch is played, it is silent.\n\np.play\n\nother classes can detect these inputs and patch into them.\n\nThe audioSpec would specify the number of channels.\n\n## new\n\n- spec:\n\n## spec\n\n## initValue\n\n## patchIn\n\n## pipinit\n\n## setInputBus\n\n- bus:\n\n## setNodeControl\n\n- nc:\n\n## synthArg\n\n## ar\n\n## makePatchOut\n\n- agroup:\n\n- private:\n\n- bus:\n\n- bundle:\n\n## rate\n\n## numChannels"}
+{"text": "SuperCollider schelp — crucial-library/HelpSource/Classes/ScalarPatchIn.schelp\n\nScalarPatchIn —\n\\scalar rate PatchIn\nCategory: Libraries>crucial>internals\nSee also: Classes/PatchIn\n\n\n\n## rate\n\n## value\n\n- val:"}
+{"text": "SuperCollider schelp — crucial-library/HelpSource/Classes/TempoSpec.schelp\n\nTempoSpec —\ndatatype specifying a control rate input representing tempo\nCategory: Spec, Libraries>crucial>Spec\nSee also: Classes/Tempo\n\n\n\n## initClass\n\n## defaultControl\n\n## rate\n\n## canAccept\n\n- thing:"}
+{"text": "SuperCollider schelp — crucial-library/HelpSource/Classes/Xor.schelp\n\nXor —\ngiven two constraint objects, validates that the test object is true for one or the other but not both\nCategory: Libraries>crucial>Constraints\nSee also: Guides/Constraints\n\n\n\n## new\n\n- a:\n\n- b:\n\n## a\n\n## b\n\n## value\n\n- obj:\n\n## reset"}
+{"text": "SuperCollider classlib — crucial-library/ServerTools/BusPool.sc\n\n```supercollider\nBusPool {\n\n classvar = 140 and: {h >= GUI.skin.buttonHeight},{\n h = min(h, GUI.skin.buttonHeight);\n w = min(w, GUI.skin.buttonHeight * 16);\n if(box, { this.box(layout,Rect(0,0,40,h)); });\n if(slider,{ this.slider(layout,Rect(0,0,w-40-(gap.x*2),h)); });\n ^this\n });\n // width < height\n // go vert\n if(w < h,{\n // height > 100\n // box, slider\n if(h > 100 and: {w >= 30},{\n h = h.max(130);\n layout.comp"}
+{"text": " if(h > 100 and: {w >= 30},{\n h = h.max(130);\n layout.comp({ |l|\n var y;\n this.box(l,Rect(0,0,min(70,w)-(gap.x),y = GUI.skin.buttonHeight));\n y = y + gap.y;\n this.slider(l,Rect(0,y,min(70,w)-(gap.x),h-y-gap.y));\n },Rect(0,0,w-gap.x,h-gap.y))\n ^this\n });\n if(h > 100 ,{\n this.slider(layout,Rect(0,0,w-gap.x,h-gap.y));\n ^this\n });\n // height < 100, > 30\n // slider\n if(h >= 30,{\n this.slider(layout,Rect(0,0,min(40,w),h));\n ^this\n });\n\n // height < 30\n // box\n if(h <= 30,{\n this.box(layout,Rect(0,0,min(40,w),h));\n ^this\n });\n\n },{// width > height\n h = min(h, GUI.skin.buttonHeight);\n\n // width > 100\n // box, slider\n\n // width < 100, > 30\n // slider\n if(w.inclusivelyBetween(30,100),{\n if(slider,{\n this.slider(layout,Rect(0,0,w,h));\n },{\n this.box(layout,Rect(0,0,w,h));\n });\n ^this\n });\n\n // width < 30\n if(w <="}
+{"text": ",w,h));\n });\n ^this\n });\n\n // width < 30\n if(w <= 30,{\n // box\n if(box,{\n this.box(layout,Rect(0,0,w,h));\n },{\n this.slider(layout,Rect(0,0,w,h));\n });\n ^this\n });\n });\n\n // any unmatched\n if(slider,{\n this.slider(layout,Rect(0,0,w,h));\n },{\n this.box(layout,Rect(0,0,w,h));\n });\n ^this\n }\n box { arg layout,bounds;\n var r,startValue,range,mod,startPoint;\n numv = NumberBox(layout,bounds)\n .value_(model.poll)\n .focusColor_(Color.yellow(1.0,0.5))\n .font_(Font(\"Helvetica\",10))\n .action_({ arg nb;\n model.activeValue_(model.spec.constrain(nb.value)).changed(numv);\n });\n numv.mouseDownAction = { arg view,x, y, modifiers, buttonNumber, clickCount;\n if(modifiers.isAlt,{\n model.activeValue_(model.spec.default).changed\n },{\n startValue = model.unmappedValue;\n mod = modifiers;\n startPoint = 0@0;\n })\n };\n numv.mouseMoveAction = { arg view,x,y,modifiers;\n var move,val,unimove;\n if(modif"}
+{"text": " view,x,y,modifiers;\n var move,val,unimove;\n if(modifiers != mod,{\n mod = modifiers;\n startValue = model.unmappedValue;\n startPoint = x@y;\n });\n if(modifiers.isCtrl,{\n move = (y - startPoint.y).neg;\n if(modifiers.isShift,{\n range = 4000.0;\n },{\n range = 300.0;\n });\n move = move.clip(range.neg,range);\n unimove = move.abs.linlin(0.0,range,0.0,1.0);\n if(move > 0,{\n val = (startValue + unimove);\n },{\n val = (startValue - unimove);\n });\n model.setUnmappedValue( val.clip(0.0,1.0) );\n });\n };\n numv.scroll = false;\n numv.clipLo = model.spec.clipLo;\n numv.clipHi = model.spec.clipHi;\n numv.focusColor = GUI.skin.focusColor ?? {model.spec.color};\n /*numv.keyDownAction = { arg char,modifiers,unicode,keycode;\n if(\"012356789-.\".includes(char),{\n this.defaultKeyDownAction(char, modifiers, unicode, keycode);\n },{\n nil\n })\n };*/\n //if(consumeKeyDowns,{\n // numv.keyDownAction = {nil};\n //});\n }\n sl"}
+{"text": "yDowns,{\n // numv.keyDownAction = {nil};\n //});\n }\n slider { arg layout, bounds;\n var r;\n slv = GUI.slider.new(layout, bounds);\n slv.focusColor = GUI.skin.focusColor ?? {model.spec.color};\n slv.setProperty(\\value,model.spec.unmap(model.poll));\n slv.thumbSize = min(bounds.height,bounds.width) / 1.61803399;\n slv.action_({arg th;\n model.activeValue_(model.spec.map(th.value)).changed(slv)\n });\n if(consumeKeyDowns,{ slv.keyDownAction = {nil}; });\n /* but slider doesnt trigger mouseDownAction */\n slv.mouseDownAction = { arg view, x, y, modifiers, buttonNumber, clickCount;\n if(modifiers.isAlt,{\n model.activeValue_(model.spec.default).changed\n })\n }\n }\n update {arg changed,changer; // always has a number box\n {\n if(changer == 'spec',{\n if(numv.notNil,{\n numv.clipLo = model.spec.clipLo;\n numv.clipHi = model.spec.clipHi;\n })\n }); \n if(changer !== numv and: {numv.notNil} and: {numv.isClosed.not},{\n numv.value_(model.poll);\n "}
+{"text": "il} and: {numv.isClosed.not},{\n numv.value_(model.poll);\n });\n if(changer !== slv and: {slv.notNil} and: {slv.isClosed.not},{\n slv.value_(model.spec.unmap(model.poll));\n });\n nil\n }.defer;\n }\n background { ^Color(0.0,0.2,0.2,0.2) }\n}\n\nKrNumberEditorGui : NumberEditorGui {\n\n background { ^Color(0.0,0.3,0.0,0.2) }\n}\n\nPopUpEditorGui : EditorGui {\n\n var popV;\n // temp, I don't really have a spec here\n // we arent editing a \"pop up\", so the class is misnamed\n // just to get this gui representation\n // maybe NumberEditor should use this gui if it has a named integers spec\n\n guiBody { arg layout;\n var horSize;\n horSize = model.labels.maxValue({arg item; item.size }) * 12;\n popV = PopUpMenu(layout,Rect(0,0,horSize,GUI.skin.buttonHeight))\n .items_(model.labels)\n .action_({ arg nb;\n model.selectByIndex(popV.value).changed(this)\n });\n popV.focusColor = GUI.skin.focusColor ?? {Color.grey(0.5,0.5)};\n popV.background = GU"}
+{"text": " ?? {Color.grey(0.5,0.5)};\n popV.background = GUI.skin.background;\n if(consumeKeyDowns,{ popV.keyDownAction = {nil}; });\n popV.value = model.selectedIndex\n }\n update { arg changed,changer;\n if(changer !== this,{\n popV.value = model.selectedIndex;\n });\n }\n}\n\nBooleanEditorGui : EditorGui {\n\n var cb;\n\n guiBody { arg layout,bounds;\n var bg,b,skin;\n skin = GUI.skin;\n bounds = (bounds ?? { layout.bounds; }).asRect;\n\n b = Rect(0,0,skin.buttonHeight,skin.buttonHeight);\n if(bounds.notNil,{\n if(b.width > bounds.width,{\n b.width= bounds.width;\n b.height = bounds.width;\n });\n if(b.height > bounds.height,{\n b.width = bounds.height;\n b.height = bounds.height;\n });\n });\n cb = Button( layout,b);\n cb.states = [[\" \",Color.black,skin.offColor],[\" \",Color.black,skin.onColor]];\n cb.font = Font(*skin.fontSpecs);\n cb.setProperty(\\value,model.value.binaryValue);\n cb.focusColor = GUI.skin.focusColor ?? {Color."}
+{"text": ");\n cb.focusColor = GUI.skin.focusColor ?? {Color.clear};\n cb.action = { model.activeValue_(cb.value != 0,this) };\n if(consumeKeyDowns,{ cb.keyDownAction = {nil}; });\n }\n update { arg changed,changer;\n if(changer !== this,{\n cb.setProperty(\\value,model.value.binaryValue);\n });\n } \n}\n\nDictionaryEditorGui : EditorGui {\n \n var <>onSave;\n \n guiBody { arg layout,bounds,onSave;\n this.onSave = onSave;\n model.editing.keysValuesDo { arg k,v;\n layout.startRow;\n ArgNameLabel(k,layout,minWidth:100);\n v.gui(layout)\n };\n if(this.onSave.notNil,{\n ActionButton(layout.startRow,\"SAVE\",{\n this.onSave.value(model.value)\n })\n })\n }\n}\n```"}
+{"text": "SuperCollider classlib — cruciallib/Gui/ActionButton.sc\n\nabstract SC/Qt/Swing all use this\n\n```supercollider\n *initClass {\n Class.initClassTree(GUI);\n }\n makeView { arg layout,x,y;\n var rect;\n if((layout.isNil or: { layout.isKindOf(PageLayout) }),{ layout = layout.asFlowView; });\n this.view = GUI.button.new(layout,Rect(0,0,x,y ? GUI.skin.buttonHeight));\n if(consumeKeyDowns,{ this.view.keyDownAction_({true}) });\n }\n flowMakeView { arg layout,x,y;\n this.view = GUI.button.new(layout.asFlowView,Rect(0,0,x,y ? GUI.skin.buttonHeight));\n if(consumeKeyDowns,{ this.view.keyDownAction_({true}); });\n }\n\n makeViewWithStringSize { arg layout,optimalWidth,minWidth,minHeight;\n this.makeView( layout,(optimalWidth + 10).max(minWidth?20),(minHeight ) )\n }\n initOneState { arg name,textcolor,backcolor;\n view.states_([[name,textcolor ? Color.black, backcolor ? Color.white]])\n }\n // sets all states\n label_ { arg string;\n view.states = view.states.collect({ arg st;\n st.put("}
+{"text": " { arg string;\n view.states = view.states.collect({ arg st;\n st.put(0,string.asString);\n st\n });\n }\n // assumes 1 state\n background_ { arg color;\n var s;\n s = view.states;\n s.at(0).put(2,color);\n view.states = s;\n view.refresh;\n }\n background {\n ^view.states[0][2]\n }\n labelColor_ { arg color;\n var s;\n s = view.states;\n s.at(0).put(1,color);\n view.states = s;\n view.refresh;\n }\n *defaultHeight { ^GUI.skin.buttonHeight }\n}\n\n// a one state button\nActionButton : SCButtonAdapter {\n\n var 40,{ title = title.copyRange(0,40) });\n if(font.isNil,{ font = GUI.font.new(*skin.fontSpecs) });\n optimalWidth = title.bounds(font).width;\n this.makeViewWithStringSize(layout,optimalW"}
+{"text": "bounds(font).width;\n this.makeViewWithStringSize(layout,optimalWidth,minWidth,minHeight);\n view.states_([[title,color ?? {skin.fontColor},\n backcolor ?? {skin.background}]]);\n view.font_(font);\n view.action_(function);\n view.focusColor_((skin.focusColor ?? {Color.grey(0.5,0.1)}).alpha_(0.1));\n if(consumeKeyDowns,{ this.keyDownAction = {true}; });\n }\n}\n\nToggleButton : SCButtonAdapter {\n\n var onFunction,<>offFunction;\n\n *new { arg layout,title,onFunction,offFunction,init=false,minWidth=20,minHeight,onColor,offColor;\n ^super.new.init(layout,init, title,minWidth,minHeight,onColor,offColor)\n .onFunction_(onFunction).offFunction_(offFunction)\n }\n value { ^state }\n value_ { arg way;\n this.toggle(way,false)\n }\n toggle { arg way,doAction = true;\n if(doAction,{\n this.prSetState(way ? state.not)\n },{\n state = way ? state.not;\n });\n view.setProperty(\\value,state.binaryValue);\n }\n // private\n init { arg layout,init,title,minWidth,minHeight,onc,offc;\n var"}
+{"text": " init { arg layout,init,title,minWidth,minHeight,onc,offc;\n var font,skin;\n skin = GUI.skin;\n font = GUI.font.new(*GUI.skin.fontSpecs);\n this.makeViewWithStringSize(layout,title.bounds(font).width,minWidth,minHeight);\n view.states = [\n [title,skin.fontColor,offc ? skin.offColor],\n [title,skin.fontColor,onc ? skin.onColor]\n ];\n state=init;\n view.value_(state.binaryValue);\n view.action_({this.prSetState(state.not)});\n view.font = font;\n view.focusColor = skin.focusColor ?? {Color(0.0, 0.85714285714286, 1.0, 0.4)};\n }\n prSetState { arg newstate;\n state = newstate;\n if(state,{\n onFunction.value(this,state)\n },{\n // if there is no offFunction value the onFunction\n (offFunction ? onFunction).value(this,state)\n });\n }\n}\n\nTile : ActionButton { // the name comes from Squeak\n\n *new { arg target,layout,minWidth=100;\n if(target.guiClass == StringGui,{\n ^target.gui(layout);\n });\n ^super.new(layout,target.asString,{\n target.gui;\n //#F6F9F5"}
+{"text": "per.new(layout,target.asString,{\n target.gui;\n //#F6F9F5\n },minWidth,GUI.skin.buttonHeight, Color.black, Color.new255(248, 248, 255))\n }\n\n}\n```"}
+{"text": "SuperCollider schelp — cruciallib/HelpSource/Classes/SimpleKDRUnit.schelp\n\nSimpleKDRUnit —\nan internal part used in KeyCodeResponder\nCategory: Libraries>crucial>internals\nSee also: Classes/KeyCodeResponder\n\n\n\n## new\n\n- modifier:\n\n- function:\n\n- description:\n\n## requireMask\n\n## function\n\n## description\n\n## value\n\n- view:\n\n- char:\n\n- modifier:\n\n- unicode:\n\n- keycode:\n\n## ==\n\n- that:\n\n## guiClass\n\n## report"}
+{"text": "SuperCollider schelp — cruciallib/HelpSource/Classes/TempoSpec.schelp\n\nTempoSpec —\ndatatype specifying a control rate input representing tempo\nCategory: Spec, Libraries>crucial>Spec\nSee also: Classes/Tempo\n\n\n\n## initClass\n\n## defaultControl\n\n## rate\n\n## canAccept\n\n- thing:"}
+{"text": "SuperCollider classlib — cruciallib/Instr/InstrSpawner.sc\n\n```supercollider\n classvar <>latency=0.07;\n\n var <>deltaPattern,nodeControl,<>connectedTo;\n\n *new { arg nodeControl;\n ^super.newCopyArgs(nodeControl)\n }\n *newByRate { arg rate,nodeControl;\n ^this.perform(rate,nodeControl)\n }\n *audio { arg nodeControl;\n ^AudioPatchIn(nodeControl)\n }\n *control { arg nodeControl;\n ^ControlPatchIn(nodeControl)\n }\n *scalar { arg nodeControl;\n ^ScalarPatchIn(nodeControl)\n }\n *stream { arg nodeControl;\n ^ScalarPatchIn(nodeControl)\n }\n *noncontrol { arg nodeControl;\n ^ObjectPatchIn(nodeControl)\n }\n server { ^nodeControl.server }\n group { ^nodeControl.group }\n disconnectFrom { |patchOut|\n connectedTo = nil;\n }\n}\n\nAudioPatchIn : PatchIn {\n\n rate { ^\\audio }\n readFromBus { arg bus;\n nodeControl.value = bus.index;\n }\n value_ { arg val;\n if(nodeControl.node.isPlaying,{\n nodeControl.value = val;\n })\n }\n}\n\nControlPatchIn : AudioPatchIn {\n rate { ^\\control }\n}\n\nScalarPatchIn : ControlPatchIn {\n rate { ^\\scalar }\n value_ { arg val;\n // nothing to do\n }\n}\n"}
+{"text": "atchIn {\n rate { ^\\scalar }\n value_ { arg val;\n // nothing to do\n }\n}\n\nObjectPatchIn : ScalarPatchIn {\n rate { ^\\noncontrol }\n}\n\nPatchOut {\n\n var <>source,<>group,patchOutsOfInputs;\n var busses;\n\n *new { arg source,group,bus;\n ^this.perform(source.rate ?? \n {Error(\"source has nil rate\" + source).throw},\n source,group,bus)\n }\n *prNew {arg source,group,bus;\n ^super.newCopyArgs(source,group.asGroup,bus).init;\n }\n *audio { arg source,group,bus;\n ^AudioPatchOut.prNew(source, group,bus)\n }\n *control { arg source,group,bus;\n ^ControlPatchOut.prNew(source, group,bus)\n }\n *scalar { arg source, group,bus;\n ^ScalarPatchOut.prNew(source, group,bus)\n }\n *stream { arg source,group,bus;\n ^ScalarPatchOut.prNew(source, group,bus)\n }\n *noncontrol { arg source,group,bus;\n ^ObjectPatchOut.prNew(source,group,bus)\n }\n init {}\n busses { ^(busses ?? {busses = Dictionary.new}) }\n connectTo { arg patchIn,needsValueSetNow=true;\n // am i already connected to this client ?\n if(connectedTo.is"}
+{"text": "SetNow=true;\n // am i already connected to this client ?\n if(connectedTo.isNil or: {connectedTo.includes(patchIn).not},{\n connectedTo = connectedTo.add(patchIn);\n });\n patchIn.connectedTo = this;\n this.perform(patchIn.rate,patchIn,needsValueSetNow);// set value, bus etc.\n }\n disconnect {\n connectedTo.do({ |patchIn|\n patchIn.disconnectFrom(this)\n })\n }\n free {\n // tell my connectedTo that i'm gone\n this.releaseBusses;\n this.disconnect;\n }\n\n server { ^group.server }\n isPlaying { ^group.isPlaying }\n\n bus_ { arg b;\n if(b != bus,{\n bus = b.asBus(this.rate,source.numChannels,this.server);\n\n if(bus.numChannels != source.numChannels,{\n warn(\"numChannels mismatch ! source:\" + source\n + source.numChannels + \"vs. supplied bus:\" + b);\n });\n\n BusPool.retain(bus,source,\\out);\n connectedTo.do({ arg pti;\n pti.readFromBus(bus);\n });\n })\n }\n hasBus { ^bus.notNil and: {bus.index.notNil} }\n\n // allocate extra outs for custom use\n // and store them here in the PatchOut\n allocBus { |name,rate,numChannels|\n var b;\n if(this.busses[name].notNil,{\n Er"}
+{"text": "numChannels|\n var b;\n if(this.busses[name].notNil,{\n Error(\"Bus for \"+name+\"already allocated\").throw;\n });\n b = BusPool.alloc(rate,this.server,numChannels,source,name);\n this.busses[name] = b;\n ^b\n }\n releaseBusses {\n // main bus\n if(bus.notNil and: {bus.index.notNil},{\n BusPool.release(bus,source);\n });\n bus = nil;\n\n // custom requested busses\n if(busses.notNil,{\n busses.keysValuesDo({ |name,bus|\n BusPool.release(bus,source);\n });\n busses = nil;\n })\n }\n}\n\nControlPatchOut : PatchOut { // you are returned from a .kr play\n\n init {\n if(bus.isKindOf(BusSpec),{\n bus = BusPool.makeBusFromSpec(bus,this.server,source,\\out)\n },{\n // nil : speakers\n // integer : that out\n // server : private on that server\n\n // temp hack until the \\scalar problem is corrected\n if(source.isKindOf(IrNumberEditor).not,{\n bus = bus.asBus(this.rate,source.numChannels,this.server);\n BusPool.retain(bus,source,\\out);\n },{\n bus = nil;\n })\n });\n }\n rate { ^\\control }\n synthArg { ^bus.index } //need some initialValue"}
+{"text": " { ^\\control }\n synthArg { ^bus.index } //need some initialValue\n\n control { arg controlPatchIn,needsValueSetNow;\n if(needsValueSetNow,{\n // TODO ! check if on same server\n // dont have to this unless changed\n controlPatchIn.readFromBus(bus)\n })\n }\n audio { arg audioPatchIn;\n // K2A convertor needed\n // the patchIn owns the convertor ?\n // per input ?\n thisMethod.notYetImplemented;\n }\n scalar { arg scalarPatchIn;\n // polling of value not yet implemented on scserver\n // scalarPatchIn.value = bus.poll;\n //[this,scalarPatchIn,this.source]\n // .debug(\"control -> scalar patch ? this,scalarPatchIn,this.source\");\n thisMethod.notYetImplemented;\n }\n}\n\nAudioPatchOut : ControlPatchOut {\n\n rate { ^\\audio }\n synthArg { ^bus.index }\n audio { arg audioPatchIn,needsValueSetNow;\n if(needsValueSetNow,{\n // check if on same server\n audioPatchIn.readFromBus(bus)\n // create mixer if needed\n });\n }\n control { arg controlPatchIn,needsValueSetNow;\n //no problem, an audio output into a control input is common\n // and no action needs to be taken\n }\n scalar { arg scalarPatchIn;\n // polling of value not yet implemented on scserver\n // scalarPatchIn.value"}
+{"text": "arPatchIn;\n // polling of value not yet implemented on scserver\n // scalarPatchIn.value = bus.get;\n thisMethod.notYetImplemented;\n }\n}\n\nScalarPatchOut : PatchOut {\n\n // floats,NumberEditors, numeric pattern players, midi, wacom\n // things that are not ON the server\n init {\n if(bus.isKindOf(BusSpec),{ // ignore\n bus = nil;\n });\n }\n rate { ^\\scalar }\n synthArg {\n ^source.synthArg\n }\n audio { arg audioPatchIn,needsValueSetNow=false;\n if(needsValueSetNow,{\n audioPatchIn.value = source.value;\n })\n }\n control { arg controlPatchIn,needsValueSetNow=false;\n if(needsValueSetNow,{\n controlPatchIn.value = source.value;\n });\n }\n scalar { arg scalarPatchIn;\n //thisMethod.notYetImplemented;\n }\n}\n\nObjectPatchOut : ScalarPatchOut {\n\n}\n\n// this class is only used for KrNumberEditor to send its changes to the server\n// it sends it directly to the Synth using the NodeControl\n// its not the best design actually\n\nUpdatingScalarPatchOut : ScalarPatchOut {\n\n var enabled=false;\n\n *new { arg source,bus,enabled=true;\n ^this.prNew(source,enabled)\n }\n *prNew {arg source,enabled; ^super.newCopyArgs(source).in"}
+{"text": " }\n *prNew {arg source,enabled; ^super.newCopyArgs(source).init(enabled) }\n\n init { arg enabled=true;\n if(enabled,{\n source.addDependant(this)\n })\n }\n audio { arg audioPatchIn,needsValueSetNow=false;\n if(needsValueSetNow,{\n audioPatchIn.value = source.value;\n });\n this.enable;\n }\n control { arg controlPatchIn,needsValueSetNow=false;\n if(needsValueSetNow,{\n controlPatchIn.value = source.value;\n });\n this.enable;\n }\n scalar { arg scalarPatchIn;\n this.enable;\n }\n enable {\n if(enabled.not,{\n source.addDependant(this);\n enabled = true;\n })\n }\n update {\n connectedTo.do({ arg c; c.value = source.value })\n }\n free {\n this.releaseBusses; // probably don't have any\n source.removeDependant(this);\n enabled = false;\n }\n}\n```"}
+{"text": "SuperCollider classlib — cruciallib/UncoupledUsefulThings/PrettyPrintStream.sc\n\n```supercollider\n var tabs=0;\n\n nl {\n super.nl;\n tabs.do({ this.tab; });\n }\n\n storeArgs { arg args,itemsPerLine=1;\n this << \"(\";\n tabs = tabs + 1;\n this.nl;\n args.storeItemsOn(this,itemsPerLine);\n tabs = tabs - 1;\n this.nl;\n this << \")\";\n }\n indent { arg way=1; tabs = tabs + way; }\n\n}\n```"}
+{"text": "SuperCollider classlib — ddwChucklib/BPStream.sc\n\nreference a stream in a BP environment\n\n```supercollider\n// normal behavior is to set the environment when creating the stream\n// however -- sometimes you might need to make the stream outside the environment\n// in that case you can pass in an environment\n// if the envir arg to *new is nil, we set the environment at stream time\n\nBPStream : Pattern {\n var <>key, <>resetSource, <>envir;\n *new { |key, resetSource = false, envir|\n ^super.newCopyArgs(key, resetSource, envir)\n }\n\n asStream {\n var streamKey = (key ++ \"Stream\").asSymbol;\n envir ?? { envir = currentEnvironment; };\n (resetSource or: { envir[streamKey].isNil }).if({\n envir.use({\n streamKey.envirPut(key.asSymbol.envirGet.asStream);\n streamKey.envirGet.isNil.if({\n \"Source stream for BPStream(%) is not populated.\"\n .format(key.asCompileString).warn;\n });\n });\n });\n ^FuncStream({ |inval|\n streamKey.envirGet.next(inval)\n }, { this.reset }).envir_(envir) // make sure FuncStream knows which environment\n }\n\n reset {\n envir.use { (key ++ \"Stream\").asSymbol.envirGet.reset }\n }\n\n printOn { |stream| st"}
+{"text": "ream\").asSymbol.envirGet.reset }\n }\n\n printOn { |stream| stream << \"BPStream(\" <<< key << \")\" }\n // not including envir here because it could be an infinitely-recursive data structure\n // (envir contains BPStream, which contains envir etc.)\n storeArgs { ^[key, resetSource] }\n// storeOn { |stream| this.printOn(stream) }\n}\n```"}
+{"text": "SuperCollider patch — ddwChucklib/Prototypes/windowbounds1366.scd\n\nset gui window bounds for msi 1366x768 layout ~controlpanelBounds = switch(Platform.ideName.asSymbol) { \\scel } { Rect(745, 29, 650, 688) } { Rect(534, 4, 916, 852) };\n\n```supercollider\n// set gui window bounds for msi 1366x768 layout\n\n// ~controlpanelBounds = switch(Platform.ideName.asSymbol)\n// { \\scel } { Rect(745, 29, 650, 688) }\n// { Rect(534, 4, 916, 852) };\n~controlpanelBounds = case\n{ (~development ? true) or: { Platform.ideName.asSymbol == \\scel } } { Rect(745, 29, 650, 688) }\n{ Rect(534, 4, 916, 852) };\n~mixerBounds = Rect(0, 0, 546, 264); // change\n~codedocBounds = Rect(1, 260, 534, 397);\n~postwindowBounds = Rect(1, 658, 675, 220);\n\n~serverGui = false;\n\n// replace default definition with small skin (horizontal)\nMixerChannelGUI.defaultDef = MixerGUIDef(Point(540, 25),\n [MixerMuteWidget, MixerRecordWidget, MixerNameWidget, MixerPresendWidget"}
+{"text": "Widget, MixerRecordWidget, MixerNameWidget, MixerPresendWidget,\n MixerPanWidget, MixerLevelSliderH, MixerLevelNumber, MixerPostsendWidget,\n MixerOutbusWidget],\n [ Rect(5, 5, 20, 20),\n Rect(30, 5, 20, 20),\n Rect(55, 10, 60, 15), // 115\n Rect(120, 0, 60, 20), // 190\n Rect(185, 10, 50, 15), // 245\n Rect(240, 10, 100, 15), // 340\n Rect(345, 10, 50, 15), // 395\n Rect(400, 0, 70, 20), // 470\n Rect(475, 10, 60, 15) // 535\n ]);\n\nMixerChannelDef.at(\\mix1x1).guidef = MixerGUIDef(Point(440, 25),\n [MixerMuteWidget, MixerRecordWidget, MixerNameWidget, MixerPresendWidget,\n MixerLevelSliderH, MixerLevelNumber, MixerPostsendWidget,\n MixerOutbusWidget],\n [ Rect(5, 5, 20, 20),\n Rect(30, 5, 20, 20),\n Rect(55, 10, 60, 15), // 115\n Rect(120, 0, 60, 20), // 190\n Rect(240, 10, 100, 15), // 340\n Rect(345, 10, 50, 15), // 395\n Rect(400, 0, 70, 20), // 470\n Rect(475, 10, 60, 15) // 535\n ]);\n\nMixerPresendWidget.defaultSlider"}
+{"text": ", 60, 15) // 535\n ]);\n\nMixerPresendWidget.defaultSliderBounds = Rect(0, 2, 60, 5);\nMixerPresendWidget.defaultMenuBounds = Rect(0, 10, 60, 15);\n\n// parameterize VP creation\nswitch(Platform.ideName.asSymbol)\n{ \\scapp } {\n ~useScroll = false;\n ~voicerColumns = 2;\n ~voicerRows = 7;\n};\n/*default*/ {\n ~useScroll = true;\n if(~development ? true) {\n ~voicerColumns = 1;\n ~voicerRows = 14;\n } {\n ~voicerColumns = 2;\n ~voicerRows = 7;\n }\n};\n\n~voicersWith4Controls = 6;\n```"}
+{"text": "SuperCollider schelp — ddwMIDI/HelpSource/Guides/ddwMIDI_Guide.schelp\n\nddwMIDI Guide\nCategory: External Control>MIDI\nGeneral notes on ddwMIDI usage\n\n# Overview\n\nThe ddwMIDI Quark provides two main ways of working with MIDI information:\n\n- Sockets and controllers || Respond to MIDI note and controller data.\n- MIDIRecBuf and MIDIBufManager || Record, store and manipulate MIDI note data.\n\nThis document is intended to cover the main usage patterns. Implementation details may be found in the class references, linked in the text below.\n\nWhy another responder hierarchy?\n\nThe standard MIDI responders (MIDIFunc, MIDIdef) are organized around the incoming message type. The ddwMIDI responders are organized around what you want to do with the information. For example, if you want to play notes using a MIDI keyboard:\n\n- Standard MIDI responders: Create MIDIFuncs or MIDIdefs, one for note-on messages and another for note-off, containing functions to handle the note onset and release logic.\n- ddwMIDI responders: Create a Voicer to play the notes, and a VoicerMIDISocket to connect MIDI messages to the Voicer.\n\nFor another example, ddwChucklib can trigger processes using note-on messages. MTSocket makes the connection. Thus, the class of the responder explains how the incoming messages will behave (while, in the standard MIDI responders, you would have to inspect a function definition -"}
+{"text": "ing messages will behave (while, in the standard MIDI responders, you would have to inspect a function definition -- error prone, to say the least).\n\n# Sockets and controllers\n\nddwMIDI responders divide into two categories:\n\n- Sockets || Sockets handle note-on and note-off messages. Every socket is expected to respond to both on and off messages; that is, there is no need to create separate responders for them.\n\n- AbstractMIDISocket is the parent of all MIDI sockets. If you need a custom socket, inherit from this class.\n- BasicMIDISocket installs two functions (note-on and note-off), to handle any logic you like. The functions are passed\n```supercollider\n|note, velocity|\n```\n as arguments.\n- VoicerMIDISocket directs note-on and note-off messages to a Voicer. The Voicer handles node allocation and voice-stealing.\n- MIDIThruSocket passes note messages to another MIDI channel, with optional pre-processing. The forwarded messages are sent through MIDIIn, so they can be received by MIDIFunc/MIDIdef as well as other ddwMIDI responders.\n- MIDI2OSCSocket transmits note messages over OSC to SuperCollider running on a remote machine. Not extensively tested.\n- MIDIRecSocket records note data into a MIDIRecBuf.\n\n- Controllers || Controllers handle continuous-control, pitch-bend and aftertouch messages.\n\n- AbstractMIDIControl is the parent of all MIDI"}
+{"text": "end and aftertouch messages.\n\n- AbstractMIDIControl is the parent of all MIDI controller classes.\n- BasicMIDIControl installs a function. The function receives\n```supercollider\n|value, divisor, ccnum|\n```\n as arguments.\n- VoicerMIDIController connects control messages to a VoicerGlobalControl, which represents a control input that should apply to all synths played by the Voicer.\n- VoicerSusPedal makes a Voicer respond to the sustain footswitch.\n- MixerMIDIControl connects control messages to a MixerChannel's level control.\n- MIDIThruControl passes note messages to another MIDI channel.\n- MIDI2OSCControl transmits note messages over OSC to SuperCollider running on a remote machine. Not extensively tested.\n\n## Identifying MIDI channels\n\nIn ddwMIDI, specify the source of incoming messages in the following ways:\n\n- OBJECT || MEANING\n-\n```supercollider\nnil\n```\n || Default MIDI device, channel 0\n- Integer || Channel number, assuming default MIDI device\n-\n```supercollider\n\\omni\n```\n || Default MIDI device, any channel\n- Array\n```supercollider\n[device, channel]\n```\n || The specified device and channel\n- Array\n```supercollider\n[device, \\omni]\n```\n || The specified device, any channel\n- Array\n```supercollider\n[\\all, ch"}
+{"text": "```\n || The specified device, any channel\n- Array\n```supercollider\n[\\all, channel]\n```\n || Any device, given channel\n- Array\n```supercollider\n[\\all, \\omni]\n```\n || Any device, any channel\n\nNotes:\n\n- SuperCollider indexes MIDI channels as 0-15. Most devices index them 1-16. If you specify channel 0 in SC, expect to use channel 1 on the device.\n- Devices are identified by the integer index into\n```supercollider\nMIDIPort.sources\n```\n. Device 0 is the first in this array, and so on. Normally this is copied from\n```supercollider\nMIDIClient.sources\n```\n upon the first use of any socket or controller.\n- The default MIDI device is index 0 in\n```supercollider\nMIDIPort.sources\n```\n. By default, this is the first device listed by\n```supercollider\nMIDIClient.sources\n```\n. You can override the default device, by initializing MIDIPort explicitly:\n```supercollider\nMIDIPort.init([defaultDeviceIndex])\n```\n. This assumes you know the index into the\n```supercollider\nMIDIClient.sources\n```\n array. Typically, then, you will initialize MIDIClient first, and search the array for the device you want. See #Selecting a default MIDI device.\n\n## Controller numbers\n\nController numbers may be specified as follows:\n\n- OBJECT || MEANING\n- Integer || The controller number itself\n-\n```su"}
+{"text": " OBJECT || MEANING\n- Integer || The controller number itself\n-\n```supercollider\n\\pb\n```\n || Pitch-bend wheel\n-\n```supercollider\n\\touch\n```\n || Aftertouch\n-\n```supercollider\n\\omni\n```\n || Any controller\n-\n```supercollider\n\\ptouch\n```\n || Poly-aftertouch\n-\n```supercollider\nCControl\n```\n instance || Encapsulate a physical control and an attached button\n\nTime doesn't permit a full explanation of CControl in this draft. Soon...\n\nNote:\nBy default, continuous controllers do not respond until the incoming controller value either comes close to, or crosses, the existing value. This is to prevent the value in SuperCollider from jumping suddenly to a physical controller value that may be quite distant. You can disable this behavior globally by setting\n```supercollider\nAbstractMIDIControl.syncByDefault = false\n```\n. It is currently not supported to choose this behavior per responder.\n\n# Buffers of MIDI data\n\nTo be written later.\n\nExamples:\n## Basic usage of VoicerMIDISocket\n\n```supercollider\ns.boot;\n\nv = Voicer(20, \\default);\nk = VoicerMIDISocket([\\all, \\omni], v); // any device, any channel\n\n// connect modwheel to pan\nk.addControl(1, \\pan, 0, \\bipolar);\n\n// connect veloc"}
+{"text": " pan\nk.addControl(1, \\pan, 0, \\bipolar);\n\n// connect velocity to amp\nk.noteOnArgsPat = Pbind(\n \\amp, Pkey(\\velocity).linlin(0, 127, 0.05, 0.25)\n);\n\n// play awhile...\n\nk.free;\n\nk = VoicerMIDISocket(0, v); // default device, channel 0\nk.free;\n\n// Pitch-bend requires the SynthDef to support it\n(\nSynthDef(\\pb, { |out, freq = 440, gate = 1, pb = 1, amp = 0.1|\n var sig = Mix(Saw.ar(freq * pb * [1, 1.003])) * amp,\n eg = EnvGen.kr(Env.adsr(0.01, 0.1, 0.5, 0.15), gate, doneAction: 2),\n filt_eg = EnvGen.kr(Env(#[8000, 2000], #[0.15], \\exp));\n sig = LPF.ar(sig, filt_eg);\n Out.ar(out, (sig * eg).dup)\n}).add;\n);\n\nv = Voicer(20, \\pb);\nv.gui;\n\nk = VoicerMIDISocket(0, v);\n\n// Here, \"spec\" is 3 (i.e., semitones)\n// The addControl method automatically sets up the spec properly\nk.addControl(\\pb, \\pb, 1, 3);\n\n// unmap\nk.removeControl(\\pb);\nv.unmapGlobal(\\pb);\n\n// To do it manually:"}
+{"text": "oveControl(\\pb);\nv.unmapGlobal(\\pb);\n\n// To do it manually: the spec should turn semitones into midiratio\nv.mapGlobal(\\pb, nil, 1, [-3, 3].midiratio);\nk.addControl(\\pb, \\pb); // use the mapping just created\n\nk.free;\n```\n\n## Selecting a default MIDI device\n\n```supercollider\n// Init the MIDIClient, to get the available devices.\nMIDIClient.init;\n\n// I'm looking for my FastTrack Pro.\n// Substitute your own device here\ni = MIDIClient.sources.detectIndex { |endpoint|\n endpoint.name.contains(\"FastTrack\")\n};\n\nMIDIPort.init([i]);\n\n// Now MIDIPort places the FastTrack in slot 0 -- the default device\nMIDIPort.sources[0];\n// prints: MIDIEndPoint(\"FastTrack Pro\", \"FastTrack Pro MIDI 1\")\n\nnil.asChannelIndex // default device\n// prints: MIDIChannelIndex('FastTrack Pro' : 'FastTrack Pro MIDI 1', 0)\n```"}
+{"text": "SuperCollider classlib — ddwPeakMonitor/PeakMonitorGui.sc\n\nworkaround for crucial gui issue closing a Swing window executes viewDidClose before calling remove on me so the model variable is already nil and .remove doesn't clean up the model I'll keep the model in a variable that crucial doesn't know about\n\n```supercollider\n guiBody { arg lay;\n lay.startRow;\n leftFlow = FlowView(lay, Rect(0, 0, model.numChannels * 13 + 10, 210), margin: 2@2);\n multiSl = GUI.multiSliderView.new(leftFlow, Rect(0, 0, model.numChannels * 13 + 2, 200));\n\n rightFlow = FlowView(lay, Rect(0, 0,\n // ax + b(x-1) = ax + bx - b = (a+b)x - b\n max((lay.decorator.gap.x + 50) * model.numChannels - lay.decorator.gap.x + 10, 210),\n 210), margin: 2@2); // height\n\n clipButtons = Array.fill(model.numChannels, { arg i;\n GUI.button.new(rightFlow, Rect(0, 0, 50, 20))\n .states_([\n [\"ok\", Color.black, Color.grey],\n [\"CLIP\", Color.white, Color.red]\n ])\n .action_({ // arg b;\n clipButtons.do({ |b, j|\n Post << \"Channel \" << j << \" maximum clip: \" << maxClip[j] << \"\\n\";\n max"}
+{"text": "Channel \" << j << \" maximum clip: \" << maxClip[j] << \"\\n\";\n maxClip[j] = 0;\n b.value_(0)\n });\n });\n });\n rightFlow.startRow;\n maxRecentView = GUI.textView.new(rightFlow, Rect(0, 0, 200, 100));\n\n maxClip = 0 ! model.numChannels;\n recentSize = model.freq*2;\n maxRecent = Array.new(recentSize);\n myModel = model;\n }\n\n update {\n var newpeaks, str;\n newpeaks = model.peaks.collect({ arg p, i;\n (p > maxClip[i]).if({ maxClip[i] = p });\n ((p = p.abs) > 1).if({\n { if(multiSl.notClosed) { clipButtons.at(i).value_(1) } }.defer;\n });\n p.clip(0,1)\n });\n // update \"recent peak\" display\n (maxRecent.size >= recentSize).if({ maxRecent.removeAt(0) });\n maxRecent.add(model.peaks);\n str = \"Channel peaks:\\n\\n\";\n maxRecent.flop.do({ |chan, i|\n str = str ++ format(\"%: % dB\\n\", i+1, chan.maxItem.ampdb.round(0.01));\n });\n {\n if(multiSl.notClosed) {\n multiSl.value_(newpeaks.ampdb.linlin(-60, 0, 0, 1));\n maxRecentView.setString(str, 0, maxRecentView.string.size);"}
+{"text": " 1));\n maxRecentView.setString(str, 0, maxRecentView.string.size);\n };\n }.defer;\n }\n\n remove {\n var tempModel = myModel;\n if(myModel.notNil) {\n tempModel = myModel;\n // must do this first to prevent infinite recursion\n myModel = nil;\n tempModel.free;\n }\n }\n\n}\n```"}
+{"text": "SuperCollider classlib — ddwVoicer/miditest.sc\n\n```supercollider\n var close = {\n var gctemp;\n voicer.active.if({\n \"\\n\\nTest ended. Last settings of global controls:\".postln;\n // must free midi controls in reverse order\n // globalControls is an IdentityDictionary, so this is the only way\n gctemp = Array.new(voicer.globalControls.size);\n\n voicer.globalControlsByCreation.do({ arg gc;\n gctemp.add(gc);\n Post << $\\\\ << gc.name << \", \" << gc.value << \", \\n\";\n });\n gctemp.reverseDo({ |gc| gc.midiControl.free });\n // prevent infinite recursion\n layout.onClose = nil;\n layout.close;\n socket.free; // clear and garbage objects\n voicer.free;\n socket = nil;\n voicer = nil;\n });\n };\n\n // MIDIPort.autoFreeSockets.not.if({\n // MethodError(\"MIDIPort.autoFreeSockets must be true to use miditest.\", this).throw;\n // });\n\n channel = channel ? 0;\n // can have controllers on a different midi channel (or different device)\n ctlChannel = ctlChannel ? channel;\n\n // make the player\n voicer = makeVoicerFunc.(this, initArgs, target: target, bus: bus)\n ??"}
+{"text": " makeVoicerFunc.(this, initArgs, target: target, bus: bus)\n ?? { Voicer.new(20, this, initArgs, target: target, bus: bus) };\n socket = VoicerMIDISocket.new(channel, voicer); // plug into MIDI\n\n // make guis for controls other than freq and gate\n // first get the InstrSynthDef\n // how to exempt args? provide non-SimpleNumber in initArgs\n // (Ref of SimpleNumber works to make fixed arg)\n patch = voicer.nodes.at(0).patch;\n synthdef = patch.asSynthDef;\n argNames = patch.argNames ?? { this.argNames };\n excludeCtls = excludeCtls ++ #[\\freq, \\gate, \\out];\n\n // now make midi controllers, but only for kr inputs\n // we have to go to the synthdef because only it knows which are noncontrols\n synthdef.allControlNames.do({ |cname|\n (cname.rate == \\control and:\n { excludeCtls.includes(cname.name).not }\n ).if({\n i = argNames.detectIndex({ |name| name == cname.name });\n // you might have added NamedControls in the Instr func\n // which will not have specs and shouldn't turn into midi controls\n if(i.notNil) {\n parg = patch.args[i];\n socket.addControl(\n nil, // socket will allocate a controller for me\n argNames["}
+{"text": "addControl(\n nil, // socket will allocate a controller for me\n argNames[i],\n (name == \\pb).if(1, patch.args[i].value),\n// (name == \\pb).if(\n// [7.midiratio.reciprocal, 7.midiratio, \\exponential, 0, 1],\n// parg.tryPerform(\\spec) ?? { patch.argSpecs[i] }),\n parg.tryPerform(\\spec) ?? { patch.argSpecs[i] },\n ctlChannel\n );\n };\n });\n });\n // make stop button\n voicer.addProcess([[\"Stop test\", close]], \\toggle); // so it's a button not a menu\n\n layout = voicer.gui.masterLayout;\n layout.onClose = close;\n\n // now user can play\n \"\\n\\nTry your Instr using your midi keyboard. Arguments have been routed as shown\".postln;\n \"in the console window.\".postln;\n ^voicer\n }\n\n miditestMono { arg channel = 0, initArgs, target, bus, ctlChannel, excludeCtls;\n ^this.miditest(channel, initArgs, target, bus, ctlChannel, { |instr, initArgs, target, bus|\n MonoPortaVoicer(1, instr, initArgs, bus, target)\n }, excludeCtls);\n }\n\n openFile {\n var str = this.path;\n if(str.respondsTo(\\openDocument)) {"}
+{"text": " openFile {\n var str = this.path;\n if(str.respondsTo(\\openDocument)) {\n str.openDocument;\n } {\n // this method is deprecated... use it only if openDocument isn't found\n str.openTextFile;\n }\n }\n\n}\n\n// for SynthDef\n// similar except Instr-miditest gets its specs from the Instr\n// here, you have to supply the specs in the miditest message\n// specs should be given as in Instr: an array each element of which corresponds to an arg in order\n// nil specs go to ControlSpecs.specs to look by name\n// to give a default value for a midi control, put it in the spec\n\n+ SynthDef {\n miditest { arg channel = 0, specs, target, bus, ctlChannel, makeVoicerFunc;\n var voicer, socket, patch, spec, name, layout, cnames, md;\n\n var close = {\n var gctemp;\n voicer.active.if({\n \"\\n\\nTest ended. Last settings of global controls:\".postln;\n gctemp = Array.new(voicer.globalControls.size);\n\n voicer.globalControlsByCreation.do({ arg gc;\n gctemp.add(gc);\n Post << $\\\\ << gc.name << \", \" << gc.value << \", \\n\";\n });\n gctemp.reverseDo({ |gc| gc.midiControl.free });\n\n // prevent infinite recursion\n layout.onClose = nil;\n layout.close"}
+{"text": " // prevent infinite recursion\n layout.onClose = nil;\n layout.close;\n socket.free; // clear and garbage objects\n voicer.free;\n socket = nil;\n voicer = nil;\n });\n };\n\n // MIDIPort.autoFreeSockets.not.if({\n // MethodError(\"MIDIPort.autoFreeSockets must be true to use miditest.\", this).throw;\n // });\n\n channel = channel ? 0;\n ctlChannel = ctlChannel ? channel;\n\n this.send(target.asTarget.server); // tell the server about me\n\n // make the player\n voicer = makeVoicerFunc.(this.name, #[], target: target, bus: bus)\n ?? { Voicer.new(20, this.name, target: target, bus: bus) };\n socket = VoicerMIDISocket.new(channel, voicer); // plug into MIDI\n\n // make guis for controls other than freq and gate\n // first get the InstrSynthDef\n // how to exempt args? provide non-SimpleNumber in initArgs\n\n // now make midi controllers\n // use (midiControls: #[name0, name1...]) to choose which controls get midified\n // otherwise it's all of them\n md = this.metadata ?? { () };\n cnames = md[\\midiControls] ?? { this.allControlNames.collect(_.name) };\n if(md[\\specs].notNil and: { specs.isNil }) {\n specs = this"}
+{"text": "(md[\\specs].notNil and: { specs.isNil }) {\n specs = this.allControlNames.collect { |cname|\n var temp = md[\\specs][cname.name.asSymbol];\n temp.tryPerform(\\asSpec) ?? { temp }\n };\n } {\n specs ?? { specs = [] };\n };\n this.allControlNames.do({ arg cn;\n var i;\n // freq and gate must be omitted\n name = cn.name.asSymbol;\n i = this.allControlNames.detectIndex { |cn| name == cn.name.asSymbol };\n #[\\freq, \\gate, \\outbus].includes(name).not.if({\n specs[i].respondsTo(\\asSpec).if({\n spec = specs.at(cn.index).asSpec ?\n ControlSpec.specs.at(name) ?\n ControlSpec.new; // this is probably not 100% robust\n }, {\n spec = specs[i];\n });\n (spec.rate != \\scalar and: { cnames.includes(name) }).if({\n socket.addControl(\n nil, // let Socket find me a controller\n name,\n (name == \\pb).if(1, spec.default),\n (name == \\pb).if(\n [7.midiratio.reciprocal, 7.midiratio, \\exponential, 0, 1],\n spec),\n ctlChannel\n );\n }, {\n "}
+{"text": "ponential, 0, 1],\n spec),\n ctlChannel\n );\n }, {\n if(spec.notNil) {\n voicer.setArgDefaults([name, spec.tryPerform(\\default) ?? { spec }])\n };\n });\n });\n });\n\n // make stop button\n voicer.addProcess([[\"Stop test\", close]], \\toggle); // so it's a button not a menu\n\n layout = voicer.gui.masterLayout;\n layout.onClose = close;\n\n // now user can play\n \"\\n\\nTry your SynthDef using your midi keyboard. Arguments have been routed as shown\".postln;\n \"in the console window.\".postln;\n ^voicer\n }\n\n miditestMono { arg channel = 0, specs, target, bus, ctlChannel;\n ^this.miditest(channel, specs, target, bus, ctlChannel, { |instr, initArgs, target, bus|\n MonoPortaVoicer(1, instr, initArgs, bus, target)\n });\n }\n}\n```"}
+{"text": "SuperCollider classlib — ixi/classes/XiiSlicer.sc\n\n```supercollider\n + urgent :\nexponential amp?\nerror when reposition, if set one layer then go to 8 and 7 no volume at all\nwhen there is only one state if you try to go back to it it does not work\n#####\n\npitch range areas draw \n\nmultiple drag selection object\n\nautomovement, flocking, wind, jump\nlock nodes X/Y buttons and/or shortcuts\n\nbe able to choose if clicks o not when loop crossing.\n\ntry broadcasting buffer IDs from bufferpool via OSC to integrate non Supercollider (OF?) applications\n*/\n\nXiiSlicer {\n classvar slicerindex; // global slicer instances count\n\n var instanceindex; // local value of this instance in global count\n \n var <>xiigui, <>win, params;\n var ldSndsGBufferList, selbPool;\n var stateDict, stateNum;\n\n var pitchRange, pitchRangeLimits, amp, outbus, rate, shift, start, length;\n var numOfLayers, bufferGlobalLimits, lowGraphicsMode, buffer, mute;\n var ampSpec;\n\n var gBufferPoolNum, poolName;\n\n var canvas, boxes, nodes, displays, selection;\n var players;\n var hcanvas, channels, server;\n var style, sndView, selected;\n var playheadsResponder;\n var sndNameList, gBufferP"}
+{"text": "w, selected;\n var playheadsResponder;\n var sndNameList, gBufferPoolNum, bufferList;\n //var sendTrigIndex; // to avoid sendTrig index collisions\n //var rate, shift, start, length;\n var startLabel, lengthLabel, shiftLabel, pitchLabel; // LABELS for global values\n var rateRangeSl, hiRateLabel, lowRateLabel;\n var lowGraphicsButt, numOfLayersButton;\n var randNodesButt, randBoxesButt, randButt;\n var bufferPop, globalVolSl, outbusPop, startButt;\n var statesPop, clearButt, storeButt;\n\n *new { arg server=Server.default, channels=2, setting = nil;\n ^super.new.initXiiSlicer(server, channels, setting);\n }\n\n updatePoolMenu \n {\n var poolname, poolindex;\n poolname = selbPool.items.at(selbPool.value); // get the pool name (string)\n selbPool.items_(XQ.globalBufferDict.keys.asArray.sort); // put new list of pools\n poolindex = selbPool.items.indexOf(poolname); // find the index of old pool in new array\n if(poolindex != nil, {\n selbPool.valueAction_(poolindex); // nothing changed, but new poolarray or sound \n ldSndsGBufferList.value(poolname);\n },"}
+{"text": " new poolarray or sound \n ldSndsGBufferList.value(poolname);\n }, {\n selbPool.valueAction_(0); // loading a pool for the first time (index nil) \n ldSndsGBufferList.value(XQ.globalBufferDict.keys.asArray[0]); // load first pool\n });\n }\n\n initAll { // CREATE SYNTHDEFS //\n if ( buffer == nil ) { buffer = XQ.globalBufferDict.at(poolName)[0][bufferPop.value] }; \n\n boxes.size.do ({ arg i;\n try { var srate = 44100; var synthdef;\n if ( server.actualSampleRate != nil ) { srate = server.actualSampleRate } ;\n if ( buffer.numChannels == 1, { synthdef = \\xiiSlicerMonoPlayer }, \n { synthdef = \\xiiSlicerStereoPlayer } ); \n // BEWARE that the synthdef index for the SendTrig is i+sendTrigIndex to avoid index collision with other triggers in ixiQuarks\n players.put(i, Synth(synthdef, [\\buffer , buffer, \\rate, rate, \\start, start, \n \\length, length, \\index, i + instanceindex ]));\n boxes[i].updateSynths(amp/numOfLayers); // update pan and vol\n if ( i > numOfLayers, { players[i].set(\\rate, 0) }); //"}
+{"text": "an and vol\n if ( i > numOfLayers, { players[i].set(\\rate, 0) }); // now stop the ones that are not visible\n }; //{ \"snd server not init?\".postln }; \n \n });\n this.updateLimits; // finally calculate each layer start and length\n }\n \n \n closeAll \n {\n players.do({ arg i; i.free });\n }\n \n\n updateCanvas {\n canvas.clearDrawing; \n canvas.refresh;\n }\n \n\n setRateRange { arg a, b;\n pitchRange = [ a, b, ((b - a).abs / canvas.bounds.height ).round(0.0001) ]; \n }\n\n setRate { arg pos; \n rate = pitchRange[0] + ((canvas.bounds.height - pos) * pitchRange[2]).round(0.001);\n try { pitchLabel.string = \"rate : \" + rate };\n\n //(\"rate \" + rate).postln;\n /*\n case \n { pos < hcanvas } // top area\n {\n if ( pos == 0, \n { rate = pitchRange[0] }, // fix float rounding problem\n { rate = pitchRange[1] + (pitchRange[3] * ((hcanvas - pos).abs)) } // scale to mid to max\n );\n }\n { pos == hcanvas } // center\n { rate = pitchRange[1] }\n { pos > hcanvas } // bottom area\n { \n if ( pos == 0, \n { rate = pitchRange[0] }, // fix float rounding proble\n { rate = p"}
+{"text": " { rate = pitchRange[0] }, // fix float rounding proble\n { rate = pitchRange[2] + ( pitchRange[4] * ((hcanvas - pos).abs) ) }\n );\n };\n */\n //rate.postln;\n /*\n def setPitch(self, i) :\n if i < self.app.height*0.5 : # top. mouse range 0 to middle 300\n if i == 0 : # very top'\n self.app.pitch = self.app.pitchLimits[0] # fix float rounding problem\n+\n else:\n self.app.pitch = self.app.pitchLimits[1] + ( self.app.pitchLimits[3] * abs(self.rev - i) ) # scale to mid to max\n elif i == self.app.height*0.5 :# middle\n self.app.pitch = self.app.pitchLimits[1]\n else : # bottom. the difference is that mouse range is 300 to 600 here\n self.app.pitch = self.app.pitchLimits[2] + ( self.app.pitchLimits[4] * abs(self.app.height - i) )\n */\n }\n\n updateLimits {\n // update global values\n this.setRate(nodes[0].loc.y); // pitch, length\n length = nodes[0].loc.x; // in pixels\n start = nodes[1].loc.x; // in pixels\n shift = nodes[1].loc.y - hcanvas; // in pixels\n\n try { \n lengthLabel.string = \"length : \" + length;\n startLabel.string = \"start : \""}
+{"text": " lengthLabel.string = \"length : \" + length;\n startLabel.string = \"start : \" + start;\n shiftLabel.string = \"shift : \" + shift;\n pitchLabel.string = \"rate : \" + rate;\n };\n\n numOfLayers.do({ arg i; var mysttime, mylength, width;\n \n width = displays[0].bounds.width; // displays width. 620px\n\n mysttime = start + (i * shift); // \"i\" counter needed here\n mylength = length;\n \n if (mysttime > (width + displays[0].bounds.left), { // wrap on right\n mysttime = mysttime % width;\n mylength = length;\n if (mylength > width, { // cut on right\n mylength = width;\n });\n });\n \n if (mysttime + mylength < displays[0].bounds.left, { // wrap on left\n mysttime = width - ((mysttime*(-1)) % width); // positive modulo from right\n mylength = length;\n //if (mysttime + mylength > width, { // cut on right\n // mylength = width - mysttime + displays[0].bounds.left;\n //});\n });\n\n if (mysttime + mylength - displays[0].bounds.left > width, { // cut on right\n mylength = width - mysttime + displays[0].bounds.left;\n });\n \n if (mysttime < displays[0].bounds.left, { //cut on left\n mylength = mylength + mysttime - displays[0].bounds.left; // -- = +\n mysttime = displays[0].bounds.left"}
+{"text": "[0].bounds.left; // -- = +\n mysttime = displays[0].bounds.left;\n });\n\n if ( (mysttime + mylength) <= mysttime, { mylength = 0.5 }); //minimum\n \n // update graphical representation\n displays[i].drawbounds.left = mysttime;\n displays[i].drawbounds.width = mylength;\n \n // update players\n try { var pstart, plength, relativeWidthFactor;\n pstart = bufferGlobalLimits[0] + (mysttime * (bufferGlobalLimits[1]/width));\n plength = ( mylength ) * (bufferGlobalLimits[1]/width);// selection \n\n if ((pstart+plength) > 1) { plength = 1 - pstart }; // never overflow 1 limit\n\n players[i].set(\\start, pstart); //normalise to 0/1 range \n players[i].set(\\length, plength);\n players[i].set(\\rate, rate); // general;\n }//{\"snd server not init?\".postln}\n }); // end loop\n\n { canvas.clearDrawing; canvas.refresh; }.defer(0.001); // hack**\n }\n\n \n \n mouseDown // handles mouse down on canvas\n { arg view, x, y, mod, button; \n var l, selectionflag;\n\n selectionflag = true;\n\n if ( (selected != nil) && (selected.class == XiiSlicerBox), { \n try { selected.deselect }; // only works with boxes\n selected = nil;"}
+{"text": "licerBox), { \n try { selected.deselect }; // only works with boxes\n selected = nil;\n });\n \n\n l = [nodes, boxes, displays]; // mouseable items lists by cathegory\n block { arg break;\n l.size.do( { arg n;\n l[n].size.do( { arg i;\n if (l[n][i].bounds.contains(Point(x, y)) == true) {\n selected = l[n][i]; // this is clicked \n case { button == 1 } \n { \n l[n][i].mouseDown(x,y);\n if (l[n][i].class == XiiSlicerDisplay, { selectionflag = false });\n }\n { button == 3 } // MUTE\n { \n selectionflag = 0; //never with right click\n l[n][i].rightMouseDown(x,y); \n canvas.clearDrawing;\n canvas.refresh; \n if ( n > 0, // only boxes and displays control audio layers\n { try{ players[i].set(\\mute, l[n][i].color.alpha.round) } }\n ); \n }; // end case\n break.value(l.size-1); // now BREAK. job done\n };\n }); \n });\n };\n\n //selected.postln;\n \n // mouse on background?\n if ( selectionflag == 1, { selection.start(x,y) });\n }\n\n initInstances // graph"}
+{"text": "ctionflag == 1, { selection.start(x,y) });\n }\n\n initInstances // graphical elements of GUI\n {\n // set classvars\n XiiSlicerRect.canvasBounds = canvas.bounds;\n XiiSlicerRect.players = Ref(players); // as ref!\n XiiSlicerDisplay.win = win; //set classvar\n XiiSlicerDisplay.canvasBounds = canvas.bounds;\n\n numOfLayers.do({ arg i; var color, ypos;\n color = Color.rand(0.3, 0.8); // each layer has a rand color\n // DISPLAYS\n displays.put( i, XiiSlicerDisplay.new( Rect(10, 10, 620, 40), color ) );\n displays[i].label =\n StaticText(win, Rect(10,10, 100, 15))\n .font_(style.normal)\n .string_(i+1);\n // BOXES\n boxes.put( i, XiiSlicerBox.new( Rect(10,10, 12, 12), color ) );\n boxes[i].setIndex(i); //**\n boxes[i].label = \n StaticText( win, Rect(10,10, 0, 0) )\n .font_(style.normal)\n .string_(i+1);\n });\n\n // NODES\n nodes.size.do({ arg i; var x;\n x = (canvas.bounds.width/2)-20; // both aligned in center of screen\n nodes.put( i, XiiSlicerRect.new( Rect("}
+{"text": "ed in center of screen\n nodes.put( i, XiiSlicerRect.new( Rect(x+(i*20), canvas.bounds.height/2, 14, 14), \n [Color(0.1,0.1,0.1), Color.white][i] ) );\n });\n\n selection = XiiSelection.new(boxes, canvas.bounds);\n }\n\n reposition { var dw, dh, inbetween, dx, dy;\n\n dy = 10; // y loc for first one\n inbetween = ( dy * 3 ) / numOfLayers; \n dh = ( canvas.bounds.height - (dy * 5)) / numOfLayers; // 65 # height.\n\n displays.size.do({ arg i; var color, ypos;\n if (i < numOfLayers,\n {\n displays[i].bounds = Rect(10.5, dy + 0.5, 620.5, dh + 0.5);\n displays[i].drawbounds = displays[i].bounds.copy; // this as well \n dy = dy + dh + inbetween; // next Y position\n boxes[i].bounds = Rect(10.5+((canvas.bounds.width-20).rand), 10.5+((canvas.bounds.height-20).rand), 12.5, 12.5);\n try { players[i].set(\\rate, rate) } ; // do i need this? \n } , { //OFF the rest\n displays[i].bounds.top = -1000; // go offscreen\n displays[i].drawbounds.top = -1000;\n box"}
+{"text": " offscreen\n displays[i].drawbounds.top = -1000;\n boxes[i].bounds.top = 1000; // low position to mute\n try { players[i].set(\\rate, 0) } ; // STOP**;\n }\n );\n // all of them\n displays[i].updateLabel; \n boxes[i].updateLoc;\n boxes[i].updateLabel;\n boxes[i].updateSynths(amp/numOfLayers); // update pan and vol\n });\n this.updateLimits;\n }\n\n randAll\n {\n this.randNodes;\n this.randBoxes;\n }\n\n randNodes\n {\n nodes.collect(_.randLoc);\n this.updateLimits; // updates global values of synths as well\n }\n\n randBoxes\n {\n boxes.size.do({ arg i;\n if (i < numOfLayers,\n { boxes[i].randLoc },\n { boxes[i].bounds.top = 1000 }\n );\n boxes[i].updateLoc;\n boxes[i].updateLabel;\n boxes[i].updateSynths(amp/numOfLayers);// synths\n });\n\n { canvas.clearDrawing; canvas.refresh; }.defer(0.001); // hack**\n }\n \n\n // called from XiiSoundFileView when selected loop is moved\n setLoopRange {arg chnl, startPos, numSelectedFrames;\n var lo, hi, selfile;\n\n// [bufferGlobalLimits[0], \"loop"}
+{"text": "ar lo, hi, selfile;\n\n// [bufferGlobalLimits[0], \"loop range\"].postln;\n \n bufferGlobalLimits[0] = startPos/buffer.numFrames;\n bufferGlobalLimits[1] = bufferGlobalLimits[0] + (numSelectedFrames/buffer.numFrames);\n\n XiiSlicerDisplay.selectionDelta = bufferGlobalLimits[1]-bufferGlobalLimits[0];\n\n this.updateLimits;\n }\n\n changeNumOfLayers { arg n; //Num of layers\n numOfLayers = n;\n //XiiSlicerBox.gNumLayers = numOfLayers;\n this.reposition; \n numOfLayersButton.value = n - 1; //must be one less. check button code for details\n }\n\n getPositions {\n var positions;\n\n positions = Array.fill(10, {0}); // empty array right now. max 8 layers + 2 control nodes\n boxes.size.do({ arg i; // 0 to 7th position\n positions[i] = boxes[i].bounds; //.getPos;\n });\n nodes.size.do({ arg i; // 8th and 9th positions\n positions[i+8] = nodes[i].bounds; //.getPos;\n });\n ^positions;\n }\n\n initialise { arg setting, state = \"state 1\";\n var point, positions, colors;\n\n //setting.postln;\n\n if (setting.isNil, {\n point = Point(100, 100);\n params = [ nil, nil, pitchRangeLimits, pitchRange"}
+{"text": "(100, 100);\n params = [ nil, nil, pitchRangeLimits, pitchRange, numOfLayers, rate, start, \n length, amp, shift, lowGraphicsMode, buffer, outbus ];\n }, { // coming from a preset setting\n // ok - set state 1 as default state, and load vars - GUI views take care of themselves\n try {\n point = setting[1];\n \n stateDict = setting[2];\n stateNum = stateDict.size;\n params = setting[2].at(state.asSymbol);\n } {\n point = Point(win.bounds.top, win.bounds.left); //no point in this case\n \n params = setting.at(state.asSymbol).deepCopy;\n stateDict = setting;\n stateNum = stateDict.size;\n };\n //params.postln;\n\n // restore params\n positions = params[0].deepCopy;\n colors = params[1].deepCopy;\n pitchRangeLimits = params[2].copy;\n pitchRange = params[3].copy;\n numOfLayers = params[4].copy; \n rate = params[5].copy; \n start = params[6].copy; \n length = params[7].copy;\n shift = params[8].copy;\n amp = params[9].copy;\n \n lowGraphicsMode = params[10].copy;\n buffer = params[11].copy;\n outbus = par"}
+{"text": "[10].copy;\n buffer = params[11].copy;\n outbus = params[12].copy;\n \n statesPop.items_(stateDict.keys.asArray.sort); //update pull down menu\n //stateDict.keys.asArray.postln;\n });\n\n lowGraphicsButt.valueAction_(lowGraphicsMode);\n\n //XiiSlicerBox.gNumLayers = numOfLayers;\n //XiiSlicerBox.gAmp = amp;\n globalVolSl.value_(amp); //sets but doesnt trigger action //.valueAction_(amp);\n\n this.reposition; // NOT sure why I need to do this when not restoring a state\n numOfLayersButton.valueAction_(numOfLayers-1); //MUST be one less than variable. Check button code for details\n \n // set initial state from setting or random situation //\n if(setting.isNil, { \n this.randAll \n }, { // Restote positions from params[0] array of positions\n numOfLayers.do({ arg i; // 0 to max 7th position\n boxes[i].bounds = params[0][i];\n boxes[i].color = params[1][i];\n displays[i].color = boxes[i].color;\n });\n nodes.size.do({ arg i; // 8th and 9th positions\n nodes[i].bounds = params[0][i+8]; //.getPos;\n });\n }); \n // ************** remove this following line later ??!!!! \n this.setRateRange(pitchRangeLimits"}
+{"text": " remove this following line later ??!!!! \n this.setRateRange(pitchRangeLimits[0], pitchRangeLimits[0] + pitchRangeLimits[1].abs ); \n this.setRate(nodes[0].loc.y); // pitch, length\n\n outbusPop.value = outbus/2;\n try{ players.do({ arg i; i.set(\\outbus, outbus) }) };\n\n \n rateRangeSl.lo_(0.5 + (params[3][0].copy/pitchRangeLimits[1])); // normalise to range 0 to 1\n rateRangeSl.hi_(0.5 + (params[3][1].copy/pitchRangeLimits[1]));\n lowRateLabel.string = params[3][0].copy; \n hiRateLabel.string = params[3][1].copy; \n\n nodes.collect(_.updateLoc);\n boxes.collect(_.updateLoc);\n boxes.collect(_.updateLabel); \n //boxes.collect(_.updateSynths); // update pan and vol\n boxes.do({ arg b; b.updateSynths(amp/numOfLayers) });\n (\"amp is\"+amp).postln;\n\n win.bounds.left = point.x;\n win.bounds.top = point.y;\n\n this.updateLimits;\n }\n\n getColors { \n var colors;\n colors = Array.fill(8, {0});\n boxes.size.do({ arg i; // 0 to max 7th position\n colors[i] = boxes[i].color.copy;\n "}
+{"text": " i; // 0 to max 7th position\n colors[i] = boxes[i].color.copy;\n });\n ^colors;\n }\n\n getState { // for save settings\n var point;\n point = Point(win.bounds.left, win.bounds.top); \n\n params = [ this.getPositions, this.getColors, pitchRangeLimits, pitchRange, numOfLayers, \n rate, start, length, shift, amp, lowGraphicsMode, buffer, outbus ];\n\n if(stateDict.size == 0, {\n stateDict.add(\"state 1\".asSymbol -> params.copy); // we create a state\n });\n //stateDict.postln;\n \n ^[2, point, stateDict];\n }\n\n /* INIT */\n\n initXiiSlicer { arg server_, channels_, setting;\n var point, params;\n var updatePoolMenu; \n var setplayheads; \n\n if ( slicerindex == nil, // global slicer instances count\n { slicerindex = 600 }, // first instance opened\n { \n //XiiAlert(\"A single Slicer can be run. sorry.\");\n //^nil;\n [\\slicerindex, slicerindex].postln;\n //slicerindex = 600;\n slicerindex = slicerindex + 8;\n //(\"opening a new copy of Slicer with instanceindex \" + slicerindex).postln;\n } // new instance being opened. 8 layers max for each\n );\n instanceindex = slicerindex; // each instance knows its own index in the global count\n \n channels = ch"}
+{"text": "anceindex = slicerindex; // each instance knows its own index in the global count\n \n channels = channels_;\n server = server_;\n \n selected = nil;\n style = XiiStyles(channels);\n\n players = Array.fill(8, {0}); // 8 is max num of layers\n displays = Array.fill(8, {0});\n boxes = Array.fill(8, {0});\n nodes = Array.fill(2, {0});\n\n bufferGlobalLimits = Array.fill(2, {0}); // global limits of the selected buffer\n\n stateDict = ();\n stateNum = 0;\n\n // set params\n numOfLayers = 8;\n rate = 1;\n start = 0;\n length = 1;\n amp = 0.5;\n shift = 1;\n outbus = 0;\n\n mute = false;\n \n //pitchRange = [-2, 0, 2, 0, 0]; // seetop, middle of screen and bottom\n pitchRangeLimits = [-5, 10]; // mix and max//range\n pitchRange = [-5, 5, 4]; // low, top, range/canvas.bounds.width \n\n if ( GUI.id == \\swing, \n { lowGraphicsMode = 1 },\n { lowGraphicsMode = 0 }\n );\n\n /*\n n = self.size[1]*0.5 # half the height of the window\n self.__pitchLimits = l # items 0,1,2 (top, midd, bottom)\n self.__pitchLimits.append( (l[0] - l[1]) / n) # sub 3\n self.__pitchLimits.append( (l[1] - l[2]) / n) # sub 4\n *"}
+{"text": "\n self.__pitchLimits.append( (l[1] - l[2]) / n) # sub 4\n */\n setplayheads = { arg time, resp, msg; // red playheads\n var pos;\n pos = msg[2] - instanceindex; \n if ( (pos >= 0) && (pos <= 7) , { // within range for this particular instance of Slicer\n displays[pos].setplayhead(msg[3]); // sendTrigIndex is to avoid duplicated indexes between different ixiQuarks SendTrigs\n });\n };\n\n playheadsResponder = OSCresponderNode( server.addr, '/ixi/slicer/playheads'+instanceindex, setplayheads ).add;\n\n /// GUI //////\n\n // WIN\n win = Window(\"Slicer\", Rect(100, 100, 772, 494), resizable: false);\n\n win.view.keyDownAction = \n { arg view, char, modifiers, unicode, keycode; \n var delta; \n //[\"keyDownAction\", modifiers, unicode, keycode].postln;\n\n if ( modifiers == 8519680, { delta = 5 }, { delta = 1 }); //SHIFT\n\n case \n { keycode == 32 } { // Space key MUTE & UNMUTE\n if ( mute == true, {\n globalVolSl.valueAction_(amp); \n mute = false;\n }, {\n globalVolSl.valueAction_(0); \n mute = true;\n });\n \n } \n { keycode == 27 } { // ESC"}
+{"text": " mute = true;\n });\n \n } \n { keycode == 27 } { // ESC quits \n this.closeAll;//.value;\n win.close;\n }\n { (keycode >= 49) && (keycode <= 56) } { // keys 1 to 8\n this.changeNumOfLayers(keycode-48); // set num of layers\n } \n { keycode == 38 } { // up\n selected.bounds.top = selected.bounds.top - delta;\n selected.updateLoc;\n try { selected.updateLabel }; \n } \n { keycode == 40 } { // down\n selected.bounds.top = selected.bounds.top + delta;\n selected.updateLoc;\n try { selected.updateLabel }; \n } \n { keycode==39 } { // right \n selected.bounds.left = selected.bounds.left + delta;\n selected.updateLoc;\n try { selected.updateLabel };\n } \n { keycode==37 } { // left \n selected.bounds.left = selected.bounds.left - delta;\n selected.updateLoc;\n try { selected.updateLabel };\n };\n };\n\n // Instantiate objects\n canvas = UserView(win, Rect(120, 2, 650, 482))\n .canFocus_(false)\n .drawFunc_({ arg view;\n // smoothing off ONLY if button is activated\n if ( lowGraphicsMode =="}
+{"text": "iew;\n // smoothing off ONLY if button is activated\n if ( lowGraphicsMode == 1, { Pen.smoothing_(false) } ); // faster rendering in java\n \n Pen.color = Color(0.5, 0.5, 0.5, 1);\n Pen.strokeRect( Rect(0.5, 0.5, 640+0.5, 480+0.5 ) );\n\n displays.collect(_.draw); // on background\n \n nodes.do({ arg n; // lines between boxes and nodes//\n Pen.color = n.color; // two different colors\n numOfLayers.do({ arg i; Pen.line( boxes[i].loc, n.loc ) });\n Pen.stroke;\n });\n \n Pen.color = Color(0.9, 0, 0, 1);\n displays.collect(_.drawplayhead);\n Pen.stroke;\n\n if ( GUI.id == \\cocoa,\n { win.refresh }, \n { this.updateCanvas }\n );\n \n boxes.collect(_.draw);\n nodes.collect(_.draw);\n selection.draw;\n })\n //.relativeOrigin_(true) // use this for the refresh\n .clearOnRefresh_(true) // no refresh when window is refreshed\n .mouseMoveAction_({ arg view, x, y;\n if ( selected != nil ) { // if there is a selection\n selected.mouseMoved(x,y);\n // in case it is a control node, update globals and its display\n if"}
+{"text": "ed(x,y);\n // in case it is a control node, update globals and its display\n if ( nodes.find([selected]) != nil , { this.updateLimits });\n }\n })\n .mouseDownAction_({ arg view, x, y, mod, button; \n this.mouseDown(view, x, y, mod, button)\n })\n .mouseUpAction_({ arg view, x, y;\n if ( selected == nil, {\n selection.doSelection; \n },{ \n selected.mouseUp;\n });\n }); //end canvas\n\n //***** ///\n hcanvas = canvas.bounds.height*0.5;\n //*****///\n\n this.initInstances; \n\n // WIDGETS //\n\n // buffer pools //\n selbPool = PopUpMenu.new(win, Rect(10, 5, 100, 16))\n .font_(style.normal)\n .items_(if(XQ.globalBufferDict.keys.asArray == [], {[\"no pool\"]}, {XQ.globalBufferDict.keys.asArray}))\n .value_(0)\n .canFocus_(false)\n .background_(Color.white)\n .action_({ arg item;\n gBufferPoolNum = item.value;\n ldSndsGBufferList.value(selbPool.items[item.value]);\n });\n\n \n bufferPop = PopUpMenu.new(win, Rect(10, 27, 100, 16)) // 550\n .font_(style"}
+{"text": "Menu.new(win, Rect(10, 27, 100, 16)) // 550\n .font_(style.normal)\n .items_([\"no buffer 1\", \"no buffer 2\"])\n .background_(Color.new255(255, 255, 255))\n .canFocus_(false) \n .action_({ arg popup;\n //this.closeAll;\n buffer = XQ.globalBufferDict.at(poolName)[0][popup.value];\n //if ( startButt.value == 1, { this.initAll }); //restart to update \n bufferGlobalLimits[0] = XQ.globalBufferDict.at(poolName)[1][popup.value][0] / buffer.numFrames;\n bufferGlobalLimits[1] = XQ.globalBufferDict.at(poolName)[1][popup.value][1] / buffer.numFrames;\n XiiSlicerDisplay.selectionDelta = bufferGlobalLimits[1]-bufferGlobalLimits[0]; \n \n try{ players.do({ arg i; i.set(\\buffer, buffer) }) }; \n this.updateLimits; // finally calculate each layer start and length \n })\n .addAction({ bufferPop.action.value( bufferPop.value )}, \\mouseDownAction);\n \n \n ldSndsGBufferList = { arg argPoolName, firstpool=false; \n poolName = argPoolName.asSymbol;\n "}
+{"text": ", firstpool=false; \n poolName = argPoolName.asSymbol;\n if ( try { XQ.globalBufferDict.at(poolName)[0] } != nil, {\n sndNameList = [];\n bufferList = List.new;\n XQ.globalBufferDict.at(poolName)[0].do({arg buf, i;\n sndNameList = sndNameList.add(buf.path.basename);\n bufferList.add(buf.bufnum);\n });\n bufferPop.items_(sndNameList); // get all global sounds and put them into the list\n // put the first file into the view and load buffer (if first time)\n if(firstpool, { { bufferPop.action.value(0) }.defer(0.5) }); // load BUFFER with delay!!!!!!!!\n\n }, {\n \"got no files\".postln;\n sndNameList = [];\n });\n };\n\n ldSndsGBufferList.value(selbPool.items[0].asSymbol, true); // GET BUFFERPOOL??\n \n /*\n ldSndsGBufferList = {arg argPoolName;\n poolName = argPoolName.asSymbol;\n if(try {XQ.globalBufferDict.at(poolName)[0] } != nil, {\n sndNameList = [];\n bufferList = List.new;\n XQ.globalBufferDict.at(poolN"}
+{"text": ";\n bufferList = List.new;\n XQ.globalBufferDict.at(poolName)[0].do({arg buff;\n sndNameList = sndNameList.add(buff.path.basename);\n bufferList.add(buff.bufnum);\n // assign random buffer to each drop\n //soundFuncArray.do({|dict| dict.buffer = sndNameList.size.rand });\n });\n bufferPop.items_(sndNameList);\n bufferPop.action.value(0); // put the first file into the view and load buffer\n }, {\n sndNameList = [];\n });\n };\n\n ldSndsGBufferList.value(selbPool.items[0].asSymbol);\n */\n \n // num of layers //\n numOfLayersButton = PopUpMenu.new(win, Rect(70, 54, 40, 16))\n .font_(style.normal)\n .items_([\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"])\n .value_(7)\n .canFocus_(false)\n .background_(Color.white)\n .action_({ arg item;\n numOfLayers = item.value + 1; // the position in array + 1\n //XiiSlicerBox.gNumLayers = numOfLayers;\n this.reposition; //set new situation\n (\"new num of layers is\" + numOfLayers).postln;\n //this.changeNumOfLayers;\n });\n\n \n "}
+{"text": " + numOfLayers).postln;\n //this.changeNumOfLayers;\n });\n\n \n StaticText( win, Rect( 10, numOfLayersButton.bounds.top-7, 50, 30) )\n .font_(style.normal)\n .string_(\"layers\"); //\n\n // random situations //\n randButt = Button(win, Rect(10, 80, 100, 16))\n .states_([[\"random state\", Color.black, Color.clear]])\n .font_(style.normal)\n .canFocus_(false)\n .action_({ arg butt; this.randAll });\n\n // random nodes\n randNodesButt = Button(win, Rect(10, 100, 100, 16))\n .states_([[\"random nodes\", Color.black, Color.clear]])\n .font_(style.normal)\n .canFocus_(false)\n .action_({ arg butt; this.randNodes });\n\n // random boxes\n randBoxesButt = Button(win, Rect(10, 120, 100, 16))\n .states_([[\"random slices\", Color.black, Color.clear]])\n .font_(style.normal)\n .canFocus_(false)\n .action_({ arg butt; this.randBoxes });\n\n // states\n statesPop = GUI.popUpMenu.new(win, Rect(10, 150, 100, 16))\n .font_(style.normal)\n .items_( if(stateDict.size > 0, { stateDict.keys.asArray.sort }, { ["}
+{"text": "ems_( if(stateDict.size > 0, { stateDict.keys.asArray.sort }, { [\"states\"] }) )\n .value_(0)\n .background_(Color.white)\n .action_({ arg item; var newdict; // var chosenstate;\n stateNum.postln;\n if(stateNum > 0, { // if there are any states : RESTORE\n //stateDict.keys.postln;\n /*stateDict.keys.do({ arg key;\n (\"is\"+item.items[item.value]+\"equal to\"+key).postln;\n (item.items[item.value].asSymbol == key).postln;\n });*/\n //stateDict.at(item.items[item.value].asSymbol).postln;\n \n this.initialise(stateDict.deepCopy, item.items[item.value].asSymbol);\n });\n });\n \n clearButt = GUI.button.new(win, Rect(10, 170, 47, 18))\n .canFocus_(false)\n .font_(style.normal)\n .states_([[\"clear\", Color.black, Color.clear]])\n .action_({arg butt;\n stateNum = 0;\n stateDict = ();\n statesPop.items_([\"states\"]);\n });\n\n storeButt = GUI.button.new(win, Rect(63, 170, 47, 18))\n .canFocus_(false)\n .font_(style.normal)\n .st"}
+{"text": " 18))\n .canFocus_(false)\n .font_(style.normal)\n .states_([[\"store\", Color.black, Color.clear]])\n .action_({arg butt;// var statesarray;\n stateNum = stateNum + 1;\n statesPop.items_(Array.fill(stateNum, {|i| \"state \"++(i+1).asString}));\n statesPop.value_(stateNum-1);\n\n params = [ \n this.getPositions.deepCopy, \n this.getColors.deepCopy,\n pitchRangeLimits.deepCopy, \n pitchRange.deepCopy, \n numOfLayers.copy, \n rate.copy, \n start.copy, \n length.copy,\n shift.copy, \n amp.copy, \n lowGraphicsMode.copy, \n buffer.copy, \n outbus.copy \n ];\n\n //(\"stored amp is\"+params[9]).postln;\n \n stateDict.add((\"state \"++stateNum.asString).asSymbol -> params.copy);\n //soundFuncArray = soundFuncArray.deepCopy; // make a new stamp of sndfarray\n });\n\n \n // RATE range\n StaticText(win, Rect(10, 212, 100, 16))\n .font_(style.normal)\n .string_(\"Rate range\");\n \n rateRangeSl = RangeSlider(win, Rect(10, 230, 100, 12"}
+{"text": "ate range\");\n \n rateRangeSl = RangeSlider(win, Rect(10, 230, 100, 12))\n .mouseUpAction_({ arg view, x, y;\n this.setRate(nodes[0].loc.y); // update pitch \n players.do({ arg p; p.set(\\rate, rate) }); // update all\n })\n .action_({ arg sl;\n this.setRateRange(\n pitchRangeLimits[0] + (sl.lo.round(0.001) * pitchRangeLimits[1]), \n pitchRangeLimits[0] + (sl.hi.round(0.001) * pitchRangeLimits[1])\n );\n lowRateLabel.string = pitchRange[0];\n hiRateLabel.string = pitchRange[1];\n });\n \n lowRateLabel = StaticText(win, Rect(10, 240, 100, 16))\n .font_(style.normal)\n .string_(pitchRange[0]);\n \n hiRateLabel = StaticText(win, Rect(10, 240, 100, 16))\n .font_(style.normal)\n .string_(pitchRange[1])\n .align_(\\right); // RIGHT ALIGN\n\n ampSpec = ControlSpec(0, 1, \\linear, 0, 0); // min, max, mapping, step\n // AMPLITUDE \n globalVolSl = OSCIISlider(win, Rect(10, 290, 100, 12), \"- vol\", 0, 1, 1, 0.01, \\amp)\n .font_(style.normal"}
+{"text": ", 12), \"- vol\", 0, 1, 1, 0.01, \\amp)\n .font_(style.normal)\n .canFocus_(false)\n .action_({ arg sl; \n amp = sl.value;\n //amp = ampSpec.map(sl.value);\n //XiiSlicerBox.gAmp = amp; // inform them\n //boxes.collect(_.updateSynths); //they know how to calculate each's amp\n boxes.do({ arg b; b.updateSynths(amp/numOfLayers) });\n //(\"global amp is\"+amp).postln;\n });\n\n outbusPop = PopUpMenu.new(win, Rect(10, 325, 50, 16)) \n .font_(style.normal)\n .items_(XiiACDropDownChannels.getStereoChnList)\n .value_(0)//params[8]/2)\n .canFocus_(false)\n .background_(Color.white)\n .action_({ arg ch;\n outbus = ch.value * channels;\n try{ players.do({ arg i; i.set(\\outbus, outbus) }) };\n });\n \n startButt = Button(win, Rect(65, 325, 45, 16))\n .states_([[\"start\", Color.black, Color.clear],\n [\"stop\", Color.black, XiiColors.onbutton]])\n .font_(style.normal)\n .canFocus_(false)\n .action_({ arg butt; \n if ( butt.value == 1, { this.initAll }"}
+{"text": ")\n .action_({ arg butt; \n if ( butt.value == 1, { this.initAll }, { this.closeAll } )\n });\n\n \n\n startLabel = StaticText(win, Rect(10, 360, 100, 16))\n .font_(style.normal)\n .string_(\"start :\");\n\n lengthLabel = StaticText(win, Rect(10, 375, 100, 16))\n .font_(style.normal)\n .string_(\"length :\"); \n\n shiftLabel = StaticText(win, Rect(10, 390, 100, 16))\n .font_(style.normal)\n .string_(\"shift :\");\n \n pitchLabel = StaticText(win, Rect(10, 405, 100, 16))\n .font_(style.normal)\n .string_(\"rate :\");\n\n lowGraphicsButt = Button(win, Rect(10, 430, 100, 16))\n .states_([[\"set low-fi graphics\", Color.black, Color.clear],\n [\"set hi-fi graphics\", Color.black, XiiColors.onbutton]])\n .font_(style.normal)\n .canFocus_(false)\n .action_({ arg butt; \n lowGraphicsMode = butt.value;\n displays.do({ arg i; i.lowGraphicsMode = lowGraphicsMode });\n boxes.do({ arg i; i.lowGraphicsMode = lowGraphicsMode });\n selection.lowGraphicsMode = lowGraphicsMode; \n\n if ( l"}
+{"text": "ode });\n selection.lowGraphicsMode = lowGraphicsMode; \n\n if ( lowGraphicsMode == 1, { Pen.smoothing_(false) }, {Pen.smoothing_(true)} ); \n });\n // end GUI description\n\n // INITAL STATE //\n this.initialise(setting);\n\n // FINALLY\n win.front;\n win.view.focus(true);\n win.onClose_({ // must be passed within brackets\n var t;\n (\"closing Slicer\" + instanceindex).postln;\n slicerindex = nil; // only if single Slicer copy mode\n this.closeAll; \n XQ.globalWidgetList.do({arg widget, i; if(widget == this, { t = i })}); //get position in array\n try{ XQ.globalWidgetList.removeAt(t) }; \n });\n }\n}\n```"}
+{"text": "SuperCollider classlib — ixi/classes/XiiSoundFileView.sc\n\ntest the view\n\n```supercollider\nXQ.globalBufferList[0][0][0] // here one gets the first buffer\nXQ.globalBufferList[0][1][0] // and here the selection for that\n\n a = Synth(\\playBufXSndFileView2x2, \n [\\bufnum, 0, \n \\start, XQ.globalBufferList[0][1][0][0], \n \\end, (XQ.globalBufferList[0][1][0][0]+XQ.globalBufferList[0][1][0][1]), \n \\loop, 1]);\n\n*/\n\nXiiSoundFileView { \n\n var <>xiigui, <>win;\n var soundfile.numFrames, { end = soundfile.numFrames });\n\n XQ.globalBufferDict.at(poolname.asSymbol)[1][fileNumInPool] = [start, sndfileview.selections[0][1]];\n });\n\n normButt = Button(win, Rect(575, 195, 65, 18))\n .states_([[\"normalize\", Color.black, Color.clear]])\n .canFocus_(false)\n .font_(GUI.font.new(\"Helvetica\", 9))\n .action_({arg butt; \n var cond, tempbuf;\n cond = Condition.new;\n Routine.run({\n tempbuf = XQ.buffers(poolname.asSymbol)[fileNumInPool];\n tempbuf.normalize(normalization);\n Server.default.sync(cond);\n tempbuf.write(tempbuf.path, \"AIFF\", XQ.pref.bitDepth);\n Server.default.sync(cond);\n {\n soundfile = SoundFile.new;\n soundfile.openRead(tempbuf.path);\n sndfileview.soundfile_(soundfile);\n sndfileview.read(0, soundfile.numFrames);\n win.refres"}
+{"text": "_(soundfile);\n sndfileview.read(0, soundfile.numFrames);\n win.refresh;\n }.defer;\n });\n });\n\n volSlider = OSCIISlider(win, Rect(575, 222, 65, 8), \"norm\", 0, 1, 1, 0.01)\n .canFocus_(false)\n .value_(1)\n .font_(GUI.font.new(\"Helvetica\", 9))\n .action_({arg slider; \n normalization = slider.value;\n });\n\n cropButt = GUI.button.new(win, Rect(645, 195, 45, 18))\n .states_([[\"crop\",Color.black,Color.clear]])\n .canFocus_(false)\n .font_(GUI.font.new(\"Helvetica\", 9))\n .action_({arg butt; \n \n var startFrame, numSelFrames, soundfile, view;\n\n startFrame = sndfileview.selections[0][0]; // the start\n numSelFrames = sndfileview.selections[0][1]; // end of the selection\n // if sound is playing, stop before cropping\n if(caller.isKindOf(XiiBufferPlayer), {\n caller.startButtList[chnl].valueAction_(0);\n \n XQ.pref.bufferPlayerTracks.do({ |i|\n if(caller.sfdropDownList[i].value == caller.sfdropDownList[chnl].value, {\n caller.startB"}
+{"text": "i].value == caller.sfdropDownList[chnl].value, {\n caller.startButtList[i].valueAction_(0)\n });\n });\n caller.viewerList[chnl].win.close; \n });\n \n {\n // crop the sound\n XQ.buffers(poolname.asSymbol)[fileNumInPool]\n .crop(startFrame, numSelFrames, false);\n XQ.selections(poolname.asSymbol)[fileNumInPool] = [0, numSelFrames];\n }.defer(0.2);\n \n {\n view = XiiSoundFileView.new(\n XQ.buffers(poolname.asSymbol)[fileNumInPool], \n numInPool, // the index in the pool\n poolname, // the poolname\n [0,0],\n caller, chnl);\n win.close;\n [\\caller, caller].postln;\n if(caller.isKindOf(XiiBufferPlayer), {\n caller.viewerList[chnl] = view;\n \"caller viewer :\".post; caller.viewerList[chnl].postln;\n });\n if(caller.isKindOf(XiiBufferPool), {\n \"caller is bufferpool\".postln;\n caller.refreshBuffers; // refresh the buffer name (adding _CR)\n });\n }.defer(0.5);\n });\n\n numFrames"}
+{"text": " (adding _CR)\n });\n }.defer(0.5);\n });\n\n numFramesView = GUI.staticText.new(win, Rect(348, 222, 80, 12))\n .font_(GUI.font.new(\"Helvetica\", 9))\n .string_(\"frames : \"+ selArray[1] );\n\n selStartView = GUI.staticText.new(win, Rect(420, 222, 80, 12))\n .font_(GUI.font.new(\"Helvetica\", 9))\n .string_(\"selStart : \"+ selArray[0] );\n\n selEndView = GUI.staticText.new(win, Rect(495, 222, 80, 12))\n .font_(GUI.font.new(\"Helvetica\", 9))\n .string_(\"selEnd : \"+ selArray[1] );\n\n \n loopButt = OSCIIRadioButton(win, Rect(696,197,14,14), \"loop\")\n .font_(GUI.font.new(\"Helvetica\", 9))\n .action_({arg val; \n if(val==1, { loop = true }, { loop = false });\n });\n\n playButt = GUI.button.new(win, Rect(740, 195, 43, 18))\n .states_([[\"play\",Color.black,Color.clear], [\"stop\",Color.black, XiiColors.onbutton]])\n .font_(GUI.font.new(\"Helvetica\", 9))\n .action_({arg butt;\n "}
+{"text": "_(GUI.font.new(\"Helvetica\", 9))\n .action_({arg butt;\n start = sndfileview.selections[0][0]; // the start\n end = start + sndfileview.selectionSize(0); // end of the selection\n if(sndfileview.selectionSize(0) < 10, {\n end = soundfile.numFrames-1;\n seltime = (soundfile.numFrames-start)/44100;\n }, { \n seltime = sndfileview.selections[0][1]/44100;\n });\n if(butt.value == 1, {\n synthRunFlag = true;\n if(loop == false, {\n if(chNum == 1, {\n synth = Synth(\\xiiPlayBufXSndFileView1x1, \n [\\out, outbus, \\bufnum, buffer.bufnum, \\start, start, \n \\end, end, \\out, outbus, \\vol, vol]);\n }, {\n synth = Synth(\\xiiPlayBufXSndFileView2x2, \n [\\out, outbus, \\bufnum, buffer.bufnum, \\start, start, \n \\end, end, \\out, outbus, \\vol, vol]);\n });\n }, {\n if(chNum == 1, {\n synth = Synth(\\xiiLoopBufXSndFileView1x1, \n [\\out, outbus, \\bufnum, buffer.bufnum, \\start, start, \n \\end, end, \\out, outbus, \\vol, vol"}
+{"text": "bufnum, \\start, start, \n \\end, end, \\out, outbus, \\vol, vol]);\n }, {\n synth = Synth(\\xiiLoopBufXSndFileView2x2, \n [\\out, outbus, \\bufnum, buffer.bufnum, \\start, start, \n \\end, end, \\out, outbus, \\vol, vol]);\n });\n });\n this.startTimeCursor;\n }, { \n timeCursorTask.stop;\n resetclock.clear;\n synth.free; \n synthRunFlag=false;\n });\n })\n .focus(true);\n \n win.onClose_({ \n // write window position to archive.sctxar\n this.close;\n //caller.postln;\n if(caller.isKindOf(XiiBufferPlayer), {\n // \"caller is bufferplayer\".postln;\n caller.viewerList[chnl] = nil;\n });\n point = Point(win.bounds.left, win.bounds.top);\n Archive.global.at(\\win_position).put(poolname.asSymbol, point);\n }); \n } \n \n startTimeCursor {\n resetclock.clear;\n timeCursorTask.stop;\n \n timeCursorTask = Task({ var pos; \n pos = 0;\n if(loop == false, { // not looping\n resetclock = SystemClock.sched(seltime, { \n {play"}
+{"text": " // not looping\n resetclock = SystemClock.sched(seltime, { \n {playButt.value_(0)}.defer; \n if(synthRunFlag, {synth.free}); synthRunFlag=false; \n {sndfileview.timeCursorPosition_(start)}.defer;\n timeCursorTask.stop;\n nil});\n inf.do({\n {\n win.isClosed.not.if({ // if window is not closed, update...\n sndfileview.timeCursorPosition_(start+pos)\n })\n }.defer;\n pos = pos + (Server.default.sampleRate/10);\n 0.1.wait;\n });\n }, { // looping\n resetclock = SystemClock.sched(seltime, {\n {sndfileview.timeCursorPosition_(start)}.defer;\n timeCursorTask.reset;\n pos = 0;\n nil;\n });\n \n inf.do({\n {\n win.isClosed.not.if({ // if window is not closed, update...\n sndfileview.timeCursorPosition_(start+pos)\n })\n }.defer;\n\n pos = pos + (Server.default.sampleRate/10);\n //{sndfileview.timeCursorPosition_(start+pos)}.defer;\n 0.1.wait;\n });\n })\n }).start;\n }\n \n close { \n timeCursorTask.stop;"}
+{"text": ");\n })\n }).start;\n }\n \n close { \n timeCursorTask.stop; \n resetclock.clear;\n if(synthRunFlag, {synth.free});\n win.close;\n }\n \n setBufferPlayerSelections {arg startPos, numSelectedFrames;\n // \" -- start, numSelectedFrames\".post; [startPos, numSelectedFrames].postln;\n sndfileview\n .setSelectionStart(1, startPos)\n .setSelectionSize(1, numSelectedFrames) // size in frames\n\n }\n \n}\n```"}
+{"text": "SuperCollider classlib — miSCellaneous_lib/Classes/HS/PHelpSynthPlayer.sc\n\n```supercollider\n Created: 2026-09-24, version 0.24.1\n Copyright (C) 2009-2026 Daniel Mayer\n Email: daniel-mayer@email.de\n URL: http://daniel-mayer.at\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n*/\n\nPHSplayer : PHelpSynthPlayer {}\n\nPHelpSynthPlayer : PHelpSynthUsePlayer {\n\n *new { arg pHelpSynth;\n ^super.new(pHelpSynth);\n }\n \n play { |clock, quant, hsPlay = true, pbindPlay = true"}
+{"text": "ynth);\n }\n \n play { |clock, quant, hsPlay = true, pbindPlay = true, quantBufferTime = 0.2|\n var startQuant, demandQuant, receiveQuant, thisClock = clock ?? TempoClock.default, adaptQuant = true, latestQuant, hsStartFunc;\n\n (justPlaying.not && justStopping.not).if {\n justPlaying = true;\n #startQuant, demandQuant, receiveQuant = \n helpSynth.makeAdaptedQuants(thisClock, quant.asQuant, adaptQuant, quantBufferTime);\n latestQuant = [startQuant, demandQuant, receiveQuant].sort({|x,y| x.phase <= y.phase}).last;\n Task({ justPlaying = false; }).play(thisClock, quant: latestQuant);\n \n isPlaying.not.if {\n (hsPlay == true).not.if {\n Error(\"hsPlay must be true at first call of play - false at resume only\").throw;\n };\n helpSynth.hasJustStartedWithPause.not.if { helpSynth.allocBus };\n \n CmdPeriod.add(this);\n helpSynth.isListening.not.if { \n helpSynth.listen(pHelpSynth.relDemandIndexUserNums.size);\n };\n helpSynth.updateDemandIndexOffsets(pHelpSynth);\n helpSynth.resetInitSeconds;\n \n hsStartFunc = helpSynth."}
+{"text": ");\n helpSynth.resetInitSeconds;\n \n hsStartFunc = helpSynth.hasJustStartedWithPause.if {\n \n { helpSynth.schedRun(true, helpSynth.demandLatency) }\n }{\n { helpSynth.play(pHelpSynth.helpSynthArgs ?? [], helpSynth.demandLatency) }\n };\n \n Task(hsStartFunc).play(clock, quant: startQuant);\n\n #helpSynthDemandPlayer, helpSynthReceivePlayer = \n [\\demandPattern, \\receivePattern].collect({|x| pHelpSynth.perform(x).asEventStreamPlayer});\n helpSynth.demandStreams_indexOffsets.put(helpSynthDemandPlayer.originalStream, helpSynth.lastDemandIndexOffset);\n helpSynth.receiveStreams_indexOffsets.put(helpSynthReceivePlayer.originalStream, helpSynth.lastDemandIndexOffset);\n\n pbindPlay.if {\n helpSynthDemandPlayer.play(clock, quant: demandQuant);\n helpSynthReceivePlayer.play(clock, quant: receiveQuant);\n isPbindPlaying = true;\n };\n \n helpSynth.mainPHSplayer = this;\n // players are freed separately with CmdPeriod (free)\n // [helpSynthDemandPlayer, helpSynthReceivePlayer"}
+{"text": "iod (free)\n // [helpSynthDemandPlayer, helpSynthReceivePlayer].do({|x| CmdPeriod.remove(x)}); \n helpSynth.isPHSplaying = true;\n isPlaying = true;\n \n helpSynth.hasJustStartedWithPause.if { helpSynth.hasJustStartedWithPause = false };\n }{\n hsPlay.if { Task({ helpSynth.schedRun(true, helpSynth.demandLatency) }).play(clock, quant: startQuant); };\n (pbindPlay && isPbindPlaying.not).if {\n helpSynthDemandPlayer.play(clock, quant: demandQuant);\n helpSynthReceivePlayer.play(clock, quant: receiveQuant);\n isPbindPlaying = true;\n }\n }\n }\n }\n\n stop { |hsStop = false, pbindStop = true, addAction|\n var clock = helpSynthReceivePlayer.clock, hsStopLatency, \n nextDemandAbs, stopAbs, stopBufferTime = 0.1;\n\n (justPlaying.not && justStopping.not).if {\n justStopping = true;\n stopAbs = stopBufferTime * clock.tempo + clock.beats;\n hsStopLatency = helpSynth.demandLatency * clock.tempo; \n clock.schedAbs(stopAbs, {\n (isPbindPlaying && pbindStop).if {\n nextD"}
+{"text": "(stopAbs, {\n (isPbindPlaying && pbindStop).if {\n nextDemandAbs = helpSynthDemandPlayer.nextBeat;\n hsStop.if {\n helpSynth.schedRun(false, nextDemandAbs - clock.beats / clock.tempo + hsStopLatency); \n };\n helpSynthDemandPlayer.stop; \n clock.schedAbs(helpSynth.totalLatency * clock.tempo + clock.beats, { helpSynthReceivePlayer.stop; isPbindPlaying = false; });\n clock.schedAbs((helpSynth.totalLatency + cleanupDelay) * clock.tempo + clock.beats, { addAction.value; nil; });\n clock.schedAbs((helpSynth.totalLatency + cleanupDelay) * clock.tempo + nextDemandAbs, { justStopping = false; }); \n }{\n clock.schedAbs(cleanupDelay * clock.tempo + stopAbs, { justStopping = false; }); \n hsStop.if { helpSynth.schedRun(false, hsStopLatency); };\n };\n nil;\n })\n }\n }\n \n pause { |hsStop = true, pbindStop = true, addAction|\n this.stop(hsStop, pbindStop, addAction);\n }\n \n cmdPeriod { this.free }\n \n free {\n isPlaying.not.if {\n // \"Player not playing\".warn;\n "}
+{"text": "\n \n free {\n isPlaying.not.if {\n // \"Player not playing\".warn;\n }{\n helpSynthDemandPlayer.stop;\n helpSynthReceivePlayer.stop;\n helpSynth.isPHelpSynthPlaying = false; \n isPlaying = false;\n isPbindPlaying = false;\n\n helpSynth.otherPHSusePlayers.do(_.free);\n SystemClock.sched(helpSynth.totalLatency + cleanupDelay, { this.clearBookkeeping; });\n helpSynth.free(helpSynth.totalLatency + cleanupDelay);\n };\n CmdPeriod.remove(this);\n }\n}\n```"}
+{"text": "SuperCollider classlib — miSCellaneous_lib/Classes/Sieves/Sieve.sc\n\n```supercollider\n Created: 2026-09-24, version 0.24.1\n Copyright (C) 2009-2026 Daniel Mayer\n Email: daniel-mayer@email.de\n URL: http://daniel-mayer.at\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n*/\n\nSieve {\n\n classvar <>limit = 65536;\n\n var > { |addOffset| ^this.shift(addOffset) }\n\n shiftTo { |targetOffset|\n ^(mode == \\points).if {\n (list.size != 0).if { this.shift(targetOffset - list[0]) }{ this }\n }{\n offset.isNil.if { this }{ this.shift(targetOffset - offset) }\n }\n }\n\n >>! { |targetOffset| ^this.shiftTo(targetOffset) }\n\n shiftToZero { ^list.shiftTo(0) }\n\n // we want to copy the Sieve's list too\n copy { ^this.deepCopy }\n\n // new Sieve, same list object\n weakCopy { ^this.superPerform(\\copy) }\n\n // take over mode and offset from Sieve and pass an appropriate array\n copyWith { |seqCollection, withCheck = true|\n var new = this.weakCopy;\n\n seqCollection.isKindOf(SequenceableCollection).not.if {\n SimpleInitError(\n \"copyWith expects SequenceableCollection as first arg\"\n ).throw\n };\n\n seqCollection.every(_.isInteger).not.if {\n SimpleInitError(\n \"SequenceableCol"}
+{"text": "y(_.isInteger).not.if {\n SimpleInitError(\n \"SequenceableCollection must consist of Integers\"\n ).throw\n };\n\n (mode == \\points).if {\n withCheck.if {\n (seqCollection.every { |point, i|\n (point > 0) and: { (i == 0) or: { point > seqCollection[i-1] } }\n }).not.if {\n SimpleInitError(\n \"With mode = \\points SequenceableCollection \" ++\n \"must be strictly ascending\"\n ).throw\n }\n };\n }{\n withCheck.if {\n seqCollection.every(_>0).not.if {\n SimpleInitError(\n \"With mode = \\intervals SequenceableCollection\" ++\n \"must consist of positive Integers\"\n ).throw\n }\n };\n }\n ^new.miSC_setList(seqCollection.asList)\n }\n\n // apply operator or Function to List and pass the result\n // to a new Sieve with copied mode and offset\n copyApplyTo { |operator, withCheck = true|\n ^this.copyWith(operator.applyTo(this.list), withCheck)\n }\n\n // equality also considers different modes\n == { |that|\n ^(this.mode == that.mode).if {\n list == that.list and: { this.offset == that.offset }\n }{\n (this.mode == \\points).if {\n this == that.weakCopy.toPoints\n }{\n that == this.weakCopy.toPoints\n "}
+{"text": "akCopy.toPoints\n }{\n that == this.weakCopy.toPoints\n }\n }\n }\n\n // segment methods are most efficient for receiver of mode == \\points,\n // output is new Sieve object of mode \\points anyway\n segmentGreaterEqual { |lo|\n var index, point, sieve, doCheck = true;\n sieve = Sieve.newEmpty;\n ^(mode == \\points).if {\n (list.size != 0).if {\n index = list.miSC_lowestIndexForWhichGreaterEqual(lo);\n index.notNil.if { sieve.miSC_setList(list.copyRange(index, list.size-1)) }\n };\n sieve\n }{\n offset.notNil.if {\n point = offset;\n (offset >= lo).if { sieve.list.add(point); doCheck = false };\n\n list.do { |interval|\n point = point + interval;\n doCheck.if {\n (point >= lo).if { doCheck = false; sieve.list.add(point) }\n }{\n sieve.list.add(point)\n }\n }\n };\n sieve\n }.miSC_setMode(\\points);\n }\n\n segmentLessEqual { |hi|\n var index, point, sieve;\n sieve = Sieve.newEmpty;\n ^(mode == \\points).if {\n (list.size != 0).if {\n index = list.miSC_highestIndexForWhichLessEqual(hi);\n index.notNil.if { sieve.mi"}
+{"text": "hestIndexForWhichLessEqual(hi);\n index.notNil.if { sieve.miSC_setList(list.copyRange(0, index)) }\n };\n sieve\n }{\n offset.notNil.if {\n point = offset;\n index = 0;\n while { index <= (list.size-1) }{\n point = point + list[index];\n (point <= hi).if { sieve.list.add(point) }{ index = list.size - 1 };\n index = index + 1;\n }\n };\n sieve\n }.miSC_setMode(\\points);\n }\n\n // extra method is more efficient than to apply segmentLessEqual and segmentGreaterEqual\n segmentBetweenEqual { |lo, hi|\n var index, point, sieve, doLoCheck = true, loIndex, hiIndex;\n sieve = Sieve.newEmpty;\n ^(lo > hi).if {\n sieve\n }{\n (mode == \\points).if {\n (list.size != 0).if {\n loIndex = list.miSC_lowestIndexForWhichGreaterEqual(lo);\n hiIndex = list.miSC_highestIndexForWhichLessEqual(hi);\n (loIndex.isNil or: { hiIndex.isNil }).if {\n sieve\n }{\n sieve.miSC_setList(list.copyRange(loIndex, hiIndex))\n }\n }{\n sieve\n }\n }{\n offset.notNil.if {\n point = offset;\n index"}
+{"text": " sieve\n }\n }{\n offset.notNil.if {\n point = offset;\n index = 0;\n while { index <= (list.size-1) }{\n point = point + list[index];\n\n doLoCheck.if {\n (point >= lo).if {\n doLoCheck = false;\n (point <= hi).if {\n sieve.list.add(point)\n }{\n index = list.size - 1\n };\n }\n }{\n (point <= hi).if {\n sieve.list.add(point)\n }{\n index = list.size - 1\n };\n };\n index = index + 1;\n }\n };\n sieve\n }\n }.miSC_setMode(\\points);\n }\n\n segmentGreater { |lo| ^this.segmentGreaterEqual(lo + 1) }\n\n >=! { |lo| ^this.segmentGreaterEqual(lo) }\n >! { |lo| ^this.segmentGreaterEqual(lo + 1) }\n\n segmentLess { |hi| ^this.segmentLessEqual(hi - 1) }\n\n <=! { |hi| ^this.segmentLessEqual(hi) }\n =! { |bounds| ^this.segmentBetweenEqual(*bounds"}
+{"text": ", hi]\n <>=! { |bounds| ^this.segmentBetweenEqual(*bounds) }\n <>! { |bounds| ^this.segmentBetweenEqual(bounds[0] + 1, bounds[1] - 1) }\n\n printOn { arg stream;\n if (stream.atLimit, { ^this });\n stream << \"Sieve(\" ;\n stream << (this.mode.asString ++ \", \");\n (this.mode == \\intervals).if { stream << (this.offset.asString ++ \", \") };\n list.printOn(stream);\n stream << \")\" ;\n }\n\n storeOn { arg stream;\n var thisMode;\n if (stream.atLimit, { ^this });\n\n stream << \"[ \" ;\n list.storeItemsOn(stream);\n stream << \" ]\" ;\n\n stream << \".toSieve(\";\n stream << offset.asString;\n stream << \", \\\\\";\n thisMode = this.mode.asString;\n stream << thisMode;\n stream << \", \\\\\";\n stream << thisMode;\n stream << \")\";\n }\n\n // private\n\n // These setters don't check the Sieve's state,\n // the user should not directly set mode and offset.\n\n miSC_setMode { |v| mode = v }\n miSC_setOffset { |v| offset = v }\n miSC_setList { |v| list = v }\n\n miSC_sieveOp { |args, withOffsets = false, doSum = false, op|\n var goOn = true, last, counts, items, offsets, limit, next,\n minIndices, min, leftIndices,"}
+{"text": "n = true, last, counts, items, offsets, limit, next,\n minIndices, min, leftIndices, counter, minIndicesDict = IdentityDictionary.new,\n indicesQueue = PriorityQueue.new;\n\n #items, offsets, limit = (withOffsets.if {\n this.miSC_checkOffsetArgs(args);\n }{\n this.miSC_checkArgs(args);\n });\n\n offsets.isNil.if { offsets = 0!(items.size) };\n\n // adjust offset if Sieve is passed\n items.do { |item, i|\n item.isKindOf(Sieve).if {\n // set to nil with empty Sieve\n offsets[i] = (item.mode == \\points).if {\n (item.list.size != 0).if { offsets[i] + item.list[0] };\n }{\n item.offset.notNil.if { offsets[i] + item.offset };\n }\n }\n };\n\n items = items.collect(_.miSC_streamifySieveItems);\n counts = offsets;\n counts.do { |offset, i|\n ((offset.notNil) and: { offset <= limit }).if {\n indicesQueue.put(offset, i);\n leftIndices = leftIndices.add(i);\n }\n };\n\n mode = doSum.if { \\points }{ \\intervals };\n\n leftIndices.notNil.if { while { goOn }{\n // partial sums stored in PriorityQueue\n min = indicesQueue.topPriority.round.asInteger;\n minIndices = indicesQueue."}
+{"text": "icesQueue.topPriority.round.asInteger;\n minIndices = indicesQueue.pop;\n\n // if more than one min is found, indices are collected in Dictionary\n while { indicesQueue.topPriority == min }{\n minIndices.isInteger.if {\n minIndicesDict.clear;\n minIndices = minIndicesDict.put(minIndices, true)\n };\n minIndicesDict.put(indicesQueue.pop, true)\n };\n\n // operator decides what happens at this partial sum\n doSum.if {\n case\n { op == \\u }\n { list.add(min); last = min }\n { op == \\s }\n { (minIndices.size == items.size).if { list.add(min); last = min } }\n { op == \\sd }\n { minIndices.isInteger.if { list.add(min); last = min } }\n { op == \\d }\n { (minIndices == 0).if { list.add(min); last = min } }\n }{\n case\n { op == \\u }\n {\n last.notNil.if { list.add(min - last) }{ offset = min };\n last = min\n }\n { op == \\s }\n {\n (minIndices.size == items.size).if {\n last.notNil.if { list.add(min - last) }{ offset = min };\n last = min\n }\n }\n { op == \\sd }\n {\n minIndices.isInteger.if {\n last.notNil.if { list.add(min - last) }{ offset = min };\n last = min\n }\n }\n { op == \\d }\n {\n (minIndices == 0).if {\n last.notNil.if {"}
+{"text": "\n { op == \\d }\n {\n (minIndices == 0).if {\n last.notNil.if { list.add(min - last) }{ offset = min };\n last = min\n }\n }\n };\n\n // faster than minIndices.asArray.do { ...\n counter = { |i|\n next = items[i].next;\n next.notNil.if {\n counts[i] = counts[i] + next;\n (counts[i] <= limit).if { indicesQueue.put(counts[i], i) }\n };\n (next.isNil or: { counts[i] > limit }).if { leftIndices.remove(i) };\n };\n minIndices.isInteger.if { counter.(minIndices) }{ minIndices.keysDo(counter.(_)) };\n\n case\n { op == \\u }\n { (leftIndices.size == 0).if { goOn = false } }\n { op == \\s }\n { (leftIndices.size < (items.size)).if { goOn = false } }\n { op == \\sd }\n { (leftIndices.size == 0).if { goOn = false } }\n { op == \\d }\n { (leftIndices[0] != 0).if { goOn = false } };\n } };\n\n ^this\n }\n\n miSC_checkOffsetArgs { |args|\n var offsets, items, limit, maxSize = args.size,\n classes = [Integer, Pattern, Stream, Sieve];\n args.size.odd.if {\n limit = args.last.value;\n limit.isKindOf(Integer).not.if {\n SimpleInitError(\n \"l"}
+{"text": "\n limit.isKindOf(Integer).not.if {\n SimpleInitError(\n \"limit -- given as last item of an odd number \" ++\n \"of args --\\n must be or eveluate to an Integer\").throw\n };\n maxSize = maxSize - 1\n }{\n limit = Sieve.limit\n };\n maxSize.do { |i|\n i.even.if {\n items = items.add(args[i])\n }{\n offsets = offsets.add(args[i])\n }\n };\n items.every { |x| classes.any(x.isKindOf(_)) }.not.if {\n SimpleInitError(\n \"Sieve base items must be Integers > 0, Sieves or: \\n\" ++\n \"Patterns or Streams to make Integers > 0 (intervals)\"\n ).throw\n };\n items.any { |x| x.isKindOf(Integer) and: { x <= 0 } }.if {\n SimpleInitError(\"Integers as sieve bases must be > 0\").throw\n };\n offsets.every { |x| x.isKindOf(Integer) }.not.if {\n SimpleInitError(\"Offsets must be Integers\").throw\n };\n ^[items, offsets, limit]\n }\n\n miSC_checkArgs { |args|\n var items = args, limit,\n classes = [Integer, Pattern, Stream, Sieve];\n\n args.last.isKindOf(Ref).if {\n items = items.drop(-1);\n // if new gets a Ref eval twice\n limit = args.last.value.value;\n limit.isKind"}
+{"text": " if new gets a Ref eval twice\n limit = args.last.value.value;\n limit.isKindOf(Integer).not.if {\n SimpleInitError(\"limit -- given as last arg wrapped \" ++\n \"into a Ref object --\\n\" ++\n \"must be an Integer\"\n ).throw\n }\n }{\n limit = Sieve.limit\n };\n items.every { |x| classes.any(x.isKindOf(_)) }.not.if {\n SimpleInitError(\n \"Sieve base items must be Integers > 0, Sieves or: \\n\" ++\n \"Patterns or Streams to make Integers > 0 (intervals)\"\n ).throw\n };\n items.any { |x| x.isKindOf(Integer) and: { x <= 0 } }.if {\n SimpleInitError(\"Integers as sieve bases must be > 0\").throw\n };\n ^[items, nil, limit]\n }\n}\n\n+SequenceableCollection {\n\n // iterated bisection, expects ordered list\n miSC_lowestIndexForWhichGreaterEqual { |lo|\n var goOn = true, loIndex = 0, hiIndex = this.size - 1, newIndex, index;\n\n (this[hiIndex] < lo).if { goOn = false };\n (this[loIndex] >= lo).if { goOn = false; index = 0 };\n\n while { goOn }{\n ((hiIndex - loIndex) <= 1).if { goOn = false; index = hiIndex };\n newIndex = div(hiIndex + loInde"}
+{"text": " false; index = hiIndex };\n newIndex = div(hiIndex + loIndex, 2);\n\n (this[newIndex] == lo).if { goOn = false; index = newIndex };\n (this[newIndex] < lo).if { loIndex = newIndex }{ hiIndex = newIndex };\n };\n\n ^index\n }\n\n // iterated bisection, expects ordered list\n miSC_highestIndexForWhichLessEqual { |hi|\n var goOn = true, loIndex = 0, hiIndex = this.size - 1, newIndex, index;\n\n (this[loIndex] > hi).if { goOn = false };\n (this[hiIndex] <= hi).if { goOn = false; index = hiIndex };\n\n while { goOn }{\n ((hiIndex - loIndex) <= 1).if { goOn = false; index = loIndex };\n newIndex = div(hiIndex + loIndex, 2);\n\n (this[newIndex] == hi).if { goOn = false; index = newIndex };\n (this[newIndex] > hi).if { hiIndex = newIndex }{ loIndex = newIndex };\n };\n\n ^index\n }\n\n}\n```"}
+{"text": "SuperCollider classlib — miSCellaneous_lib/Classes/VarGui/extInteger_2.sc\n\n```supercollider\n Created: 2026-09-24, version 0.24.1\n Copyright (C) 2009-2026 Daniel Mayer\n Email: daniel-mayer@email.de\n URL: http://daniel-mayer.at\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n*/\n\n+Integer {\n\n miSC_partMax { |part|\n ^(part.size + 1).collect {|i|\n case\n { i == 0 }{ part[i] }\n { i == part.size }{ this - part[i - 1] }\n { true }{ part[i] - part[i - 1] }\n }.maxItem;\n }\n\n miSC_eqPart { |p"}
+{"text": "i] - part[i - 1] }\n }.maxItem;\n }\n\n miSC_eqPart { |part, k|\n // search for quite equal partitions, needed for column break\n // part expects ordered list that describes a partition of the integer by indices (ascending numbers > 0, < given integer)\n // gives a new partition with k indices\n var eqPart, subPart, eqSubPart, newEqSubPart, min, newMin, div, l, m, r, deltaLo, deltaHi, eqIndex;\n case \n { k == (part.size + 1) }\n { eqPart = part }\n { k > (part.size + 1) }\n { Error(\"no possible partition\").throw; }\n { k == 2 }\n { \n m = part.size;\n r = part.detectIndex(_ >= (this/2));\n case\n { r.isNil }\n { eqPart = [part[m-1]] }\n { r == 0 }\n { eqPart = [part[0]] }\n { true }{ \n deltaLo = (this/2) - part[r - 1];\n deltaHi = part[r] - (this/2);\n eqPart = (deltaLo >= deltaHi).if { [part[r]] }{ [part[r - 1]] };\n }\n }\n { true }\n { \n // search around k-th part, then go on recursively\n\n l = 0;\n div = this/k;\n while { \n (r.isNil) && (l < (part.size - k)) \n }{ \n (part[l] >= div).if { r = l };\n l = l + 1"}
+{"text": ")) \n }{ \n (part[l] >= div).if { r = l };\n l = l + 1;\n };\n \n ((r.isNil) || (r == 0)).if {\n eqIndex = ((r.isNil).if { part.size - k }{ 0 });\n subPart = part.drop(eqIndex + 1) - part[eqIndex];\n eqSubPart = (this - part[eqIndex]).miSC_eqPart(subPart, k - 1);\n }{\n [r - 1, r].do {|i,j|\n subPart = part.drop(i+1) - part[i];\n newEqSubPart = (this - part[i]).miSC_eqPart(subPart, k - 1);\n newMin = max(part[i], (this - part[i]).miSC_partMax(newEqSubPart));\n ((j == 0) or: { newMin < min }).if {\n min = newMin;\n eqIndex = i;\n eqSubPart = newEqSubPart;\n };\n };\n };\n eqPart = [part[eqIndex]] ++ (eqSubPart + part[eqIndex]); };\n ^eqPart\n }\n \n \n}\n```"}
+{"text": "SuperCollider schelp — miSCellaneous_lib/HelpSource/Classes/Fb1_Lorenz.schelp\n\nFb1_Lorenz —\nLorenz pseudo ugen\nCategory: Libraries>miSCellaneous>Nonlinear\nSee also: Overviews/miSCellaneous, Guides/Introduction_to_miSCellaneous, Classes/Fb1, Classes/GFIS, Classes/Fb1_ODE, Classes/Fb1_ODEdef, Classes/Fb1_ODEintdef, Classes/Fb1_MSD, Classes/Fb1_SD, Classes/Fb1_Hopf, Classes/Fb1_HopfA, Classes/Fb1_HopfAFDC, Classes/Fb1_VanDerPol, Classes/Fb1_Duffing\n\n\n\nFb1_ODE wrapper for the Lorenz ODE system:\n\nu'(t) = s * (v(t) - u(t))\n\nv'(t) = (u(t) * (r - w(t))) - v(t)\n\nw'(t) = (u(t) * v(t)) - (b * w(t))\n\nIt returns a 3-channel signal. See Fb1_ODE for general information about Fb1 ODE integrator UGens.\n\nHISTORY AND CREDITS: Big credit to David Pirrò from IEM Graz for pointing me to the symplectic integration methods, which are essential for audifying ODEs, as they help to ensure numeric stability in the long run (e.g. to avoid drifts of"}
+{"text": "ifying ODEs, as they help to ensure numeric stability in the long run (e.g. to avoid drifts of oscillations that are mathematically expected to be regular). See the chapter on integration in his dissertation #[2], pp 135-146. You might also want check David Pirròs optimized ODE compiler named Henri #[3]. Big credit also to Nathaniel Virgo who brought up the buffering strategy used in Fb1, which is Fb1_ODE's working horse.\n\nWarning:\nEspecially with self-defined ODEs the usage of this class is – inherently – highly experimental. Be careful with amplitudes, as always with feedback it can become loud! Sudden blowups might result form the mathematical characteristics of the ODE systems or they might come from parameter changes on which ODEs can react extremely sensitive to, they can also stem from numerical accumulation effects. It is highly recommended to take precautionary measures, e.g. by limiting/distorting operators (tanh, clip, softclip, distort) with the compose option (See Fb1_ODE#Examples 5#Fb1_ODE Examples 5) and/or external limiting and/or using MasterFX from the JITLibExtensions quark.\n\nNote:\nThe convenience of direct definition of the ODE relation comes with the price of a large number of UGens involved. You might want to allow a higher number of UGens with the server option numWireBufs. For a nice workflow I'd recommended to take reduced blockSizes (e.g. 1, 2, 4, 8, 16) while experimenting as compile time is short"}
+{"text": " reduced blockSizes (e.g. 1, 2, 4, 8, 16) while experimenting as compile time is shorter, but once you have finished the design of a SynthDef it might pay going back to blocksize 32 or 64 for runtime efficiency, especially if many kr UGens are involved.\n\n## References\n\n- Trefethen, Lloyd N.; Birkisson Ásgeir; Driscoll, Tobin A. (2017): Exploring ODEs. SIAM - Society for Industrial and Applied Mathematics. Free download from: https://people.maths.ox.ac.uk/trefethen/Exploring.pdf\n- Pirrò, David (2017). Composing Interactions. Dissertation. Institute of Electronic Music and Acoustics, University of Music and Performing Arts Graz. Free download from: https://pirro.mur.at/media/pirro_david_composing_interactions_print.pdf\n- https://git.iem.at/davidpirro/henri\n\n## new\n\nCreates a new Fb1_Lorenz ar object.\n\n- s:\nDefaults to 10.\n\n- r:\nDefaults to 30.\n\n- b:\nDefaults to 2.\n\n- tMul:\nTime multiplier, which determines velocity of proceeding in the dynamic system. The default value 1 means that the step delta of time equals 1 / sample duration. For getting audible oscillations you might, depending on the ODE definition, have to pass much higher values. Can also be a kr / ar UGen and might also be negative.\n\n"}
+{"text": " definition, have to pass much higher values. Can also be a kr / ar UGen and might also be negative.\n\n- t0:\nInitial time. Expects Number. Defaults to 0.\n\n- y0:\nInitial value of the ODE. Expects array of size 3. Defaults to #[1, 1, 1].\n\n- intType:\nIntegration type. Expects one of the Symbols, for which procedures are stored with Fb1_ODEintdef. The use of symplectic procedures (with prefix 'sym') is highly recommended. Defaults to \\sym2. For more accurate integration you can try symplectic procedures of higher order like \\sym4, \\sym8 etc. Families of integration procedures:\n\n- Symplectic: \\sym2, \\sym2_d, \\sym4, \\sym4_d, \\sym6, \\sym6_d, \\sym8, \\sym8_d, \\sym12, \\sym12_d, \\sym16, \\sym16_d, \\sym32, \\sym32_d, \\sym64, \\sym64_d\n- Euler: \\eu, \\eu_d, \\eum, \\eum_d, \\eui, \\eui_d\n- Prediction-Evaluation-Correction: \\pec, \\pece, \\pecec, \\pecece\n- Runge-Kutta: \\rk3, \\rk3_d, \\rk3h, \\rk3h_d, \\rk4, \\rk4_d\n- Adams-Bashforth: \\ab2, \\ab3, \\ab4, \\ab5, \\ab6\n- Adams-Bashforth-Moul"}
+{"text": "ab2, \\ab3, \\ab4, \\ab5, \\ab6\n- Adams-Bashforth-Moulton: \\abm21, \\abm22, \\abm32, \\abm33, \\abm43, \\abm44, \\abm54, \\abm55, \\abm65, \\abm66\n\n- compose:\nOperator(s) / Function(s) to be applied to the system value on a per-sample base. This of course blurs the numeric procedure but can be used for containing or in a creative way. Can be an operator Symbol, a Function or an arbitrarily mixed SequenceableCollection thereof. The Functions are in any case expected to take an array (the system state) as first argument. If only one Function is given it must output an array of same (system) size. Within a SequenceableCollection a Function must output a value of size 0. Within a SequenceableCollection an operator Symbol is applied only to the corresponding component. A Function can optionally take a second argument which is for ar UGens passed via composeArIn.\n\n- composeArIn:\nar UGen or SequenceableCollection thereof or a SequenceableCollection that can contain both. This is the way to use ar UGens within a Function passed to compose. UGens are passed to the Function's second argument.\n\n- dt0:\nFirst time delta in seconds to be used for the language-side calculation of first values of a multi-step intType procedure. This will mostly be irrelevant as (single-step) symplectic procedures are to be preferred. In case of a multi-step procedure a dt0 value will be derived from the default server's properties (sample duration * tMul).\n\n- argL"}
+{"text": " value will be derived from the default server's properties (sample duration * tMul).\n\n- argList0:\nInitial argList value(s) to be used for the language-side calculation of first values of a multi-step intType procedure. This will mostly be irrelevant as (single-step) symplectic procedures are to be preferred. If no UGens are passed to argList, values will be assumed from passed argList Numbers.\n\n- init_intType:\nIntegration type for language-side calculation of first values of a multi-step intType procedure. This will mostly be irrelevant as (single-step) symplectic procedures are to be preferred. Defaults to \\sym8.\n\n- withOutScale:\nBoolean. Determines if the Fb1_ODEdef's default scaling values for integration and differential signals should be applied to the output. Defaults to true.\nWarning: withOutScale does not implement a general safety net functionality, withOutScale's default value true does by no means say that output is limited. The default scaling values of predefined Fb1_ODEdefs are average assumptions and can, under different circumstances, always lead to high out levels.\n\n- withDiffChannels:\nBoolean. Determines if channel(s) with differential value(s) should be returned. This is only applicable with integration types with a sizeFactor == 2, which means that for every sample the values of the differential are buffered. As by default this is not the case for all predefined numeric procedures, there exist variants with appendix '_d', e.g. \\sym2_d. Defaults"}
+{"text": "cedures, there exist variants with appendix '_d', e.g. \\sym2_d. Defaults to false.\n\n- withTimeChannel:\nBoolean. Determines if accumulated time is output in an additional channel.\nWarning: with constant tMul it produces an ascending DC which is not affected by leakDC if this is set to true. Might especially be of interest if time is modulated. Defaults to false.\n\n- blockSize:\nInteger, this should be the server blockSize. If no Integer is passed, the current default server's blockSize is assumed (in contrast to Fb1). So explicitely passing a blockSize should only be necessary in special cases, e.g. when compiling before booting. However for a pleasant workflow for ar usage it's recommended to use Fb1_ODE with a reduced server blockSize in order to reduce SynthDef compile time.\n\n- graphOrderType:\n0, 1 or 2. Determines if topological order of generated BufRd and BufWr instances in the SynthDef graph is forced by additional UGens.\n\n##Type 0: forced graph order is turned off.\n##Type 1 (default): graph order is forced by summation and miSCellaneous>WaveFolding\nSee also: Overviews/miSCellaneous, Guides/Introduction_to_miSCellaneous, Classes/SmoothClipS, Classes/SmoothClipQ, Classes/SmoothFoldS, Classes/SmoothFoldQ, Classes/SmoothFoldS2, Classes/SmoothFoldQ2\n\n\n\nWave folding is a synthesis technique from analog days, going back to Donald Buchla and the tradition of west coast synthesis. Smooth clipping and folding pseudo ugens from miSCellaneous lib come in variants which include quadratic and sinusoidal waveshaping and allow clipping and folding without aliasing. This can also be used for buffer scratching, a synthesis technique which I have been experimenting with recently with great fun.\n\nExamples:\n\n## Ex. 1: Different types of folding\n\n```supercollider\n// A typical usage is preamplifying a signal, here we start with a sine wave, compare plots\n\n{\n [\n // just smooth clipping\n SmoothClipS.ar(SinOsc.ar(50) * 10),\n\n // folding with main lib's Fold ugen\n Fold.ar(SinOsc.ar(50) * 10, -1, 1),\n\n // folding with rather l"}
+{"text": "gen\n Fold.ar(SinOsc.ar(50) * 10, -1, 1),\n\n // folding with rather low smoothing\n // wave shaper is partiallly a sine wave\n SmoothFoldS.ar(SinOsc.ar(50) * 10, smoothAmount: 0.3),\n\n // folding with maximum smoothing\n // wave shaper is full sine wave\n SmoothFoldS.ar(SinOsc.ar(50) * 10, smoothAmount: 1),\n\n // wave is folded back only to border ranges\n SmoothFoldS.ar(SinOsc.ar(50) * 10, foldRange: 0.3),\n\n // folding with different sizes of border ranges\n SmoothFoldS2.ar(SinOsc.ar(50) * 10, foldRangeLo: 0.5, foldRangeHi: 0.2)\n ]\n}.plot(1/50)\n```\n\n## Ex. 2: Generating rich spectra by folding sine waves\n\n```supercollider\n// Folding ugens do multichannel expansion, let two anticyclic sines control the fold range,\n// control smoothing amount with MouseX\n\n(\nx = {\n var source = SinOsc.ar(50);\n SmoothFoldS.ar(source, -0.1, 0.1, SinOsc.kr(0.05, [0, pi]).range(0.1, 1), MouseX.kr(0, 1))\n}.scope\n);\n\nx.release\n\n// Compare with the parabolic smoothing variant, the difference isn't great in this case\n\n(\nx = {\n var source = SinOsc.ar(50);\n SmoothFoldQ.ar(source, -0."}
+{"text": " {\n var source = SinOsc.ar(50);\n SmoothFoldQ.ar(source, -0.1, 0.1, SinOsc.kr(0.05, [0, pi]).range(0.1, 1), MouseX.kr(0, 1))\n}.scope\n);\n\nx.release\n\n// slow modulations of source frequency with independent LFOs\n\n(\nx = {\n var source = SinOsc.ar(50 * { LFDNoise3.kr(0.1).range(0.98, 1.02) } ! 2);\n SmoothFoldS.ar(source, -0.1, 0.1, SinOsc.kr(0.05, [0, pi]).range(0.1, 1))\n}.scope\n);\n\nx.release\n\n// Adding more complexity by applying preamplification (causes more folding) and adding an offset,\n// these operations are also L/R-independent\n\n(\nx = {\n var source = SinOsc.ar(\n 50 * { LFDNoise3.kr(0.1).range(0.98, 1.02) } ! 2,\n 0,\n { LFDNoise3.kr(0.15).range(0.5, 3) } ! 2,\n { LFDNoise3.kr(0.2).range(-2, 2) } ! 2\n );\n SmoothFoldS.ar(source, -0.1, 0.1, SinOsc.kr(0.05, [0, pi]).range(0.1, 1))\n}.scope\n);\n\nx.release\n```\n\n## Ex. 3: Applying modulated folding to LFO sources\n\n```supercollider\n// the other way round, take a lfo"}
+{"text": " modulated folding to LFO sources\n\n```supercollider\n// the other way round, take a lfo source and modulate folding parameters, here the relative folding range\n\n(\nx = {\n var source = LFDNoise3.ar(0.3!2).range(0.5, 1);\n SmoothFoldS.ar(source, -0.1, 0.1, SinOsc.ar([50, 50.1]).range(0.1, 1) )\n}.scope\n);\n\nx.release\n\n// modulating fold bounds\n\n(\nx = {\n var source = LFDNoise3.ar(0.3!2).range(0.5, 1);\n var bounds = SinOsc.ar([50, 50.1]).range(0.02, 0.1);\n SmoothFoldS.ar(source, bounds.neg, bounds)\n}.scope\n);\n\nx.release\n\n// modulating bounds and range\n\n(\nx = {\n var source = LFDNoise3.ar(0.3!2).range(0.5, 1);\n var range = SinOsc.ar([50, 50.1]).range(0.02, 0.1);\n SmoothFoldS.ar(source, range.neg, range, SinOsc.ar([200, 200.1]).range(0.5, 1))\n}.scope\n);\n\nx.release\n```\n\n## Ex. 4: Buffer scratching with folded signal as position control\n\n```supercollider\n// Interesting micro textures can be generated that way.\n// Technically this is waveshaping with an audio buffer as transfer function and the folded signal as source.\n\n// compare with granulation, sound file from bu"}
+{"text": " as transfer function and the folded signal as source.\n\n// compare with granulation, sound file from buffer granulation tutorial\n\nb = Buffer.read(s, Platform.miSCellaneousDirs[0] +/+ \"Sounds\" +/+ \"kitchen_sounds_1.wav\");\n// This searches the most likely extension places for the miSCellaneous folder.\n// In case of an extraordinary install situation or a removed sound file, pass the concerned path.\n\n(\nSynthDef(\\bufScratchFold, { |bufnum = 0, globalFreq = 0.7, localOscSize = 0.01, foldRange = 0.28,\n localFreq = 0.87, preAmp = 1.4, smoothAmount = 0.36|\n var sig = BufRd.ar(\n 1,\n bufnum,\n (\n // define global and local movement\n LFDNoise3.ar(globalFreq).range(0.2, 0.7) +\n SmoothFoldS.ar(\n // adding space by decorrelating the local scratching / oscillation\n LFTri.ar(localFreq * ({ LFDNoise3.ar(0.2).range(0.999, 1.001) } ! 2)) * preAmp,\n foldRange: foldRange,\n smoothAmount: smoothAmount\n ) * localOscSize\n ) * BufFrames.ir(bufnum)\n );\n // as local oscillation can stick with positive or negative values, a dc leaker is recommended\n Out.ar(0, LeakDC.ar(sig) * EnvGate.new)\n}).add\n"}
+{"text": " Out.ar(0, LeakDC.ar(sig) * EnvGate.new)\n}).add\n);\n\nx = Synth(\\bufScratchFold, [bufnum: b])\n\nx.set(\\preAmp, 5.4)\nx.set(\\foldRange, 0.08)\nx.set(\\localFreq, 0.5)\nx.set(\\localOscSize, 0.05)\nx.set(\\foldRange, 0.02)\nx.set(\\localFreq, 0.1)\n\nx.release\n```"}
+{"text": "SuperCollider schelp — redSys/HelpSource/Classes/RedTween.schelp\n\nRedTween —\ntweening for sclang and scserver\nCategory: Red>redScore\nSee also: Classes/RedInterpolator\n\n\nA class for mapping values between different ranges using different curvatures. It works best in combination with the EaseOverview##Ease quark, but is also fine to use on its own.\nBasically it maps a value from a certain range to another range with an optional curvature.\n\n## ar, kr\n\nCreate an UGen version.\n\n## Language side implementation\n\n## new\n\n- source:\nThe beginning.\n\n- target:\nThe destination.\n\n- curve:\nThe curvature.\n\n- inMin:\nLowest input value.\n\n- inMax:\nHighest input value.\n\nIf the curve argument is\n```supercollider\nnil\n```\n then a linear mapping will be used. If it is a SimpleNumber then internally a lincurve method will be applied (so the curvature will work in the same was as for the Env class). Though the real benefit of this class is to set the curve argument to an EaseOverview##Ease object or write a custom mapping function. This allows to do proper tweening/easing.\n\n## value\n\n## Language side implementation\n\n## curve\nCurvature if set. Else\n```supercollider\nnil\n```\n.\n\n## func\nFunction.\n\n## inMax\nGet or set the maximum.\n\n## inMin\nGet or set the minimum.\n\n## source\nGet or set the source (start) value.\n\n## target\nGet or set the target (end) value.\n\n## value\nPer"}
+{"text": " source (start) value.\n\n## target\nGet or set the target (end) value.\n\n## value\nPerform the lookup.\n\n- t:\nA Float 0.0 to 1.0.\n\nExamples:\n\n\n//--linear mapping from 0-1 to 10-20\na= RedTween(10, 20)\na.value(0)\na.value(0.5)\na.value(0.999)\n\n//--same but with a curvature of 4\na= RedTween(10, 20, 4)\na.value(0)\na.value(0.5)\na.value(0.999)\n100.collect{|x| a.value(x/99)}.plot\n\n//--similar but map from -1 to 1 to 10-20 using a curvature of -4\na= RedTween(10, 20, -4, -1, 1)\na.value(-1)\na.value(0)\na.value(0.999)\n100.collect{|x| a.value(x/99*2-1)}.plot\n\n//--custom curvature function\na= RedTween(10, 20, {|t| t*t*t*t*t})\na.value(0)\na.value(1)\n100.collect{|x| a.value(x/99)}.plot\n\n//--ease objects\na= RedTween(-10, 20, EaseInSine)\n100.collect{|x| a.value(x/99)}.plot\na= RedTween(-10, 20, EaseInAtan(20))\n100.collect{|x| a.value(x/99)}.plot\n\n//--helper method for arrays\na= [-10, 20, EaseInQuart].asRedTween\n100.collect{|x| a.value(x/99)}.plot\n\n//--the .value class method\n//n"}
+{"text": "\n100.collect{|x| a.value(x/99)}.plot\n\n//--the .value class method\n//note how the input value is the first argument, and then the source, target, curve etc.\nRedTween.value(0.55, 10, 20, {|t| t.postln; t*t*t}, 0.5, 1.0)\n\n//--audio examples\ns.boot\n{SinOsc.ar(400, 0, RedTween.kr(MouseX.kr(0, 1), 0, 1, 4).poll)}.play\n{SinOsc.ar(400, 0, RedTween.kr(MouseX.kr(0, 1), 0, 1, {|t| t*t*t}).poll)}.play\n{SinOsc.ar(400, 0, RedTween.kr(MouseX.kr(0, 1), 0, 1, EaseInAtan).poll)}.play\n{SinOsc.ar(400, 0, RedTween.kr(LFSaw.ar(0.5)*0.5+0.5, 0, 1, EaseInBack).poll)}.play"}
+{"text": "SuperCollider classlib — redSys/redUGens/RedLine.sc\n\nredFrik\n\n```supercollider\n//resettable and pausable line\n\nRedLine {\n *ar {|start= 0, end= 1, dur= 1, curve= 0, run= 1, reset= 0, mul= 1, add= 0|\n var line= Sweep.ar(reset, 1/dur*run).lincurve(0, 1, start, end, curve, \\minmax);\n ^MulAdd(line, mul, add);\n }\n *kr {|start= 1, end= 2, dur= 1, curve= 0, run= 1, reset= 0, mul= 1, add= 0|\n var line= Sweep.kr(reset, 1/dur*run).lincurve(0, 1, start, end, curve, \\minmax);\n ^MulAdd(line, mul, add);\n }\n}\n```"}
+{"text": "SuperCollider patch — redUniverse/HelpSource/Quarks/redUniverse/Examples/051-boids2.scd\n\neverybody chase first boid mouse controls the first boid\n\n```supercollider\n//everybody chase first boid\n//mouse controls the first boid\n\n(\nvar width= 300, height= 300, w, wgrav, world, n= 50;\n\n//--world\nw= RedWindow(\"boids test2\", Rect(128, 64, width, height)).front;\nwgrav= RedVector2D[0, 0.98];\nworld= RedWorld(RedVector2D[width, height], wgrav, 15, 0.05); //dim,grav,maxvel,damp\n\n//--objects\n{\n var loc= RedVector2D[width, height].rand;\n var vel= RedVector2D[0.5, 0.5].rand2;\n var mass= 0.5.rrand(4);\n RedBoid(world, loc, vel, RedVector2D[0, 0], mass, mass*5) //world,loc,vel,acc,mass,size\n .maxForce_(2);\n}.dup(n);\n\n//--loop\nw.draw{\n world.objects.do{|o, i|\n if(i!=0, {\n o.addForceSeek(world.objects[0].loc);\n //o.addForceArrive(world.objects[0].loc, 100); //everybody chase first boid\n }, {\n world.objects[0].loc= w.mouse;\n });\n //o.addFor"}
+{"text": "\n }, {\n world.objects[0].loc= w.mouse;\n });\n //o.addForce(world.gravity);\n o.update;\n world.contain(o);\n\n //--render\n Pen.fillColor= Color.grey(1-(i/n), 0.5);\n Pen.fillOval(Rect.aboutRedObject2D(o));\n };\n};\nw.play;\nCmdPeriod.doOnce({w.close});\n)\n```"}
+{"text": "SuperCollider patch — redUniverse/HelpSource/Quarks/redUniverse/Examples/101-particle-system_synth.scd\n\nparticlesystem. with mouse controlling world gravity and system position with simple grain sounds mapped to each particle.\n\n```supercollider\n//particlesystem.\n//with mouse controlling world gravity and system position\n//with simple grain sounds mapped to each particle.\n\n(\ns.waitForBoot{\n\n var width= 300, height= 300, w, world,\n sys, synths;\n\n //--synthesis\n SynthDef(\\sine, {|out= 0, freq= 400, fm= 1, beat= 1, amp= 0, pan= 0, gate= 1|\n var z, e;\n e= EnvGen.ar(Env.asr(0.01, 1, 0.02), gate, doneAction:2);\n z= SinOsc.ar(freq+SinOsc.ar(fm, 0, beat), 0, Lag.kr(amp, 0.1));\n Out.ar(out, Pan2.ar(z*e, pan));\n }).add;\n s.sync;\n synths= (); //keep track of synths with this dictionary\n\n //--world\n w= RedWindow(\"particlesystem test2\", Rect(128, 64, width, height)).front;\n world= RedWorld3(RedVector2D[width, height], 0, 20, 1.25); //dim,grav,maxvel,damp\n\n //--system\n sys= RedParticleSystem.new;\n sys.removeAction= {|o|"}
+{"text": "--system\n sys= RedParticleSystem.new;\n sys.removeAction= {|o| synths.at(o.hash).release}; //free synth when particle dies\n\n //--loop\n w.draw{\n\n //--create a new particle and update the old ones\n var newPart= RedParticle(world, w.mouse+5.rand2, 0, RedVector2D[2.rand2, -10.rand], 1.5, 5.rand).age_(40.rrand(50));\n sys.add(newPart); //add it to the system\n synths.put(newPart.hash, Synth(\\sine)); //create a corresponding synth\n sys.addForce(world.gravity); //world gravity for all particles\n sys.update; //update the system and thereby all objects\n\n sys.do{|o| //iterate all particles\n synths.at(o.hash).set( //find corresponding synth and set params\n \\freq, 200.rrand(o.loc[1]+200),\n \\pan, o.loc[0]/width*2-1,\n \\beat, o.mass*(o.vel.mag*10),\n \\fm, o.mass*1000,\n \\amp, (1/40)*(o.age/50)*(o.vel.mag/10)\n )\n };\n\n //--mouse\n world.gravity= RedVector2D.newFrom(w.mouse/([width, height])-0.5);\n\n //--render\n sys.do{|o| //iterate all particles\n Pen.fillColor= Color.grey(o.age/50, 1);\n Pen.fill"}
+{"text": " Pen.fillColor= Color.grey(o.age/50, 1);\n Pen.fillOval(Rect.aboutRedObject2D(o));\n };\n };\n w.play;\n CmdPeriod.doOnce({w.close});\n w.onClose= {synths.do{|x| x.free}};\n}\n)\n```"}
+{"text": "SuperCollider patch — redUniverse/HelpSource/Quarks/redUniverse/Examples/235-3Dplanes.scd\n\nspinning planes / rectangles\n\n```supercollider\n//spinning planes / rectangles\n\n(\nvar width= 640, height= 480, w, wgrav, world,\nn= 100, thetas= 0.dup(n), speeds= {|i| i+1/10000}.dup(n);\nvar planes;\n\n//--world\nw= RedWindow(\"3Dplanes\", Rect(128, 64, width, height)).front;\nwgrav= RedVector2D[0, 0.01];\nworld= RedWorld3(RedVector2D[width, height], wgrav, 20, 0.01);\n\n//--objects\n{|i|\n var loc= RedVector2D[i.linlin(0, n-1, 0, width), height*0.5];\n var vel= RedVector2D[0, 0];\n var acc= RedVector2D[0, 0];\n var obj= RedObject(world, loc, vel, acc, speeds[i]*5000, 50);\n}.dup(n); //world,loc,vel,acc,mass,size\n\nplanes= {|i| Red3DPlane(RedVector3D[0, i+1/n-0.5, 0])}.dup(n);\n\n//--loop\nw.draw{\n Pen.strokeColor= Color.grey(1, 0.5);\n Pen.translate(0, -50);\n\n world.objects.do{|o, i|\n thetas["}
+{"text": "en.translate(0, -50);\n\n world.objects.do{|o, i|\n thetas[i]= thetas[i]+speeds[i];\n planes[i].rotation= RedVector3D[thetas[i], thetas[i], thetas[i]];\n planes[i].update;\n\n o.addForce(world.gravity);\n o.update;\n world.contain(o);\n\n //--render\n planes[i].render(1.25, 250); //1= exaggerate, 2= standard\n Pen.use{\n Pen.translate(o.loc[0], o.loc[1]);\n planes[i].drawOutlines;\n };\n };\n};\nw.play;\nCmdPeriod.doOnce({w.close});\n)\n```"}
+{"text": "SuperCollider patch — sInstruments/startMenu.scd\n\n```supercollider\n(\n//--settings\nvar prefName= \"startMenuPref.json\";\nvar winRect= Rect(1, Window.availableBounds.height, 240, 320); //x, y, w, h\n\n//--functions and objects\nvar keyFunc;\nvar keyLookup= ();\nvar prefDict;\nvar themes= SGUI.themes.keys.asArray.sort;\n\n//--gui\nvar preferencesButton;\nvar buttons= List.new;\nvar pwin, win= Window(\"sInstruments menu\", winRect);\nwin.userCanClose= false;\nwin.layout= VLayout(\n HLayout(\n StaticText().string_(\"sInstruments: \"++SInstruments.version),\n nil,\n (preferencesButton= SGUIsettings()).view\n )\n);\n\nwin.layout.add(StaticText().string_(\"Click to launch instruments...\"));\nSInstruments.instruments.do{|name|\n var button= Button().states_([\n [\" \"++name, SGUI.palette.buttonText, SGUI.palette.button],\n [\"•\"++name, SGUI.palette.highlight, SGUI.palette.button],\n [\"•\"++name, SGUI.palette.buttonText, SGUI.palette.highlight]\n ]).action_{SInstruments.toFront(name)}"}
+{"text": "UI.palette.highlight]\n ]).action_{SInstruments.toFront(name)};\n buttons.add(button);\n win.layout.add(button);\n};\n\nwin.layout.add(StaticText().string_(\"Click to launch inputs...\"));\nSInstruments.inputs.do{|name|\n var button= Button().states_([\n [\" \"++name, SGUI.palette.buttonText, SGUI.palette.button],\n [\"•\"++name, SGUI.palette.highlight, SGUI.palette.button],\n [\"•\"++name, SGUI.palette.buttonText, SGUI.palette.highlight]\n ]).action_{SInstruments.toFront(name)};\n buttons.add(button);\n win.layout.add(button);\n};\n\npreferencesButton.action= {\n var palette= SGUI.palette;\n var themePopup;\n var ctrlPopup, altPopup, cmdPopup, lessPopup;\n var cancelButton, storeButton;\n var pos, name= \"preferences\";\n var items= ['_']++SInstruments.instruments++\\sLauncher;\n pwin= Window.allWindows.detect{|x| x.name==name};\n if(pwin.isNil, {\n pos= Window.screenBounds.extent*0.6;\n pwin= Window(name, Rect.aboutPoint(pos, 250, 100));\n pwin.view.layout_"}
+{"text": "ow(name, Rect.aboutPoint(pos, 250, 100));\n pwin.view.layout_(VLayout(\n HLayout(\n StaticText().string_(\"Theme\").maxWidth_(50),\n themePopup= PopUpMenu().items_(themes)\n ),\n nil,\n StaticText().string_(\"Shortcuts for launching instruments and/or bring to front\"),\n HLayout(\n StaticText().string_(\"key 'ctrl'\").maxWidth_(65),\n StaticText().string_(\"=\").maxWidth_(25),\n ctrlPopup= PopUpMenu().items_(items)\n ),\n HLayout(\n StaticText().string_(\"key 'alt'\").maxWidth_(65),\n StaticText().string_(\"=\").maxWidth_(25),\n altPopup= PopUpMenu().items_(items)\n ),\n HLayout(\n StaticText().string_(\"key 'cmd'\").maxWidth_(65),\n StaticText().string_(\"=\").maxWidth_(25),\n cmdPopup= PopUpMenu().items_(items)\n ),\n HLayout(\n StaticText().string_(\"key '<'\").maxWidth_(65),\n StaticText().string_(\"=\").maxWidth_(25),\n lessPopup= PopUpMenu().items_(items)\n ),\n nil,\n HLayout(\n [View(), stretch:1],\n cancelButton= Button().states_([\n [\"Cancel\", p"}
+{"text": " stretch:1],\n cancelButton= Button().states_([\n [\"Cancel\", palette.buttonText, palette.button]\n ]),\n storeButton= Button().states_([\n [\"Store\", palette.buttonText, palette.button]\n ])\n )\n ));\n SGUI.adapt(pwin);\n pwin.view.keyDownAction= {|view, chr, mod, unicode, keycode, key|\n if(unicode==27, {pwin.close}); //esc\n };\n themePopup.action= {|view|\n var p= SGUI.selectTheme(themes[view.value]);\n Window.allWindows.do{|w| w.view.palette= p};\n };\n themePopup.value= themes.indexOf(SGUI.currentTheme);\n ctrlPopup.action= {|view|\n keyLookup[\\keyCtrl]= view.items[view.value];\n };\n ctrlPopup.value= ctrlPopup.items.indexOf(keyLookup[\\keyCtrl])?0;\n altPopup.action= {|view|\n keyLookup[\\keyAlt]= view.items[view.value];\n };\n altPopup.value= altPopup.items.indexOf(keyLookup[\\keyAlt])?0;\n cmdPopup.action= {|view|\n keyLookup[\\keyCmd]= view.items[view.value];\n };\n cmdPopup.value= cmdPopup.items.indexOf"}
+{"text": "view.value];\n };\n cmdPopup.value= cmdPopup.items.indexOf(keyLookup[\\keyCmd])?0;\n lessPopup.action= {|view|\n keyLookup[\\keyLess]= view.items[view.value];\n };\n lessPopup.value= lessPopup.items.indexOf(keyLookup[\\keyLess])?0;\n cancelButton.action= {\n pwin.close;\n };\n storeButton.action= {\n if(File.exists(SInstruments.preferencesDir).not, {SInstruments.preferencesDir.mkdir});\n File.use(SInstruments.preferencesDir+/+prefName, \"w\", {|file|\n file.write(\"{\\n\");\n file.write(\"'theme': '%'\".format(themePopup.items[themePopup.value]));\n file.write(\",\\n\");\n file.write(\"'keyCtrl': '%'\".format(ctrlPopup.items[ctrlPopup.value]));\n file.write(\",\\n\");\n file.write(\"'keyAlt': '%'\".format(altPopup.items[altPopup.value]));\n file.write(\",\\n\");\n file.write(\"'keyCmd': '%'\".format(cmdPopup.items[cmdPopup.value]));\n file.write(\",\\n\");\n file.write(\"'keyLess': '%'\".format(lessPopup.items[lessPopup.value]));\n file.write(\"\\n}\");\n });\n pwin.close;\n };\n });\n pwin.front"}
+{"text": "n}\");\n });\n pwin.close;\n };\n });\n pwin.front;\n};\n\nif(File.exists(SInstruments.preferencesDir+/+prefName), {\n prefDict= (SInstruments.preferencesDir+/+prefName).parseYAMLFile;\n SGUI.selectTheme(prefDict[\"theme\"].asSymbol);\n keyLookup.put(\\keyCtrl, prefDict[\"keyCtrl\"].asSymbol);\n keyLookup.put(\\keyAlt, prefDict[\"keyAlt\"].asSymbol);\n keyLookup.put(\\keyCmd, prefDict[\"keyCmd\"].asSymbol);\n keyLookup.put(\\keyLess, prefDict[\"keyLess\"].asSymbol);\n});\n\nkeyFunc= {|view, chr, mod, unicode, keycode, key|\n case\n {mod.isCtrl} {SInstruments.toFront(keyLookup[\\keyCtrl])}\n {mod.isAlt} {SInstruments.toFront(keyLookup[\\keyAlt])}\n {mod.isCmd} {SInstruments.toFront(keyLookup[\\keyCmd])}\n {chr==$<} {SInstruments.toFront(keyLookup[\\keyLess])};\n};\nView.globalKeyDownAction= View.globalKeyDownAction.addFunc(keyFunc);\n\nOSCFunc({|msg| //from SGUI report\n {\n buttons.detect{|b|\n b"}
+{"text": "{|msg| //from SGUI report\n {\n buttons.detect{|b|\n b.states[0][0].replace(\" \", \"\").contains(msg[1].asString);\n }.value= 2;\n }.defer;\n}, \\toFront);\nOSCFunc({|msg| //from SGUI report\n {\n var but= buttons.detect{|b|\n b.states[0][0].replace(\" \", \"\").contains(msg[1].asString);\n };\n if(but.notNil, {but.value= 1});\n }.defer;\n}, \\endFront);\nOSCFunc({|msg| //from instruments\n {\n buttons.detect{|b|\n b.states[0][0].replace(\" \", \"\").contains(msg[1].asString);\n }.value= 0;\n }.defer;\n}, \\closed);\n\nwin.front;\nwin.onClose= {\n if(pwin.notNil, {pwin.close});\n View.globalKeyDownAction= View.globalKeyDownAction.removeFunc(keyFunc);\n};\nSGUI.adapt(win);\n\ns.options.numWireBufs= s.options.numWireBufs.max(128);\ns.options.memSize= s.options.memSize.max(2**16);\ns.latency= 0.08;\ns.boot;\n)\n```"}
+{"text": "SuperCollider classlib — sc3-dot/sc/ext/Synthdef.ext.sc\n\n```supercollider\n dot { | aStream |\n aStream\n << \"digraph \\\"\" << this.name << \"\\\" { \\n\"\n << \"graph [splines=\" << Dot.useSplines.asString << \"];\\n\"\n << \"node [fontsize=\" << Dot.fontSize.asString << \"];\\n\"\n << \"node [fontname=\" << Dot.fontName.asString << \"];\\n\"\n << \"edge [arrowhead=box,arrowsize=0.25];\\n\";\n this.allControlNames.do { | each |\n each.dot(aStream)\n };\n this.children.do { | each |\n each.dot(aStream)\n };\n this.children.do { | each |\n each.inputs.do { | input index |\n input.dotEdge(aStream, each, index)\n }\n };\n aStream << \" }\\n\"\n }\n\n draw {\n Dot.draw(this)\n }\n\n drawAndPlay {\n this.play;\n Dot.draw(this)\n }\n\n}\n```"}
+{"text": "SuperCollider classlib — scgraph/GBorderedRectangle.sc\n\n```supercollider\n ^this.multiNew\n (\n 'audio',\n w,\n h,\n border_thickness,\n fill_color[0],\n fill_color[1],\n fill_color[2],\n fill_color[3],\n border_color[0],\n border_color[1],\n border_color[2],\n border_color[3]\n );\n }\n}\n```"}
+{"text": "SuperCollider classlib — wslib/wslib-classes/Extensions/String/extString-couldBeNumber.sc\n\nwslib\n\n```supercollider\n// number testing\n\n+ String {\n \n couldBeNumber { //test if a string could be converted to number using .interpret\n ^this.every({ |item, i| \n ((item.isDecDigit) or: (item == $.))\n or: ((item == $-) && (i == 0))\n });\n }\n \n couldBeHex {\n ^this.every({ |item, i|\n (item.isDecDigit) or: ([$a, $b, $c, $d, $e, $f].includes(item.toLower) ) }); \n }\n \n asNumberIfPossible {\n if(this.couldBeNumber && (this != \"-\") )\n {^this.interpret} {^this}\n }\n \n asHexIfPossible { |else|\n else = else ? { ^this };\n if(this.couldBeHex) \n {^(\"16x\" ++ this).interpret} { else.value };\n }\n\n}\n```"}
+{"text": "SuperCollider classlib — wslib/wslib-classes/Extensions/Various/extSoundFile-splitChannels.sc\n\nextract one channel using server carefull: overwrites existing files files will go into folder with file name of original, containing the channels as numbered files of the same format as the original runs in background, channels one by one might be slow, but doesn't freeze the lang use splitChannelsLang for doing this from the lang instead of server carefull: overwrites existing files files will g\n\n```supercollider\n+ SoundFile { \n \n extractChannel { |ch = 0, numFrames = -1, startFrame = 0, outPath, server, doneAction|\n // extract one channel using server\n var outFile;\n server = server ? Server.default;\n \n outPath = outPath ?? { \n path.removeExtension.makeDir;\n path.removeExtension ++ \"/\" ++ \n path.basename.removeExtension ++ \"_\" ++ (ch+1)\n ++ \".\" ++ ( path.extension ? headerFormat ); \n };\n \n outFile = this.class.new( outPath );\n \n server.waitForBoot( {\n \"reading channel % of file %\\n\".postf( ch+1, path.basename );\n Buffer.readChannel(server, path, channels: [ch],\n action: { |buf| \n \"writing channel % of file %\\n\".postf( ch+1, path.basename );\n Buffer( server, buf.numFrames"}
+{"text": "ostf( ch+1, path.basename );\n Buffer( server, buf.numFrames, buf.numChannels, buf.bufnum )\n .writeAction(outPath, headerFormat, sampleFormat,\n action: { |buf2|\n buf.free;\n \"done channel % of file %\\n\".postf( ch+1, path.basename );\n doneAction.value( outFile, buf );\n }\n ) } ); \n } );\n \n ^outFile\n }\n \n splitChannels { |outPath, startFrame = 0, numFrames, server, \n doneAction, newHeaderFormat, newSampleFormat|\n \n // carefull: overwrites existing files\n //\n // files will go into folder with file name of original, containing\n // the channels as numbered files of the same format as the original\n \n var outFiles;\n var xFunc;\n \n server = server ? Server.default;\n \n outPath = outPath ? path;\n \n outFiles = { |i| // array with soundfiles for channels\n var aPath;\n SoundFile( outPath.removeExtension ++ \n \"/\" ++ outPath.basename.removeExtension ++ \"_\" ++ (i+1)\n ++ \".\" ++ ( outPath.extension ? headerFormat ) ); } ! numChannels;\n \n outPath.removeExtension.makeDir; // will create a dir even if operation fails\n \n // runs in background, channels one by one\n // might be slow, but does"}
+{"text": " if operation fails\n \n // runs in background, channels one by one\n // might be slow, but doesn't freeze the lang\n // use splitChannelsLang for doing this from the lang instead of server\n \n xFunc = { |ch| // recursive function\n if( ch < numChannels )\n { this.extractChannel( ch, \n numFrames ? -1, startFrame ? 0, outFiles[ ch ].path, \n server, { xFunc.value( ch + 1 ) } ) }\n { doneAction.value( outFiles ); }; \n };\n \n xFunc.value( 0 );\n \n ^outFiles\n }\n \n splitChannelsLang { |outPath, startFrame = 0, numFrames, chunkSize = 1048576, \n doneAction, newHeaderFormat, newSampleFormat|\n \n // carefull: overwrites existing files\n //\n // files will go into folder with file name of original, containing\n // the channels as numbered files of the same format as the original\n \n var rawData, rawChannels;\n \n var outFiles;\n \n numFrames.notNil.if({ numFrames = numFrames * numChannels; },\n { numFrames = inf });\n \n // chunkSize must be a multiple of numChannels\n chunkSize = (chunkSize/numChannels).floor * numChannels;\n \n outPath = outPath ? path;\n \n outFiles = { |i| // array with soundfiles for channels\n var aPath;\n SoundFile.new\n .headerFormat_( newHeaderFormat"}
+{"text": "annels\n var aPath;\n SoundFile.new\n .headerFormat_( newHeaderFormat ? headerFormat )\n .sampleFormat_( newSampleFormat ? sampleFormat )\n .numChannels_(1)\n .path_( outPath.removeExtension ++ \n \"/\" ++ outPath.basename.removeExtension ++ \"_\" ++ (i+1)\n ++ \".\" ++ ( outPath.extension ? headerFormat ) ); } ! numChannels;\n \n outPath.removeExtension.makeDir; // will create a dir even if operation fails\n \n outFiles.do( _.openWrite );\n \n this.seek(startFrame, 0);\n \n \n { (numFrames > 0) and: {\n rawData = FloatArray.newClear(min(numFrames, chunkSize));\n this.readData(rawData);\n //\"next chunk (size=%) read\\n\".postf( rawData.size );\n rawData.size > 0\n }\n }.while({\n \n rawData = rawData.clump( numChannels );\n \n rawChannels = { FloatArray.newClear( rawData.size ); } ! numChannels;\n rawData.do({ |samp, i|\n numChannels.do({ |ii| rawChannels[ii][i] = samp[ii] });\n });\n \n rawChannels.do({ |channelData, i|\n if( outFiles[i].writeData(ch"}
+{"text": "do({ |channelData, i|\n if( outFiles[i].writeData(channelData) == false )\n { MethodError(\"SoundFile writeData failed.\", this).throw };\n //\"next channel (%) written chunk\\n\".postf( i+1 );\n \n // write, and check whether successful\n // throwing the error invokes error handling that closes the files\n \n });\n numFrames = numFrames - chunkSize;\n });\n outFiles.do( _.close );\n doneAction.value( outFiles );\n ^outFiles\n } \n \n }\n \n+ Buffer {\n \n writeAction { arg path,headerFormat=\"aiff\",sampleFormat=\"int24\",\n numFrames = -1, startFrame = 0,leaveOpen = false, action;\n this.addToServerArray;\n doOnInfo = action;\n this.waitForBufInfo;\n server.listSendMsg( \n this.writeMsg(path,headerFormat,sampleFormat,numFrames,startFrame,\n leaveOpen, {|buf|[\"/b_query\",buf.bufnum]}) \n );\n }\n }\n```"}
+{"text": "SuperCollider classlib — wslib/wslib-classes/Main Features/File management/extFile-WesleyanCheck.sc\n\n```supercollider\n *isWesleyanBuild { this.deprecated( thisMethod ); ^File.getcwd.basename == \"SC3\" } // simple check\n \n *getBuildDate {\n var out, file;\n this.deprecated( thisMethod );\n if( File.isWesleyanBuild )\n { file = File(String.scDir ++ \n \"/SuperCollider.app/Contents/Resources/English.lproj/Credits.rtf\",\"r\");\n out = file.readAllString.stripRTF.split( $\\n )[2].split( $ )[0];\n file.close;\n } {out = \"\"};\n ^out;\n }\n }\n```"}
+{"text": "SuperCollider classlib — wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc\n\n```supercollider\nnotenumber to notename and backwards conversion\nalso includes convenience methods for frequency (cps)\n\nmidivoicetype can be used to test if a certain note\nor frequency is included in a certain voice type\n\nvoice types are currently in english and dutch\n\nnote names are as found in Logic Pro. Sibelius and some other brands\nuse other: C4 in Logic = C3 in Sibelius\n\nmethods included:\n\nSimpleNumber-midiname\n convert a midi notenumber to a notename\n adds a 'cents' method\nSimpleNumber-midivoicetype\n get the voicetypes who can sing this midi notenumber\nSimpleNumber-cpsname\n convert frequency to a notename\nSimpleNumber-cpsvoicetype\n get the voicetypes who can sing this frequency\nString-namemidi\n convert a notename to a midi notenumber\nString-namename\n convert a notename to a standardized notename\nString-namecps\n convert a notename to a frequency\nString-namevoicetype\n get the voicetypes who can sing this notename\nArray-makeScale\n make a scale from start- to endnote based on groundnote\n including a number of tuning tables and combinations\n notenames are always enharmonically transposed to the closest one\n\nConvenience methods for Symbol and Array classes were added.\n\nW. Snoei 2005\n\n*/\n\n+ SimpleNumber {\n midiname { arg sign;\n // format \""}
+{"text": "oei 2005\n\n*/\n\n+ SimpleNumber {\n midiname { arg sign;\n // format \"[notename][b/#][octave]\"\n // arg sign can be String, Symbol or Char containing # or b\n // # forces altered notes to # sign\n // b forces altered notes to b sign\n // nil or n chooses most common alterations (F#, C#, G#, Bb, Eb)\n // examples: \"C#-2\" , \"Gb7\"\n // adds 'cents' method for deviation in cents\n var out;\n if(sign.isNil) {sign = $n};\n if(sign.class == Symbol) {sign = sign.asString};\n if(sign.class == String) {sign = sign[0]};\n out = IdentityDictionary[\n $# -> [\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"A#\", \"B\"],\n $b -> [\"C\", \"Db\", \"D\", \"Eb\", \"E\", \"F\", \"Gb\", \"G\", \"Ab\", \"A\", \"Bb\", \"B\"],\n $n -> [\"C\", \"C#\", \"D\", \"Eb\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"Bb\", \"B\"]\n ].at(sign)[this.round(1.0) % 12] ++ ((this.round(1.0) / 12).floor - 2).asInteger;\n out.addUniqueMethod('cents', { ((this - this.round(1.0)) * 100).round(10e-8) });\n out.addUniqueMethod('alt', { IdentityDictionary[$# -> 1, $b -> -1].at(out[1"}
+{"text": "ethod('alt', { IdentityDictionary[$# -> 1, $b -> -1].at(out[1]) ? 0 })\n //out.cents_( ((this - this.round(1.0)) * 100).round(10e-8) );\n ^out;\n }\n\n midivoicetype { arg type, language = 'en', filter; //type: testing / filter: 'm' or 'f'\n // midi nn -> type of voice\n // outputs an array of voicetypes\n // +/- are added behind voicetype if the note\n // is in the outer regions of the voicetype\n var voiceDict, out;\n\n voiceDict = IdentityDictionary[\n\n 'nl' -> IdentityDictionary[ //min -, min, max, max +, male/female\n 'bas' -> [\"D1\",\"E1\",\"E3\",\"G3\", 'm'],\n 'bariton' -> [\"F1\",\"G1\",\"G3\",\"B3\", 'm'],\n 'tenor' -> [\"A1\",\"B1\",\"B3\",\"D4\", 'm'],\n 'alt' -> [\"E2\",\"F2\",\"F4\",\"A4\", 'f'],\n 'mezzosopraan' -> [\"G2\",\"A2\",\"A4\",\"C5\", 'f'],\n 'sopraan' -> [\"B2\",\"C3\",\"C5\",\"E5\", 'f']\n ],\n\n 'en' -> IdentityDictionary[ //min -, min, max, max +, male/female\n 'bass' -> [\"D1\",\"E1\",\"E3\",\"G3\", 'm'],\n 'baritone' -> [\"F1\",\"G1\",\"G3\",\"B3\","}
+{"text": " 'm'],\n 'baritone' -> [\"F1\",\"G1\",\"G3\",\"B3\", 'm'],\n 'tenor' -> [\"A1\",\"B1\",\"B3\",\"D4\", 'm'],\n 'contralto' -> [\"E2\",\"F2\",\"F4\",\"A4\", 'f'],\n 'mezzo-soprano' -> [\"G2\",\"A2\",\"A4\",\"C5\", 'f'],\n 'soprano' -> [\"B2\",\"C3\",\"C5\",\"E5\", 'f']\n ]\n ][language];\n\n out = [];\n filter = filter ? ['m','f'];\n filter = [filter].flat;\n\n if(type.isNil)\n {\n voiceDict.keys.do({\n |item|\n var reach;\n reach = voiceDict.at(item);\n if( reach.includesAny(filter) )\n {\n if( (this >= reach.at(0).namemidi) &&\n (this < reach.at(1).namemidi) )\n {out = out.add(item.asString ++ \" -\") };\n if( (this >= reach.at(1).namemidi) &&\n (this <= reach.at(2).namemidi) )\n {out = out.add(item.asString) };\n if( (this > reach.at(2).namemidi) &&\n (this <= reach.at(3).namemidi) )\n {out = out.add(item.asString ++ \" +\") };\n };\n });\n } {\n out = false;\n type = type.asSym"}
+{"text": " \" +\") };\n };\n });\n } {\n out = false;\n type = type.asSymbol;\n if( (this >= voiceDict.at(type).at(0).namemidi) &&\n (this < voiceDict.at(type).at(1).namemidi) )\n {out = \"-\"; };\n if( (this >= voiceDict.at(type).at(1).namemidi) &&\n (this <= voiceDict.at(type).at(2).namemidi) )\n {out = true; };\n if( (this > voiceDict.at(type).at(2).namemidi) &&\n (this <= voiceDict.at(type).at(3).namemidi) )\n {out = \"+\"; };\n }\n ^out;\n }\n\n makeScale {arg type = 'major', startNote, endNote;\n // startnote and endnote are note names\n // input is midi note number\n // output is midi note numbers\n ^Array.makeScaleMidi(this, type,\n {startNote.namemidi}.try, {endNote.namemidi}.try);\n }\n\n makeScaleMidi {arg type = 'major', startNote, endNote;\n // all args/input are midi note number\n ^Array.makeScaleMidi(this, type, startNote, endNote);\n }\n\n makeScaleCps {arg type = 'major', startNote, endNote;\n // all args/input are midi note number\n ^Array.makeScaleCps(this, type, startNote, endNote);\n }\n\n makeScaleName {arg type = 'major', startNote, endNote;\n // startn"}
+{"text": ");\n }\n\n makeScaleName {arg type = 'major', startNote, endNote;\n // startnote and endnote are note names\n // input is midi note number\n // output is note names\n ^Array.makeScaleName(this.midiname, type, startNote, endNote);\n }\n\n cpsname { arg sign;\n ^this.cpsmidi.midiname(sign);\n }\n\n cpsvoicetype {\n ^this.cpsmidi.midivoicetype;\n }\n cpstransp { arg trans;\n ^(this.cpsmidi + trans).midicps;\n }\n }\n\n/*\n+ Nil {\n midiname {^this}\n namemidi {^this}\n namename {^this}\n cpsname {^this}\n namecps {^this}\n cpsmidi {^this}\n midicps {^this}\n cpsmidi {^this}\n midiratio {^this}\n ratiomidi {^this}\n }\n*/\n\n+ String {\n //var <>cents; -- won't work, why?\n\n *notesDict { ^IdentityDictionary[ $C -> 0, $D -> 2, $E -> 4, $F -> 5, $G -> 7, $A -> 9, $B -> 11 ]; }\n notesDict { ^String.notesDict; }\n\n namemidi { arg cents;\n // format \"[notename][bb/b/#/x][octave(-9/9)]\"\n // examples: \"C#-2\" , \"Gbb7\"\n // min notenr = -84 (C-9)\n // max notenr = 145 (Bx9)\n var notename, addition, octave = 0;\n if(cents.isNil)"}
+{"text": " 145 (Bx9)\n var notename, addition, octave = 0;\n if(cents.isNil)\n { cents = {this.cents}.try ? 0 }; //override when available as method of input string\n ^(this.notesDict.at(this.getNote) + 24\n + this.getAlt + (this.getOctave * 12) + (cents * 0.01) );\n }\n\n getAlt {\n var addition = 0;\n if ({this.alt}.try.isNil) {\n this.do({ |item|\n if (item == $#) {addition = addition + 1};\n if (item == $b) {addition = addition - 1};\n if (item == $x) {addition = addition + 2};\n });\n this.addUniqueMethod('alt', {addition}) };\n ^this.alt;\n }\n\n getOctave {\n //var octave = 0;\n //octave =\n ^this.extractNumbers[0] ? 3;\n //.asString;\n //if(this.reverse[1] == $-) {octave = \"-\" ++ octave};\n //^octave.interpret;\n }\n\n getNote { ^this[0].toUpper; }\n\n *makeNoteName {arg name = $C, alt = 0, octave = 3, cents = 0, maxAlt=3;\n var out, altString = \"\";\n\n if(name.isNumber) {name = name.midiname.first};\n if(name.class != Char) {name = name.asString.first};\n\n cents = cents + ((alt.excess(maxAlt)) * 100);\n alt = alt.clip2(maxAlt);\n alt.abs.do({ al"}
+{"text": "t)) * 100);\n alt = alt.clip2(maxAlt);\n alt.abs.do({ altString = altString ++\n (if(alt.isPositive) {\"#\"} {\"b\"}); });\n if(alt==2) {altString=\"x\"};\n out = name.asString ++ altString ++ octave.round(1).asInteger;\n out.addUniqueMethod('cents', { cents });\n out.addUniqueMethod('alt', { alt });\n ^out;\n }\n\n forceNoteName {arg toName = $C, maxAlt=12;\n var newAlt, inNoteNr, toNoteNr, diff, octave;\n if(toName.isNumber) {toName = toName.midiname.first};\n if(toName.class != Char) {toName = toName.asString.first};\n inNoteNr = this.notesDict[this.getNote];\n diff = (inNoteNr - this.notesDict[toName];).wrap(-5, 6);\n octave = this.getOctave;\n\n case { (diff.neg + inNoteNr) > 11 }\n {octave = octave + 1}\n { (diff.neg + inNoteNr) < 0 }\n {octave = octave - 1};\n\n newAlt = this.getAlt + diff;\n ^String.makeNoteName(toName, newAlt, octave, {this.cents}.try ? 0, maxAlt:maxAlt)\n }\n\n /*\n\n forceSign {arg toSign = \"\", maxAlt=12; // will force to sign if possible, or else one less\n // NOT FINISHED YET!"}
+{"text": "=12; // will force to sign if possible, or else one less\n // NOT FINISHED YET!!\n var inAlt, toAlt, toAltIn, inNote, inNoteNr, outName, nearestNext;\n toAltIn = toSign.getAlt;\n toAlt = [toAltIn.excess(-1), toAltIn.excess(1)].sort;\n inNote = this.namename;\n inAlt = inNote.getAlt;\n ^if(toAltIn !== 0) {\n inNoteNr = this.namename.notesDict[this.getNote] + inAlt;\n if(toAltIn.isPositive)\n {nearestNext = this.notesDict.values.sort.select({ |item|\n (item >= (inNoteNr - toAltIn).wrap(0,11)) && (item <= (inNoteNr - (toAltIn - 1)).wrap(0,11)); });\n if(nearestNext.first.isNil)\n {nearestNext = [inNoteNr]\n outName = this.notesDict.findKeyForValue(nearestNext.first) }\n\n {nearestNext = this.notesDict.values.sort.select({ |item|\n (item >= (inNoteNr - (toAltIn + 1)).wrap(0,11)) && (item <= (inNoteNr - toAltIn).wrap(0,11)); });\n nearestNext.postln;\n outName = this.notesDict.findKeyForValue(nearestNext.last) };\n\n inNote.forceNoteName(outName, maxAlt"}
+{"text": "nearestNext.last) };\n\n inNote.forceNoteName(outName, maxAlt);\n } { inNote };\n }\n */\n\n makeScale {arg type = 'major', startNote, endNote;\n ^Array.makeScale(this, type, startNote, endNote);\n }\n\n makeScaleName {arg type = 'major', startNote, endNote;\n ^Array.makeScaleName(this, type, startNote, endNote);\n }\n\n makeScaleCps {arg type = 'major', startNote, endNote;\n ^Array.makeScaleCps(this.namecps, type, startNote, endNote);\n }\n\n makeScaleMidi {arg type = 'major', startNote, endNote;\n ^Array.makeScaleMidi(this.namemidi, type, startNote, endNote);\n }\n\n namename {arg cents, sign;\n // convert to standardized format and add 'cents' method\n // with enharmonic transposition\n ^this.namemidi(cents).midiname(sign);\n }\n\n namecps { arg cents;\n ^this.namemidi(cents).midicps;\n }\n\n // testing\n testnamemidi { arg ifTrue=true, ifFalse=false, cents = 0;\n // if ifTrue and ifFalse are functions they will\n // be called with this and cents as arguments\n // and the result returned (a.k.a if statement included)\n ^if({this.namemidi}.try.notNil)\n {ifTrue.value(this, cents)}\n {ifFalse.value(this, cents)};\n }\n\n // try and always return default if fails\n tryn"}
+{"text": "ifFalse.value(this, cents)};\n }\n\n // try and always return default if fails\n trynamemidi { arg cents, default = \"C3\";\n ^({this.namemidi(cents)}.try ? {default.namemidi(cents)}.try) ? default;\n }\n\n trynamename {arg cents, sign, default;\n ^this.testnamemidi(_.namename(_, sign), default ? this, cents);\n }\n\n trynamecps { arg cents, default = \"C3\";\n ^this.testnamemidi(_.namecps(_), {default.trynamecps(cents)}, cents);\n }\n\n namevoicetype {arg type, language='en', filter;\n ^this.namemidi.midivoicetype(type, language, filter)\n }\n\n nametransp { arg trans;\n ^(this.namemidi + trans).midiname;\n }\n }\n\n+ Symbol {\n namemidi { arg cents;\n ^this.asString.namemidi(cents);\n }\n\n makeScale {arg type = 'major', startNote, endNote;\n ^Array.makeScale(this, type, startNote, endNote);\n }\n\n makeScaleName {arg type = 'major', startNote, endNote;\n ^Array.makeScaleName(this, type, startNote, endNote);\n }\n\n makeScaleCps {arg type = 'major', startNote, endNote;\n ^Array.makeScaleCps(this.namecps, type, startNote, endNote);\n }\n\n makeScaleMidi {arg type = '"}
+{"text": "is.namecps, type, startNote, endNote);\n }\n\n makeScaleMidi {arg type = 'major', startNote, endNote;\n ^Array.makeScaleMidi(this.namemidi, type, startNote, endNote);\n }\n\n namename {arg cents, sign;\n ^this.namemidi(cents).midiname(sign);\n }\n\n namecps { arg cents;\n ^this.namemidi(cents).midicps;\n }\n\n testnamemidi { arg ifTrue=true, ifFalse=false, cents = 0;\n ^if({this.namemidi}.try.notNil)\n {ifTrue.value(this, cents)}\n {ifFalse.value(this, cents)};\n }\n\n trynamemidi { arg cents, default = 'C3';\n ^this.asString.trynamemidi(cents, default);\n }\n\n trynamename {arg cents, sign, default;\n ^this.testnamemidi(_.namename(_, sign), default ? this, cents);\n }\n\n trynamecps { arg cents, default = 'C3';\n ^this.testnamemidi(_.namecps(_), {default.trynamecps(cents)}, cents);\n }\n\n namevoicetype {arg type, language='en', filter;\n ^this.namemidi.midivoicetype(type, language, filter)\n }\n }\n\n+ SequenceableCollection {\n\n *makeScaleMidi { arg groundNote = 60, type= 'major', startNote, endNote;\n var outArray = [0];\n var finalScale = ["}
+{"text": "major', startNote, endNote;\n var outArray = [0];\n var finalScale = [], i=0;\n var scale = (\n //scales:\n 'major': [0,2,4,5,7,9,11],\n 'minor': [0,2,3,5,7,8,10],\n 'harm-minor': [0,2,3,5,7,8,11],\n 'melo-minor': [0,2,3,5,7,9,11], //only up, use 'minor' for down\n 'blues': [0,3,5,6,7,10],\n 'blues-major': [0,2,3,4,7,9],\n 'pentatonic': [0,2,4,6,8,10],\n 'chromatic': (0,1..11),\n 'quartertones': (0,0.5..11.5),\n\n //tuning tables:\n 'just':// 7-limit tritone basic\n [1, 16/15, 9/8, 6/5, 5/4, 4/3, 7/5, 3/2, 8/5, 5/3, 9/5, 15/8].ratiomidi,\n 'fifth': // based on pure fifths from goundnote\n Array.fill(12, {|i| ((3/2)**(i-6)).ratiomidi.wrap(0, 12) }).sort,\n\n //tuning tables from Apple Logic Pro:\n 'pythagorean': [ 0, 2187/2048, 9/8, 32/27, 81/64, 4/3, 729/512, 3/2,\n 6561/4096, 27/16, 16/9, 243/128].ratiomidi,\n 'werckmeister': //Andreas"}
+{"text": ", 16/9, 243/128].ratiomidi,\n 'werckmeister': //Andreas Werckmeister III (1681), the most famous one\n ([0, 1.9218, 3.90225, 6.9609, 8.8827, 10.9218] ++\n [256/243, 32/27, 4/3, 1024/729, 128/81, 16/9 ].ratiomidi).sort,\n 'indian': //North Indian Gamut, modern Hindustani Gamut out of 22 or more Shrutis\n [1, 16/15, 9/8, 6/5, 5/4, 4/3, 45/32, 3/2, 8/5, 27/16, 9/5, 15/8].ratiomidi,\n 'arabic': // empirical..\n [ 0, 1.3, 1.8, 2.5, 3.55, 5.02, 6.23, 7.06, 7.86, 8.57, 9.3, 11.1],\n\n // tuned scales:\n 'just-major': [1, 9/8, 5/4, 4/3, 3/2, 5/3, 15/8].ratiomidi,\n 'just-minor': [1, 9/8, 6/5, 4/3, 3/2, 8/5, 9/5].ratiomidi,\n 'fifth-major': [1, 9/8, 81/64, 4/3, 3/2, 27/16, 243/128].ratiomidi,\n 'fifth-minor': [1, 9/8, 32/27, 4/3, 3/2, 128/81, 16/9].ratiomidi\n\n ).at(type.asSymbol);\n\n if(scale.isNil"}
+{"text": ".ratiomidi\n\n ).at(type.asSymbol);\n\n if(scale.isNil)\n {if(type.isArray)\n {scale = type}\n {(\"Array-makeScale: input 'type' not valid: \" ++ type).warn}\n };\n\n startNote = startNote ? groundNote;\n endNote = endNote ? (startNote + 11);\n i = ((startNote - groundNote) * (scale.size/12)).floor;\n\n // recursive calculation\n while {outArray.last < endNote}\n {outArray = outArray.add(groundNote + scale.wrapAt(i) + ((i/scale.size).floor * 12));\n i=i+1};\n\n // corrections:\n /* if(outArray.last > endNote)\n {outArray.pop};\n\n if(outArray[1] < startNote)\n {outArray.removeAt(1);}; */\n\n ^outArray.select({ |item| (item >= (startNote -0.5)) && (item <= (endNote + 0.5)) });\n\n }\n\n *makeScale { arg groundNote = \"C3\", type= 'major', startNote, endNote;\n ^Array.makeScaleMidi(groundNote.namemidi, type,\n {startNote.namemidi}.try, {endNote.namemidi}.try).midiname;\n }\n\n *makeScaleName { arg groundNote = \"C3\", type= 'major', startNote, endNote;\n // same as above - for convenience and clarity if needed\n ^Array.makeScaleMidi(groundNote.namem"}
+{"text": " for convenience and clarity if needed\n ^Array.makeScaleMidi(groundNote.namemidi, type,\n {startNote.namemidi}.try, {endNote.namemidi}.try).midiname;\n }\n\n *makeScaleCps { arg groundNote = 261.62556530114, type= 'major', startNote, endNote;\n ^Array.makeScaleMidi(groundNote.cpsmidi, type,\n {startNote.cpsmidi}.try, {endNote.cpsmidi}.try).midicps;\n }\n\n *fillNoteNames { arg startNote = \"C3\", endNote = \"B3\", step=1;\n // equal to Array.makeScale(type:'chromatic') but probably faster..\n var startNoteMidi = startNote.namemidi;\n ^(startNoteMidi, (startNoteMidi + step) .. endNote.namemidi).midiname;\n }\n\n namemidi { arg cents;\n ^this.collect(_.namemidi(cents));\n }\n namecps { arg cents;\n ^this.collect(_.namecps(cents));\n }\n namename {arg cents, sign;\n ^this.collect(_.namemidi(cents).midiname(sign));\n }\n midiname { arg sign;\n ^this.collect(_.midiname(sign));\n }\n cpsname { arg sign;\n ^this.collect(_.cpsname(sign));\n }\n }\n```"}
+{"text": "SuperCollider schelp — source/BhobUGens/sc/HelpSource/Classes/Latoocarfian2DL.schelp\n\nLatoocarfian2DL —\nlatoocarfian 2D chaotic generator\nSee also: Classes/Latoocarfian2DN, Classes/Latoocarfian2DC\nCategory: UGens>Generators>Stochastic\n\n\n\n```supercollider\nx(n+1) = sin(by(n)) + c*sin(bx(n))\ny(n+1) = sin(ay(n)) + d*sin(ax(n))\n```\n\nx values determine frequencies; y values determine amplitudes. Stable ranges for a & b tend to be between -3 to + 3. c & d between 0.5 and 1.5. There are combinations within these ranges that are unstable, so be prepared to tweak this oscillator.\n\n## ar, kr\n\n- minfreq,: maxfreq\niteration frequency in Hertz\n\n- a,: b, c, d\nequation variables\n\n- x0:\ninitial value of x\n\n- y0:\ninitial value of y\n\nExamples:\n\n```supercollider\n{ Latoocarfian2DL.ar(MouseX.kr(20, SampleRate.ir * 0.5), MouseX.kr(40, SampleRate.ir), mul:0.2) }.play(s);\n\n(\n{ Latoocarfian2DL.ar(\n SampleRate.ir/4,\n SampleRate.ir,\n LFNoise2.kr(2.dup, 1.5, 1.5),\n d:LFNoise2.kr(2.dup, 0.5, 1"}
+{"text": "SuperCollider schelp — source/BhobUGens/sc/HelpSource/Classes/PV_CommonMul.schelp\n\nPV_CommonMul —\nmultiplies common magnitudes\nSee also: Classes/PV_CommonMul\nCategory: UGens>FFT\n\n\n\nReturns magnitudes common to bufferA & bufferB within a tolerance level.\n\n## new\n\n- bufferA:\nfft buffer A.\n\n- bufferB:\nfft buffer B.\n\n- tolerance:\nmagnitudes within which test will pass\n\n- remove:\nscale uncommon magnitudes\n\nExamples:\n\n```supercollider\ns.boot;\n(\nb = Buffer.alloc(s, 2048, 1);\nc = Buffer.alloc(s, 2048, 1);\nd = Buffer.read(s, \"sounds/a11wlk01.wav\");\n);\n\n(\nSynthDef(\"help-commonMul\", { arg out=0, bufnumA=0, bufnumB=1, soundBufnum=2;\n var inA, inB, chainA, chainB, chain;\n inA = HPF.ar(Mix(LFSaw.ar([100, 150], 0, 0.2)), 1200);\n inB = PlayBuf.ar(1, soundBufnum, BufRateScale.kr(soundBufnum), loop: 1);\n chainA = FFT(bufnumA, inA);\n chainB = FFT(bufnumB, inB);\n chain = PV_CommonMul(chainA, chainB, MouseX.kr(0, 50"}
+{"text": ");\n chain = PV_CommonMul(chainA, chainB, MouseX.kr(0, 50), MouseY.kr);\n Out.ar(out, IFFT(chain).dup);\n}).play(s,[\\out, 0, \\bufnumA, b.bufnum, \\bufnumB, c.bufnum, \\soundBufnum, d.bufnum]);\n)\n```"}
+{"text": "SuperCollider schelp — source/BhobUGens/sc/HelpSource/Classes/PV_Compander.schelp\n\nPV_Compander —\nsimple spectral compression/expansion\nSee also: Classes/Compander\nCategory: UGens>FFT\n\n\n\nApplies compression/expansion to individual magnitudes.\n\n## new\n\n- buffer:\nfft buffer\n\n- thresh:\nmag thresh\n\n- slopeBelow,: slopeAbove\nsame as Compander\n\nExamples:\n\n```supercollider\ns.boot;\n(\nb = Buffer.alloc(s, 2048, 1);\nc = Buffer.read(s, \"sounds/a11wlk01.wav\");\n);\n\n// mostly compress\n(\nSynthDef(\"help-Compander\", { arg out=0, bufnum=0, soundBufnum=2;\n var in, chain;\n in = PlayBuf.ar(1, soundBufnum, BufRateScale.kr(soundBufnum), loop: 1);\n chain = FFT(bufnum, in);\n chain = PV_Compander(chain, MouseX.kr(1, 50), 1.2, 0.25);\n Out.ar(out, IFFT(chain).dup);\n}).play(s,[\\out, 0, \\bufnum, b.bufnum, \\soundBufnum, c.bufnum]);\n);\n\n// mostly expand\n(\nSynthDef(\"help-Compander2\", { arg out=0, bufnum=0, soundBufnum=2;\n var in, chain;\n "}
+{"text": "2\", { arg out=0, bufnum=0, soundBufnum=2;\n var in, chain;\n in = PlayBuf.ar(1, soundBufnum, BufRateScale.kr(soundBufnum), loop: 1);\n chain = FFT(bufnum, in);\n chain = PV_Compander(chain, MouseX.kr(1, 50), 2.0, 0.85);\n Out.ar(out, IFFT(chain).dup);\n}).play(s,[\\out, 0, \\bufnum, b.bufnum, \\soundBufnum, c.bufnum]);\n);\n\n// pv sustainer\n(\nSynthDef(\"help-Compander3\", { arg out=0, bufnum=0;\n var trig, in, chain;\n in =Mix(Ringz.ar(GaussTrig.ar(7.3), [160, 180], 0.2)).softclip;\n chain = FFT(bufnum, in);\n chain = PV_Compander(chain, MouseX.kr(1, 80), 0.1, 1.0);\n Out.ar(out, Limiter.ar(IFFT(chain), 0.999, 0.05).dup);\n}).play(s,[\\out, 0, \\bufnum, b.bufnum]);\n);\n\n(\nSynthDef(\"help-Compander3\", { arg out=0, bufnum=0;\n var trig, in, chain;\n in=LPF.ar(Mix(CombL.ar(Decay.ar(Dust.ar(0.5.dup(4)), 0.01, WhiteNoise.ar), 0.02, Array.rand(4, 0.005, 0.01), 0.2)), 1500);"}
+{"text": ".ar), 0.02, Array.rand(4, 0.005, 0.01), 0.2)), 1500);\n chain = FFT(bufnum, in);\n chain = PV_Compander(chain, MouseX.kr(1, 80), 0.1, 1.0);\n Out.ar(out, Limiter.ar(IFFT(chain), 0.999, 0.05).dup);\n}).play(s,[\\out, 0, \\bufnum, b.bufnum]);\n)\n```"}
+{"text": "SuperCollider schelp — source/BlackrainUGens/sc/HelpSource/Classes/BMoog.schelp\n\nBMoog —\n24db/oct rolloff - 4nd order resonant Low/High/Band Pass Filter\nSee also: Classes/SOS, Classes/RLPF, Classes/RHPF, Classes/BLowPass, Classes/BLowPass4, Classes/BHiPass, Classes/BHiPass4, Classes/BLowShelf, Classes/BHiShelf, Classes/BBandPass, Classes/BBandStop, Classes/BAllPass, Classes/IIRFilter, Classes/MoogFF\nCategory: UGens>Filters\n\n\n\nBlackRain's yet 'nother moog impersonation. oh yes.\n\n## ar\n\n- in:\ninput signal to be processed\n\n- freq:\ncutoff frequency\n\n- q:\nbandwidth / cutoffFreq.\n```supercollider\n0 < q > 1\n```\n\n- mode:\nfilter mode:\n\n- < 1 || low pass filter\n- < 2 || high pass filter\n- < 3 || bandpass filter\n\ndefaults to lowpass.\n\n- saturation:\n\nExamples:\n\n```supercollider\ns.boot;\n(\nz = {\n BMoog.ar(\n SoundIn.ar([0,1]),\n MouseX.kr(20,20000,\\exponential), // cutoff freq.\n MouseY.kr(1.0, 0.0, \\linear), // q\n 0"}
+{"text": " cutoff freq.\n MouseY.kr(1.0, 0.0, \\linear), // q\n 0, // mode - lowpass\n 0.25); // mul\n}.play\n);\nz.release;\n\n(\nz = {\n var sig, freq;\n freq = MouseX.kr(20,12000,\\exponential);\n sig = BMoog.ar(\n LFSaw.ar([freq * 0.99, freq * 1.01], 0, 0.1) ! 2,\n SinOsc.kr(SinOsc.kr(0.1),1.5pi,1550,1800),\n MouseY.kr(1,0,\\linear),\n 0); // filter mode - lowpass\n (CombN.ar(sig, 0.4, [0.4,0.35],2) * 0.4) + (sig * 0.5);\n}.play\n);\nz.release\n\n(\nz = {\n var sig, freq;\n freq = MouseX.kr(20,12000,\\exponential);\n sig = BMoog.ar(\n LFSaw.ar([freq * 0.99, freq * 1.01], 0, 0.1) ! 2,\n SinOsc.kr(SinOsc.kr(0.1),1.5pi,1550,1800),\n MouseY.kr(1,0,\\linear),\n 1); // filter mode - highpass\n (CombN.ar(sig, 0.4, [0.4,0.35],2) * 0.4) + (sig * 0.5);\n}.play\n);\nz.release\n\n(\nz = {\n var sig, freq;\n freq = MouseX.kr(20,12000,\\exponential);\n sig = BMoog.ar(\n L"}
+{"text": "q = MouseX.kr(20,12000,\\exponential);\n sig = BMoog.ar(\n LFSaw.ar([freq * 0.99, freq * 1.01], 0, 0.1) ! 2,\n SinOsc.kr(SinOsc.kr(0.1),1.5pi,1550,1800),\n MouseY.kr(1,0,\\linear),\n 2); // filter mode - bandpass\n (CombN.ar(sig, 0.4, [0.4,0.35],2) * 0.4) + (sig * 0.5);\n}.play\n);\nz.release\n\n(\nz = {\n var sig, freq;\n freq = MouseX.kr(20,12000,\\exponential);\n sig = BMoog.ar(\n LFSaw.ar([freq * 0.99, freq * 1.01], 0, 0.1) ! 2,\n SinOsc.kr(SinOsc.kr(0.1),1.5pi,1550,1800),\n MouseY.kr(1,0,\\linear),\n LFSaw.kr(1,0,3)); // filter mode - sweep modes\n (CombN.ar(sig, 0.4, [0.4,0.35],2) * 0.4) + (sig * 0.5);\n}.play\n);\nz.release\n\n// bhob's benchmark ;)\n(\nz = {\n var sig;\n sig = BMoog.ar(\n Mix(LFSaw.ar([120, 180], 0, 0.2)),\n LinExp.kr(LFCub.kr(0.1, 0.5pi), -1, 1, 280, 1500),\n 0.75,\n 2.0).dup;\n (CombN."}
+{"text": "pi), -1, 1, 280, 1500),\n 0.75,\n 2.0).dup;\n (CombN.ar(sig, 0.4, [0.4,0.35],2) * 0.4) + (sig * 0.5);\n }.play\n);\nz.release\n```"}
+{"text": "SuperCollider classlib — source/GlitchUGens/sc/GlitchUGens.sc\n\n```supercollider\n *ar { arg in = 0.0, freq = 440.0, rq = 1.0, mul = 1.0, add = 0.0;\n ^this.multiNew('audio', in, freq, rq).madd(mul, add)\n }\n *kr { arg in = 0.0, freq = 440.0, rq = 1.0, mul = 1.0, add = 0.0;\n ^this.multiNew('control', in, freq, rq).madd(mul, add)\n }\n}\n\nGlitchHPF : Filter {\n\n *ar { arg in = 0.0, freq = 440.0, mul = 1.0, add = 0.0;\n ^this.multiNew('audio', in, freq).madd(mul, add)\n }\n *kr { arg in = 0.0, freq = 440.0, mul = 1.0, add = 0.0;\n ^this.multiNew('control', in, freq).madd(mul, add)\n }\n}\n\nGlitchBPF : Filter {\n\n *ar { arg in = 0.0, freq = 440.0, rq = 1.0, mul = 1.0, add = 0.0;\n ^this.multiNew('audio', in, freq, rq).madd(mul, add)\n }\n *kr { arg in = 0.0, freq = 440.0, rq = 1.0, mul = 1.0, add = 0.0;\n ^this.multiNew('control', in, freq, rq).madd(mul, add)\n }"}
+{"text": "this.multiNew('control', in, freq, rq).madd(mul, add)\n }\n}\n\nGlitchBRF : GlitchBPF {}\n```"}
+{"text": "SuperCollider classlib — source/HOAUGens/sc/Classes/HOAConverterAcnSn3d2FuMa3.sc\n\n```supercollider\n *kr { | in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, in16 |\n ^this.multiNew('control', in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, in16)\n } \n\n checkInputs {\n if (rate == 'audio', {\n 16.do({|i|\n if (inputs.at(i).rate != 'audio', {\n ^(\" input at index \" + i + \"(\" + inputs.at(i) + \n \") is not audio rate\");\n });\n });\n });\n ^this.checkValidInputs\n }\n\n init { | ... theInputs |\n inputs = theInputs\n ^this.initOutputs(16, rate)\n }\n\n name { ^\"HOAConverterAcnSn3d2FuMa3\" }\n\n info { ^\"Generated with Faust\" }\n}\n```"}
+{"text": "SuperCollider classlib — source/HOAUGens/sc/Classes/HOARotator2.sc\n\n```supercollider\n *kr { | in1, in2, in3, in4, in5, in6, in7, in8, in9, pitch(0.0), roll(0.0), yaw(0.0) |\n ^this.multiNew('control', in1, in2, in3, in4, in5, in6, in7, in8, in9, pitch, roll, yaw)\n } \n\n checkInputs {\n if (rate == 'audio', {\n 9.do({|i|\n if (inputs.at(i).rate != 'audio', {\n ^(\" input at index \" + i + \"(\" + inputs.at(i) + \n \") is not audio rate\");\n });\n });\n });\n ^this.checkValidInputs\n }\n\n init { | ... theInputs |\n inputs = theInputs\n ^this.initOutputs(9, rate)\n }\n\n name { ^\"HOARotator2\" }\n\n info { ^\"Generated with Faust\" }\n}\n```"}
+{"text": "SuperCollider schelp — source/JoshUGens/sc/HelpSource/Classes/BFEncode2.schelp\n\nBFEncode2\nAmbisonic B format encoder\nCategory: Libraries>JoshUGens, UGens>Multichannel>Ambisonics\nSee also: Classes/BFDecode1, Classes/BFEncode1, Classes/BFEncodeSter, Classes/BFManipulate\nJoshUGens\n\n\nx, y positions:\n\n- 0 -1 behind\n- 0 1 in front\n- -1 0 right\n- 1 0 left\n\nOutput channels are in order W,X,Y,Z.\n\nWarning: Because of the way the W component is scaled, it is recommended that you only decode with BFDecode1 and it's methods. \n\n## ar\n\n- in:\nInput signal.\n\n- point_x:\nA point in the x axis.\n\n- point_y:\nA point in the y axis.\n\n- elevation:\nIn radians, -0.5pi to +0.5pi.\n\n- gain:\nA control rate level input.\n\n- wComp:\nChooses how the W channels is scaled. If 0, a scaler of 0.707 is used. If 1, W is varied according to the scaling of the X, Y and Z channels. 1 is the default.\n\n## init\n\nExamples:\n\n```supercollider\ns.boot;\n// You'll only hear the first two channels on a stereo setup.\n({\n #w, x, y, z = BFEncode2.ar(WhiteNoise.ar, MouseX.kr(-20, 20), MouseY."}
+{"text": " BFEncode2.ar(WhiteNoise.ar, MouseX.kr(-20, 20), MouseY.kr(20, -20), 0, 0.3);\n //decode for 4 channels\n BFDecode1.ar(w, x, y, z, [-0.25pi, 0.25pi, 0.75pi, 1.25pi], 0);\n}.scope(4));\n```"}
+{"text": "SuperCollider classlib — source/LoopBufUGens/sc/classes/LJP Classes/View/SCEnvelopeEdit.sc\n\nby Lance Putnam lance@uwalumni.com SCEnvelopeEdit : SCEnvelopeView { var = absTimes[bpm1], {\n// env.times[bpm1] = timePos - absTimes[bpm1];\n// absTimes[bp] = timePos;\n// },{ // going past left break point\n// env.times[bpm1] = 0;\n// absTimes[bp] = absTimes[bpm1];\n// });\n"}
+{"text": "\n// absTimes[bp] = absTimes[bpm1];\n// });\n// this.updateSegment(bpm1);\n// // a middle break point\n// },{\n// if(timePos > absTimes[bpp1], { // past right break point\n// env.times[bpm1] = absTimes[bp] - absTimes[bpm1];\n// env.times[bp] = 0;\n// absTimes[bp] = absTimes[bpp1];\n// },{ if(timePos < absTimes[bpm1], { // past left break point\n// env.times[bpm1] = 0;\n// env.times[bp] = absTimes[bpp1] - absTimes[bp];\n// absTimes[bp] = absTimes[bpm1];\n// },{\n// // set left segment dur\n// env.times[bpm1] = timePos - absTimes[bpm1];\n//\n// // set right segment dur\n// env.times[bp] = absTimes[bpp1] - timePos;\n//\n// absTimes[bp] = timePos;\n// }); });\n// this.updateSegment(bpm1);\n// this.updateSegment(bp);\n// if((timePos <= absTimes[bpp1]) && (timePos >= absTimes[bpm1]), {\n//\n//\n// });\n// }); });\n//\n// this.redraw;\n// }"}
+{"text": "\n// });\n// }); });\n//\n// this.redraw;\n// });\n// };\n//\n// this.updateAll;\n// this.redraw;\n//\n// numPoints.do({ arg i;\n// // make a breakpoint\n// if((i%pointsPerSegment) == 0, {\n// this.setThumbSize(i, 6);\n//\n// // color code breakpoints\n// if(i.div(pointsPerSegment) == env.releaseNode, {\n// this.setFillColor(i, Color.red(0.7));\n// },{\n// if(i.div(pointsPerSegment) == env.loopNode, {\n// this.setFillColor(i, Color.green(0.7));\n// },{\n// this.setFillColor(i, Color.blue(0.7));\n// });\n// });\n//\n// // Other points should be hidden.\n// },{ this.setThumbSize(i, 0) });\n// });\n//\n// }\n//\n// redraw {\n// this.value = viewPoints;\n// }\n//\n// refresh {\n// this.updateAll;\n// this.value = viewPoints;\n// }\n//\n// updateAll {\n// env.times.size.do({ arg i;\n// this.updateSegment(i);\n// });\n// }\n//\n// // updates segment values in viewPoints array\n// updateSeg"}
+{"text": ");\n// }\n//\n// // updates segment values in viewPoints array\n// updateSegment { arg segNum;\n// var time, slope, index1, index2, timeOffset;\n//\n// // update envelope cache\n// env.times = env.times;\n// env.levels = env.levels;\n// env.curves = env.curves;\n//\n// segNum = segNum.asInteger;\n//\n// time = absTimes[segNum];\n// timeOffset = absTimes[0];\n//\n// slope = env.times[segNum] / pointsPerSegment;\n//\n// index1 = pointsPerSegment * segNum;\n// index2 = index1 + pointsPerSegment - 1;\n//\n// for(index1, index2, { arg i;\n// viewPoints[0][i] = time.linlin(minTime, maxTime, 0.0, 1.0);\n// viewPoints[1][i] = env[time - timeOffset].linlin(minLevel, maxLevel, 0.0, 1.0);\n// time = time + slope;\n// });\n//\n// // draw break point at right level\n// if(slope == 0, {\n// viewPoints[1][index1] = env.levels[segNum].linlin(minLevel, maxLevel, 0.0, 1.0);\n// });\n//\n// // the last segment has an extra point at the end\n// if(segNum == (env"}
+{"text": "\n// // the last segment has an extra point at the end\n// if(segNum == (env.times.size-1), {\n// index2 = index2 + 1;\n// viewPoints[0][index2] = time.linlin(minTime, maxTime, 0.0, 1.0);\n// viewPoints[1][index2] = env.levels.last.linlin(minLevel, maxLevel, 0.0, 1.0);\n// });\n// }\n//\n// minLevel_ { arg level;\n// minLevel = level;\n// this.refresh;\n// }\n//\n// maxLevel_ { arg level;\n// maxLevel = level;\n// this.refresh;\n// }\n//\n// minTime_ { arg sec;\n// minTime = sec;\n// this.refresh;\n// }\n//\n// maxTime_ { arg sec;\n// maxTime = sec;\n// this.refresh;\n// }\n//}\n```"}
+{"text": "SuperCollider schelp — source/MCLDUGens/sc/HelpSource/Classes/Logger.schelp\n\nLogger —\nStore values to a buffer, whenever triggered\nCategory: UGens>Buffer\nSee also: Classes/ListTrig\n\n\nWrites a series of (control-rate) values to a Buffer, storing them strictly sequentially. Whenever trig crosses from non-positive to positive, the current value of the input will be written to the buffer. Storage starts at the buffer beginning and increments the write position until the buffer is full. If reset crosses from non-positive to positive, then the buffer will be zero'ed (all values set to zero) and the next write will begin again at the first entry.\n\nin can be an array - it should be of the same size as the number of channels in the buffer.\n\nNB: Logger zeroes the buffer upon first instantiation, to ensure that out-of-date data is not confused with new data. So it will definitely clobber any data you may have had in the buffer before it runs. It makes no sense to use multiple instances of Logger on the same buffer, since data will be overwritten.\n\nOutput is 1 in normal operation, then changes to 0 if triggers are received but there's no more space in the Buffer. (Flips back to 1 if you reset it.)\n\nExamples:\n\n```supercollider\ns.boot;\nb = Buffer.alloc(s, 100);\n(\n// This example simply stores values regularly sampled from an oscillator.\n// With such a small buffer, it doesn't take long to fill up.\n// Note what happens when full.\nx"}
+{"text": " With such a small buffer, it doesn't take long to fill up.\n// Note what happens when full.\nx = {\nvar source;\nsource = LFCub.kr(10, 0, EnvGen.kr(Env.linen(1, 2, 1), doneAction:2));\nLogger.kr(source, Impulse.kr(49), b.bufnum);\n}.play(s);\n);\nx.free;\nb.plot;\n\nb = Buffer.alloc(s, 100, 3);\n(\n// The same but multi-channel.\nx = {\nvar source;\nsource = LFCub.kr(10, 0, EnvGen.kr(Env.linen(1, 2, 1), doneAction:2));\nLogger.kr([source, source * 0.5, source + WhiteNoise.kr(0.3)], Impulse.kr(49), b.bufnum);\n}.play(s);\n);\nx.free;\nb.plot;\n\nb = Buffer.alloc(s, 100);\n(\n// This time we'll trigger something to create and store random values, and recall them later.\nx = { |t_trig=0, t_reset=0|\nvar source;\nsource = LFNoise0.kr(10);\nsource.poll(t_trig, \"Storing this random value\");\nLogger.kr(source, t_trig, b.bufnum, t_reset);\n}.play(s);\n);\n\nx.set(\\t_trig, 1); // Call this a few times\nb.loadToFloatArray(action:{|ar| ar.postcs}) // Dump the values\nx.set(\\t_reset, 1); // When you want to start"}
+{"text": "SuperCollider classlib — source/SCMIRUGens/sc/Classes/SpectralEntropy.sc\n\n```supercollider\n *kr {\n arg fft, fftsize=2048, numbands=1;\n \n if(numbands>fftsize) {\n \n numbands = fftsize; \n };\n \n ^this.multiNew('control', fft, fftsize, numbands);\n }\n \n init { arg ... theInputs;\n inputs = theInputs;\n\n ^this.initOutputs(theInputs[2], rate);\n }\n}\n```"}
+{"text": "SuperCollider schelp — source/SLUGens/sc/HelpSource/Classes/EnvDetect.schelp\n\nEnvDetect —\nEnvelope Follower Filter\nSee also: Classes/EnvFollow\nCategory: UGens>Analysis\n//SLUGens released under the GNU GPL as extensions for SuperCollider 3, by Nick Collins, http://composerprogrammer.com/index.html\nSLUGens\n\n\n\nCode adapted from musicdsp.org for a simple envelope tracking filter.\n\n## ar\n\n- in:\ninput\n- attack:\nattack time in seconds\n- release:\nrelase time in seconds\n\nExamples:\n\n```supercollider\n(\nSynthDef(\"help-EnvDetect\",{Out.ar(0,Pan2.ar(\nSinOsc.ar(440,0,0.3*EnvDetect.ar(LFNoise1.ar(20), MouseX.kr(0.001,0.1,'exponential'), MouseY.kr(0.001,0.1,'exponential')))\n,0.0))\n}).play\n);\n\n(\nSynthDef(\"help-EnvDetect\",{Out.ar(0,Pan2.ar(\nLFSaw.ar(EnvDetect.ar(LFNoise1.ar(11,100,200), MouseX.kr(2,0.0001,'exponential'), MouseY.kr(2,0.0001,'exponential')),0,0.3*EnvDetect.ar(LFSaw.ar(7), MouseX.kr(0.001,1,'exponential'),"}
+{"text": ".ar(LFSaw.ar(7), MouseX.kr(0.001,1,'exponential'), MouseY.kr(0.001,1,'exponential')))\n,0.0))\n}).play\n)\n```"}
+{"text": "SuperCollider patch — source/StkUGens/sc/STKinstructions.scd\n\n```supercollider\n/*\nThis package contains a number of ports of the\nStk physical models. They are not highly optimized\nand initializations can be very expensive. To\nget around this triggers are supplied in all\nunits so that they can be fired up in paused states\nand subsequently triggered and paused, thus greatly reducing\ninitialization cost. The downside of this is that\nyou have to keep track of the nodes, but that's not\na big deal. I've been initializing a bunch of instruments\nat the start, pausing for a freq seconds and then starting\nto play.\n\nInstallation instructions\n\n1) The rawwaves folder has to be parallel\nto the SuperCollider.app folder. i.e. the\nunits will look for ../rawwaves/etc. If you\nget 'realtime errors' it is in the wrong place.\nnotice: when building from source you will need to get these from the library itself (or the prebuilt lib package download from sc3-plugins sourceforge site).\nThe prebuilt UGens packages for Mac OS X come with this included.\n\n2) Copy all the .scx files to the plugins dir.\n\n3) These were compiled under 10.3.5 so they will\nonly work under XCode systems.\n\n4) Copy the classdefs file to the SCClassLibrary\nand recompile the Library.\n\n5) tests.rtf will quickly test each of the units.\nIf you get sound they're working.\n\n6) The classdefs.sc file contains minimal information\nabout each of the units. When"}
+{"text": " sound they're working.\n\n6) The classdefs.sc file contains minimal information\nabout each of the units. When it says that arguments\nare modulateable it means that they can also be changed\nwhen retriggering.\n\n7) Triggers\nWhen the trigger changes from a negative to a positive\nvalue the unit will do an STK noteOn(). In a number of\nthese models the attack portion has particular and \nnoticeable qualities so this can make a big difference.\nIt also allows you to avoid the expensive initializations.\n\nHere is an example using the Clarinet model\n*/\n(\nSynthDef(\"StkClarinet\", {arg freq=440,reedstiffness=64,noisegain=10,vibfreq=64,\n vibgain=10,breathpressure=64, gain=0.2,gate=1,bus=0, \n lag = 0.1,sloc=0,riset=0.2,decayt=0.2 ;\n\n var z,env;\n env = EnvGen.kr(Env.adsr(attackTime:riset, decayTime:0,sustainLevel:1,\n releaseTime:0.1,peakLevel:1),gate:gate, doneAction:0);\n\n z = StkClarinet.ar(\n freq:Lag.kr(freq, lag),\n reedstiffness:reedstiffness,\n noisegain:noisegain,\n vibfreq:vibfreq,\n vibgain:vibgain,\n breathpressure:breathpressure,\n trig:gate);\n Out.ar(bus, Pan2.ar(z,sloc)*env*"}
+{"text": " trig:gate);\n Out.ar(bus, Pan2.ar(z,sloc)*env*gain);\n }).load(s);\n);\n\n// test synthdef\nSynth(\"StkClarinet\", [\\riset, 12]).play\n\n// start up in paused state (usually necessary to slightly defer\n// the pause for some reason\n\n{s.sendMsg(\"/s_new\", \"StkClarinet\", n = s.nextNodeID ,0,0, \\freq, 440, \\gate, -1, \\reedstiffness, 64,\\i_bus, 0); \n {s.sendMsg(\\n_run, n, 0)}.defer(0.01); }\n// trigger a note\n s.sendBundle(nil, [\\n_set,n, \\gate, 1, \\freq, 440, \\gain, 0.1], [\\n_run, n,1]);\n // trigger another note \n s.sendBundle(nil, [\\n_set,n, \\gate, 1, \\freq, 540, \\lag, 0.1], [\\n_run, n,1]);\n // turn it off\n s.sendMsg(\\n_set, n, \\gate, -1.2);\n // pause the unit and free up the CPU\n s.sendMsg(\\n_run, n, 0);\n // start up another note\n s.sendBundle(nil, [\\n_set,n, \\gate, 1, \\freq, 100, \\vibgain, 50, \\breathpressure, 80, \\lag,0], [\\n_run, n,1]);\n// etc ( any parameters you change will apply to all subsequent notes)\n```"}
+{"text": "SuperCollider schelp — source/TagSystemUGens/sc/HelpSource/Classes/Dtag.schelp\n\nDtag —\ndemand rate tag system\nSee also: Classes/DbufTag\nCategory: UGens>Demand\n\n\nEmil Post's tag system as a demand rate ugen.\n\n## new\n\n- bufsize:\nmaximum string size - when this size is reached, the process ends (dependent on mode). Theoretically, tag systems have an infinite \"tape\" (memory) size - practically, one may want to try different finite sizes. This value is static. For a version that runs on a separate buffer, see DbufTag\n\n- v:\ndeletion number. Number of symbols that are deleted at each step.\n\n- axiom:\nthe string to start with - use integers from 0 to N, which correspond to rule indices.\n\n- rules:\nthe production rules are given as an array of arrays. For each integer the production rule at that position is chosen (see rule schema below).\n\n- recycle:\nif this is not zero, the tag system simply adds this value as an offset to its write position and continues where it normally would end. This results in a recycling tag system (see below).\n\n- mode:\nthis parameter decides in what case to apply the above recycle parameter. If recycle = 0, only mode 4 makes a difference.\n\n- mode 0 || both recycle when string overrun or string empty (default case)\n- mode 1 || recycle only when string overrun, halt when empty\n- mode 2 || recycle only when string empty, halt when overrun\n- mode 3 || always"}
+{"text": "\n- mode 2 || recycle only when string empty, halt when overrun\n- mode 3 || always halt\n- mode 4 || always halt and post information.\n- mode 5 || same, but post buffer values (max 32) and rule number.\n\nExamples:\n\n\ns.boot;\n\n// the examples by Emil Post again\n// directly listen to the tag system output (audification)\n// when the string size exceeds the size, the synth is freed (doneAction: 2)\n(\n{\n var tag, axiom, rules, size, dt;\n dt = SampleDur.ir; // play with audio rate\n size = SampleRate.ir * 2;\n axiom = [1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1];\n // axiom = axiom.scramble.keep(rrand(4, 16)).postln;\n v = 3;\n rules = [[1, 0], [1, 1, 0, 1]];\n tag = Dtag(size, v, axiom, rules);\n\n TDuty.ar(dt, 0, tag, doneAction: 2).dup * 0.1\n}.play;\n)\n\n// the above as a frequency input for a sine oscillator\n// control delta time by cursor position\n(\n{\n var tag, axiom, rules, size, dt, sineFreq;\n dt = MouseX.kr(1e-1, 1e-4, 1);\n size = 48000 * 2;\n axiom = [1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0,"}
+{"text": " 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1];\n v = 3;\n rules = [[1, 0], [1, 1, 0, 1]];\n tag = Dtag(size, v, axiom, rules);\n sineFreq = Duty.ar(dt, 0, tag, doneAction: 2)\n * 200 + 300;\n (SinOsc.ar(sineFreq.lag(dt)) * AmpCompA.kr(sineFreq) * 0.2).dup\n}.play;\n)\n\n// a slow demonstration\n// see DbufTag for an output of the string itself\n(\n{\n var tag, index, trig, rules, axiom;\n axiom = [1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1];\n rules = [[0, 0], [1, 1, 0, 1]];\n trig = Impulse.kr(4);\n tag = Dtag(256, 2, axiom, rules, mode: 5);\n index = Demand.kr(trig, 0, tag).poll(trig);\n SinOsc.ar(index* 100 + 300 + SinOsc.kr([4, 4.1], 0, 8)) * 0.1\n}.play;\n)\n\n/*\n1 0 1 0 1 0 0 1 1 1 0 1 0 1 1 1 1 0 0 1\n 1 0 1 0 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 1\n 1 0 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 1\n 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1\n "}
+{"text": " 0 1\n 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1\n 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 0\n 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 0 1 1 0 1\n 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 0 1 1 0 1 0 0\n 1 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 0 1 1 0 1 0 0 0 0 0\n 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 0 1 1 0 1 0 0 0 0 0 1 1 0 1\n ...\n\ncreating the series: 1 1 1 0 1 0 0 1 1 ...\n*/\n\n// demonstrating the mechanism of a recycling tag system\n// the tag game round the house\n(\n{\n var tag, trig;\n var deletionNumber = 3;\n var axiom = [0, 1, 2];\n var rules = [[0, 1], [2, 0], [1, 1]];\n var recycle = -3; // head start when writer was tagged.\n tag = Dtag(9, deletionNumber, axiom, rules, recycle, 5);\n\n SinOsc.ar(\n Duty.kr(1, 0, tag, doneAction:2)\n * 100 + 300 + SinOsc.kr([4, 4.1], 0, 8)\n )\n * 0.1 ! 2\n}.play;\n)\n\n// a more complicated tag system whith a random axiom.\n// u = 4\n// v varies [1..6] with cursor position\n// reinitialised when ended, a 1 sec pause each overrun."}
+{"text": "1..6] with cursor position\n// reinitialised when ended, a 1 sec pause each overrun.\n(\n{\n var tag, index, axiom, rules, freq, size;\n var deletionNumber = MouseX.kr(1, 6);\n // this is a big buffer, which is expensive to alloc in real time.\n // for large buffers, you may want to use DbufTag.\n size = 48000 * 4;\n freq = 15000;\n\n axiom = Array.fill(14, { #[0, 1, 2, 3].choose });\n axiom.join(\" \").postln;\n rules = [[0, 1, 1], [1, 3, 2, 0], [1, 2], [3, 1, 1]];\n\n tag = Dtag(size, deletionNumber, axiom, rules, 0, mode: 4);\n tag = Dseq([tag, Dseq([0], freq)], inf);\n index = Duty.ar(1 / freq, 0, tag, doneAction:2);\n SinOsc.ar(index * 1200 + 400).dup * 0.1\n\n}.play;\n)\n\n// aliens calling\n// u = 4, recycling tag system.\n// v varies (1..16) (cursor horizontal)\n// varying recycle value (cursor vertical)\n(\n{\n var tag, index, axiom, rules, freq, size;\n var deletionNumber = MouseX.kr(1, 16).floor;\n var recycle = MouseY.kr(-60, 60).floor;\n recycle = recycle + (recycle.abs < 1); // avoid 0.\n freq"}
+{"text": "floor;\n recycle = recycle + (recycle.abs < 1); // avoid 0.\n freq = SampleRate.ir;\n size = 6000; // small max string size. increase for higher complexity\n axiom = Array.fill(14, { #[0, 1, 2, 3].choose });\n axiom.join(\" \").postln;\n deletionNumber.poll(label: \"deletionNumber\");\n recycle.poll(label: \"recycle\");\n\n rules = [[0, 1, 1], [1, 3, 2, 0], [1, 2], [3, 1, 1]];\n\n tag = Dtag(size, deletionNumber, axiom, rules, recycle);\n index = Duty.ar(1 / freq, 0, tag, doneAction:2);\n SinOsc.ar(index * 1200 + 400).dup * 0.1\n\n}.play;\n)\n\n# Inputs and outputs\nMost inputs, also rule values, may themselves be demand rate ugens, or any other ugen or value. Thus, while the rule sizes stay the same, the rule values may dynamically changed. If those values are demand rate ugens, the rule values and the deletion number are evaluated each cycle, recycle is called each time the system ends.\n\nAt each step, Dtag outputs the tagged symbol, which is the rule index for the next step. If the appended string is needed instead, this can be done by applying the method #allSymbols to the UGen.\n\n# Rule schema\n\n\n0 -> 00\n1 -> 1101\n\nis written as [[0, 0], [1, 1, 0, 1]] \n\n\n0 -> 02\n1 -> 110"}
+{"text": " written as [[0, 0], [1, 1, 0, 1]] \n\n\n0 -> 02\n1 -> 1101\n2 -> 01\n\nis written as [[0, 2], [1, 1, 0, 1], [0, 1]] \n\n# Emil Post's tag systems\n\nEmil Post developed tag systems from the 1920s onward as an instrument of generalization of symbolic logic, hoping that it would allow the study of properties like decidability and completeness. Due to their intractibility he gave up the attempt to prove their unsolvability. Minsky showed later that tag systems are recursively unsolvable, i.e. of equivalent to a universal turing machine [2].\n\nThis type of rewriting system consists of an initial string of symbols (axiom), a set of rules and a deletion number (v). In our implementation, Post's parameter u (size of the alphabet) is implicit is the number of letters in the alphabet used. The deletion number is a very interesting parameter, since it determines what part of the string forms the instructions for the process and what part is omitted. Post described three classes of behaviour: termination, periodicity, and divergence. \"The classes with u = 1 or v = 1 or v = u = 2 were proven solvable. The case with u = 2, v > 2 he calls intractable, while he terms the cases u > 2, v = 2 as being of 'bewildering complexity'\" [4].\n\n# Further reading\n\n- [1] Martin Davis, The undecidable. Basic papers on undecidable propositions, unsolvable problems and computable functions, New York 1965. (see \"Account of an anticipation\").\n- [2] Marvin Mins"}
+{"text": " York 1965. (see \"Account of an anticipation\").\n- [2] Marvin Minsky, Recursive unsolvability of post's problem of tag and other topics in the theory of turing machines, Annals of Mathematics, 74:437-455, 1961.\n- [3] Elizabeth de Mol, Tracing Unsolvability. A Mathematical, Historical and Philosophical analysis with a special focus on tag systems, http://logica.ugent.be/centrum/writings/doctoraten.php (thanks a lot for introducing me to this topic!)\n- [4] Elizabeth de Mol, Closing the circle: An analysis of emil post's early work, The Bulletin of Symbolic Logic 12.\n- [5] Emil Post, Formal reductions of the combinatorial decision problem, American Journal of Mathematics, 65 (2), 197-215 (1943). (see p.203ff.)\n\nMore poetically, looking out for complex messages hidden in noise: Stanislav Lem, His Master's Voice, 1968.\n\n# How it works\n\nIn the beginning, the string is the axiom, and its first symbol is tagged. At each step, the rule is looked up that corresponds to this tagged symbol: 1 corresponds to the rule with index 1 (the 2nd), 0 corresponds to the rule with index 0 (the 1st) etc.\n\nIf no rule is found, the process halts. Otherwise, two things happen:\n\n- v number of symbols are dropped from the string by moving the tag v steps forward,\n- At the other end of the string, the symbols of the correspon"}
+{"text": " the string by moving the tag v steps forward,\n- At the other end of the string, the symbols of the corresponding production rule are appended.\n\nWhen the string is empty (i.e. the tag has reached its rightmost end), or the maximum memory size is reached, the process halts. When you set mode to 4, this information is posted (be careful, because posting at very high frequencies can overload the system).\n\n\n// One of the examples by Emil Post\n// printout: \"|\" represents the tag, \">\" represents the end of the string.\n// the printout is limited to 32 characters\n(\n{\n var tag, trig;\n trig = Impulse.kr(2); // advance 2 times a second\n tag = Dtag(\n 2048, // maximum string size\n 3, // advance three steps each turn\n [1, 0, 1], // axiom\n [[1, 0], [1, 1, 0, 1]], // rules\n 0, // no recycle\n 5 // print mode\n );\n Demand.kr(trig, 0, tag);\n 0.0 // silence for now\n}.play;\n)\n\n# Recycling tag systems: a variant of tag systems\n\nLike in an early procedure by Emil Post, in this implementation the symbols are not deleted from the end, but the reading position is advanced (the tag is moved forward). Mathew Cook developed a variant, where instead of a single axiom, one has a list of axioms that is used one after the other [3].\n\nInstead of assuming an infinite tape or such an axiom list, one now can try and see what happens if one assumes a cyclic tape instead - while this may not add any expressive power to the concept, it is an interesting special case. At"}
+{"text": " a cyclic tape instead - while this may not add any expressive power to the concept, it is an interesting special case. At the loop point (a certain limit string size), a new axiom is chosen from the beginning (r > 0), or backward, from the end of the tape (r < 0).\n\nIf recycle is not 0, instead of halting, the old string is reused by cutting out an axiom of that length from the current position and the process continues. For r > 0 the read position is advanced by r steps, for r < 0 the tag is moved back by r steps.\nIf mode = 1, recycling happens only when the string is too large.\nIf mode = 2, recycling happens happens only when the string is empty. (see above)\n\n\n// example:\n0 1 0|0 1 1 (vertical line is the tag. with r= 2, the new axiom would be 01, v= -3 it would be 010)\n\nIn the metaphor of the tag game, the recycle parameter ( r ) is the head start for the runaway writer before the tagger (see: http://en.wikipedia.org/wiki/Tag_%28game%29 )"}
+{"text": "SuperCollider snippet — Spectrogram of a sound file\n\nGenerates an Image containing the spectrogram of a soundfile\n\n```supercollider\n// requires SignalBox quark\n\n// 1. pick an fft size (must be power of two)\n~size = 2048;\n~size = 4096;\n\n// 2. path to a sound file\n~path = Platform.resourceDir +/+ \"sounds/a11wlk01.wav\";\n\n(\n// 3. analyze audio : this may take a little while for a long sound file\nvar data = Signal.read(~path);\nvar size = ~size;\n\nvar sf = SoundFile.openRead(~path);\nvar sampleRate = sf.sampleRate;\n\nvar hops = 4;\nvar window = Signal.hanningWindow(size);\n\nvar numFrames = (data.size / size * hops);\nvar fftMags = Array(numFrames);\n\nvar imag = Signal.newClear(size);\nvar cosTable = Signal.fftCosTable(size);\n\nsf.close;\n\n(data.size / size * hops).asInteger.do { |j|\n var i = j / hops;\n var r = data[(size * i).asInteger..(size * (i + 1) - 1).asInteger];\n r = r.addAll(Array.fill(size - r.size, {0}));\n r = r * window;\n fftMags.add((fft(r, imag, cosTable).magnitude.log10)[0..(size * 20000/sampleRate).asInteger]);\n};"}
+{"text": "agnitude.log10)[0..(size * 20000/sampleRate).asInteger]);\n};\n\n~fftMags = fftMags;\n);\n\n(\n// 4. generate image : this may also take a little while\nvar width = ~fftMags.size;\nvar height = ~fftMags[0].size;\nvar image = Image.new(width, height);\nvar scaleFunc = { |pixel| pixel.lincurve(0, height, 1, height, curve: 3) }; // curve factor for Y scaleing (0 = linear, 3 =~ mel scale)\nimage.setPixels(Int32Array.fill(width * height, { |i|\n var index = scaleFunc.(height - (i / width) - 1).asInteger;\n var frame = i % width;\n var mag = ~fftMags[frame][index];\n Image.colorToPixel(Color.gray(0, mag.lincurve(-2, 1, 0, 1, curve: 1.5))); // input range to adjust threshold, curve factor for contrast: 0-2\n}), Rect(0, 0, image.width, image.height));\n~image.free;\n~image = image;\n);\n\n// 5. display image\n~image.plot;\n```"}
+{"text": "SuperCollider snippet — yet another tweet\n\ndirty and noisy \"result\" of remembering/learning sc again. still dont understand why it does not work when i move .ar/kr to var definition. hh... will turn it into synthdef...\n\n```supercollider\n{var a=LFNoise0,b=SinOscFB,c=Pulse;b.ar(a.ar([2,3])*(c.ar([5,7],b.kr([7,5]))*(a.ar([3,2]))*[800,1200]),(c.kr([100,80])*[2,3]))}.play\n```"}
+{"text": "SuperCollider snippet — test test test silly gfx patch\n\nromanessco\n\n```supercollider\n// romanescoesque \n(\n var wi = 400, he = 400;\n var window = Window( \"\", Rect(100,100,wi+20,he+20) ).front;\n var view = UserView( window,Rect(10,10,wi,he) ).canFocus_(false);\n \n \n var c1 = Color.green( 0.2 ).alpha_( 0.1 ),c2 = Color.green, numSteps = 64, cstep = reciprocal( numSteps-1 );\n\n var point = Point(wi/2,he/2);\n var rect1 = Rect.aboutPoint( point, 10,10 );\n var rect2 = Rect.aboutPoint( point, 140,140 );\n var xstep = ( rect2.width-rect1.width ) / 2 / ( numSteps -1 );\n var ystep = ( rect2.height-rect1.height ) / 2 / ( numSteps -1 );\n\n view.drawFunc = { |v|\n var b0 = v.bounds.moveTo( 0,0 );\n Color.black.set;\n Pen.fillRect( b0 );\n\n Pen.width = 1;\n\n do( numSteps, { |i|\n blend( c1,c2, i*cstep ).set;\n Pen.use({\n Pen.rotate( pi * 4 / (numSteps"}
+{"text": " Pen.use({\n Pen.rotate( pi * 4 / (numSteps-1) * i, wi/2,he/2 );\n Pen.fillRect( rect2.insetBy( i*xstep, i*ystep ) )\n })\n // Color.grey.set;\n // Pen.strokeRect( rect2.insetBy( i*xstep, i*ystep ) );\n })\n\n }\n)\n```"}
+{"text": "SuperCollider snippet — floating02 patch\n\nLate night patching. Ocean and percussion.\n\n```supercollider\n(\n~phi = (5.sqrt + 1) /2;\n//squelchy space dust\n{ var dif, sig, f, curveA, curveB, filterA, filterB, local, local0, local1, gendy, inA, inB, pink;\n gendy = Gendy1.kr(0.1)!2;\n pink = PinkNoise.kr()!2;\n local = LocalIn.kr(2, 1);\n local0 = local[0];\n local1 = local[1];\n f = 0.01;\n curveA = 0.6;\n curveB = 0.4;\n dif = ( Blip.ar(f, 11)-(13*Blip.ar(f, 11, 1/13)) );\n sig = Limiter.ar(8999999 * LeakDC.ar(dif));\n sig = BandSplitter2.ar(sig, 6000 * ((local0).range(0.01, 2)) );\n inA = sig[0];\n inB = sig[1];\n inB = DelayN.ar(inB, 0.5, gendy.range(0, 0.5));\n LocalOut.kr(sig);\n //twinpeak ala hordijk\n filterA = SVF.ar(\n (inA+(curveA *inB)),\n 10000 * ((5*local0).range(0.01, 2)) ,\n 0.3 * pink.lag(0.5).range(1, 1.1)\n );\n filterB = SVF.ar(\n (-1)*(inB+(curveB * inA)),\n 800 * ((4*local1"}
+{"text": "\n (-1)*(inB+(curveB * inA)),\n 800 * ((4*local1).range(0.01, 2)),\n 0.9 * pink.lag(0.5).range(1, 1.1)\n );\n sig = LeakDC.ar(Limiter.ar((filterA+filterB)/2.5));\n }.play;\n\n//perc\n{ var dif, sig, f, curveA, curveB, filterA, filterB, local, local0, local1, gendy, inA, inB, pink, pink2;\n gendy = Gendy1.kr(0.1)!2;\n local = LocalIn.kr(2, 1);\n pink = PinkNoise.kr()!2;\n pink2 = PinkNoise.kr()!2;\n local0 = local[0];\n local1 = local[1];\n f = 0.1;\n curveA = 0.3;\n curveB = 0.8;\n dif = ( Dust2.ar(f)-(3*Dust2.ar(f, 1/3)) );\n sig = Limiter.ar(9999999 * LeakDC.ar(dif));\n sig = BandSplitter2.ar(sig, 2000 );\n sig[0] = ((CombC.ar(sig[0], 0.001, (local1/9999999).range(0.0001, 0.001), 2)/3) + (4*sig[0]))/5;\n LocalOut.kr(sig);\n //twinpeak ala hordijk\n inA = sig[0];\n inB = sig[1];\n inB = DelayN.ar(inB, 0.1, gendy.range(0, 0.1));\n filterA = SVF"}
+{"text": ".ar(inB, 0.1, gendy.range(0, 0.1));\n filterA = SVF.ar(\n (inA+(curveA * inB)),\n (1100/2) * ((3*local0).range(0.01, 2)) ,\n 0.98* pink2.range(0.99, 1.02)\n );\n filterB = SVF.ar(\n (-1)*(inB+(curveB * inA)),\n 100 * ((4*local1).range(0.01, 2)),\n 0.993* pink.range(0.99, 1.005)\n );\n sig = Limiter.ar((filterA+filterB)/3.1);\n }.play;\n\n//fill out the silences with some subtle stereo intrigue\n{(Crackle.ar(SinOsc.kr(0.02).range(0.4, 2))!2/30)}.play;\n{{(Crackle.ar(SinOsc.kr(0.02*~phi).range(0.4, 2))/20)}!2}.play;\n)\n```"}
+{"text": "SuperCollider snippet — Animation of Simple Harmonic Motion\n\nA GUI for animating summation of partials as simple harmonic motion, depicted as circular rotation correlated with a graph of amplitude vs. time.\n\n```supercollider\n(\n//Created by Eli Fieldsteel 2022 Feb 26\n\nvar shm, spectrum;\n\n//frequency-scaling factor: closer to zero -> slow motion\nvar freq_scale = 0.5;\n\n//amplitude-scaling factor: pixel radius when amplitude = 1\nvar amp_scale = 80;\n\n//spectrum is provided as an array containing one or more events\n//each event represents a sine wave with keys for 'freq', 'amp', and 'phs'\n\n//uncomment for examples\n/*sine (the default)*/ spectrum = [ (freq:1, amp:1, phs:0) ];\n// /*harmonics 1 & 2 */ spectrum = [ (freq:1, amp:1, phs:0), (freq:2, amp:1/2, phs:0) ];\n// /*harmonics 1 thru 4 */ spectrum = ((1..4).collect({ |n| (freq:n, amp:1/n, phs:0) }));\n// /*sawtooth*/ spectrum = ((1..12).collect({ |n| (freq:n, amp:1/n, phs:0) }));\n// /*square*/ spectrum = ((1,3..11).collect({ |n| (freq:n, amp:1/n, phs:0) }));\n// /*t"}
+{"text": "({ |n| (freq:n, amp:1/n, phs:0) }));\n// /*triangle*/ spectrum = ((1,3..11).collect({ |n| (freq:n, amp:1/(n**2), phs:n.odd.asInteger*pi+(pi/2)) }));\n// /*impulse (i.e. \"Blip\")*/ spectrum = ((1..12).collect({ |n| (freq:n, amp:1/4, phs:pi/2) }));\n\nWindow.closeAll;\n\nshm = {\n arg input = [(freq:1, amp:1, phs:0)], freqscl=0.5, ampscl=75, datasize=200, framerate=40;\n var win, cview, wview, phs;\n var t = 0; //time/phase counter\n var wavedata = Array.newClear(datasize); //waveform y-coordinate values\n\n win = Window(\n \"Simple Harmonic Motion Animation — (spacebar to pause/unpause)\",\n Rect(100, 100, 1020, 520)\n ).background_(Color.gray(0.2)).front;\n win.view.decorator_(FlowLayout(win.view.bounds, 10@10, 10@10));\n cview = UserView(win.view, 1000@500).background_(Color.gray(0.25));\n\n cview.drawFunc_({ |v|\n var center, newcenter, x, y;\n\n //dividing line between circles/waveform\n Pen.width_(2);\n Pen.strokeColor_"}
+{"text": "ing line between circles/waveform\n Pen.width_(2);\n Pen.strokeColor_(Color.gray(0.5));\n Pen.line(600@0, 600@520);\n Pen.stroke;\n\n //draw circles\n Pen.capStyle_(1);\n Pen.width_(2);\n input.do({ |sine, i|\n if (center == nil) { center = 300@250} { center = newcenter };\n x = cos(( (((t * freqscl) + (sine.phs / sine.freq ))) * sine.freq ) % 2pi) * sine.amp;\n y = sin(( (((t * freqscl) + (sine.phs / sine.freq ))) * sine.freq ) % 2pi) * sine.amp;\n newcenter = (x@y) * ampscl * Point(1,-1);\n newcenter = newcenter.translate(center);\n Pen.strokeColor_(Color.gray(i.linlin(0, input.size, 0.7, 0.5), 0.8));\n Pen.addArc(center, sine.amp * ampscl, 0, 2pi);\n });\n Pen.stroke;\n\n //draw radii\n center = nil;\n Pen.width_(4);\n input.do({ |sine, i|\n if (center == nil) { center = 300@250} { center = newcenter };\n x = cos(( (((t * freqscl) + (sine.phs / sine.freq ))) * sine.freq ) % 2pi) * sine.amp;\n y = sin(("}
+{"text": "req ))) * sine.freq ) % 2pi) * sine.amp;\n y = sin(( (((t * freqscl) + (sine.phs / sine.freq ))) * sine.freq ) % 2pi) * sine.amp;\n newcenter = (x@y) * ampscl * Point(1,-1);\n newcenter = newcenter.translate(center);\n Pen.strokeColor_(Color(0.25, i.linlin(0, input.size-1, 0.55, 0.85), 0.95, 0.9));\n Pen.line(center, newcenter);\n Pen.stroke;\n });\n\n //draw horizontal line connecting radii to waveform\n Pen.width_(2);\n Pen.strokeColor_(Color.gray(1,0.3));\n Pen.line(600@(newcenter.y), newcenter);\n Pen.stroke;\n\n //store y-coordinate\n wavedata = wavedata.rotate(1);\n wavedata.put(0, newcenter.y);\n\n //draw waveform with connecting lines between adjacent wavedata values\n Pen.width_(3);\n Pen.strokeColor_(Color(1, 0.75, 0, 0.6));\n wavedata.drop(-1).do({ |y,i|\n if (y.notNil && wavedata.wrapAt(i+1).notNil)\n {Pen.line(Point(600 + (i*2), y), Point(600 + (i*2+2), wavedata.wrapAt(i+1)))};\n });\n Pen.stro"}
+{"text": "*2+2), wavedata.wrapAt(i+1)))};\n });\n Pen.stroke;\n\n //advance time\n (t = t + (2pi/framerate))%2pi;\n\n });\n\n cview.frameRate_(framerate);\n cview.animate_(true);\n\n //spacebar to pause\n cview.keyDownAction_({ |v, char|\n if (char == $ ) { cview.animate_(cview.animate.not) };\n });\n};\n\nshm.(spectrum, freq_scale, amp_scale); //run\n)\n```"}
+{"text": "SuperCollider snippet — Simple noise mixer with GUI\n\na simple noise eq with 10 filter bands and a gui.\n\n```supercollider\n(\nNdef(\\x).clear;\nNdef(\\x, {\n |amp1 = 0, amp2 = 0, amp3 = 0, amp4 = 0, amp5 = 0, amp6 = 0,\n amp7 = 0, amp8 = 0, amp9 = 0, amp10 = 0, rq = 0.8|\n var freq1=36, freq2=75, freq3=157, freq4=329, freq5=688, freq6=1440, freq7 = 3013,\n freq8 = 6303, freq9=13184, freq10=18000;\n\n var sig = [PinkNoise.ar(1), PinkNoise.ar(1)];\n sig = BPeakEQ.ar(sig, freq1, rq, amp1);\n sig = BPeakEQ.ar(sig, freq2, rq, amp2);\n sig = BPeakEQ.ar(sig, freq3, rq, amp3);\n sig = BPeakEQ.ar(sig, freq4, rq, amp4);\n sig = BPeakEQ.ar(sig, freq5, rq, amp5);\n sig = BPeakEQ.ar(sig, freq6, rq, amp6);\n sig = BPeakEQ.ar(sig, freq7, rq, amp7);\n sig = BPeakEQ.ar(sig, freq8, rq, amp8);\n sig = BPeakEQ.ar(sig, freq9, rq, amp9);\n sig = BP"}
+{"text": "ig = BPeakEQ.ar(sig, freq9, rq, amp9);\n sig = BPeakEQ.ar(sig, freq10, rq, amp10);\n sig = Limiter.ar(sig * 0.1, 1, 0.01);\n\n}).play;\n\ntry{~win.close};\n~win = Window('noise mixer', Rect(400,400,600,300));\n~win.front.alwaysOnTop_(true);\n~reset = {\n b.value_(0.31);\n a.do{ |sl| sl.value_(0.5)};\n Ndef(\\x).resetNodeMap;\n};\n\na = {Slider(~win, Rect(0, 0, 20, 100)).value_(0.5)} ! 10;\nb = Slider(~win, Rect(0, 00, 10, 10)).value_(0.31).action_({ |sl|\n Ndef(\\x).set(\\rq, sl.value.linlin(0, 1, 0.1, 3).postln)});\nc = StaticText().string_(\"Filter Bands\").align_(\\center);\nd = StaticText().string_(\"Q Factor\").align_(\\center);\ne = Button().states_([[\"reset\"]]).action_({ ~reset.value});\n\n~win.layout = HLayout(\n VLayout(c, HLayout(*a)),\n VLayout(d, b),\n e\n);\n\na.do{ |ins, c=0| c = c+1; ins.addAction({ |sl|\n ~sl = sl.value;\n ~low = -24;\n ~high ="}
+{"text": "ction({ |sl|\n ~sl = sl.value;\n ~low = -24;\n ~high = 24;\n switch(c,\n 1, {Ndef(\\x).set(\\amp1, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 2, {Ndef(\\x).set(\\amp2, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 3, {Ndef(\\x).set(\\amp3, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 4, {Ndef(\\x).set(\\amp4, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 5, {Ndef(\\x).set(\\amp5, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 6, {Ndef(\\x).set(\\amp6, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 7, {Ndef(\\x).set(\\amp7, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 8, {Ndef(\\x).set(\\amp8, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 9, {Ndef(\\x).set(\\amp9, ~sl.linlin(0, 1, ~low, ~high).postln)},\n 10, {Ndef(\\x).set(\\amp10, ~sl.linlin(0, 1, ~low, ~high).postln)},\n\n)});\n}\n"}
+{"text": "SuperCollider snippet — Polyswing_asym\n\nRhythm-Experiment for sambalike patterns. The goal are cyclic patterns that accelerate in asymetrical way inside one cycle.\n\n```supercollider\n// Rhythm-Experiment for sambalike patterns. The goal are cyclic patterns that accelerate in asymetrical way inside one cycle.\n\n// Masterclock is a LFSaw that's bent via lincurve with the \"swing\"-argument.\n// Speed is in Hz.\n\n// Behaves asymetrial.\n// swing = 0 is linear. Negative values shift things towards start, positive values towards end of cycle.\n\n// The masterclock is chopped with the \"div\"-argument in shorter parts for each instrument.\n// Negative values and zero for \"div\" should be avoided.\n\n// The raw clock-signals control the instruments. More organic than classic triggers and envelopes, but strange sometimes.\n\n// Default volumes of intruments are high for saturation and distortion.\n\ny=Synth(\\polyswingasym)\ny.free\n\ny.set(\\swing,0.5);\n\ny.set(\\speed,1);\n\ny.set(\\kickv,86);\ny.set(\\snrv,72);\ny.set(\\hhv,111);\ny.set(\\tmv,64);\ny.set(\\clvv,30);\ny.set(\\wdv,20);\n\ny.set(\\deckick,6);\ny.set(\\decsnr,4);\n\ny.set(\\div1,2);\ny.set(\\"}
+{"text": "\ny.set(\\decsnr,4);\n\ny.set(\\div1,2);\ny.set(\\div2,3);\ny.set(\\div3,5);\ny.set(\\div4,6);\ny.set(\\div5,7);\ny.set(\\div6,4);\n\ny.set(\\frqkick,65);\ny.set(\\frqtm,195);\n\n(\nSynthDef(\\polyswingasym,{\n\n arg frqkick=45, frqtm=135, reskick=0.05, deckick=4, decsnr=4, speed=1, swing=0.5, div1=2, div2=3, div3=4, div4=6, div5=8, div6=3, out=0, kickv=86, snrv=74, hhv=110, tmv=70, clvv=30, wdv=100;\n\n var sig, master, master2, trig1, trig2, trig21, trig3, trig4, trig5, trig6,\n kick,envkick,snr,envsnr,hh,tm,clv,wd;\n\n master = LFSaw.ar(speed,pi,0.5,0.5).lincurve(0,1,0,1,swing);\n\n trig1 = (master%(1/div1))*div1;\n trig2 = (master%(1/div2))*div2;\n trig3 = (master%(1/div3))*div3;\n trig4 = (master%(1/div4))*div4;\n trig5 = (master%(1/div5))*div5;\n trig6 = (master%(1/div6))*div6;\n\n envkick = (("}
+{"text": "div5;\n trig6 = (master%(1/div6))*div6;\n\n envkick = (((trig1.neg+1).lincurve(0,1,0,1,deckick).cubed*2)+1).lag(0.001);\n\n envsnr = ((trig2.neg+1).lincurve(0,1,0,1,decsnr).cubed).lag(0.001);\n\n kick= Resonz.ar(trig1,frqkick*envkick,0.005,kickv);\n snr= (Resonz.ar(trig2,222,0.02,4)+WhiteNoise.ar(0.01)+Dust2.ar(123,0.01))*envsnr.tanh*snrv;\n hh= RHPF.ar(Mix.new(Resonz.ar(trig3,Array.linrand(11,4000,6500),0.0005)),2400,0.4,hhv);\n tm= Resonz.ar(trig4,frqtm,0.03,tmv);\n clv= HPF.ar(Mix.new(Resonz.ar(trig5,Array.linrand(9,500,3500),0.01,clvv)),700);\n wd= Resonz.ar(trig6,850,0.04,wdv);\n\n sig = kick+snr+hh+tm+clv+wd;\n\n Out.ar(out,LeakDC.ar(sig!2).tanh);\n}).add;\n)\n```"}
+{"text": "SuperCollider snippet — Filter Explorer @ 1000 Hz of the Cutoff Frequency (Centre Frequency)\n\nSpecial Thanks to Russell Johnston who gave an excellent solution to MouseLeaveAction issue via the sc-users list!\nThanks to Fredrik Olofsson who mentioned to the related issue as well.\n\n```supercollider\n(\ns.waitForBoot{\n var synth, srcs, snds, path, win, bnds, view, vIn, scope, h, w, v, iW, oW, btns, f, snd, flt, fltSel, fltTxts;\n \n fltSel = Bus.control(s,1);\n \n synth = {\n arg which, frq, mul;\n var in, src, rq;\n in = Saw.ar(200,0.3!2);\n srcs = [\n Decay.ar(\n Impulse.ar(LFGauss.kr(5, 0.5).range(2, 7)),\n 0.1,\n in*MouseButton.kr(0, 1, 0.001)\n ),\n WhiteNoise.ar(0.08!2),\n PinkNoise.ar(0.08!2),\n BrownNoise.ar(0.08!2),\n GrayNoise.ar(0.08!2),\n ClipNoise.ar(0.08!2),\n Impulse.ar(10!2),\n Dust.ar(10!2),\n Dust2.ar(10!2),\n Crackle.ar(1.5, 0.08!2)\n ];\n src = Select.ar(which, srcs);\n \n rq"}
+{"text": " 0.08!2)\n ];\n src = Select.ar(which, srcs);\n \n rq = MouseY.kr(0.01, 10, 1);\n \n snds = [\n src,\n LPF.ar(src, frq),\n LPF.ar(LPF.ar(src, frq), frq),\n HPF.ar(src, frq),\n BRF.ar(src, frq, rq),\n BPF.ar(src, frq, rq),\n Resonz.ar(src, frq, rq),\n Resonz.ar(\n Resonz.ar(src, frq, rq),\n frq,\n rq\n ),\n BBandPass.ar(src, frq, rq),\n RLPF.ar(src, frq, rq),\n RHPF.ar(src, frq, rq)\n ];\n \n flt = Out.kr(fltSel, MouseX.kr(0, snds.size));\n \n Select.ar(In.kr(fltSel), snds) * mul\n };\n \n snd = synth.play(args:[frq:1000, mul:0, which:0]);\n \n bnds = Window.screenBounds;\n h = bnds.height;\n w = bnds.width;\n win = Window(\"control\", Rect(0, 0, w, h)).fullScreen;\n win.onClose_{ snd.free };\n iW = w/srcs.size;\n oW = w/snds.size;\n \n StaticText(win, Rect(10, 10, 500, 30))\n .align_(\\"}
+{"text": "size;\n \n StaticText(win, Rect(10, 10, 500, 30))\n .align_(\\topLeft)\n .font_(Font(\"Arial\", 24))\n .string_(\"Input Signal (Source) Seleciton:\");\n \n btns = srcs.size.collect {\n |i|\n var x, inputs, outputs;\n inputs = [\n \"decay\",\n \"whiteNoise\",\n \"pinkNoise\",\n \"brownNoise\",\n \"grayNoise\",\n \"clipNoise\",\n \"impulse\",\n \"dust\",\n \"dust2\",\n \"crackle\"\n ][i];\n Button(win, Rect(iW * i, 50, iW, 30))\n .states_([\n [inputs, Color.grey, Color.white],\n [inputs, Color.white, Color.grey]\n ])\n .action_{ arg butt;\n if(butt.value == 1) {\n snd.set(\\which, i);\n btns.size.do{|n|\n [n, i];\n if (n != i) { btns[n].value = 0 }\n }\n }\n }\n .value_(if(i==0) { 1 })\n };\n \n StaticText(win, Rect(10, 95, 2000, 60))\n .align_(\\topLeft)\n .font_(Font(\"Arial\", 24))\n .string_(\"Input Signal (Source) Seleciton: Select the output signal (filtered sound) by pressing the mouse button and dragging the mouse pointer across the columns. The vertical position of the 5th through 11th columns is related to the Q-factor.\");\n \n "}
+{"text": "er across the columns. The vertical position of the 5th through 11th columns is related to the Q-factor.\");\n \n view = UserView(win, Rect(0, 160, w, h-430));\n \n vIn = true;\n \n view\n .mouseDownAction_{ |view, x, y, modifiers, buttonNumber, clickCount|\n if(buttonNumber==0 && (clickCount==1)) { snd.set(\\mul, 1) }\n }\n .mouseUpAction_{ |view, x, y, modifiers, buttonNumber, clickCount|\n if(buttonNumber==0) { snd.set(\\mul, 0) }\n }\n .mouseLeaveAction_{ |view, x, y|\n snd.set(\\mul, 0)\n }\n .mouseMoveAction_{ | view, x, y |\n if (view.bounds.containsPoint(x@(y + 160))) {\n vIn = true;\n snd.set(\\mul, 1)\n } {\n if (vIn) {\n vIn = false;\n view.mouseLeaveAction.()\n } }\n }\n .animate_(true);\n \n fltTxts = snds.size.collect{\n |i|\n var outputs;\n outputs = [\n \"S\\nR\\nC\",\n \"S\\nR\\nC\\n↓\\nL\\nP\\nF\",\n \"S\\nR\\nC\\n↓\\nL\\nP\\nF\\n↓\\nL\\nP\\nF\",\n \"S\\nR\\nC\\n↓\\nH\\nP\\nF\",\n \"S\\nR\\nC\\n↓\\nB\\nR\\nF\",\n \"S\\nR\\nC\\"}
+{"text": "\\nR\\nC\\n↓\\nB\\nR\\nF\",\n \"S\\nR\\nC\\n↓\\nB\\nP\\nF\",\n \"S\\nR\\nC\\n↓\\nR\\nE\\nS\\nO\\nN\\nZ\",\n \"S\\nR\\nC\\n↓\\nR\\nE\\nS\\nO\\nN\\nZ\\n↓\\nR\\nE\\nS\\nO\\nN\\nZ\",\n \"S\\nR\\nC\\n↓\\nB\\nB\\nA\\nN\\nD\\nP\\nA\\nS\\nS\",\n \"S\\nR\\nC\\n↓\\nR\\nL\\nP\\nF\",\n \"S\\nR\\nC\\n↓\\nR\\nH\\nP\\nF\"\n ][i];\n StaticText(view, Rect(oW * (i + 0.1), 10, 200, 500))\n .align_(\\topLeft)\n .font_(Font(\"Arial\", 24))\n .string_(outputs)\n };\n \n view.drawFunc = {\n snds.do {\n |which, i|\n Pen.strokeColor = Color.black;\n Pen.moveTo(0@0);\n Pen.lineTo(0@h);\n Pen.translate(oW, 0);\n Pen.stroke;\n \n fltTxts[i].stringColor_(\n if(fltSel.getSynchronous.asInteger==i) {\n Color.black\n }{\n Color.gray\n }\n )\n }\n };\n \n ServerMeterView.new(s, win, 10@(h-235),"}
+{"text": ")\n }\n };\n \n ServerMeterView.new(s, win, 10@(h-235), 0, 2);\n \n scope = UserView(win, Rect(90, h-257, 247, 247));\n Stethoscope(s, view:scope);\n \n FreqScopeView(win, Rect(350, h-255, w-360, 245))\n .active_(true)\n .freqMode_(1);\n \n win.front\n}\n)\n```"}
+{"text": "SuperCollider snippet — Equal-Loudness Contour Experience in SC\n\nEqual-Loudness Contour Experience in SC\n\nspecial thanks to James Harkins who resolved my errors in the code via the sc-users list!\n\n```supercollider\n(\ns.waitForBoot{\n var\n freqs = [0] ++ Array.geom(19, 30, 1.425),\n strps = [$a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $q, $r, $t, $u],\n numDB = 34,\n buttW = 39,\n buttH = 13,\n strpH = buttH * numDB,\n margL = 0,\n margR = 10,\n margT = 10,\n margB = 10,\n windW = buttW * strps.size + margL + margR,\n windH = strpH + margT + margB,\n winPH = Window.screenBounds.width - windW / 2,\n winPV = Window.screenBounds.height - windH / 2;\n\n strps.size.do{\n |i|\n (freqs[i] < 1000).if(\n { freqs[i] = freqs[i].round(5) },\n { freqs[i] = freqs[i].round(500) }\n )\n };\n\n x = {\n |freq=0, amp=1, trig=0|\n SinOsc.ar(\n freq,\n 0,\n amp*(EnvGen.ar(Env.asr(0.08, 0.2, 0.12, \\welch), trig"}
+{"text": "Gen.ar(Env.asr(0.08, 0.2, 0.12, \\welch), trig, doneAction: 0))\n )\n }.play;\n\n w = Window.new(\"Equal-Loudness Contour Finding Tool\",Rect(winPH, winPV, windW, windH)).front;\n\n strps.do{\n |name, frqIdx|\n var frqStrp = VLayoutView(w,Rect(frqIdx*buttW + margL, margT, buttW, strpH)),\n thisFreq = freqs[frqIdx],\n dbLabelW = buttW/2,\n lastClickId= 0;\n\n (frqIdx == 0).if(\n {\n StaticText(frqStrp, buttW@buttH)\n .string_(\"dB\")\n .align_(\\center)\n .font_(Font(\"Arial\", 9))\n .stringColor_(Color.grey);\n\n name = numDB.collect{\n |dbIdx|\n var db = (1/(2**(dbIdx/2))).ampdb.round;\n StaticText(frqStrp, dbLabelW@buttH)\n .string_(db)\n .align_(\\center)\n .font_(Font(\"Arial\", 9))\n .stringColor_(Color.grey);\n };\n },\n\n {\n StaticText(frqStrp, buttW@buttH)\n .string_((thisFreq<1000).if({ thisFreq+\"Hz\" },{ (thisFreq/1000)+\"kHz\""}
+{"text": ").if({ thisFreq+\"Hz\" },{ (thisFreq/1000)+\"kHz\" }))\n .align_(\\center)\n .font_(Font(\"Arial\", 9));\n\n name = numDB.collect{\n |dbIdx|\n var db = (1/(2**(dbIdx/2))).ampdb.round;\n Button(frqStrp, buttW@buttH)\n .states_([\n [\n \"\",\n Color.grey,\n Color.green(1, 1-(((dbIdx)*9)/400))\n ],\n [\n db,\n Color.grey,\n Color.new(0,1,0.7, 1-(((dbIdx)*9)/400))\n ]\n ])\n .mouseDownAction_{\n x.set(\n \\freq, freqs[frqIdx].postln,\n \\amp, db.dbamp.postln, \\trig, 1\n );\n name[lastClickId].value = 0;\n }\n .mouseUpAction_{\n x.set(\\trig, 0);\n lastClickId = dbIdx\n }\n }\n }\n )\n }\n}\n)\n```"}
+{"text": "SuperCollider snippet — generative melody\n\n```supercollider\n/*\nRequires SC3-plugins:\nJPverb\nWaveLoss\nGreyhole\n*/\n\n(\nNdef(\\n, {\n\n //var lfo = A2K.kr(HenonC.ar(1));\n //var lfo = A2K.kr(StandardL.ar([1,3]));\n var lfo1 = LFPulse.kr(1/16).range(1/2,1);\n var lfo = min(LFTri.kr([lfo1/2, lfo1/3], mul: 3).tanh, LFDNoise1.kr(lfo1));\n\n var in = lfo.range(0, 11).round;\n // Kumoi scale\n var scale = [\n \\s0.kr(1),\n \\s1.kr(0),\n \\s2.kr(1),\n \\s3.kr(1),\n \\s4.kr(0),\n \\s5.kr(1),\n \\s6.kr(0),\n \\s7.kr(1),\n \\s8.kr(0),\n \\s9.kr(1),\n \\s10.kr(0),\n \\s11.kr(0)\n ];\n\n var inscale = Select.kr(in, scale);\n var semi = in * inscale;\n\n var trig = Changed.kr(semi);\n var trig2 = PulseDivider.kr(trig, 3);\n var midi = TChoose.kr(trig2, \\root.kr(60) + [0, 12, 24]) + (semi) * (inscale > 0);\n\n var env = Decay2.kr(in:t"}
+{"text": " + (semi) * (inscale > 0);\n\n var env = Decay2.kr(in:trig * (inscale > 0), decayTime:lfo1);\n var freq = midi.midicps;\n var sig = SinOscFB.ar(freq.lag(0.01) * [1, 1.01], feedback: SinOsc.kr(0.1).range(0.3,0.7)) * env;\n\n sig = RLPF.ar(sig, env.range(880, 2200), 0.3);\n sig = XFade2.ar(sig, JPverb.ar(HPF.ar(sig, 100), t60:1, size:3), 0);\n sig = XFade2.ar(sig, WaveLoss.ar(sig), -0.1);\n sig = XFade2.ar(sig, Greyhole.ar(sig), -0.75);\n\n sig * 0.2;\n\n}).play;\n);\n\n/////////////////////////\n// randomly change the scale\n// (Kumoi scale sounds nice)\n(\nvar vals = Array.fill(12, 0);\nvar scale = Scale.choose(size:[5,7].choose, pitchesPerOctave:12);\nscale.name.postln;\nscale.degrees.do({arg val;\n vals[val] = 1;\n});\nvals.do({arg val, i;\n var key = (\\s ++ i).asSymbol;\n Ndef(\\n).set(key, val);\n});\n)\n```"}
+{"text": "SuperCollider snippet — Molecular music box\n\nInspired by this post http://www.kimri.org/blog/?p=487 I rewritten the algo to use more the patterns, so it's generated on the fly and it's easy to customize it =)\n\n```supercollider\n(\n TempoClock.default.tempo = 1;\n \n Pbind(\n \\index, Pseq((0..15),inf),\n \\dur, 1/4,\n \\octave, 4,\n \\do, Prout({ arg ev;\n var degstr = Pseq((0..24)).asStream; // degrees\n var lenstr = Pseq([4,3],inf).asStream; // note length\n var buf = Array.fill(16,{List.new}); // record loop buffer\n var deg, len;\n\n len = lenstr.next;\n\n inf.do { \n\n var i = ev[\\index];\n var n = buf[i];\n\n if(n.size != 0) {\n // previous note found, change note length\n len = lenstr.next;\n };\n\n deg = degstr.next;\n n.add([deg, len]);\n\n len.do {\n var i = ev[\\index];\n var n = buf[i];\n\n if(n.size != 0) {\n ev[\\degree] = n.flop[0];\n ev[\\legato] = n.flop[1];\n } {\n ev[\\isRest] = true;\n };\n ev = deg.yield;\n };\n }\n }),\n ).trace.play\n);\n\n(\n// change"}
+{"text": " = deg.yield;\n };\n }\n }),\n ).trace.play\n);\n\n(\n// change the rules a bit\n \nPdef(\\mol,\n Pbind(\n \\index, Pseq((0..15),inf),\n \\dur, 1/4,\n //\\root, Pseq([2,0],inf),\n \\mtranspose, Pseq([0,3,4,3],inf).stutter(8),\n \\octave, 4,\n \\scale, Scale.dorian,\n \\do, Prout({ arg ev;\n var degstr = Pseq((0..13),inf).asStream;\n var lenstr = Pseq([3,8,2],inf).asStream;\n var buf = Array.fill(16,{List.new});\n var keep = 3; // max note per chord\n var deg, len;\n\n len = lenstr.next;\n\n inf.do { \n\n var i = ev[\\index];\n var n;\n buf[i] = buf[i].keep(0-keep);\n n = buf[i];\n\n if(n.size != 0) {\n // previous note found, change note length\n len = lenstr.next;\n };\n\n deg = degstr.next;\n n.add([deg, len]);\n\n len.do {\n var i = ev[\\index];\n var n = buf[i];\n\n if(n.size != 0) {\n ev[\\degree] = n.flop[0];\n ev[\\legato] = n.flop[1]/2;\n //ev[\\legato] = 1;\n } {\n ev[\\isRest] = true;\n };"}
+{"text": "v[\\legato] = 1;\n } {\n ev[\\isRest] = true;\n };\n ev = deg.yield;\n };\n }\n }),\n ).trace\n).play;\n)\n```"}
+{"text": "SuperCollider snippet — Greyhole example\n\nSee Greyhole from DEIND UGens at SCPlugins\n\n```supercollider\nSpec.add(\\delayTime, [0, 2]);\nSpec.add(\\damp, [0, 1]);\nSpec.add(\\size, [0.5, 3]);\nSpec.add(\\diff, [0, 1]);\nSpec.add(\\feedback, [0, 1]);\nSpec.add(\\modDepth, [0, 50]);\nSpec.add(\\modFreq, [0, 10]);\n\nNdef(\\reverb, {\n var in = SoundIn.ar([14, 15]);\n Greyhole.ar(in, \\delayTime.kr(2), \\damp.kr(0), \\size.kr(1), \\diff.kr(0.707), \\feedback.kr(0.9), \\modDepth.kr(0.1), \\modFreq.kr(0.61))\n})\n```"}
+{"text": "SuperCollider snippet — Scanned Synthesis Visualisation\n\nVisualization of scanned string synthesis.\n\n```supercollider\n~numsprings = 41;\n(\nSynthDef(\\scansynth41, { arg amp=0.1, gate=1, pan=0, freq=440, spring, damp;\n var in, ou;\n var springs;\n var sel;\n var env;\n in = LPF.ar(LocalIn.ar(1), XLine.ar(1,10,0.3)) * 0.97 + (LPF.ar(Trig.ar(gate, 0.01),200) * WhiteNoise.ar.range(0.98,1));\n spring = spring.dup(~numsprings);\n damp = damp.dup(~numsprings);\n ou = in;\n springs = spring.collect { arg spr, i;\n ou = Spring.ar(ou, spr, damp[i]);\n };\n LocalOut.ar(ou);\n sel = VarSaw.ar(freq * [0.999,1,0.499,2,1.01] * 0.5, width: LFNoise2.ar(1/2).range(0.2,0.5)).range(0, spring.size-1);\n SendReply.ar(Impulse.ar(30), cmdName: '/sel', values: sel);\n SendReply.ar(Impulse.ar(30), cmdName: '/springs', values: springs);\n ou = Splay.ar(SelectX.ar(sel, springs), 1);\n env = EnvGen.ar(Env.adsr(0.3,0.1,0.8"}
+{"text": ");\n env = EnvGen.ar(Env.adsr(0.3,0.1,0.8,0.1, peakLevel:1),gate:gate,doneAction:2);\n ou = Pan2.ar(ou, pan, amp);\n // ou.poll(label:\"out\");\n Out.ar(0, ou[0]);\n Out.ar(0, ou[1]);\n}).load;\n);\n\n(\nvar window, view, redraw;\n\n// OSC bridge from synth to language\nif ( ~updateSelector != nil, {~updateSelector.free});\nif ( ~updateSprings != nil, {~updateSprings.free});\no = OSCFunc({|msg, time, addr, recvPort|\n ~sel = msg[3..];\n}, '/sel');\nn = OSCFunc({|msg, time, addr, recvPort|\n // ~springs = msg[3..];\n msg[3..].do { |item, i|\n ~springs[i] = item;\n }\n // ~springs.postln;\n}, '/springs');\n~springs=Array.fill(~numsprings, 0);\n~sel = Array.fill(5, 0);\n\n// simulation window drawing\nif (~max == nil) { ~max = 0.001; \"max\".postln; };\nwindow = Window.new(bounds:Rect(0,0,800,600),server:s);\nwindow.front;\nCmdPeriod.doOnce({window.close});\nview = U"}
+{"text": ".front;\nCmdPeriod.doOnce({window.close});\nview = UserView(window, window.bounds);\nview.background = Color.white;\nview.resize = 5;\nview.drawFunc = {\n |view|\n var jumpwidth = view.bounds.width / (~numsprings-1);\n Pen.fillColor = Color.black;\n Pen.strokeColor = Color.black;\n ~springs.do({\n |spring, i|\n var height = (spring/~max*view.bounds.height/2) + (view.bounds.height/2);\n var circlesize = (view.bounds.height.pow(2) + view.bounds.width.pow(2)).sqrt / 50;\n\n if (spring.abs > ~max, {\n ~max = spring.abs;\n \"maxspring\"+~max.postln;\n });\n\n if (i == 0, {Pen.moveTo(Point(0, height))},\n {Pen.lineTo(Point(i*jumpwidth, height))});\n Pen.addOval(Rect(i*jumpwidth-(circlesize/2), height-(circlesize/2), circlesize, circlesize));\n });\n Pen.fillStroke;\n Pen.color = Color.red;\n ~sel.do({\n |sel, i|\n Pen.moveTo(Point(sel*jumpwidth, view.bounds.height));\n Pen.lineTo(Point(sel*jumpwidth, 0));\n });\n Pen.fillSt"}
+{"text": "en.lineTo(Point(sel*jumpwidth, 0));\n });\n Pen.fillStroke;\n};\nview.frameRate = 30;\nview.animate = true;\n~charmap = Dictionary.new(17);\n~charmap.put($a, 45); // C\n~charmap.put($w, 46); // C#\n~charmap.put($s, 47); // D\n~charmap.put($e, 48); // D#\n~charmap.put($d, 49); // E\n~charmap.put($f, 50); // F\n~charmap.put($t, 51); // F#\n~charmap.put($g, 52); // G\n~charmap.put($y, 53); // G#\n~charmap.put($h, 54); // A\n~charmap.put($u, 55); // Bb\n~charmap.put($j, 56); // B\n~charmap.put($k, 57); // C\n~charmap.put($o, 58); // C#\n~charmap.put($l, 59); // D\n~charmap.put($p, 60); // D#\n~charmap.put($;, 61); // E\n\nview.keyDownAction = {\n |view, char|\n // (\"keydown\" + char).postln;\n\n ~lastchar = char;\n if (~charmap.at(char) != nil, {\n (\"kd freeing\" + ~syn).postln;\n ~syn.release(0.02);\n ~max = 0.001;\n ~syn = Synth(\\scansynth41, [\\freq, ~charmap.at(char).midicps, \\spring, ~spring, \\damp, ~"}
+{"text": "~charmap.at(char).midicps, \\spring, ~spring, \\damp, ~damp, \\pan, ~pan], s);\n (\"kd creating\" + ~syn).postln;\n });\n};\n);\n\n( // control window\nvar window, dampknob, damptext, springknob, springtext, resetbutton, panknob, pantext, newbounds;\nwindow = Window.new(server:s);\ndamptext = StaticText.new();\ndamptext.string = \"damping\\n\";\ndampknob = Knob.new(window);\ndampknob.mode = \\vert;\ndampknob.action = {\n |knob|\n var value = 100.pow(knob.value)*0.01;\n damptext.string_(\"damping\\n\"++value);\n value.postln;\n ~damp = value;\n ~syn.set(\\damp, value);\n};\nspringtext = StaticText.new();\nspringtext.string = \"spring\\n\";\nspringknob = Knob.new(window);\nspringknob.mode = \\vert;\nspringknob.action = {\n |knob|\n var value = 12.pow(knob.value)*0.01;\n springtext.string_(\"spring\\n\"++value);\n value.postln;\n ~spring = value;\n ~syn.set(\\spring, value);\n};\npantext = StaticText.new();\npantext.string = \"pan\\n\";\npanknob = Knob.new(window);\npanknob.mode = \\vert;\npanknob.action = {\n |knob|\n "}
+{"text": "window);\npanknob.mode = \\vert;\npanknob.action = {\n |knob|\n var value = knob.value * 2 - 1;\n pantext.string_(\"pan\\n\"++value);\n value.postln;\n ~pan = value;\n ~syn.set(\\pan, value);\n};\nspringknob.valueAction_(0.5);\ndampknob.valueAction_(0.5);\npanknob.valueAction_(0.5);\nresetbutton = Button(window).states_([['Reset', Color.black]]).action_({ (\"resetting max to 0, was\" + ~max).postln; ~max = 0;});\nwindow.layout = VLayout(HLayout(springknob, springtext), HLayout(dampknob, damptext), HLayout(panknob, pantext), resetbutton);\nwindow.bounds = Rect(800,0,400,400);\nwindow.front;\n)\n```"}
+{"text": "SuperCollider snippet — more fun with patternproxies, feat. a hack to access internals of the EventStreamPlayer\n\npossibly too-detailed demo of using functions to generate patterns, and then a function to modify the internals of the resulting EventStreamPlayers while they are running. \n \n* This latter function uses a sort of hack (thanks to [Jonatan](http://sccode.org/kymatica), see discussion on sc-users [here](http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/getting-at-an-EventStreamPlayer-s-Pbind-tp7586138p7586148.html)) to get at the arrays inside the patternpairs of the patternproxy inside the 'receiver' inside the stream of the player. \n`z = i.stream.slotAt('receiver');`\n\n* The point here is that using this technique, one need not maintain administrative data about the patterns themselves -- one only has to remember the players as they are being created.\n\n`\n`\nand the meta-point here, beyond me having fun figuring out markdown, is that i would like to make an argument for a less hacky way of legally getting at an EventStreamPlayer's progenitor Pattern.\n \n \n \n* [http://soundcloud.com/all-n4tural/constant-blues-acapella-rmx](http://soundcloud.com/all-n4tural/constant-blues-acapella-rmx)\n* [http://soundcloud.com/all-n4tural/worldwide-ra"}
+{"text": "a-rmx)\n* [http://soundcloud.com/all-n4tural/worldwide-razzledazzle](http://soundcloud.com/all-n4tural/worldwide-razzledazzle)\n\n```supercollider\n// switching to mono cz SinedPink.aiff is boring\n\n// two BufRd-based synths, one percussive, one smoother:\n(\nSynthDef(\\bufRdperc1, {| out = 0, bufnum = 0, rate=1, inter=2, posfrac = 0.5, dur = 1, amp = 0.9|\n var widthfrac = (dur/BufDur.ir(bufnum)) * rate;\n var sig = Splay.ar([ \n BufRd.ar(1, bufnum, Phasor.ar(\n 0, \n (BufRateScale.kr(bufnum) * rate), \n (posfrac * BufSamples.kr(bufnum)), \n (posfrac * BufSamples.kr(bufnum)) + (widthfrac * BufSamples.kr(bufnum))), \n 1, inter)\n ]);\n Out.ar(out, sig \n * EnvGen.kr(Env.perc,1,1,0,dur,2)\n * amp\n )\n}).add;\n\nSynthDef(\\bufRdsmooth1, {| out = 0, bufnum = 0, rate=1, inter=2, posfrac = 0.5, dur = 1, amp = 1|\n var widthfrac = ((dur/2)/BufDur.ir(bufnum)) * rate;\n var forward = BufRd.ar("}
+{"text": ")/BufDur.ir(bufnum)) * rate;\n var forward = BufRd.ar(1, bufnum, Phasor.ar(\n 0, \n (BufRateScale.kr(bufnum) * rate.abs), \n (posfrac * BufSamples.kr(bufnum)) - (widthfrac * BufSamples.kr(bufnum)), \n (posfrac * BufSamples.kr(bufnum)) + (widthfrac * BufSamples.kr(bufnum))), \n 1, inter);\n var backward = BufRd.ar(1, bufnum, Phasor.ar(\n 0, \n (BufRateScale.kr(bufnum) * rate.abs * (-1)), \n (posfrac * BufSamples.kr(bufnum)) + (widthfrac * BufSamples.kr(bufnum)), \n (posfrac * BufSamples.kr(bufnum)) - (widthfrac * BufSamples.kr(bufnum))), \n 1, inter);\n var sound = BiPanB2.ar(forward,backward,FSinOsc.kr(dur));\n sound = sound * EnvGen.kr(Env.sine,1,1,0,dur,2);\n sound = sound * amp;\n Out.ar(out, sound);\n}).add;\n\n);\n\n//\n// two functions that generate Pbinds\n(\n~make1perc = { |durs, lib|\n var n = durs.size;\n Pbind(\n \\bufnum, PatternProxy(Pseq({lib.choose}!n,inf)),\n \\rate"}
+{"text": "num, PatternProxy(Pseq({lib.choose}!n,inf)),\n \\rate, PatternProxy(Pseq([1],inf)),\n \\posfrac, PatternProxy(Pseq({512.rand/512}!n,inf)),\n \\dur, PatternProxy(Pseq(durs,inf)),\n \\amp, PatternProxy(Pseq({(1..3).choose}!n,inf)), \n \\instrument,PatternProxy(Pfunc({ |ev| (\"bufRdperc\" ++ ev[\\bufnum].numChannels) }))\n );\n};\n\n~make1smooth = { |durs, lib|\n var n = durs.size;\n Pbind(\n \\bufnum, PatternProxy(Pseq({lib.choose}!n,inf)),\n \\rate, PatternProxy(Pseq([1],inf)),\n \\posfrac, PatternProxy(Pseq({512.rand/512}!n,inf)),\n \\dur, PatternProxy(Pseq(durs,inf)),\n \\amp, PatternProxy(Pseq({(1..3).choose}!n,inf)), \n \\instrument,PatternProxy(Pfunc({ |ev| (\"bufRdsmooth\" ++ ev[\\bufnum].numChannels) }))\n );\n};\n\n//\n//\n// the function with the hack to get at, and modify while running, the internals of the patterns\n\n~frac = { |n = 1|\n ~players.do{ |i|\n var z = i.stream.sl"}
+{"text": "frac = { |n = 1|\n ~players.do{ |i|\n var z = i.stream.slotAt('receiver'); // the hack. it wd be nice to have legal method for this\n z.patternpairs.at(z.patternpairs.indexOf('posfrac') + 1).source = Pseq({512.rand/512}!n,inf)\n } \n};\n\n);\n\n//\n//\n//\n// fun things to execute at runtime\n//\n\n/*\n~buffers is an array of mono Buffers. if you don't have any, you can do\n~buffers = [Buffer.read(s, Platform.resourceDir ++ \"/sounds/a11wlk01.wav\")];\n*/\n\n[1/8, 1/4, 1/2].do{|i| ~players = ~players.add((~make1perc.([i], [~buffers.choose])).play)}\n\n1.do{~players = ~players.add((~make1smooth.([1], [~buffers.choose])).play)}\n\n~frac.();\n~frac.(x = 1);\n~frac.(x = x*2);\n~frac.(x = x+2);\n~frac.(x.postln);\n\n~players.pop.stop;\n```"}
+{"text": "SuperCollider snippet — Kepler 22-b atmosphere\n\nwind whirls\n\n```supercollider\n(\nfork { \n Ndef(\\ttwnd).play;//(d,2,addAction:\\addToHead);\n loop {\n var seed = thisThread.randSeed = 100000000.rand.debug('seed');\n Ndef(\\ttwnd, {\n var freq = [20, 7500];\n Splay.ar(\n { \n var bands = 2.rrand(10);\n var sig = { [BPF,RLPF,RHPF].choose.ar(\n LFNoise2.ar(freq[0].rrand(freq[1]), LFNoise2.kr(0.1.exprand(10))),\n Array.rand(bands, freq[0], freq[1]),\n Array.rand(bands, 0.2, 1.8)\n ).mean } ! 2;\n Rotate2.ar(sig[0], sig[1], LFSaw.kr(0.1.exprand(10)));\n } ! 4.rrand(6).debug('source'),\n 0.5.rrand(1)\n );\n }).fadeTime_(1.rrand(4.0));\n 10.0.rrand(40).debug('wait(bts)').wait;\n }\n}\n)\n```"}
+{"text": "SuperCollider snippet — seeking an Array!\n\nthis code throws a scrambled array of arrays seeking among them for the original array,\nIt only sounds when it founds it. (may take a while)\nthe idea started trying a SCtweet, but became with this funny code!\n\n```supercollider\n(// * //watch the postWindow\na=[\"m\",\"x\",\"f\",\"k\",\"d\",\"p\"];\nx=Array;\ny=x.newClear(6);\n~mxfkdp=Task({\n inf.do({y.put(x.series(6,0,1).choose,a.scramble).postln;\n 0.03.wait;})}).play;\nm=fork({inf.do({\n \"array num:\".postcln;\n if(y[x.series(6,0,1).choose.postcln]==a,\n {\"lo encontraste!/found it!\".postcln;\n 1.do({GVerb.ar(\n EnvGen.ar(Env.perc(0.01,8),1,doneAction:2)*\n Blip.ar(XLine.kr(440,1600,8)),50,10,0.02)}.play);\n ~mxfkdp.stop;\n m.stop;}, \n {\"buscando.../seeking...\".postcln;});\n 0.03.wait})});\n);\n//.SCtweetLong\n```"}
+{"text": "SuperCollider snippet — esoteric tweet\n\nusing sines to make simple number series sound dreamy eerie.\n\ni'm still waiting for rukano to explain what exactly the LFGauss is doing here ..\n\n```supercollider\n// http://twitter.com/#!/alln4tural/status/99846300173991936\n// http://soundcloud.com/tengototen/esoteric-tweet\n\nfork{loop{h=[5,7,8].choose*(2**(2..8).choose);play{Splay.ar({SinOsc.ar(exprand(h,h+(h/64)),0,0.1)}!64)*LFGauss.ar(9,1/4,0,0,2)};2.wait}};\n\n// really i wanted to do this:\nfork{loop{h=([33,38,40].choose.midicps)*(2**((0 .. 5).choose));play{Splay.ar({SinOsc.ar(exprand(h-(h/256),h+(h/256)),0,0.1)}!64)*LFGauss.ar(19,1/4,0,0,2)};4.wait}};\n// or more like a constant drone:\nfork{loop{h=([33,38,40].choose.midicps)*(2**((0 .. 4).choose));play{Splay.ar({SinOsc.ar(exprand(h-(h/64),h+(h/64)),0,0.1)}!8)*LFGauss.ar(19,1/4,0,0,2)};0.25.wait"}
+{"text": "8)*LFGauss.ar(19,1/4,0,0,2)};0.25.wait}};\n// primes\nfork{loop{h=(4 .. 100).choose.nthPrime*(2**(0..3).choose);play{Splay.ar({SinOsc.ar(exprand(h-(h/256),h+(h/256)),0,0.1)}!64)*LFGauss.ar(19,1/4,0,0,2)};2.wait}}; \n// Fibonacci\nfork{loop{h=(List.fib(15).choose)*(2**(0..4).choose);play{Splay.ar({SinOsc.ar(exprand(h-(h/64),h+(h/64)),0,0.1)}!64)*LFGauss.ar(19,1/4,0,0,2)};2.wait}}; \n\n// but they were too long.\n// __________________________\n// inspired by http://sctweets.tumblr.com/post/8379573991/sinosc \n// (http://soundcloud.com/rukano)\n```"}
+{"text": "SuperCollider snippet — Dub Echo\n\nA pretty simple Dub echo, approximating something like the [Space Echo](https://secure.wikimedia.org/wikipedia/en/wiki/Space_Echo) made popular by King Tubby, Scientist, Lee Perry, et al. Built around the Feedback Quark, though I'm not really leaning on the functionality it provides over a simple LocalOut-based feedback path.\n\n```supercollider\nSynthDef(\\dubecho,{|length = 1, fb = 0.8, sep = 0.012|\nvar input = In.ar(0, 2);\nvar output = input + Fb({\n\narg feedback; // this will contain the delayed output from the Fb unit\n\nvar left,right;\nvar magic = LeakDC.ar(feedback*fb + input);\nmagic = HPF.ar(magic, 400); // filter's on the feedback path\nmagic = LPF.ar(magic, 5000);\nmagic = magic.tanh; // and some more non-linearity in the form of distortion\n#left, right = magic; // let's have named variables for the left and right channels\nmagic = [DelayC.ar(left, 1, LFNoise2.ar(12).range(0,sep)), DelayC.ar(right, 1, LFNoise2.ar(12).range(sep,0))]; // In addition to the main delay handled by the feedback quark, this adds separately modulated delays to the left and right channels, which with a small \"sep\" value creates a bit of spatialization\n\n},length);\nReplaceOut.ar(0, output"}
+{"text": " \"sep\" value creates a bit of spatialization\n\n},length);\nReplaceOut.ar(0, output);\n}).store;\n\n// Example Usage\n~echo = Synth(\\dubecho, [\\length, TempoClock.default.tempo*(3/8), \\fb, 0.7, \\sep, 0.0012], addAction: \\addToTail);\n~echo.free;\n~echo.set(\\gate, 0);\n```"}
+{"text": "SuperCollider snippet — Dawn\n\nJust going crazy with modulation. Sample is available here: http://soundcloud.com/schemawound/schemawound-dawn-demo-version\n\n```supercollider\n(\nSynthDef(\"additivePad\", \n { arg numOfCycles = 100;\n var lfo;\n var lfo2;\n var lfo3;\n lfo = SinOsc.kr([Rand(0.5,1000),Rand(0.5,1000)], 1.5pi, 0.5, 0.5);\n lfo3 = SinOsc.kr([Rand(0.1,0.5),Rand(0.1,0.5)], 1.5pi, 0.5, 0.5);\n lfo2 = SinOsc.kr([(Rand(0.5,1000) * lfo) * lfo3, (Rand(0.5,1000) * (1 - lfo)) * (1 - lfo3)], 1.5pi, 0.5, 0.5);\n Out.ar(\n 0, \n Mix.arFill(\n numOfCycles,\n { \n SinOsc.ar(\n Rand(40,1000),\n 0, \n (numOfCycles.reciprocal * 0.75) * lfo2)\n }\n ) * EnvGen.kr(Env.perc(Rand(0.1,30), Rand(0.1,30)), doneAction: 2)\n )\n }\n).send(s); \n);\n\n(\nr = Routine({\n 200.do({\n x = Synth.new(\"additivePad\"); \n 10.wait;\n });\n});\n);"}
+{"text": "\n x = Synth.new(\"additivePad\"); \n 10.wait;\n });\n});\n);\n\nr.play;\n```"}
+{"text": "SuperCollider forum — DynGen - Dynamic UGen\n\nActually, I’m not too happy about the add method, see concerns about the `add` method · Issue #22 · capital-G/DynGen · GitHub\n\nIn short, I would prefer something like:\n\n```supercollider\n// returns the DynGenDef bound to symbol \\foo, creating it on demand\nDynGenDef(\\foo);\n\n// get \\foo def and send code to the Server\nDynGenDef(\\foo).load(\"some code\");\n\n// get \\foo def and tell the Server to read the given file\nDynGenDef(\\foo).readFile(\"myCode.txt\");\n```\n\nI don’t care too much about the actual method names, but more about the general pattern."}
+{"text": "SuperCollider forum — Sc.wasm - SuperCollider for the web\n\nThat’s the snippet I tried. After running it i’m not able anymore to edit and also lines of code are missing\n\n```supercollider\nTempoClock.default.tempo = 90/60\ns.boot\ns.meter\n\n// Reverb bus:\n\n(\ns.waitForBoot({\n~verbBus = Bus.audio(s, 2);\n\nSynthDef(\\globalVerb, {\narg inbus = 0, out = 0, mix = 1, room = 1, damp = 0.2, amp = 1.5;\nvar dry, wet;\ndry = In.ar(inbus, 2);\nwet = FreeVerb2.ar(dry[0], dry[1], mix, room, damp);\nOut.ar(out, wet * amp);\n}).add;\n\ns.sync;\n\n~verbSynth = Synth.tail(s, \\globalVerb, [\\inbus, ~verbBus]);\n});\n);\n\n(\nSynthDef(\\kick, {\narg out = 0, amp = 0.5, pan = 0, atk = 0.001, dec = 0.22;\n\nvar pitchEnv, bodyEnv, body, click, clickEnv, sig;\n\n// kurzer Pitch-Fall für mehr \"Punch\"\n\npitchEnv = EnvGen.kr(Env([100, 55], [0.03], -4));\n\n// Body etwas länger\nbodyEnv = EnvGen.kr(\nEnv.perc(atk, dec, 1, -"}
+{"text": "\nbodyEnv = EnvGen.kr(\nEnv.perc(atk, dec, 1, -4),\ndoneAction: 2\n);\n\nbody = SinOsc.ar(pitchEnv) * bodyEnv;\n\n// etwas definierterer Attack\nclickEnv = EnvGen.kr(\nEnv.perc(0.0005, 0.01, 1, -8)\n);\n\nclick = BPF.ar(WhiteNoise.ar(1), 2500, 0.8) * clickEnv * 0.25;\n\n// leichte zusätzliche Obertöne für kleine Speaker\nsig = body + click;\nsig = (sig * 2.5).tanh * 0.5;\n\nOut.ar(out, Pan2.ar(sig * amp, pan));\n}).add;\n\nSynthDef(\\bass, {\narg freq = 40, amp = 0.15, pan = 0,\natk = 2, dec = 1, sus = 0.8, rel = 6,\nffreq = 120, fmax = 1200, rq = 0.3;\n\nvar osc, sub, env, fenv, drift, sig;\n\n// very slow pitch drift\ndrift = SinOsc.kr(0.03).range(0.995, 1.005);\n\n// layered oscillators\nosc = Saw.ar(freq * [0.995, 1.0, 1.005] * drift);\nosc = Mix(osc) * 0.5;\n\n// soft sub layer\nsub = SinOsc.ar(freq * 0.5 , 0, 0.2);\n\n// slow amplitude envelope\n\nenv = EnvGen"}
+{"text": "5 , 0, 0.2);\n\n// slow amplitude envelope\n\nenv = EnvGen.ar(Env.perc(atk, rel), doneAction: 2);\n\n// slowly opening filter\nfenv = EnvGen.ar(Env([ffreq, fmax], [rel * 0.7], \\exp));\n\nsig = osc + sub;\n\n// resonant lowpass sounds richer than plain LPF\nsig = RLPF.ar(sig, fenv, rq);\n\n// gentle s aturation\n//sig = tanh(sig * 1.5);\n\nsig = sig * env * amp;\n\nOut.ar(0, Pan2.ar(sig, pan));\n}).add;\n\n// Pdef(\\bass).play(quant: 0);\n\nSynthDef(\\whitenoise, {\narg atk=0.01, dec=0.1, amp=0.5, pan=0, filtfreq=15000;\n\nvar env, sig;\n\nsig = Decay.ar(Dust.ar(100), 0.1) * WhiteNoise.ar;\n\nsig = HPF.ar(sig, filtfreq);\n\nenv = EnvGen.ar(Env.perc(atk, dec), doneAction:2);\n\nsig = sig * env * amp;\n\nOut.ar(0, Pan2.ar(sig, pan));\n}).add;\n\n//{Decay.ar(Dust.ar(200), 1)}.plot(3)\n\nSynthDef(\\sinenoise, {\n\narg amps = 0.05 ,\n\nampn = 0.05,\nfreq = 440,\npan = 0,\nreln = 0.3,\nrels"}
+{"text": "n = 0.05,\nfreq = 440,\npan = 0,\nreln = 0.3,\nrels = 0.8,\nsend = 0;\n\nvar envn, envs;\nvar white, pink, noiseMix;\nvar sine, sig;\n\n// ---------- Noise envelope ----------\nenvn = EnvGen.ar(\nEnv.perc(0.0001, reln, 1, -4),\ndoneAction: 0\n);\n\n// ---------- Sine envelope ----------\nenvs = EnvGen.ar(\nEnv.perc(0.001, rels, 1, -4),\ndoneAction: 2\n);\n\n// ---------- Noise sources ----------\nwhite = WhiteNoise.ar;\npink = PinkNoise.ar;\n\n// Smooth morph between noise types\nnoiseMix = XFade2.ar(\nwhite,\npink,\nSinOsc.kr(0.2)\n) * envn;\n\n// ---------- Sine source ----------\nsine = SinOsc.ar(\nfreq\n) * envs;\n\n// ---------- Proper mixing ----------\nsig = (noiseMix * 0.3 * ampn) + (sine * amps);\nsig = HPF.ar(sig, 600);\n\nsig = Pan2.ar(sig, pan);\n\nOut.ar(~verbBus, sig * send);\nOut.ar(0, sig);\n\n}).add;\n\nSynthDef(\\spectrumSwarm, {\narg freq = 3520, amp = 0.3, panSpread = 0.8, rel = 1, dust = 12 ,\nsend = 0;\n\nvar freqs, s"}
+{"text": "read = 0.8, rel = 1, dust = 12 ,\nsend = 0;\n\nvar freqs, sig, grains, env;\n\nfreqs = freq * [0.5, 1, 1.01, 1.5, 2, 2.02, 3];\ngrains = Dust.ar(dust);\nenv = EnvGen.ar(Env.perc(0.001, rel), doneAction: 2);\n\nsig = Mix.fill(freqs.size, {\nvar osc;\nosc = SinOsc.ar(\nfreqs.choose * LFNoise1.kr(0.5).range(0.99, 1.01)\n);\nosc * grains\n});\n\nsig = HPF.ar(sig, 300);\nsig = Splay.ar(sig, panSpread);\nsig = sig * env * amp;\nOut.ar(~verbBus, sig * send);\nOut.ar(0, sig);\n}).add;\n\n// This needs some more optimization\nSynthDef(\\saw, {\narg freq = 220, amp = 0.08, atk = 2, rel = 6, pan = 0,\nffreq = 900, rq = 0.25, detune = 0.015, send = 0.5;\n\nvar sig, env, freqs, drift, cutoff, widthMod;\n\n// slow independent drift for each voice\ndrift = LFNoise1.kr([0.03, 0.05, 0.07, 0.11, 0.13]).range(1 -\ndetune, 1 + detune);\n\nfreqs = freq * drift * [0.5, 0.99, 1, 1.01, 2];\n\nsig = Saw.ar(f"}
+{"text": " drift * [0.5, 0.99, 1, 1.01, 2];\n\nsig = Saw.ar(freqs);\n\n// slow stereo movement\nwidthMod = SinOsc.kr(0.02).range(0.4, 1.0);\nsig = Splay.ar(sig, widthMod);\n\nenv = EnvGen.ar(Env.perc(atk, rel, 1, -4), doneAction: 2);\n\n// slow filter drift\ncutoff = ffreq * LFNoise1.kr(0.04).range(0.6, 1.2);\ncutoff = cutoff.clip(80, 2000);\n\n// darker main filter\nsig = RLPF.ar(sig, cutoff, rq);\n\n// trim harsh top a bit more\nsig = LPF.ar(sig, cutoff * 1.2);\n\n// slight hollow/complex color\nsig = BRF.ar(sig, LFNoise1.kr(0.03).range(300, 1200), 0.3);\n\n// gentle saturation\nsig = tanh(sig * 1.4);\n\nsig = sig * env * amp;\nsig = Balance2.ar(sig[0], sig[1], pan);\nOut.ar(~verbBus, sig * send);\nOut.ar(0, sig);\n}).add;\n\nSynthDef(\\klank, {\narg freq = 440, amp = 0.05, pan = 0, rel = 2, send = 0.1;\n\nvar harm, amps, ring, exc, sig, env;\n\nharm = [1, 2, 3, 4];\namps = [0.2, 0.15, 0.1, 0.05"}
+{"text": " = [1, 2, 3, 4];\namps = [0.2, 0.15, 0.1, 0.05];\nring = [1, 1.2, 0.8, 1.5];\n\nexc = PinkNoise.ar(0.02) * Decay2.ar(Impulse.ar(1), 0.001, 0.1);\n\nsig = Klank.ar(`[harm, amps, ring], exc, freq);\n\nenv = EnvGen.kr(Env.perc(0.01, rel), doneAction: 2);\n\nsig = sig * env * amp;\nOut.ar(~verbBus, sig * send);\nOut.ar(0, Pan2.ar(sig, pan));\n}).add;\n\n// {EnvGen.kr(Env([0, 1, 0], [0.1, 5, 0.01], -8))}.plot(5)\n\nPdef(\\drum1,\nPbind(\n\\instrument, \\kick,\n\n// Organic generative timing\n//\\dur, Pseq([1, 1, Prand([Rest(0.5),0.5,0.1]), 1, 1],inf),\n\n\\dur, Pseq([0.25, 1, Prand([0.5, Rest(0.5)]), 1, 1], inf),\n//\\dur, Pseq([1], inf),\n\n//\\freq, 55,\n\\amp, Pwhite(0.6, 0.65),\n\\dec, Pwhite(0.1, 0.2)\n)\n);\n\nPdef(\\hh,\nPbind(\n\\instrument, \\whitenoise,\n\\dur, Pwrand([2, 0.5, Rest(0.5)], [0.6, 0.25, 0.15], inf),"}
+{"text": "rand([2, 0.5, Rest(0.5)], [0.6, 0.25, 0.15], inf),\n\\amp, Pwhite(0.05, 0.1),\n\\dec, Pwhite(0.3, 0.52),\n\\pan, Pwhite(-0.3, 0.3),\n\\atk, Pwhite(0.01, 0.05),\n\\filtfreq, Pwhite(8000, 10000)\n)\n);\n\nPdef(\\bass,\nPbind(\n\\instrument, \\bass,\n\\dur, Pseq([4, 2], inf),\n\\freq, Pseq([45, 52, 60, 48].midicps, inf),\n\\amp, 0.12,\n\\atk, 0.02,\n\\dec, 0.5,\n\\rel, 5,\n\\ffreq, Pseg(Pseq([80], inf), 20),\n\\fmax, Pseg(Pseq([500, 550, 600, 650], inf), 28),\n\\rq, 0.1\n)\n);\n\nPdef(\\sines,\nPbind(\n\\instrument, \\sinenoise,\n\\scale, Scale.minor,\n\\root, 9,\n\\degree, Pwrand([0,2,4,5], [0.4,0.3,0.2,0.1], inf),\n\\octave, Pwhite(4,6),\n\n\\dur, Prand([0.25, 1, Prand([0.5, Rest(0.25)], Rest(4)), 1, 1],\ninf),\n\n\\reln, Pwhite(0.0004, 0.002),\n\\rels, Pwhite(0.08, 5),\n\\amps, Pwhite(0.01, 0.02),\n\\ampn, Pwhite(0.1, 0.2),\n\\pan,"}
+{"text": "(0.01, 0.02),\n\\ampn, Pwhite(0.1, 0.2),\n\\pan, Pwhite(-0.8,0.8),\n\\send, 0.6\n)\n);\n\nPdef(\\sines2,\nPbind(\n\\instrument, \\sinenoise,\n\\scale, Scale.minor,\n\\root, 9,\n\\degree, Pwrand([0,2,4,5], [0.4,0.3,0.2,0.1], inf),\n\\octave, Pwhite(7,8),\n\n\\dur, Prand([2, 0.5, Prand([1, Rest(1)], Rest(2)), 1,4], inf),\n\n\\reln, Pwhite(0.0004, 0.02),\n\\rels, Pwhite(0.08, 5),\n\\amps, Pwhite(0.005, 0.012),\n\\ampn, Pwhite(0.1, 0.2),\n\\pan, Pwhite(-0.8,0.8)\n)\n);\n\nPdef(\\noise2,\nPbind(\n\\instrument, \\sinenoise,\n\\dur, Prand([0.5, Rest(1), 0.5], inf),\n\\reln, Pwhite(0.0001, 0.012),\n\\rels, 0.1,\n\\amps, Pwhite(0.01, 0.02),\n\\ampn, Pwhite(0.3, 0.5),\n\\pan, Pwhite(-0.8,0.8),\n\\send, 1\n)\n);\n\nPdef(\\noise3,\nPbind(\n\\instrument, \\sinenoise,\n\\dur, Prand([Pseq([0.1, 0.1, 0.1, 0.1]), Rest(4)], inf),\n\\reln, Pwhite(0."}
+{"text": " 0.1, 0.1, 0.1]), Rest(4)], inf),\n\\reln, Pwhite(0.0001, 0.012),\n\\rels, 0.1,\n\\amps, Pwhite(0.002, 0.003),\n\\ampn, Pwhite(0.04, 0.07),\n\\pan, Pwhite(-0.8,0.8),\n\\send, 1\n)\n);\n\nPdef(\\particles,\nPbind(\n\\instrument, \\spectrumSwarm,\n\\dur, Pwhite(0.05, 0.2),\n\\freq, Pseg(Pseq([800, 2000, 5000, 1200], inf), Pseq([12, 18,\n10], inf), \\exp),\n\\rel, Pwhite(0.03, 0.2),\n\\dust, Pwhite(1, 4),\n\\amp, Pwhite(0.05, 0.18),\n\\send, 0.8\n)\n);\n\nPdef(\\burst,\nPbind(\n\\instrument, \\sinenoise,\n\\dur, Pseq([0.25, 0.25, 0.25, Rest(8)], inf),\n\\freq, Pexprand(1000, 12000),\n\\reln, 0.005,\n\\rels, 0.15,\n\\amps, Pwhite(0.01, 0.03),\n\\ampn, Pwhite(0.6, 1.2),\n\\pan, Pwhite(-1, 1)\n)\n);\n\nPdef(\\sawpad,\nPbind(\n\\instrument, \\saw,\n\\dur, Pseq([4], inf),\n\\freq, Pseq(([45, 52, 60, 48] + 12).midicps, inf),\n/*\\dur, Pseq([4, 6, 8], inf),\n\\f"}
+{"text": " 12).midicps, inf),\n/*\\dur, Pseq([4, 6, 8], inf),\n\\freq, ([220, 233.08, 261.63, 311.13].choose * [0.5, 1, 2].choose),\n*/\\atk, Pwhite(2.0, 4.0),\n\\rel, Pwhite(5.0, 10.0),\n\\amp, Pwhite(0.03, 0.06),\n\\ffreq, Pwhite(500, 1200),\n\\rq, Pwhite(0.18, 0.35),\n\\pan, Pwhite(-0.4, 0.4),\n\\send, 0.5\n)\n);\n\nPdef(\\pklank,\nPbind(\n\\instrument, \\klank,\n\\freq, Pseq([440, 659.29, 523.25, 440],inf),\n\\dec, Pwhite(0.001, 0.12),\n\\amp, Pwhite(0.8, 0.9),\n\\pan, Pwhite(-1,1),\n\\rel, Pwhite(0.5, 4),\n\\dur, Pwhite(0.2, 4),\n\\send, 0.8\n)\n);\n\n// Play the whole thing\n\n~r = Routine({\n\nPdef.all.do(_.stop);\n\nPdef(\\pklank).play(quant: 0);\nPdef(\\bass).play(quant: 0);\n\n32.wait;\n\nPdef(\\sines).play(quant: 0);\nPdef(\\particles).play(quant: 0);\n\n32.wait;\n\nPdef(\\drum1).play(quant: 0);\nPdef(\\sines2).play(quant: 0);\nPdef(\\pklank).stop;\n\n32.wa"}
+{"text": "\\sines2).play(quant: 0);\nPdef(\\pklank).stop;\n\n32.wait;\n\nPdef(\\sawpad).play(quant: 0);\nPdef(\\noise3).play(quant: 0);\n\n64.wait;\n\nPdef(\\pklank).play(quant: 0);\nPdef(\\noise2).play(quant: 0);\nPdef(\\hh).play(quant: 0);\nPdef(\\noise3).stop;\n\n64.wait;\n\nPdef(\\drum1).play(quant: 0);\n// Pdef(\\burst).play(quant: 0);\nPdef(\\sawpad).play(quant: 0);\nPdef(\\pklank).stop;\n\n32.wait;\n\nPdef(\\pklank).play(quant: 0);\n\n16.wait;\n\n// Optional: fade out layers one by one\nPdef(\\sawpad).stop;\n8.wait;\nPdef(\\burst).stop;\n8.wait;\nPdef(\\noise2).stop;\nPdef(\\particles).stop;\n Pdef(\\drum1).stop;\nPdef(\\hh).stop;\n\n16.wait;\n\n// Leave only drums and bass for outro\nPdef(\\hh).stop;\nPdef(\\sines).stop;\nPdef(\\sines2).stop;\n16.wait;\n\n// Stop everything\nPdef(\\drum1).stop;\nPdef(\\bass).stop;\nPdef(\\pklank).stop;\n}).play;\n);\n\n~r.stop\n```"}
+{"text": "SuperCollider forum — Cybernetic music with SuperCollider\n\n- Peak\n\nhttps://youtu.be/oGjpLmFJiT8?t=228\n\nThe Serge Peak output sounds a bit like the max of two signals with a slight distortion.\n\nWhat do you think ?\n\n```supercollider\n(\nNdef(\\test, {\n var in, sig, osc1, osc2;\n in = LocalIn.ar(1);\n osc1 = SinOsc.ar(freq: \\osc1_freq.kr(150)) * \\osc1_amp.kr(0.4);\n osc2 = SinOsc.ar(freq: \\osc2_freq.kr(448)) * \\osc2_amp.kr(-0.3);\n osc1.max(osc2).distort;\n}).play;\n\nSpec.add(\\osc1_freq, [0.1, 14000, 'exp', 0, 440, \"Hz\"].asSpec);\nSpec.add(\\osc2_freq, [0.1, 14000, 'exp', 0, 440, \"Hz\"].asSpec);\nSpec.add(\\osc1_amp, [-1, 1, 'lin', 0, 0].asSpec);\nSpec.add(\\osc2_amp, [-1, 1, 'lin', 0, 0].asSpec);\n\nNdef(\\test).gui;\n)\n```"}
+{"text": "SuperCollider forum — Cybernetic music with SuperCollider\n\nGeoffroy:\n\n```supercollider\n...\nsine1 = SinOsc.ar(freq: \\sin_freq.kr(440.0) * (1 + (\\fm_amount.kr(0) * sine2)) * in);\n...\n```\n\nI don’t really know why I’m using the “*” operation with the feedback loop, and not the “+” operation (which was my first guess).\n\nI tried both, and they create wildly different sounds! In fact, any or all of the “*” in that line can be changed to “+” to get very different sounds. As you have it, the frequency will always modulate between positive and negative values (since in is bipolar), which appears to create a more chaotic sound. Using addition instead of multiplication will result in more of a classic FM sound, as this is the standard technique for FM synthesis to add the modulator to the frequency.\n\nEven in the simplest FM synth with 1 modulator and 1 carrier, using multiplication instead of addition creates a much different sound:\n\n```supercollider\n(\nNdef(\\freqadd, {// frequency + modulator (classic FM sound)\n var freq = MouseY.kr(20, 4000, 1);\n var mratio = MouseX.kr(1/8, 8, 1);\n var mod = SinOsc.ar(freq * mratio) * freq * mratio * \\index.kr(5);\n var car = SinOsc.ar(freq + mod);\n car = LeakDC.ar(car);\n car = Pan2.ar(car, \\pan.kr(0), \\"}
+{"text": "eakDC.ar(car);\n car = Pan2.ar(car, \\pan.kr(0), \\amp.kr(0.3));\n}).play;\n);\n\n(\nNdef(\\freqmul, {// frequency * modulator (more chaotic sounding)\n var freq = MouseY.kr(20, 4000, 1);\n var mratio = MouseX.kr(1/8, 8, 1);\n var mod = SinOsc.ar(freq * mratio) * freq * mratio * \\index.kr(5);\n var car = SinOsc.ar(freq * mod);\n car = LeakDC.ar(car);\n car = Pan2.ar(car, \\pan.kr(0), \\amp.kr(0.3));\n}).play;\n)\n```"}
+{"text": "SuperCollider forum — Cybernetic music with SuperCollider\n\nThanks @nathan ! I read your blog this morning, and it’s really well written and I’m eager to try some of your techniques. I started by trying to understand what an Integrator is, I’m not quite there yet. Thanks again for your music and teaching."}
+{"text": "SuperCollider forum — Why you should always wrap Synth(...) and Synth:set in Server.default.bind { ... }\n\nprko:\n\nWouldn’t it be better in terms of timing accuracy to write the output of the SynthDef as OffsetOut.ar instead of Out.ar?\n\nYes, but often it’s not critical.\n\n prko:\n\nCan it be enclosed by a function to reduce the typing?\n\nIf something is possible to execute outside of a function, then it’s possible to execute inside a function. (Actually everything runs inside a function. Interactive code gets compiled into a function, and then this function is executed just like any other.)\n\n prko:\n\nCan { ... }.play be also used when SynthDef(...).play can be used?\n\nHere, it’s helpful to understand the message format instead of just regarding server abstractions as black boxes. SynthDef().play and {}.play both send a SynthDef-receive /d_recv message, with a second message (/s_new) embedded in it, to be executed when the SynthDef is ready for use. Whether this is a freestanding message or part of a bundle, doesn’t matter.\n\nWhat is odd about it is that bind is used for timing control, but, because the sounding part (/s_new) is the completion message belonging to an asynchronous command, the sounding part will not be timed precisely. So you can but it won’t be exact (thus, not really much point to it).\n\nhjh"}
+{"text": "SuperCollider forum — ddwPlug quark\n\nsmoge:\n\nI think the SynthDefs should be generated and evaluated early, and their names should follow the transformations.\n\nNot sure what you mean by “generated early,” can you clarify?\n\nI’m not sure templates / macros are necessary. In my hypothetical example, numOscs and outChannels must be non-controls. At evaluation time, these two args would get concrete numbers and others would each get an OutputProxy sourced from a Control UGen. The current SynthDef builder makes a Control channel for every function argument but this doesn’t always have to be the case.\n\nNow, what is a good syntax to specify which function arguments are noncontrol? This, I don’t know right now. The hypothetical above makes the noncontrols a property of the concrete def; a problem is that you’d have to specify every non-control (no good way to specify a default for a non-control). Macros or templates may be a good way to solve that, or there might be another way.\n\nhjh"}
+{"text": "SuperCollider forum — Roar saturator\n\nIt’s not directly related to any of this discussion, but I just want to drop this entertaining article so everyone can have a chance to read))\n\n cs.cmu.edu\n\nLandin66.pdf\n\n 1173.45 KB"}
+{"text": "SuperCollider forum — Awesome SuperCollider list\n\nHello Mads,\n\nI made a pull request on github with the add of Supercollider Syntax for Visual Studio Code from Salkin-mada\n\nI hope this will encourage him to continue and improve its extension.\n\nSincerely yours\n\nDilectio aka IpadDilectio on Github"}
+{"text": "SuperCollider forum — GrainUtils - sub-sample accurate EventScheduler and dynamic VoiceAllocator\n\nI think i can encapsulate the grainphase generation into another ugen RampIntegrator which then needs these three arguments:\n\n- trig, multichannel expands when receiving an array of triggers from our VoiceAllocator\n\n- rate, multichannel expands when receiving an array of frequencies\n\n- subSampleOffset, from our EventScheduler\n\nThe user can then for example use the multichannel windowPhases from VoiceAllocator to drive an oscillator / window function which then can be used for multichannel FM of the RampIntegrator.\n\nInstead of latching the rates like we are doing internally for EventScheduler and VoiceAllocator, the RampIntegrator just integrates its frequency, like Sweep is doing and therefore enables FM and additionally adds the sub-sample offset on phase reset from the trigger input, to be subsample accurate.\n\nThe potential example would then look like this, where the RampIntegrator is still pseudo code and we for example use an ExponentialWindow to modulate its frequency per grain.\n\n```supercollider\n(\n{\n var numChannels = 8;\n\n var reset, tFreqMD, tFreq;\n var overlapMD, overlap;\n var events, voices;\n var fmods, grainFreqs, grainPhases, grainWindows;\n var grainOscs, grains, sig;\n\n reset = Trig1.ar(\\reset.tr(0), SampleDur.ir);\n\n tFreqMD = \\tFreqM"}
+{"text": "(\\reset.tr(0), SampleDur.ir);\n\n tFreqMD = \\tFreqMD.kr(2);\n tFreq = \\tFreq.kr(10) * (2 ** (SinOsc.ar(0.3) * tFreqMD));\n\n overlapMD = \\overlapMD.kr(0);\n overlap = \\overlap.kr(1) * (2 ** (SinOsc.ar(0.3) * overlapMD));\n\n events = EventScheduler.ar(tFreq, reset);\n\n voices = VoiceAllocator.ar(\n numChannels: numChannels,\n trig: events[\\trigger],\n rate: events[\\rate] / overlap,\n subSampleOffset: events[\\subSampleOffset],\n );\n grainWindows = HanningWindow.ar(voices[\\phases], \\windowSkew.kr(0.1));\n\n fmods = ExponentialWindow.ar(voices[\\phases], \\pitchSkew.kr(0.1), \\pitchShape.kr(0.5));\n grainFreqs = \\freq.kr(440) * (1 + (fmods * \\fmIndex.kr(2));\n\n grainPhases = RampIntegrator.ar(\n trig: voices[\\triggers],\n rate: grainFreqs,\n subSampleOffset: events[\\subSampleOffset]\n );\n\n grainOscs = sin(grainPhases * 2pi);\n grains = grainOscs * grainWindows;\n\n grains = PanAz.ar(2, grains, \\pan.kr(0));\n sig = grains"}
+{"text": "\n grains = PanAz.ar(2, grains, \\pan.kr(0));\n sig = grains.sum;\n\n sig * 0.1;\n\n}.play;\n)\n```"}
+{"text": "SuperCollider forum — PortedPlugins (formerly MKPlugins): Server plugins ported from elsewhere\n\nGreat work, @madskjeldgaard! It’s a lot of fun to play around with those!\n\nOn Windows, they only work with the SuperCollider 64-bit version. I got some “ERROR : LoadLibrary ...” messages when trying to run them with the 32-bit v.\n\n(Just mentioning this in case some runs into the same erorrs.)"}
+{"text": "SuperCollider forum — Podcast with James McCartney\n\nBubo:\n\nGreat podcast. I learned a lot about the history of SuperCollider and about the technological / cultural / musical environment that led to its creation. It’s really mind-boggling to hear how fast audio technology and computer music evolved during the 80s and 90s, when programs became able to compute faster than sound and when the music tech industry wasn’t that developed compared to nowadays.\n\nTotally agreed. The historical development is super interesting. The late 80s, 90s and early 00s were a “gold rush” period of computer music. The majority of realtime environments emerged just then – and kept the position! Thereafter, I always wondered when, due to the progress in technology, something new would appear and replace the proven working horses SC, Pd, ChucK etc., but no big alternative showed up so far. And yes, on the other hand, audio technology is much more ubiquitous.\n\n Bubo:\n\nI would love to hear about that new language too. It looks like a really fun project. Does anyone have something to share about it? It looks like James McCartney already presented it to small audiences.\n\nJames McCartney has been on past SC symposiums. You can do a web search and will find some info snippets about his ideas. He should have been a speaker (on his new projects) at the cancelled 2020 symposium:\n\n SC Symposium 2020 [CANCELLED]: Registration open + tentative schedule\n\n Hey all,\nRegistration for the 2020 SuperCollider Symposium at Wesleyan University in Middletown"}
+{"text": "gistration for the 2020 SuperCollider Symposium at Wesleyan University in Middletown, Connecticut, USA, taking place March 27-29, is now open!\nRegistration for the symposium itself is $40, there is also an optional dinner on Saturday which is $50. Special hotel rates are available at two hotels in the area.\nGo here for more details (note – the certificate for the site is expired so you may have to click through some security warnings from your browser): https://pkp.wesleyan.edu/ocs..."}
+{"text": "SuperCollider forum — Visual synthesis project\n\nLukasNowok:\n\nhere is a very loose and unsystematic exploration of visual sound synthesis. Feel free to add posts\n\nVery nice images.\n\n(I’m in the progress of writing some synthesis macro’s in POV-Ray, also to marry sound & vision https://ingoogni.nl/ )"}
+{"text": "SuperCollider forum — Hadron Updates\n\ndscheiba:\n\nI also recently took a look at implementing a sclang lexer in Rust and came across this nice looking library called GitHub - zesterer/chumsky: Write expressive, high-performance parsers with ease. which seems like a very nice approach at lexer/ast construction - but it seems you also got one working now, very nice, congratulations!\n\nI looked at a number of parsing libraries in Rust, including chumsky, but ultimately decided to hand-code one out of a combination of reasons:\n\na) Most wouldn’t, or wouldn’t easily, support building a linear/postorder parse tree output, relying instead on the traditional dynamically-allocated tree data structures, and\n\nb) I didn’t like their API for creating detailed error messages, and\n\nc) Many sacrifice speed for usability, whereas I feel like a handwritten parser you can have both\n\n dscheiba:\n\nConcerning the CI - why do you want to use the Google Cloud for this? I always appreciated the Gitlab CI (although the Github Actions are more convenient nowadays) and once you have a runner up and running it is also pretty nice - at least better than Jenkins If you want to stay closer to GitHub but want to avoid GitHub I think Gitea is also worth taking a look - it has something similar to GitHub actions, see Compared to GitHub Actions | Gitea Documentation - but most likely you still need an environment for your runner in this case.\n\nI am using GitLab CI. The GitLab instance at solit"}
+{"text": " an environment for your runner in this case.\n\nI am using GitLab CI. The GitLab instance at solitarybees.us is a VM running on Google Cloud. The runner is a separate instance VM. I just have some sysadmin work left to do to get everything set up, or a volunteer could step in and save me the trouble.\n\nThis is actually my second attempt at leaving GitHub, and the first attempt was using Gitea. I like Gitlab better. But yes, either Gitea or Gitlab will require the same amount of work in rebuilding my CI system in this new context. I can do it, but this second attempt on Hadron I’m trying to be more communicative about what I’m doing and more open in asking for help, in the hopes that I can build a sustainable community around the project this time."}
+{"text": "SuperCollider forum — LLM appreciation/rant thread\n\nSpacechild1:\n\nI’m currently (manually) reworking large parts of scsynth and supernova and while doing so, I keep getting more and more ideas.\n\nI think it would be really interesting if you described how scsynth was supposed to work and then asked AI for any ways it deviated and any bugs it could find. Then compared what you found with what it found."}
+{"text": "SuperCollider forum — Music for virtual organs\n\nmadskjeldgaard:\n\nIf you take one of them, please respond in the comments with the one you have used.\n\nI’ve redeemed kmgv-yht5. Thanks very much; really excited to hear this work!"}
+{"text": "SuperCollider forum — Wave Terrain Synthesis\n\nIntriguing visual pattern.\n\nBTW, you could write the repetition also with wrap resp. the Wrap UGen\n\n```supercollider\n~circle = {\n arg x, y, repeat;\n f = (\n (Wrap.ar(x, repeat.neg/2, repeat/2)).squared +\n (Wrap.ar(y, repeat.neg/2, repeat/2)).squared\n ).sqrt;\n f = Wrap.ar(f, 0, 2*pi).sin;\n};\n```\n\nThe last Wrap above is of course equivalent to mod. A variant would be taking Fold which does “mirrored wrapping”. Fold has a bit less edge, it’s about the difference between sawtooth and triangular waveforms. I have tried this example with SmoothFoldS2 from miSCellaneous_lib. With the smooth param the edge of the sound can be controlled continously.\n\n```supercollider\n~circle = {\n arg x, y, repeat, smooth = 0;\n f = (\n (SmoothFoldS2.ar(x, repeat.neg/2, repeat/2, 1, 1, smooth)).squared +\n (SmoothFoldS2.ar(y, repeat.neg/2, repeat/2, 1, 1, smooth)).squared\n ).sqrt;\n f = SmoothFoldS2.ar(f, 0, 2*pi, 1, 1, smooth).sin;\n};\n```\n\nSmoothening the wrap variants could be done by applying a Lag / LPF to the resulting waveform (not the Wrap)."}
+{"text": "SuperCollider forum — Suspension retrospective\n\njamshark70:\n\nMy opinion is that topics in the Questions or Code Review categories should police topic boundaries relatively tightly\n\nI don’t think anyone but the thread’s author should be able to make that decision - having a third party adjudicate over what the author finds on-topic seems problematic. How many questions or code reviews have gone off topic as identified by the original author? I imagine this is quite a small percentage and not worth the trouble altogether.\n\nI don’t know how discourse works, but a flagging-like system asking the commentor(s) to move their conversation to another thread might be more appropriate?"}
+{"text": "SuperCollider forum — List of contemporary composers working (almost) exclusively in SC\n\nPoint taken, the wording was a bit more clumsy than I’d normally allow myself. What I (probably) mean when I say the words art music and academic is music that’s primarily research-based and exploratory; stuff that’s going into possibly new sonic territories and driven by some personal obsession. Which, as far as I’m concerned, is a very large bag... Any definition of anything within the arts is in any case going to run into trouble very soon, which is why I usually don’t even bother too much anymore trying to put stuff into solid categories. I’m more interested in the experiential aspects than possible post hoc explanations. Obviously there’s a place for analysis, but this will mostly be reductive to the point of near meaninglessness."}
+{"text": "SuperCollider forum — Keeping SuperCollider evolving with minimal impact on users work\n\nSC exists at all only because James McCartney had a point of view when he built it. There’s been ample disagreement lately with some aspects of that point of view, but if SC didn’t reflect a point of view, then it would be boring and nobody would use it.\n\nAn SC4 needs a point of view. That is, someone, or a small group, will have to make decisions and stick to them, even if some current users get upset about it.\n\nI tend to agree that SC3 is a done deal... not much wiggle room. SC4 needs to break stuff (as SC3 did wrt SC2).\n\nOf the threading discussion fizzling out, I thought there was something approaching a consensus that a Promise with an explicit .await was the way to go...? Promises seem relatively uncontroversial; I don’t see a reason to have dropped that idea.\n\nThat’s perhaps tangential though, because SC4 might not benefit from too much consensus-building (because seeking too broad of a consensus is likely to err on the side of “no, don’t break that” → nothing gets done).\n\nhjh"}
+{"text": "SuperCollider forum — Keeping SuperCollider evolving with minimal impact on users work\n\nnow, if we all rely on 10 core volunteer devs, SC4 seems an immense endeavour...\n\nMaybe we should ask them. They might have no interest in SC3 maintenance, or no interest in SC4 dev, but in all cases, maybe I should be writing a grant (with @muellmusik) to fund dev time somehow... it is on my radar to try to find a way to maintain codebases that are a the root of practices..."}
+{"text": "SuperCollider forum — VSTPlugin v0.4 released!\n\nI downloaded the binaries and installed on two different M1 macs, one macbook M1 still running OSX11.0 with SC in Rosetta mode and one Macmini running OSX13.1 in ARM mode - it works like a charm on both. The same un-quarantine procedure as described on the Github page worked in both cases. I was also able to use VST and VST3 plugs which did not make it in the previous version.\n\nI was wondering if there is/could be a method to close an editor window, even though as I understand it, the window is totally separate from SC? And would it be technically possible to embed the editor in a SC view? (I suspect not...)"}
+{"text": "SuperCollider forum — SAPF users?\n\nCompletely agree I also think it sounds really great. And also about a bit difficult to recall where you are in your code. I keep a separate window open of help file so I can check the number of input’s. But maybe this in time this will become ingrained in memory..."}
+{"text": "SuperCollider forum — SAPF users?\n\nmikecalvert:\n\nI keep a separate window open of help file so I can check the number of input’s. But maybe this in time this will become ingrained in memory...\n\nHaskell also doesn’t use parentheses, but the number of inputs is in the type definition, and apart from that, it’s not significantly different from the other languages in this particular point."}
+{"text": "SuperCollider forum — My favourite dirty octave down (analogue style)\n\nIt sounds good and very playful to tweak\n\n```supercollider\n(\n{\n var source, freqMod, ampMod, complexWave, env, smacMy, bitchU;\n var upPhase, invPrevPhase, trig;\n freqMod = LFNoise1.kr(1.2!2).range(2, 150);\n ampMod = LFNoise1.kr(1.7!2).abs;\n\n source = LPF.ar(LeakDC.ar(SoundIn.ar(0) + PinkNoise.ar(1)));\n bitchU = Mix.fill(12, { |i| source * SinOsc.ar(freqMod * (i + 1) * 1.059, 0, ampMod / (i + 1)) });\n upPhase = InRange.ar(source);\n invPrevPhase = LFPulse.ar(freqMod!2) - Delay1.ar(upPhase);\n trig = upPhase * invPrevPhase.abs;\n\n smacMy = ToggleFF.ar(trig).madd(2,-1);\n ///////////smacMy = bitchU ;\n smacMy = smacMy + (0.1 * GVerb.ar(processedSignal * source * alternatePhase, revtime: 5));\n\n bitchU + smacMy * 0.2\n}.play;\n)\n```"}
+{"text": "SuperCollider forum — VstPlugin pre-release (outdated)\n\nEDIT: here’s the stable release VSTPlugin v0.1.0 released!\n\nHi, I’m happy to share a pre-release of VstPlugin. It’s been a month since the last test release and the project has developed a lot thanks to all the valuable feedback and discussions I had.\n\nBinaries (just unzip into your Extensions directory):\n\nWindows 64-bit: https://drive.google.com/open?id=134Fr053BXFu5HtQMCZeb51L4cOxV36wp\n\nWindows 32-bit: https://drive.google.com/open?id=1LcYCvWSQJZea-EprHEL3rJVI5g1K4Y7T\n\nmacOS 64-bit: https://drive.google.com/open?id=1BWGmgQoAoNyYArGszsjAn_aWJgpgYkgy\n\nHere is the source code: https://git.iem.at/pd/vstplugin/tree/develop\n\nNOTE: Many method names and parameters have changed, so old examples probably won’t work.\n\nI’ve updated the documentation and added some examples (could be more, of course).\n\nI think it would be also good to have a short Tutorial/Guide.\n\nIf possible, send bug reports to https://git.iem.at/pd/vstplugin/issues (needs an GitHub or gmail account) because it’s easier for me to track them. Otherwise just post them here.\n"}
+{"text": "ub or gmail account) because it’s easier for me to track them. Otherwise just post them here.\n\nWhat’s new:\n\nGeneral:\n\n- VstPlugin is now fully realtime-safe!\n\n- class methods for searching a Server for plugins (in the platform specific default paths and/or user provided paths).\n\n- the plugin info is cached on the Client side, so you can access it without actually creating plugin instances\n\n- each searched plugin is stored under a key which is generated from plugin name + subfolder (e.g. ‘GVST/GChorus’). those keys can be used in -open.\n\n- -open now also accepts relative paths (which are resolved to the currently executing file).\n\n- easier to use VST instruments: the -midi method returns an instance of VstPluginMIDIProxy which basically has the same interface as MIDIOut and can be used as such (e.g. as the MIDI target for \\midi Pbinds). all other MIDI messages have been removed from VstPluginController (except for raw MIDI).\n\nGUI:\n\n- -showGui is gone; instead there’s -editor to show the VST editor (Windows and Linux only) and -gui for the Qt GUI.\n\n- you can use the Qt GUI and VST editor simultaneously (but you have to -open with ‘editor: true’)\n\n- -gui now follows the SC conventions and can be either opened as a new Window or embedded in existing views!\n\n- it’s possible to change models, so you can use a single view and switch between different Vst"}
+{"text": "iews!\n\n- it’s possible to change models, so you can use a single view and switch between different VstPluginController instances\n\n- parameter displays are now text fields, where you can type the value as a string (not supported by all plugins)\n\n- VstPluginGui also has a pop-up menu for changing programs, panels for reading/writing program/bank files and a dialog for searching, browsing and opening plugins.\n\n- various customization points on class and instance level\n\nInternal:\n\n- several optimizations for local Servers (most data is now transferred via temp files)\n\n- more reliable OSC communication with remote Servers\n\n- proper MVC via object dependency. you can add objects as dependants and they will receive all necessary updates. (needs to be documented.)\n\nCheers, Christof"}
+{"text": "SuperCollider forum — VstPlugin pre-release (outdated)\n\nalways use VstPlugin.search(verbose: true) to find out which plugin crashes.\n\nonly buggy plugins should crash the Server in the search because I’m doing nothing but opening them, getting some info and closing them. this works with every decent plugin I’ve tested... but I’m working to make the search safe in a way that it never crashes the Server.\n\nfor the mercurial VST it seems like it’s printing repeatedly to stdout which floods the console.\n\nMany times until the IDE crashes.\n\nhow many? I might need to deactivate stdout during the search... anyway, thanks for reporting!"}
+{"text": "SuperCollider forum — Common Design Patterns in SuperCollider\n\nHello!\n\nDo we have a compendium of commonly used design patterns when coding in SuperCollider? What are your favorites? How do you organize your code?\n\nI feel that this topic can be very individual... but at the same time, it would be great to have references about how different people (especially super-experienced ones) are dealing with it."}
+{"text": "SuperCollider forum — SuperCollider en français\n\nbonjour à tous les 2,\n\nje découvre supercollider depuis 6 mois environ et le trouve passionnant\n\ncontent de voir un fil en français , merci beaucoup pour les ressources"}
+{"text": "SuperCollider forum — Building SuperCollider (and plugins) on Mac M1\n\nHello all,\n\ntried to compile and run SC3 plugins on a M1 and got this known error (for every plugin) when booting the server:\n\n*** ERROR: dlopen ‘/Users/jan/Library/Application Support/SuperCollider/Extensions/SC3plugins/HOAUGens/HOABeamDirac2HOA4_supernova.scx’ err ‘dlopen(/Users/jan/Library/Application Support/SuperCollider/Extensions/SC3plugins/HOAUGens/HOABeamDirac2HOA4_supernova.scx, 0x0002): tried: ‘/Users/jan/Library/Application Support/SuperCollider/Extensions/SC3plugins/HOAUGens/HOABeamDirac2HOA4_supernova.scx’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’)), ‘/usr/lib/HOABeamDirac2HOA4_supernova.scx’ (no such file)’\n\nIs there a way to get SC3 working in the meanwhile and an instruction how to do so?\n\nThanks,\n\nJan"}
+{"text": "SuperCollider forum — Building SuperCollider (and plugins) on Mac M1\n\nIt’s most probably not, i had downloaded the last release. So one would have to compile SC specifically for M1 then? Is there something specific that would work differently in that case?"}
+{"text": "SuperCollider forum — VSTPlugin v0.3.0 released!\n\nIs there a way to control how often the VST GUI gets updated/redrawn?\n\n@t36s do you experience any problems? I just realized that I have a wrong (i.e. too slow) refresh rate in the macOS VSTPlugin implementation , but this should only affect plugins which don’t have their own timer (mostly older ones). Will be fixed in the next bug fix release."}
+{"text": "SuperCollider forum — Nathan Ho - Haywire Frontier\n\nThanks so much, Pierre! I do want to figure out some kind of way to make the source code for the full album available but I haven’t decided on my preferred way to do that yet. After the full release!\n\nIn the meantime, I have extensively documented how I use SC on YouTube, and the process for making these tracks is a pretty straightforward extension of what I do on there. I also plan on writing about the process of making of this album too.\n\n tremblap:\n\nps I am pissing everyone off in my train carriage trying to download my purchase of the full album, while listening on repeat to the teaser track\n\n^^ Reminder to everyone else: if you aren’t blasting this on speakers on public transit, the listening setup is not how the artist intended. ^^"}
+{"text": "SuperCollider forum — Universal MLPRegressor for preset interpolation\n\nEric_Sluyter:\n\nOr is there a straightforward and automatic way to do all this with ProtoDef?\n\nI have to study the helpfile in more detail. At least I know that you can seperate processing logic from gui by extending the ProtoDef definitions over multiple files."}
+{"text": "SuperCollider forum — Way to limit maximum output volume\n\nAlberto DeCampo wrote a SafetyNet Quark that could be just what you need:\n\n GitHub\n\nadcxyz/SafetyNet\n\nA SuperCollider quark that protects users from dangerous audio signals. - adcxyz/SafetyNet\n\nOr there is StageLimiter from BatLib:\n\n github.com\n\n supercollider-quarks/BatLib/blob/master/StageLimiter.sc\n\n```supercollider\n//Batuhan Bozkurt 2009\nStageLimiter\n{\n classvar lmSynth, lmFunc, activeSynth;\n\n *activate\n { |numChannels = 2|\n fork\n {\n lmFunc =\n {\n {\n activeSynth =\n Synth(\\stageLimiter,\n target: RootNode(Server.default),\n addAction: \\addToTail\n );\n }.defer(0.01)\n };\n lmSynth = SynthDef(\\stageLimiter,\n```\n\n This file has been truncated. show original\n\nAnd about MouseX, we should definitely look into it if there’s a bug! I have no time right now, but generally what it takes is to find a minimal way to reproduce the bug, and then file an issue on supercollider’s github page"}
+{"text": "SuperCollider forum — Better parallel streams: a work in progress\n\nscztt:\n\nPspawn seems to try to remedy this, but it ignores the pattern system entirely and uses it’s own particular interpretation of Events, it’s own keys etc. For me, this feels like a recipe for disaster...\n\nWe may have to agree to disagree here: I think that mixing parent and child streams into one output stream is more likely to be disastrous. It will create considerable challenges if you want to apply filtering to the composite output stream that depends on the format of the output events, because the parent events have a totally different purpose and design. It’s my opinion that these should be kept separate.\n\nhjh"}
+{"text": "SuperCollider forum — A new approach to SynthDef control input syntax\n\nVIRTUALDOG:\n\nThe .kr is what “declares” it as a named control, so you can just write \\name.kr; or [\\name.kr, \\name2.kr];.\n\n... which opens you up to the problem of using the same control in multiple locations, where you have to take care with the defaults.\n\nIt has come up fairly often, when this is discussed, that many users (myself included) find it useful to have a quick glance at the available controls, without having to pick out symbols in the middle of complex expressions. It is true that, if you’re using symbol.kr and you want to pull controls to the top and highlight them visually, that the best way is var lines with the name appearing as the var name and as the symbol. One of the motivations for this design is to keep the visual highlighting but remove the redundancy.\n\nUsers who aren’t interested in this kind of input-summary can keep using symbol.kr as they like, of course, no problem. My initial stab at this was mainly just to see if it’s possible / practical. Possible, yes. Practical, remains to be seen.\n\nhjh"}
+{"text": "SuperCollider forum — Why use editors like (Neo)Vim/Emacs?\n\nI think vim keybindings are almost a programming language per se... I felt it was too much for me, beyond the basic ones.\n\nI usually have the same problem, but emacs shows in the mini buffer what are the options, so you learn as you go. You can just type the command too.\n\nThe benefit in productivity only comes when muscle memory is acquired. I feel that very clearly using XMonad (a tiling window manager), for example. Dragging windows on the screen is very tedious."}
+{"text": "SuperCollider forum — Playmodes - WIP\n\nJust finished this piece for a museum in Amsterdam, on display until January.\n\nAll sound comes from raster scanning sonification of the image, using additive synthesis in Supercollider (a bank of 1000 sinusoidal oscillators). This is similar to how Metasynth worked.\n\nI generate the images in Processing (Java), and use Max/msp as an easy GUI generator to control the whole thing...\n\nThe trick here is that, along the years, i have learned to create synthetic visual spectrograms: I manually coded timbres, pitches, rhythms... which give rise to images that “sound good” when sonified.\n\nIn fact, if you visualize the resulting sound in a melodic scale spectrogram you get the exact same image than the one it was used to generate the sound...\n\n+info on the project here:\n\n playmodes.com\n\nEspectres |"}
+{"text": "SuperCollider forum — RFC: Sweep and Phasor subsample interpolation fixes\n\nI favor B - re: A as I understand it changing the UGen signatures creates problems for people maintaining alternatives to sclang for one...\n\ncan you overcome the false positive problem by checking 2 samples back? if the penultimate sample is neither 0.f nor 1.0 then assume its a continuous signal?\n\nphilosophically the more complete solution is to ban discontinuous signals and treat triggers as 1 sample ramps always..."}
+{"text": "SuperCollider forum — White house urges developers to avoid c & c++?\n\nI guess there would be a lot of resistance to the idea of C++ as a past technology among C++ developers – so the White House announcement is interesting at least as a warning to companies who stand to lose a lot of revenue from government contracts if they insist on C++.\n\nFrom this outsider’s perspective, C++ is horribly messy (e.g. #pragma once is hilarious ). That was the reason for my question – is there a reason other than inertia why C++ hasn’t already been replaced by Rust?\n\nThat is... C++ is still entrenched enough that the WH announcement is newsworthy. I can think of a couple reasons. One is inertia: the industry has invested a lot in the C++ ecosystem and it’s painful to think of dropping it in favor of something that’s less familiar. Another could be some practical benefit that you can get only from C++, which makes the messiness worth it. I was wondering what that is.\n\nhjh"}
+{"text": "SuperCollider forum — Time to have standard style to write help documentation?\n\ngirthrub:\n\nBtw have you shared the code (for the reformatting of the doc) anywhere?\n\nNo.\n\nI did not save the code that worked well because I found a problem in the code.\n\nCurrently I have a new code with a better structure than the previous one. However, there are some problems with regular expressions. Sharing this code will be a bit ridiculous I think. I will share it when I have solved the regular expression problems.\n\nUsing the capture function ($0, $1 ...) and negative search ((? supercollider 3 > tutorials\n\nIf you’re controlling external gear, then your signals don’t live in the server, and MixerChannel wouldn’t be useful.\n\nhjh"}
+{"text": "SuperCollider forum — ScIDE is important\n\nI agree with @shiihs:\n\n shiihs:\n\nI tend to agree that, at present, having ScIDE seriously lowers the learning curve for the majority of users. It comes with the system, starts instantaneously without any required configuration, doesn’t require jumping through burning hula-hoops to boot the server etc. It’s highly specialized for the task it was designed to do, and it’s quite good at it (not perfect obviously, but then, what is...).\n\nFrom my own experience of teaching composers, musicians and non-musicians, and as a learner with a background in composition, the learning curve of SuperCollider is stiffer than other programs. As far as I know and have experienced, some of the multimedia arts students are more used to programming after the first few semesters than other fields such as music and humanities. Even engineering and science students in the early semesters, including maths and physics, are not used to programming.\n\nSC for visually-impaired coders\n\nAs far as editing SC code, it would be beneficial for both users and developers to retire SCIDE and replace it with a standard editor with good accessibility features like VSCode, and also ensure that SC plugins for it are also tested for accessibility. As editors have gotten more complex, so are the features required for accommodating disabled users, and building on the foundation of a well-maintained editor is the only viable solution for that in the long term.\n\nI think that retiring the SC-IDE may discourage many SC beginners who are not familiar with the field of computer science or music informatics. This may lead to a decrease in the number of SC"}
+{"text": " not familiar with the field of computer science or music informatics. This may lead to a decrease in the number of SC users.\n\nIn the meantime, I have tried using Emacs, Atom, Vim, Sublime Text and VSCode etc as SuperCollider front-ends, but my choice was mostly to use\n\n- SC-IDE and\n\n- sclang from a batch file or terminal on MacOS and Linux, and from the command prompt on Windows.\n\nMy recent experience with SuperCollider VSCode / Language Server Protocol support has been extremely positive. It is easy to install and use. The only problem is the keyboard shortcuts, which are different from SC-IDE. I also tried to install SCNVim, but I could not follow the instructions to finish it; and the others are not as intuitive to me.\n\nWhy my flavour is fixed to SC-IDE seems to be due to my lack of computer science background.\n\nWe probably need to review the recent threads on the SuperCollider frontends:\n\nRecent threads about the frontend for SuperCollider\n\n- Which IDE is the most popular for SuperCollider editing code nowadays\n\n Which IDE is the most popular for SuperCollider editing code nowadays Questions\n\n I am curious which alternative IDE is currently the most popular amongst SC users. Some previous research about two years ago many SuperCollider users preferred using VS Code as a more general-purpose code editor and then added the “vscode-supercollider” extension as a versatile option for those who work with multiple programming languages and want a unified development environment. Is VS Code still the way to-go besides the default IDE.\nTh"}
+{"text": " and want a unified development environment. Is VS Code still the way to-go besides the default IDE.\nThanks\n\n- Which IDE do you use?\n\n Which IDE do you use? Questions\n\n I am a newbie in programming and sometimes SC-IDE lacks typing and editing features... I am would like to try out a new text editor, but I am lost with so many options. Which text editor do you like to use with SC? Why? Any compatibility issues? Which works best for live coding? Which works best for large projects? Which is better for OSX? Linux?\nWhich IDE do you use ?\npoll\n[]'s\nZé Craum\n\n- SuperCollider VSCode / Language Server Protocol support\n\n SuperCollider VSCode / Language Server Protocol support Development\n\n I’ve been slowly working on proper + full-featured Visual Studio Code support for SuperCollider / sclang for a little while now. The core functionality can be implemented mainly in Language Server Protocol, an open standard that specifies how an IDE can connect to a language runtime like sclang. Most or all of the existing SC IDE functionality can more or less be expressed in terms of LSP, along with a pile of interesting new functionality.\nThe advantage here is that LSP is an open standard, im...\n\n- SCNVim - A NeoVim frontend for SuperCollider\n\n SCNVim - A NeoVim frontend for SuperCollider Libraries and Quarks\n\n hello\nI realized that scnvim does not have it’s own thread and it rightly deserves one so here it is!\nscnvim is a neovim plugin that integrates"}
+{"text": " thread and it rightly deserves one so here it is!\nscnvim is a neovim plugin that integrates SuperCollider into the editor including post window, status line, automatic snippet generation and loads of other handy things.\n\nFeatures\n\nPost window is displayed in a regular vim buffer\n\nUse vim key bindings to navigate/move/copy etc.\nToggles back if hidden on a SuperCollider error\n\nAutomatic display of method arguments\nStatus line widgets\n\nDisplay...\n\n- hadron editor for SC\n\n Hadron editor for SC\n\n hi,\ni built an editor/ide for supercollider for my own stuff called Hadron. it’s for macos and windows. maybe you ppl want to check it out: https://github.com/htor/hadron-editor.\n [screenshot]\nit’s really simple, has only one “tab” for editing, a help browser, post window and basic editing capabilites. i built it mainly because i wanted to style the help browser a little cleaner, so i ended up framing the help browser into an own application. i think it can be suited well for learning sc and ...\n\n- Anyone using Sublime text IDE?\n\n Anyone using Sublime text IDE? Questions\n\n I really like the features in Sublime text and about every year (for a few hours) dive into getting it to work (with the package at https://github.com/acarabott/supercollider-sublime), but I can never get the menu items to work. That is, they work when I select them, but not when I use the key commands. L"}
+{"text": "ver get the menu items to work. That is, they work when I select them, but not when I use the key commands. Likewise, I can’t set up any custom keys. That is, I set them up, in fact, use the example on the page, but they won’t fire. Further, several menu items are missing: Evaluate selection, line, or ...\n\nMaintaining the current official IDE and implementing new features\n\nSC for visually-impaired coders\n\nThe reason is, it is unmaintained and that is unlikely to change because there isn’t the human power for it. Consider that it’s been over a year since this thread was started: Wishlist for the IDE and not a single one of those features has been implemented, in fact there hasn’t been a single commit in that part of the codebase since February 2022.\n\n@VIRTUALDOG:\n\nCould the following Hadron Editor for SC be the next IDE if maintaining the current official SC IDE is problematic? @htor would be more active in maintaining his IDE and implementing new features requested by other users if his IDE is accepted as the default IDE.\n\nWhat I can do\n\nAll I can do is use what the developers maintain and develop. I just hope that the next environment is convenient, with class names and methods popping up as you type, and related help documents being read by searching from the current cursor position.\n\nI am not visually impaired at the moment, but my eyesight is getting worse and one day I would need more accessibility when using the computer. If it is impossible to implement such a feature with the current community developers, we need to switch to another frontend with such features (and with the features in the IDE wish list), or outsource it with proper payment"}
+{"text": " another frontend with such features (and with the features in the IDE wish list), or outsource it with proper payment using donated funds, although I think there are few users who agree with outsourcing, as it does not seem to be the basic philosophy of the SuperCollider community."}
+{"text": "SuperCollider forum — Commercial licensing (again)\n\nYou mentioned Pd. Are there examples of any loses you described, but related to Pd? Why when we speak about commercial it’s always big companies? Why we don’t think about plenty of developers, who write small mobile apps, for example? How many big companies per independent developers are there? And while there’s a chance of contributions when it’s with more permissive license from those, who used the software for a commercial project, there are no chances at all for that, when it’s not allowed to be used in such a project. The actual benefit is a wider community, which will include those independent developers. As an example of such a project - AudioKit.\n\nBut anyway it’s about “economical”/“political” views, which I tried to avoid. And direct you to another idea.\n\nIf you strongly against switching to more permissive license, that could be JUCE-like scheme. Or anything else (comment your ideas).\n\nAs I said that could be anything, that would allow using SC in proprietary projects. Again, that all could be described: when and how you’re allowed to use it. You can keep GPL, but add some exceptions. No one forced to use any particular license for their projects, you’re free to define your rules. You can write your own license in a plain human language, where you can describe the cases where it is and isn’t allowed to be used in closed source. Then think about it this way: when it’s clear, that community wouldn’t like to big companies use their software in some particular way, but the company’s lawyer makes it happen in “legal”. How many users the company would lose, if the users would discover about that"}
+{"text": "er makes it happen in “legal”. How many users the company would lose, if the users would discover about that unethical step? I think, it’s even possible with SC server with the current license. But no one would do that. This isn’t only about software, it’s bigger. Often because of something like this, wars and revolutions happen."}
+{"text": "SuperCollider forum — Users in Germany?\n\nI think someone I know was there and posted it on Instagram or something haha.\n\nSeems like there are a few different trends:\n\n- People in Berlin\n\n- People in Leipzig\n\n- People elsewhere\n\nMight be worth trying to get regular meetups going for Leipzig + Berlin and also something DE-wide a few times a year - are people interested in / motivated for this?"}
+{"text": "SuperCollider forum — Proposal: Refactor synthdef ugen optimizations\n\nPasses on the \" whole graph\" (why always \" the whole graph’? What kind of “passes”?:\n\n- Analyzing the entire graph multiple times is more computationally intensive.\n\n- It will be more complex to implement initially\n\n- There could be interactions between different optimization passes that need to be carefully managed.\n\nThe best option is a hybrid approach combining recursive graph traversal with pattern matching.\n\n- could be used to identify specific structures or subgraphs within the audio graph.\n\n---- find an \" expressive\" way to notate it; whenever you identify a structure, you add it later.\n\n- Flexibility: You can define different optimization functions for different graph levels.\n\n- pattern matching makes it easy to write (and think) (even if the final code is not written this way)\n\n- Composability\n\n- Adding an implied “type system” can help ensure the correctness of your optimizations.\n\n– After you get a clean procedure, then you start coding in c++, because it will get much messier there, and hard to reason.\n\nMinimalist example :\n\n```supercollider\noptimizeGraph :: AudioNode -> AudioNode\noptimizeGraph node = case node of\nUGen name children ->\n UGen name (map optimizeGraph children)\nConnection a b ->\n Connection (optimizeGraph a) (optimizeGraph b)\nGraph nodes ->\n let optimizedNodes = map optimizeGraph nodes\n in optimizeLocalPatterns (Graph optimizedNodes)\n\nopt"}
+{"text": "izeGraph nodes\n in optimizeLocalPatterns (Graph optimizedNodes)\n\noptimizeLocalPatterns :: AudioNode -> AudioNode\noptimizeLocalPatterns (Graph nodes) = Graph (map optimizePattern nodes)\nwhere\n optimizePattern node = case node of\n UGen \"add\" [UGen \"mul\" [a, b], c] ->\n UGen \"madd\" [a, b, c]\n -- etc etc etc ...\n _ -> node\n```\n\nGraphs are well-studied. When you try to forget they are graphs, you may make the problem more complicated (or much more difficult) to solve."}
+{"text": "SuperCollider forum — A class or method to convert integer and float to scientific pitch notation?\n\nI have made some method discussed here and in the following threads:\n\n Scales and tunings without Scale or Tuning Learning\n\n Nice!\n...the library of scales and tunings is a cool convenience though, I write \"1 3 5 7\".df(\\c) to get a C-major7 chord and \"1 3 5 7\".df(\\c,\\mixolydian) to get a C-dominant 7th. I know I could just write “1 3 5 6.5” but being a music-theory type it can be nice to just read the usual scales and modes. (my .df method uses Scale and Tuning under the hood)\n...and Scale and Tuning are explicitly used by the default Event type. So new users bump into them...\nIt would be cool if these classes were not s...\n\nThe method definitions are as follows:\n\n```supercollider\n+ Integer {\n\n midispn {\n var quarterToneStep, octave;\n quarterToneStep = [\n \\c, 'a quarter-tone raised c', 'c#', 'a quarter-tone raised c#',\n \\d, 'a quarter-tone raised d', 'd#', 'a quarter-tone raised d#',\n \\e, 'a quarter-tone raised e',\n \\f, 'a quarter-tone raised f', 'f#', 'a quarter-tone raised f#',\n \\g, 'a quarter-tone raised g', 'g#', 'a quarter-tone raised g#',\n \\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone rais"}
+{"text": "\n \\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone raised a#',\n \\b, 'a quarter-tone raised b'\n ][this * 2 % 24];\n octave = (this / 12).floor - 1;\n ^quarterToneStep ++ octave.asInteger\n }\n\n cpsspn {\n var quarterToneStep, octave;\n quarterToneStep = [\n \\c, 'a quarter-tone raised c', 'c#', 'a quarter-tone raised c#',\n \\d, 'a quarter-tone raised d', 'd#', 'a quarter-tone raised d#',\n \\e, 'a quarter-tone raised e',\n \\f, 'a quarter-tone raised f', 'f#', 'a quarter-tone raised f#',\n \\g, 'a quarter-tone raised g', 'g#', 'a quarter-tone raised g#',\n \\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone raised a#',\n \\b, 'a quarter-tone raised b'\n ][this.cpsmidi.round(0.5) * 2 % 24];\n octave = (this.cpsmidi / 12).floor - 1;\n ^quarterToneStep ++ octave.asInteger\n }\n}\n\n+ Float {\n\n midispn {\n var quarterToneStep, octave;\n quarterToneStep = [\n \\c, 'a quarter-tone raised c', 'c#', 'a quarter-tone raised c#',\n \\d,"}
+{"text": "ter-tone raised c', 'c#', 'a quarter-tone raised c#',\n \\d, 'a quarter-tone raised d', 'd#', 'a quarter-tone raised d#',\n \\e, 'a quarter-tone raised e',\n \\f, 'a quarter-tone raised f', 'f#', 'a quarter-tone raised f#',\n \\g, 'a quarter-tone raised g', 'g#', 'a quarter-tone raised g#',\n \\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone raised a#',\n \\b, 'a quarter-tone raised b'\n ][this.round(0.5) * 2 % 24];\n octave = (this / 12).floor - 1;\n ^quarterToneStep ++ octave.asInteger\n }\n\n cpsspn {\n var quarterToneStep, octave;\n quarterToneStep = [\n \\c, 'a quarter-tone raised c', 'c#', 'a quarter-tone raised c#',\n \\d, 'a quarter-tone raised d', 'd#', 'a quarter-tone raised d#',\n \\e, 'a quarter-tone raised e',\n \\f, 'a quarter-tone raised f', 'f#', 'a quarter-tone raised f#',\n \\g, 'a quarter-tone raised g', 'g#', 'a quarter-tone raised g#',\n \\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone raised a#',\n \\b, 'a quarter-"}
+{"text": "ed a', 'a#', 'a quarter-tone raised a#',\n \\b, 'a quarter-tone raised b'\n ][this.cpsmidi.round(0.5) * 2 % 24];\n octave = (this.cpsmidi / 12).floor - 1;\n ^quarterToneStep ++ octave.asInteger\n }\n}\n\n+ Symbol {\n\n midi {\n var quarterToneStep, octave;\n quarterToneStep = (\n [\n (-11 .. 12).collect { |octave|\n var pitchClasses = [\n \\c, \\cq, \\cs, \\cQ,\n \\d, \\dq, \\ds, \\dQ,\n \\e, \\eq,\n \\f, \\fq, \\fs, \\fQ,\n \\g, \\gq, \\gs, \\gQ,\n \\a, \\aq, \\as, \\aQ,\n \\b, \\bq\n ];\n pitchClasses.collect { |pitchclass|\n (pitchclass ++ octave).asSymbol\n }\n }.flat,\n (-120, -119.5 .. 156)\n ].flop\n .collect { |item|\n item[0] -> item[1]\n }.asEvent\n );\n ^quarterToneStep[this]\n }\n cps {\n var quarterToneStep, octave;\n quarterToneStep = (\n [\n (-11 .. 12).collect { |octave|\n var pitchClasses = [\n \\c, \\cq, \\cs, \\cQ,\n \\d, \\dq, \\ds, \\dQ,\n \\e, \\eq,\n \\f,"}
+{"text": ", \\cQ,\n \\d, \\dq, \\ds, \\dQ,\n \\e, \\eq,\n \\f, \\fq, \\fs, \\fQ,\n \\g, \\gq, \\gs, \\gQ,\n \\a, \\aq, \\as, \\aQ,\n \\b, \\bq\n ];\n pitchClasses.collect { |pitchclass|\n (pitchclass ++ octave).asSymbol\n }\n }.flat,\n (-120, -119.5 .. 156)\n ].flop\n .collect { |item|\n item[0] -> item[1].midicps\n }.asEvent\n );\n ^quarterToneStep[this]\n }\n}\n```\n\nThe test results are as follows:\n\n```supercollider\n\\a2.cps // -> 110.0\n110.cpsspn // -> a2\n111.cpsspn // -> a2\n\n\\aq2.cps // -> 113.22324603078\n112.cpsspn // -> a quarter-tone raised a2\n113.cpsspn // -> a quarter-tone raised a2\n114.cpsspn // -> a quarter-tone raised a2\n\n\\as2.cps // -> 116.54094037952\n115.cpsspn // -> a#2\n116.cpsspn // -> a#2\n117.cpsspn // -> a#2\n118.cpsspn // -> a#2\n\n\\aQ2.cps // -> 119.95585059318\n119.cpsspn // -> a quarter-tone raised a#2"}
+{"text": "585059318\n119.cpsspn // -> a quarter-tone raised a#2\n120.cpsspn // -> a quarter-tone raised a#2\n121.cpsspn // -> a quarter-tone raised a#2\n\n\\b2.cps // -> 123.47082531403\n122.cpsspn // -> b2\n\n\\a4.midi\n69.midispn // -> a4\n69.1.midispn // -> a4\n69.2.midispn // -> a4\n69.3.midispn // -> a quarter-tone raised a4\n69.4.midispn // -> a quarter-tone raised a4\n69.5.midispn // -> a quarter-tone raised a4\n69.6.midispn // -> a quarter-tone raised a4\n69.7.midispn // -> a quarter-tone raised a4\n69.8.midispn // -> a#4\n69.9.midispn // -> a#4\n70.midispn // -> a#4\n70.0.midispn // -> a#4\n70.1.midispn // -> a#4\n70.2.midispn // -> a#4\n70.3.midispn // -> a quarter-tone raised a#4\n70.4.midispn // -> a quarter-tone raised a#4\n70.5.midispn // -> a quarter-tone raised a#4\n70.6.midispn // -> a quarter-tone raised a#4\n70.7.midispn // -> a quarter-tone raised"}
+{"text": "ter-tone raised a#4\n70.7.midispn // -> a quarter-tone raised a#4\n70.8.midispn // -> b4\n70.9.midispn // -> b4\n71.midispn // -> b4\n```\n\nI think it is not good enough to make a PR because there are duplicate variable definitions in the different methods in a class such as pitchClasses as well as in the different classes such as quarterToneStep."}
+{"text": "SuperCollider forum — How to implement auto gain\n\nI have been messing around with @nathan s negative compression code, really cool stuff. Read more here. I was happy to read the explanation of why Compander doesn’t really work for short attack and release time (downsampling the input for detection) as this has been my own experience too, without knowing why.\n\nUsually when I work with compression in a DAW context I don’t use autogain, instead I prefer setting the makeup gain manually. However, there are a couple of situations where autogain would be a nice feature to implement. First one is expansion (corresponding to slope > 1 in Nathan’s code, where slope is the reciprocal of ratio), since expansion has the potential for making the output extremely loud. Another case would be an ‘intelligent’ compressor which compresses the input material based on the loudness of the signal so that even very dynamic material will receive (close to) the same amount of compression - there are commercial plugins doing this already, can’t think of the names right now. This is useful for applying compression as an ‘envelope shaper’ on very dynamic material rather than just a way of controlling dynamics.\n\nSo how do you best implement autogain? I suppose you need to calculate the RMS which will either introduce latency or mean than the detection of sudden changes in the dynamics of the input signal will be delayed by the RMS window size. Is there a way to implement autogain (maybe not in a ‘perfect’ way) without introducing additional latency in the signal chain?"}
+{"text": "SuperCollider forum — Why predeclared variables?\n\njamshark70:\n\nNo, absolutely not. I had thought I was suggesting to make the “temporal dead zone” simply illegal, i.e.\n\n```supercollider\n{\n xyz = 0;\n ...\n var xyz = 3;\n ...\n}\n```\n\nwould be a parse error.\n\nThis is actually not as simple as it sounds. As @scztt mentioned before, what about\n\n```supercollider\n{\n var xyz;\n {\n xyz = 3; // sets outer xyz or error?\n var xyz;\n xyz = 4;\n }\n}\n```"}
+{"text": "SuperCollider forum — Simple visual sequencer example?\n\nI see only a license and a readme in your repository. After committing more files, you have to git push again.\n\nTBH I probably don’t have time to play around with a big chunk of code.\n\nThe warning: if you’re using an Event as an object, and you do e.next = { ... } then you might think you have defined an alternate next on the event. You haven’t. next is actually defined for all objects already, and there is no way to override that at runtime. So later, when you call e.next, it will call the class library method instead of your function.\n\nThe only real “internal” about clocks that you need to understand is that there is no way to remove something from a clock once you schedule it. So, how do you stop a routine – what does r.stop really do? After r.stop, the routine is still in the clock’s queue. The difference is, r.stop sets the routine’s status so that, the next time it wakes up, it will just do nothing and yield nil. The effect from the user’s point of view is: you stop the routine, and it doesn’t do anything after that – but the reality is that it does do one more thing – it wakes up and checks the status, and then decides not to do anything.\n\nThe upshot is that if r is already scheduled and you schedule it again, then it’s scheduled twice. That’s very bad. So you can’t reuse the same scheduled object.\n\n```supercollider\n // swap out stream players\n clock = p.clock;\n p.stop;\n p = EventStreamPlayer(~stream"}
+{"text": "\n clock = p.clock;\n p.stop;\n p = EventStreamPlayer(~stream);\n clock.schedAbs(reschedTime, p.refresh);\n```\n\nIn this block of code, p is the currently active EventStreamPlayer. p.stop sets its status to have nothing to do next time – it will still wake up, but at that time, it will find that it’s done. Then p = EventStreamPlayer(~stream); makes an all-new stream player, based on the old stream (to pick up seamlessly where the other stream player left off) – and then this is scheduled for the new time. So, for that brief moment, there are two stream players on the clock:\n\n- old time: old player (which is already dead, but doesn’t know it yet)\n\n- new time: new player\n\nAnd what the user sees is: nothing happens at the old time, and the right thing happens at the new time.\n\nhjh"}
+{"text": "SuperCollider forum — Using Ndef as instrument in Pbind\n\nTatriX:\n\nIs there a way to make it work with gate ?\n\nWere you setting args? Because this is a common gotcha:\n\n```supercollider\ny = Synth(\\default)\n\n(type: \\set, id: y.nodeID, freq: 400, args: [\\freq]).play // args is actually redundant here\n\n(type: \\set, id: y.nodeID, gate: 0, args: [\\gate]).play // but not here!\n\ny = Synth(\\default)\n\n(type: \\set, id: y.nodeID, gate: 0).play // this won't turn it off, but will reset freq!\n```\n\nThat’s because the default Event args do not include gate (as a settable parameter).\n\nAlso now that I remembered to look back at this:\n\n RFluff:\n\ngetting the synthDesc for a Ndef (defined directly) is a pain. I don’t even remember how it’s done, if I ever figured it out.\n\n```supercollider\n// Make a dummy Ndef for testing\n(Ndef(\\jpjp, {|a1, a2|\n [a1, a2].poll(0.5);\n}))\n\nNdef(\\jpjp).objects // -> Order[ a SynthDefControl ]\nNdef(\\jpjp).objects[0].asDefName // -> temp__0jpjp-33677435_0\nNdef(\\jpjp).objects[0].synthDesc // -> nil\n```\n\nThere is a method for getting the SynthDesc"}
+{"text": "].synthDesc // -> nil\n```\n\nThere is a method for getting the SynthDesc from a SynthDefControl (which is what NodeProxy wraps its synths in) but alas it seem to always return nil for the nodeproxy built via functions (as opposed to synthdef names).\n\nBut it is actually possible to build those Descs “on demand”\n\n```supercollider\nNdef(\\jpjp).objects[0].synthDef.asSynthDesc // -> SynthDesc 'temp__0jpjp-33677435_0'\nNdef(\\jpjp).objects[0].synthDesc // not nil now\n```\n\nThat also gives us a way to auto-generate the msgFunc that we can use in Event.\n\n```supercollider\nNdef(\\jpjp).objects[0].synthDesc.msgFunc.cs\n// ->\n-> #{ arg a1, a2, fadeTime, out;\n var xA6F415B2 = Array.new(8);\n a1 !? { xA6F415B2.add('a1').add(a1) };\n a2 !? { xA6F415B2.add('a2').add(a2) };\n fadeTime !? { xA6F415B2.add('fadeTime').add(fadeTime) };\n out !? { xA6F415B2.add('out').add(out) };\n xA6F415B2\n```\n\nAnd the following does work by using msgFunc instead of args:\n\n```supercollider\n(Pbind(\n \\type, \\set,"}
+{"text": "Func instead of args:\n\n```supercollider\n(Pbind(\n \\type, \\set,\n \\ndef, \\jpjp,\n \\a1, Pwhite(0.0,1.0, 2),\n \\a2, Pseq([100, 101]),\n \\args, #[], // this will use msgFunc instead...\n \\msgFunc, Ndef(\\jpjp).objects[0].synthDesc.msgFunc,\n \\callback, { (\"called back\" + [Main.elapsedTime, ~id !? (_.value)]).postln; }\n).play;)\n```\n\nYou can also set the instrument instead which is used to lookup the msgFunc, but this is hardly an improvement here\n\n```supercollider\n(Pbind(\n \\type, \\set,\n \\ndef, \\jpjp,\n \\a1, Pwhite(0.0,1.0, 2),\n \\a2, Pseq([100, 101]),\n \\args, #[], // this will use msgFunc instead... directly or via...\n \\instrument, Ndef(\\jpjp).objects[0].asDefName, // used to lookup msgFunc\n \\callback, { (\"called back\" + [Main.elapsedTime, ~id !? (_.value)]).postln; }\n).play;)\n```\n\nUnfortunately I wasn’t able to get that to work inside an addParentType. \\set alas ignores ~synthDefName, even though it implicitly depends on \\instrument in its \\getMsgFunc. And trying to override the latter resulted in some wierd error I cannot figure out"}
+{"text": " \\getMsgFunc. And trying to override the latter resulted in some wierd error I cannot figure out right now:\n\n```supercollider\n(Event.addParentType(\\set, (\n id: { (\"parent set ndef\" + ~ndef).postln; ~ndef !? { |n| Ndef(n).nodeID; } },\n getMsgFunc: { |instrument| ~ndef !? {|n| instrument = ~instrument = Ndef(n).objects[0].asDefName }; (\"gMF\" + instrument).postln;\n Event.default.parent.getMsgFunc(instrument) }\n).parent_(Event.default.parent)))\n\n// Make a dummy Ndef for testing\n(Ndef(\\jpjp, {|a1, a2|\n [a1, a2].poll(0.5);\n}))\n\nNdef(\\jpjp).objects[0].synthDef.asSynthDesc\n\n(Pbind(\n \\type, \\set,\n \\ndef, \\jpjp,\n \\a1, Pwhite(0.0,1.0, 2),\n \\a2, Pseq([100, 101]),\n \\args, #[], // this will use msgFunc instead...\n \\callback, { (\"called back\" + [Main.elapsedTime, ~id !? (_.value)]).postln; }\n).play;)\n```\n\nBarfs\n\n```supercollider\ngMF temp__0jpjp-33677435_0\nERROR: Cannot convert this object to a SynthDef: ( 'instrument': default,"}
+{"text": "5_0\nERROR: Cannot convert this object to a SynthDef: ( 'instrument': default, 'db': -20.0, .....\n```\n\nIt’s probably easier to just change \\set rather than figure out how to plug all the right bits into the Event architecture to change \\set’s lookups the kosher way.\n\nSo... I’ve actually settled on this approach:\n\n```supercollider\n// one can actually copy the old \\set to a different key\nEvent.addEventType(\\stdset, Event.default.eventTypes[\\set])\n\n// and make set \"smarter\"\n(Event.addEventType(\\set, {|server|\n\n var id;\n if(~nkey.notNil and: { (id = Ndef(~nkey).nodeID).notNil }) {\n ~id = id;\n // use \\set semantics of only generating args if args.size == 0\n // although this is rather annoying, it's easily overriden by an\n // addParentType setting args to []\n if(~args.size == 0) {\n ~args = Ndef(~nkey).controlKeys(except: ~exceptArgs);\n };\n };\n ~eventTypes[\\stdset].value(~server);\n})\n);\n\n// Make a dummy Ndef for testing\n(Ndef(\\jpjp, {|a1, a2|\n [a1, a2].poll(3);\n}))\n\n// Tests\n(Pbind(\n \\type, \\set,\n \\nkey, \\jpjp,\n \\a1, Pwhite(0.0,1.0, 4),\n \\a2, Pseq("}
+{"text": "pjp,\n \\a1, Pwhite(0.0,1.0, 4),\n \\a2, Pseq((10..15)),\n \\args, #[], // autogen\n \\callback, { (\"called back\" + Main.elapsedTime).postln }\n).play;)\n\n(Pbind(\n \\type, \\set,\n \\nkey, \\jpjp,\n \\a1, Pwhite(0.0,1.0, 4),\n \\a2, Pseq((10..15)),\n \\args, #[\\a2], // specify\n \\callback, { (\"called back\" + Main.elapsedTime).postln }\n).play;)\n\nEvent.addParentType(\\set, (args: #[])) // auto by default\n\n(Pbind(\n \\type, \\set,\n \\nkey, \\jpjp,\n \\a1, Pwhite(0.0,1.0, 4),\n \\a2, Pseq((10..15)),\n //\\args, #[], // autogen is auto now\n \\callback, { (\"called back\" + Main.elapsedTime).postln }\n).play;)\n\n// Check that some standard \\set stuff still works the same, omitted here.\n```"}
+{"text": "SuperCollider forum — Experimental native PipeWire audio backend for scsynth (Linux), feedback wanted\n\nIn a way, it is a quite desirable result that the difference is not just PipeWire being better than JACK in general. Since this thread priority/performance behavior might be exploitable also in the JACK case earning us a free performance upgrade. Nice!\n\nIn the long run it looks to me like being a native PipeWire client and not rely on a translation layer for an architecture that an increasing number of Linux users aren’t even running anymore is a reasonable move. SuperCollider will of course have to support JACK for some time, but from what I can see, the Linux future is leaning increasingly towards PipeWire. The investigation in this thread can also be seen as supporting this in how the OS by default treats the PipeWire server as more performance critical than the JACK one. These kinds of benefits we want SuperCollider to enjoy.\n\nI think @jamshark70 s suggestion about exposing the choice to Linux users using the device in Server.options is good. The more users actively test both backends the more we will learn about possible differences as they develop moving forward."}
+{"text": "SuperCollider forum — LNX studio poll results\n\nExperience using LNX studio (check all that apply)\n\n- Never heard of LNX.\n\n- Never used LNX.\n\n- Currently unable to use LNX.\n\n- I think LNX is confusing.\n\n- I think LNX, has too many bugs.\n\n- I think LNX is an impressive project.\n\n- I rarely use LNX.\n\n- I occasionally use LNX.\n\n- I often use LNX.\n\n- I use LNX as my primary composition tool.\n\n- I use LNX more than SC.\n\n- I use LNX more than any other DAW.\n\n- I haven’t composed any music in LNX.\n\n- I am currently in the process of composition using LNX.\n\n- I have created more than one track using LMX.\n\n0\nvoters"}
+{"text": "SuperCollider forum — New issue: Ban contributions that make use of proprietary language models/code analysis\n\nThis has just been posted, I think it is a good idea:\n\n github.com/supercollider/supercollider\n\n Ban contributions that make use of proprietary language models/code analysis\n\n opened 11:01AM - 22 May 23 UTC\n\n capital-G\n\n enhancement\n\n ## Motivation\nI recently came across the PR https://github.com/supercollider/su...percollider/pull/6014 and I was not sure if it was a meme or a serious contribution, but it does allow for a discussion on how this community should position itself regarding the use of proprietary language models for contributions to this codebase.\n\nWhile it is fairly safe to assume that technologies such as Microsoft Co-Pilot and OpenAI ChatGPT have already analysed this repository, it does make a difference whether the people who build this codebase allow or condemn this action by banning contributions made with such tools, which is an unsolicited analysis, and therefore sharing of code, that most likely violates the GPL-3 (The Free Software Foundation had a call for papers last year to assess a position on this kind of technology https://www.fsf.org/licensing/copilot).\nSince context is necessary to understand the code, it is not tied to the atomic contribution of a PR in this case but also affects the source code written by others in a copy-left manner.\nUnfortunately, the GPL has not yet adapted to this by issuing a new license, so [to avoid license compatib"}
+{"text": "PL has not yet adapted to this by issuing a new license, so [to avoid license compatibility problems](https://wiki.debian.org/qa.debian.org/jsonevil) we should perhaps not add a clause to the license/usage of SuperCollider, but prohibit it through the terms of contribution.\n\nThere have been many requests to change the license of SuperCollider to something more friendly to use in (commercial) closed source projects, but many people who put their free time into this project don't like the idea of taking but not giving back and have contributed under this condition. Also, the source code is essentially a gift from James McCartney under the terms of this license. By using the language models, the exploitation of the code base happens not by the functional usage but through the interaction and analysis of the code itself, scanning the knowledge in the code and its contributions, and thus improving the closed source models.\n\nI understand that this technology has some (future) potential, and that it may deter new contributors in the future and I am aware that we are discussing this on GitHub, but I still suggest to ban to closed-source \"assistants\" (where the source code includes the model/weights, so the running code in the end). This avoids exploitation, while not banning the use of such an assistant in general, and may also encourage the open source development of such models.\nMaybe there are other open source projects that have also positioned themselves towards this technology and maybe we can form an alliance or adapt their position? But I have not found any yet.\n\n## Description of Proposed Feature\n\nAdd a disclaimer to [`CONTRIBUTION.md`](https://github.com/supercollider"}
+{"text": "`CONTRIBUTION.md`](https://github.com/supercollider/supercollider/blob/ef627ce2c564fe323125234e4374c9c4b0fc7f1d/CONTRIBUTING.md) that explicitly forbids contributions that use proprietary language models like Co-Pilot or ChatGPT, and also explicitly ask to disable these tools in e.g. vscode while working on this repository (maybe add a `.vscode/settings.json` that disables such plugins?)\n\n## Plan for Implementation\n\nLet's have a discussion if this should be implemented and what such a text should look like!\n\nWhat do you think?"}
+{"text": "SuperCollider forum — Is it possible to run SC as an AU for my DAW?\n\nthere used to be a way to save out as an AU, but it is long ago abandoned. If you have some C++ skills, it may be possible to pick up where it left off."}
+{"text": "SuperCollider forum — Proposal: SynthDefs could eliminate duplicate UGens\n\nSpacechild1:\n\nI’m not saying it wouldn’t be a nice feature, I’m just really wondering if it can be implemented in a reasonable way... But I don’t want to discourage you from trying\n\nSure, and it’s “as time permits” for me too. Practically speaking, that may mean “forever unfinished.”\n\nIt’s a bit unfair to refer to O(n^2) though, as I’ve already suggested using hash lookup for identifying previous input lists. While updating a hash table does have a cost, lookup is certain to be faster than a linear search so the aggregate complexity should be well less than n squared.\n\n```supercollider\nIdentityDictionary[\n (SinOsc -> Dictionary[\n [440, 0] -> sinoscInstance\n ])\n]\n```\n\nhjh"}
+{"text": "SuperCollider forum — Future of the mailing lists\n\nDear all,\n\nScott, your quote “The text email...” in your reply is sent between\n\nlines of\n\nquote=“muellmusik, post:9, topic:3736, full:true”\n\nand\n\n/quote\n\nboth in square brackets each, when read in mailing list mode and as\n\nplain text email.\n\nApart from mail user agent’s not displaying this properly and without\n\nsyntax colorzing, it garbles the message.\n\nFurthermore, is there any way to disable the lengthy email footer that\n\ncomes with each and every email? Imagine all forum posts having them\n\nadded...\n\nthank you all for your help,\n\nP\n\n- Scott Carver via scsynth noreply@m.scsynth.org [2021-06-17 10:05]:"}
+{"text": "SuperCollider forum — Future of the mailing lists\n\nPeter:\n\nI am greatful for all your support and attempts to make mailing list\n\nmode work, but feel that the situation as it is right now has many\n\ndisadvantages over the old list still.\n\nSorry you’re running into issues! I hope you can find a workflow that you’re happy with - the forum software is quite configurable, and I’m happy to make tweaks where possible, if they can improve the experience for list members, mailing list mode users or otherwise."}
+{"text": "SuperCollider forum — Creating rhythmic meso / macro structure with Demand trigger mask\n\nthanks, im just confused with:\n\n```supercollider\n\\arrayOfBinaries.kr(Array.fill(16, Array.fill(16, 1)))\n```\n\nand implementing the same logic with:\n\n```supercollider\nDseq([Dser(arrayIndex, arraySize)], inf))\n```"}
+{"text": "SuperCollider forum — Creating rhythmic meso / macro structure with Demand trigger mask\n\nokay, maybe using Dbufrd isnt a bad option, dont know yet how to go about the different sizes but i think like this you dont have to pass big array data.\n\n```supercollider\n(\n~binaryDurations = [\n [ 1, 0, 0, 0, 0, 0, 0, 0 ],\n [ 1, 0, 0, 1, 0, 0, 0, 0 ],\n [ 1, 0, 0, 1, 0, 0, 1, 0 ],\n [ 1, 0, 0, 1, 1, 0, 1, 0 ],\n [ 1, 0, 1, 1, 1, 0, 1, 0 ],\n [ 1, 0, 1, 1, 1, 0, 1, 1 ],\n [ 1, 0, 1, 1, 1, 1, 1, 1 ],\n [ 1, 1, 1, 1, 1, 1, 1, 1 ]\n].flat;\n);\n\nb = Buffer.alloc(s, ~binaryDurations.size, 1);\nb.setn(0, ~binaryDurations);\nb.getn(0, b.numFrames, {|x| x.postln });\n\n(\nSynthDef(\\test, {\n\n var tFreq = \\tFreq.kr(8);\n var trig = Impulse.ar(tFreq);\n\n var maxSize = 8;\n var seq = maxSize.collect{ |i|\n (i * maxSize..i + 1 * maxSize - 1)\n };\n\n var index = Dseq(seq[2], inf);\n\n var mask = Demand.ar(trig, 0, Dbufrd(b, index));\n\n mask.poll(trig, \\mask);\n"}
+{"text": " Dbufrd(b, index));\n\n mask.poll(trig, \\mask);\n\n trig = trig * mask;\n\n trig = Pan2.ar(trig, \\pan.kr(0));\n\n Out.ar(\\out.kr(0), trig);\n}).add;\n);\n\nSynth(\\test);\n```"}
+{"text": "SuperCollider forum — Improving Documentation - Pfunc and Pfuncn [SOLVED]\n\nThanks! Got the vibrato stuff.\n\n capogreco:\n\nPfunc(nextFunc, resetFunc)\n\nThe next value is the return value from evaluating nextFunc . If .reset is called on a stream made from this pattern, resetFunc is evaluated. The stream will run indefinitely until nextFunc returns nil .\n\nYeah, I do understand what it does, the description is clear, although the example does not help. Passing a exponential function inside it is the same of using Pexprand... Can you point out a really useful/usual utilization for Pfunc and Pfuncn?"}
+{"text": "SuperCollider forum — SCLang ScopeView prototype\n\nMaybe you have already seen this? Efficient rendering of waveforms - General Audio Programming - Audacity Forum\n\nAt least a pointer in the direction of where to look in the audacity source code..."}
+{"text": "SuperCollider forum — Pbind and samples with different durations (2)\n\nI wouldn’t make it a 0.0 – 1.0 probability value, because then you’re enforcing one and only one algorithm to determine whether to turn it into a rest or not (or requiring the user to turn a Boolean value into false = 0 and true = 1). I would just make it Boolean.\n\nIf the default is true, then I would argue you don’t need .asRest at all.\n\nPrest(1) // 8 characters\n\n1.asRest // 8 characters = not shorter = no benefit = don’t clutter the interface unnecessarily\n\n(Sure, if it’s x.rest then it would be shorter, but at a loss of some clarity and also breaking away from the precedent of the .asSomething protocol. I also find, the longer I do this, that short conveniences end up causing problems later. It’s better to write code that is slightly longer and much more clear – and it’s much better to encourage new users in this habit.)\n\n```supercollider\nPrest : FilterPattern {\n var <>boolean;\n\n *new { |pattern, boolean = true|\n ^super.new(pattern).boolean_(boolean)\n }\n\n embedInStream { |inval|\n var boolStream = boolean.asStream;\n // true = use embedding behavior for non-pattern values\n ^pattern.streamArg(true).collect { |value, inval|\n if(boolStream.next(inval)) {\n Rest(value)\n } {\n value\n }\n }.embedInStream(inval)\n }\n}\n```\n\nThen:\n\n```supercol"}
+{"text": " }\n }.embedInStream(inval)\n }\n}\n```\n\nThen:\n\n```supercollider\n// default behavior is like Rest for simple values\nPseq([0, 1, Prest(2), 3], 1).asStream.all\n-> [ 0, 1, Rest(2), 3 ]\n\n// a pattern inside Prest expands to its full length\nPseq([0, 1, Prest(Pwhite(10, 20, 3)), 3]).asStream.all\n-> [ 0, 1, Rest(11), Rest(12), Rest(11), 3 ]\n\n// probability masking also works\nPrest(Pwhite(1, 10, inf), Pn(0.5, inf).coin).asStream.nextN(10)\n-> [ Rest(7), Rest(2), 7, 8, Rest(5), 5, Rest(2), Rest(7), 2, Rest(8) ]\n\n// for comparison, the old way is longer and reads uglier\nPwhite(1, 10, inf).collect { |x| if(0.5.coin) { Rest(x) } { x } }.asStream.nextN(10)\n```\n\nhjh"}
+{"text": "SuperCollider forum — Choosing how to choose with self-normalising weights\n\njulian:\n\nYes, it is, but if you do normalizeSum first each time, you have to do it twice and divide once, for each random value. That is, you have at best a performance halving.\n\nyes but if we change prArrayWindex to normalize when the sum !=1 then there is no performance hit when normalized weights are provided!\n\nwchoose([0.5, 0.5]) would still perform as choose([0.5, 0.5]) - only `choose([1, 1]) would introduce the division. (no need to do the sum twice as we already have the value). or have I misunderstood?"}
+{"text": "SuperCollider forum — How to implement IIR filter code snippet?\n\nscztt:\n\nSo, we’re off by a factor of 2 in terms of efficiency - significant, but not enough to stop anyone from building a cool additive synths\n\nDefinitely, I think additive synthesis is a typical example where the mind trap „more is better“ is very tempting.\n\nAs additive synthesis is a favour of some of my students, I did quite a lot of SC experiments during the last years. IMO this synthesis method is a real strength of SC because of its easy multichannel handling. I think this outweighs limitations of the number of oscillators (which I hardly ever wanted to come close to).\n\nThinking about modulation and modulation control is crucial. BTW I had a lot of fun with additive FM and feedback networks. If find the time on occasion I will collect some examples."}
+{"text": "SuperCollider forum — Modulate an LPF Freq cutoff using an envelope or LFO\n\nYeah, here’s the wav files. They should just be a single cycle waveform each.\n\nTo recreate turning them into wavetables you’d need to change the file path in step a. Once it gets loaded into a buffer the bufnum might be different for you as well, mine usually gets assigned 2111 and upwards from there 2112, 2113 ... etc\n\n /uploads/default/original/2X/9/96367628031b537dd5bec5a4162f4dc178ad7158.wav\n\n /uploads/default/original/2X/e/e73ddaf4746559372207cfa1a34a5231a63a1983.wav"}
+{"text": "SuperCollider forum — Modulate an LPF Freq cutoff using an envelope or LFO\n\nOh cool, I didn’t know you could just reassign variables, I thought you had to keep passing them through to a new variable.\n\nI added the amp argument and it got rid of the clicks. It still sounds a little rough at the beginning of the notes but now it’s more of a harmonic sounding thud than a sharp click. I’ll try and adjust the amp value more and see how much smoother or rough it gets with smaller values.\n\nEdit: nm it’s clicking again :’( I’m going to try and mess with it some more tomorrow. I might need to increase the buffer size or something"}
+{"text": "SuperCollider forum — SOUL Lang Compilation to UGen\n\nJust watching the wheels of it, the problem might be that the development is done with mercurial as cvs, the license of the kronos dsp compiler says gpl3 ...\n\nlink: https://hg.sr.ht/~vnorilo/"}
+{"text": "SuperCollider forum — Code to get local IP on all platforms\n\nThank you very much for this piece of code! I also need this for a project.\n\nSorry for bumping this, but I got a few remarks to add :\n\nFirst, I think this should be useful if integrated in SCLang directly, to facilitate remote communication ? Unfortunately, I don’t know how to use git . But if the addition makes sense, and someone knows how to create a pull request, I’d be happy to help on the integration.\n\nSecond thing concerns the linux implementation. On my Ubuntu 22.04 LTS, ifconfig isn’t installed by default. It’s not difficult to install, but I’m working on a software for non-engineers people, and I’d rather have it working ‘out-of-the-box’, with no third party install. In my case, I just want the software to display local IP as text.\n\nI found this command, ip address, which, I think, was installed by default :\n\n```supercollider\nip address | grep \"inet \" | awk '{print $2}'\n```\n\nBut I don’t know if it’s the case for the whole Linux ecosystem.\n\nAlso, it outputs the ‘subaddress’ (don’t know how it’s called) : 192.168.1.37 /24.\n\nShould this be removed from the IP ?\n\nAs a reference, here’s my ‘updated’ version of the code :\n\n```supercollider\n~getLocalIPs = {\n var winCMD, macCMD, linCMD, ips;\n\n winCMD = {\n var ipInfo"}
+{"text": "cCMD, linCMD, ips;\n\n winCMD = {\n var ipInfo, ipv4s;\n ipInfo = \"ipconfig | findstr /C:IPv4\"\n .unixCmdGetStdOut\n .replace(\" IPv4 Address. . . . . . . . . . . : \", \"\");\n };\n\n macCMD = {\n (\"ifconfig | grep -Fv\" + \"inet 10.\"\n .quote + \"| grep\" + \"inet \"\n .quote + \"| grep -Fv 127.0.0.1 | awk '{print $2}'\"\n ).unixCmdGetStdOut;\n };\n\n linCMD = {\n (\"ip address | grep \\\"inet \\\" | grep -Fv 127.0.0.1 | awk '{print $2}'\")\n .unixCmdGetStdOut;\n };\n\n ips = Platform.case(\n \\osx, { macCMD.() },\n \\linux, { linCMD.() },\n \\windows, { winCMD.() }\n );\n\n ips = ips.split(Char.nl);\n ips.removeAt(ips.size-1);\n ips\n};\n```"}
+{"text": "SuperCollider forum — CPU usage of additive synthesis(beginner)\n\nLike this for shaper...\n\n```supercollider\n~sz = 2048;\n~sig_sz = ~sz / 2 + 1; // must be some n^2 + 1 for n in Real - see Shaper docs\n\n(\n~sig = Signal.fill(~sig_sz, { |i|\n var t = i.linlin(0, ~sig_sz, 0, 2pi); // t is our time index - we only need one full wave cycle - thats from 0 to 2pi\n 200.collect({ |i|\n var j = i * 3 + 1; // your code - calc harms\n sin(t*j) * (j*2).reciprocal\n }).sum // calculate all 200 freqs and sum them together\n}).normalize; // make sure |s| <= 1\n);\n\n~b = Buffer.alloc(s, ~sz);\n~b.sendCollection(~sig.asWavetableNoWrap) // send to buffer as a wavetable - see Shaper docs\n\n~b.plot;\n\n(\nx = {\n var lerp = Saw.ar(MouseX.kr(100, 1400, 1)); // lerp is used to read through the buffer - try a sine wave? lerp must be some f in [-1, 1]\n Shaper.ar(~b, lerp)\n}.play\n);\nx.free\ns.scope\n```"}
+{"text": "SuperCollider forum — CPU usage of additive synthesis(beginner)\n\nIs IFFT an option? Fill an array in the right spots with amplitudes and then transform. I have not tried it yet. (thinking of what virtual ans does, WarmPlace.ru. Virtual ANS Spectral Synthesizer )"}
+{"text": "SuperCollider forum — Sending OSC data over internet?\n\nThe way I would do this is to set up a web server instance and create a small program relaying the messages. OSCgroups looks good if it still works, otherwise you can write this server in whatever you’re comfortable with. The clients can then both connect to this server which is publicly available. (Hole punching, as Spacechild1 mentioned)\n\nMy suggestion, if you need to write your own relay is to use websockets over UDP for this since there are good, stable and easy-to-use libraries for it. I wrote a simple variant of this in Rust, but haven’t had time to bring it to a publishable state yet.\n\nI haven’t tried using a VPN into a private network. I’d be interested to hear your results if you do try!"}
+{"text": "SuperCollider forum — Ndef simple channel expansion question\n\nAs another limitation, n-ary (n>2) ops are only defined for UGens but not Ndefs at the moment.\n\n```supercollider\nblend(SinOsc.ar(), LFSaw.ar(), 0.3) // -> a XFade2\n\nNdef(\\xa) { SinOsc.ar() }\nNdef(\\xb) { LFSaw.ar() }\n\nblend(Ndef(\\xa), Ndef(\\xb), 0.4)\n// ERROR: NotYetImplementedError\n// RECEIVER: BusPlug:composeNAryOp\n```\n\nIt might be why Ndef math is not widely advertised in the documentation, as far as I can tell. I only discovered it because I saw the BinaryOpPlug class in the sources... Ndefs will actually try to play any AbstractFunction (which is a superclass of BinaryOpPlug) because:\n\n```supercollider\n+ AbstractFunction {\n prepareForProxySynthDef { ^{ this.value } }\n}\n```\n\nSo\n\n```supercollider\nNdef(\\xs, { 0.2 * SinOsc.ar() } + { 0.3 * LFSaw.ar() })\nNdef(\\xs).scope\n```\n\nWorks, even though\n\n```supercollider\nSynthDef(\\blergh, { 0.2 * SinOsc.ar() } + { 0.3 * LFSaw.ar() })\n// ERROR: Message 'def' not understood.\n```\n\ndoes not, although you can fool it by some wrapping:\n\n```supercollider\nSynthDef(\\"}
+{"text": "though you can fool it by some wrapping:\n\n```supercollider\nSynthDef(\\oh, { value({ 0.2 * SinOsc.ar() } + { 0.3 * LFSaw.ar() }) } ).add\n// needs an Out to actually play, of course\n```\n\nYou can easily guess why AbstractFunctions can’t be synthdef’d directly. The latter paradigm uses explicit I/O ugens like Out, unlike Ndef which uses a functional one, grabbing the returned value of your function and wrapping that in a single Out.\n\nSadly\n\n```supercollider\n({ 0.2 * SinOsc.ar() } + { 0.3 * LFSaw.ar() }).play\n// ERROR: Message 'play' not understood.\n// RECEIVER: a BinaryOpFunction\n```\n\nAlthough I suspect it’s not hard to make that work because when you play a regular Function, it’s almost JITLib that plays it, really via the somewhat obscure GraphBuilder class that only differs from the ProxySynthDef business in that it’s somewhat simpler and returns a regular SynthDef, but it also does the kind of function result capture and Out node addition, even with JITlib style envelope having a \\fadeTime control."}
+{"text": "SuperCollider forum — How to link a gui slider with a midi controller?\n\nmuzikman:\n\nThe prototype dependents notification is a great mechanism to set up a listener/observer type pattern.\n\nYes, it is! However, be aware that the dependency notification system is separate from object prototypes. changed and update are defined on Object, so this protocol is available to every object. (I used a prototype in that example because I didn’t want to define a class only for this example, and then have to explain how to install the class.)\n\n muzikman:\n\nOne thing I’d like to point out, is it would be nice to have this as part of the ide tutorial.\n\nIf you mean a tutorial chapter on basic GUI usage, sure. If you mean MVC, I think that’s a bit advanced for the “getting started” tutorial. It would be good to have a Guide-type document about MVC, and link to it from a “basic GUI” tutorial page. (We are pretty good about writing help for classes. The idea of writing “topic” documentation hasn’t really taken root though.)\n\n muzikman:\n\nThe tutorials and the general form in which the language is introduced led me to believe that dataflow was mainly through bus mappings of control or audio signals.\n\nI think a larger number of examples just set argument values directly...?\n\nIn any case, one thing that ended up making things easier for me (though at the time, I didn’t fully predict it) was that early on, I made a class that 1/ represents a value (with a ControlSpec) and 2/ syncs this value over to a control bus (which support"}
+{"text": " a value (with a ControlSpec) and 2/ syncs this value over to a control bus (which supports automation “for free”). This was originally for my Voicer class, where I wanted e.g. filter frequency to act like a typical hardware or software synth (all notes follow the control), but I ended up changing the hierarchy to put a freestanding GenericGlobalControl at the top.\n\nAt that time I didn’t know MVC, but then when I started looking at that, GenericGlobalControl / VoicerGlobalControl turned out to be a good Model for a single control. The way I’m using changed in these classes is a bit weird... I thought it was a good idea at the time; now I’m not so sure. But the following for instance is a legit MVC.\n\n```supercollider\ns.boot;\n\n// example uses the ddwCommon quark (I think only this one)\n~pan = GenericGlobalControl(\\pan, nil, 0, \\bipolar);\n\n(\nvar slider = Slider(nil, Rect(800, 200, 200, 50)).front;\n\nvar updater = { |obj, msg|\n switch(msg[\\what])\n { \\value } {\n defer { slider.value = ~pan.spec.unmap(~pan.value) };\n }\n { \\modelWasFreed } {\n ~pan.removeDependant(updater);\n }\n};\n\n~pan.addDependant(updater);\n\nslider.action = { |view|\n ~pan.set(~pan.spec.map(view.value))\n};\nslider.onClose = {"}
+{"text": ".set(~pan.spec.map(view.value))\n};\nslider.onClose = { ~pan.removeDependant(updater) };\n);\n\n(\np = Pbind(\n \\instrument, \\default,\n \\freq, Pexprand(200, 800, inf),\n \\dur, Pexprand(0.1, 0.4, inf),\n \\legato, Pexprand(0.3, 4, inf),\n \\pan, ~pan.asMap\n).play;\n);\n\n// `watch`: sync LFO values back to the language side\n// ... which fires off a dependant notification\n// so the GUI picks it up \"for free\"\n~pan.watch.automate { LFDNoise3.kr(LFDNoise3.kr(0.25).exprange(0.7, 14)).range(-1, 1) };\n\np.stop;\n\n~pan.stopAuto.stopWatching;\n\n~pan.free;\n```\n\nI’m rambling about that just to point out that an early object-modeling decision made some problems go away in the long term.\n\nhjh"}
+{"text": "SuperCollider forum — Granular synthesis\n\nQQQQ:\n\nThe chapter on granular synthesis from the SuperCollider book is quite helpful too\n\nDefinitely. Code examples (Alberto’s Chapter 16) can be found here:\n\n github.com\n\n GitHub - madskjeldgaard/scbookcode: The code examples used in the SuperCollider book...\n\n The code examples used in the SuperCollider book published by MIT\n\nNote the incluced and necessary extension. Also, this refers to an old SC-version, replace memStore by add.\n\nmiSCellaneous_lib contains the tutorials ‘Buffer Granulation’ and ‘Live Granulation’ (without buffering). Other classes of miSCellaneous also refer to granulation: DX suite (multichannel envelopes), PbindFx (granulation with effects), Sieves and Psieve patterns, ZeroXBufRd / TZeroXBufRd (wavesets), PLbindef / PLbindefPar (granulation and live coding).\n\nHere’s another live granulation strategy not included in the tutorial:\n\n Real-Time Attack and Decay Control of grain envelope for Granular Synthesis Questions\n\n Hi,\nPatterns are one, but certainly not the only approach. As always, much depends on personal taste. I think that Patterns are most flexible for granular synthesis, so it might be that a certain bias from my side comes across in miSCellaneous_lib’s Buffer Granulation tutorial"}
+{"text": "as from my side comes across in miSCellaneous_lib’s Buffer Granulation tutorial, although it contains alternative server-side and hybrid approaches as well.\nWith Pattern-based granulation, you can do granulation with some hundred grains triggered per second. But indeed, as @scztt points to, you are ..."}
+{"text": "SuperCollider forum — Copying Dictionary seems to \"link\" contained array\n\nmuzikman:\n\nBut exhibits the ( return array if array empty, return copy otherwise ) behaviour.\n\nThe correct explanation of the behavior is:\n\n- If the array includes slots that are unused, but allocated (x.size < x.maxSize), then .add mutates and returns the existing array.\n\n- If the array is already using all allocated slots (x.size == x.maxSize), then .add create a new array where newArray.maxSize == x.maxSize.nextPowerOfTwo (I think) and returns this new array.\n\nNow... if you use List instead of Array, then this problem almost goes away (except that .collect, .select, .reject etc then return an Array, because a List’s .species is Array – I usually don’t disagree with JMc’s decisions, but this decision, to revert Lists to Arrays for no reason that has ever been clearly explained, is baffling).\n\nMuch of the problem, then, is that Array really should be considered a low-level, implementation object, and there should be a higher-level interface that hides the implementation details. But unfortunately, since you can’t rely on a List to remain a List, it’s inconsistent. (In many cases in object-oriented programming, it would be natural and expected to get confused when inappropriately using low-level objects for high-level purposes. One problem here is that we habitually do exactly that, instead of fixing the class library to make it feasible to use List more generally.)\n\nhjh"}
+{"text": "SuperCollider forum — Error: OSC type tags\n\nProbably your C++ is producing malformed OSC packets.\n\nThe OSC specification is well documented; if your c++ thingy isn’t following the spec, of course there would be problems.\n\nSince you haven’t posted any of that code, or any examples of raw OSC data coming out of the multiplexer, there’s no way to answer your question in any detail.\n\nhjh"}
+{"text": "SuperCollider forum — Karplus–Strong string synthesis with InFeedback\n\ndietcv:\n\nIn my opinion the default choice for adding a filter into a feedback path should be a OnePole filter.\n\nThat’s fair... I don’t have a particularly compelling reason for using the second-order LPF in my example, just lazy I guess.\n\nFor KS, it’s even fine to specify the one-pole coefficient directly as a damping parameter.\n\nThanks for the correction –\n\nhjh"}
+{"text": "SuperCollider forum — Wav file as osc waveform\n\nSo I’ve done some more reading up on the Phasor and that helped a lot using examples on the supercollider website. I’ve tried to implement that into an FM tutorial I found on youtube. I can hear the kick it clicks for about 3-4 times and nothing.\n\nIs there a way I can set some operations to modulate a few parameters - such as implementing MouseX.\n\nCode is here - I know I’m a total newbie but I’ve only been doing this a few days and its quite difficult to pick up.\n\nb = Buffer.read(s, Platform.resourceDir +/+ “sounds/145775__zesoundresearchinc__909-kick.wav”);\n\n{ BufRd.ar(1, b.bufnum, Phasor.ar(0, BufRateScale.kr(b.bufnum), 0, BufFrames.kr(b.bufnum))) }.play;\n\n(\n\nSynthDef(\\fm, {\n\narg freq=500, mRatio=1, cRatio=1,\n\namp=0.2, atk=0.5, rel=3, pan=0;\n\nvar car, mod, env, framesInBuffer, trig, rate;\n\nframesInBuffer = BufFrames.kr(b.bufnum);\n\nenv = EnvGen.kr(Env.perc(atk, rel),doneAction:2);\n\nmod = SinOsc.ar(freq * mRatio, mul:freq * mRatio * index);\n\ncar = Phasor.ar(freq, BufRate"}
+{"text": "req * mRatio * index);\n\ncar = Phasor.ar(freq, BufRateScale.kr(b.bufnum), 0, framesInBuffer,) * env * amp;\n\ncar = Pan2.ar(car, pan);\n\nBufRd.ar(1, b.bufnum, car);\n\nOut.ar(0, car);\n\n}).add;\n\n)\n\nSynth(\\fm, [\\freq, 69.midicps]);\n\nMy trouble is I’ve come from working in Puredata using sliders. but im wanting to learn code so I can learn DSP and build my own VST when I’ve gained a lot more experience."}
+{"text": "SuperCollider forum — Why is NodeProxy outputting on the wrong bus if In.kr(\\out.ir) is used inside its function?\n\nThe question-mark stuff with array controls that I was talking about earlier only happens a bit later (indeed) at the SynthDesc lib stage (i.e. after the SynthDef is .added). For example, to recap & extend the duplicate-names test:\n\n```supercollider\nd = SynthDef(\\aa, { arg x = #[1, 2, 3], y = #[55, 66]; Control.names(\\x).kr(44) })\n\nd.allControlNames do: _.postln\n\n/* ->\nControlName P 0 x control [ 1, 2, 3 ]\nControlName P 3 y control [ 55, 66 ]\nControlName P 5 x control 44\n*/\n\nd.add // warns about dupes.\n\nd.desc\n\n/*\n-> SynthDesc 'aa'\nControls:\nControlName P 0 x control [ 1.0, 2.0, 3.0 ]\nControlName P 1 ? control 2.0\nControlName P 2 ? control 3.0\nControlName P 3 y control [ 55.0, 66.0 ]\nControlName P 4 ? control 66.0\nControlName P 5 x control 44.0\n*/\n```\n\nAt the ‘desc’ stage, there’s some further control reordering, meaning the internal array gets regenerated in the index order that was saved inside the ControlName objects:\n\n```supercollider\n(\nd ="}
+{"text": "x order that was saved inside the ControlName objects:\n\n```supercollider\n(\nd = SynthDef(\\aa) { arg x = #[5, 7]; SynthDef.wrap {\n arg z = #[111, 222], a_i; Out.ar(0, 0) }}\n);\n\nd.allControlNames do: _.postln\n\n/*\nControlName P 0 x control [ 5, 7 ]\nControlName P 3 z control [ 111, 222 ]\nControlName P 2 a_i audio 0.0\n*/\n\nd.add\n\nd.desc\n\n/*\n-> SynthDesc 'aa'\nControls:\nControlName P 0 x control [ 5.0, 7.0 ]\nControlName P 1 ? control 7.0\nControlName P 2 a_i audio 0.0\nControlName P 3 z control [ 111.0, 222.0 ]\nControlName P 4 ? control 222.0\n*/\n```\n\nBut the latter is actually a different collection. d.allControlNames is not the same as d.desc.controls. Confusingly there’s also d.desc.controlNames that only has the name strings, not\n\nthe ControlName objects. The allControlNames array in the SynthDef proper doesn’t get rebuilt even on add.\n\n```supercollider\nd.allControlNames do: _.postln // same as before calling d.add\n\nd.desc.controls do: _.postln // this is the one with question-marks\n\nd.desc.controlNames do: _.post"}
+{"text": "n // this is the one with question-marks\n\nd.desc.controlNames do: _.postln // just -> [ x, z, a_i ]\n```\n\nBy the way, the argNums are completely discarded at the desc stage.\n\n```supercollider\nd.desc.controls.do { |c| c.argNum.postln } // posts just nils\n```\n\nSynthDesc also comes with its own lookup and name-deduplication (of sorts) as desc.controlDict. NamedControl obviously cannot rely on the desc stuff to exist.\n\nI’ve also checked the Server-Command-Reference but it is silent on duplicate name controls. I’m guessing the behavior is to set just the first matching name. Setting by numerical index instead of name is possible in that protocol though.\n\nYeah, the server just uses the first name in order on a match:\n\n```supercollider\n(\nd = SynthDef(\\aa) { arg x = #[5, 7];\n Poll.kr(Impulse.kr(0.3), x, \"Top x:\");\n SynthDef.wrap { arg x = 111;\n Poll.kr(Impulse.kr(0.3), x, \"Bot x:\");\n };\n Out.ar(0, 0) }\n);\n\nd.allControlNames // two x's\n\nd.add;\n\nx = Synth(d) // this fails in an obscure way \"/s_new wrong argument type\"\n\n// But manual use of such synths is totally possible, even with name addressing\n\ns.sendMsg(\"/s_new\", \"aa\", s.nextN"}
+{"text": "ally possible, even with name addressing\n\ns.sendMsg(\"/s_new\", \"aa\", s.nextNodeID, 0, 1, \"x\", 66) // sets just first 'x'\n\ns.sendMsg(\"/n_set\", n, 2, 55); // can set others by index of course\n```\n\nSo I think NamedControl should emulate server behavior, i.e. find the first one that matches by name in the allControlNames. A nice feature to have would be for it search for the rest of the matches too and warn is more exist like SynthDesc does."}
+{"text": "SuperCollider forum — Parallel Routines, or how I keep losing the ability to interact with the Server\n\nYes this works for me.\n\nI’ve been going through my code, and I THINK my problems occured when I do inThanksdeed have malformed makeBundles. However, I am not able to reproduce the issue at this time. If and when it happens again I will post the code. Thanks @jamshark70"}
+{"text": "SuperCollider forum — Server clock vs. Language clock\n\nI’ve observed in Linux (and I think also in Windows) a roughly periodic timing jitter in OSC message receipt. That is, you might not be seeing language clock jitter – you might be seeing discrepancies in the timing of message transmission and/or receipt. The internal server might help because it doesn’t go through UDP, but I didn’t try that.\n\nhjh"}
+{"text": "SuperCollider forum — Rhythmically skipping through a recording, audio probing\n\nThe problem with long buffers... examples? Questions\n\n Hello,\nI thought I had understood the problem SC has with long buffers: something like when the index overflows the underlying data structure’s memory size, SC inevitably loses precision.\nIn the past, I thought I could hear examples of this behavior as sounding like downsampling. Now I’m not sure anymore, and can’t reproduce that glitch by, for example, indexing at half of a one hour buffer.\nHas it been solved somehow, or (as I’m suspecting) I didn’t understand anything of this problem? Could..."}
+{"text": "SuperCollider forum — Time-aware merging of two Event Pattern streams\n\nSure, thanks @scztt , I’d be happy to take a look at yours – it sounds somewhat similar to what I want. I’ve got a version of what I want working, more or less...with lots of caveats (e.g. doesn’t work properly when doing multiple “merges”, one after another). I’ve never explored the “innards” of an Event Pattern class before... But in the simple cases it seems to work well enough (it’s a start, anyhow ).\n\nHere’s what I have so far:\n\n```supercollider\nPtimeMerge : Pattern {\n var <> structurePattern;\n var <> valuePattern;\n *new { arg structurePattern, valuePattern;\n ^super.newCopyArgs(structurePattern, valuePattern);\n }\n\n embedInStream { arg inVal;\n var structureStream = structurePattern.asStream;\n var valueStream = valuePattern.asStream;\n var inEvent = inVal.copy;\n var cleanup = EventStreamCleanup.new;\n var curTime = 0;\n var nextValueTime = 0;\n var otherEvent = valueStream.next(inEvent);\n // otherEvent.debug(\"otherEvent\");\n nextValueTime = otherEvent.delta.value;\n loop {\n var structEvent = structureStream.next(inEvent);\n if (structEvent.isNil) { ^cleanup.exit(inVal) };\n\n // \"curTime: % nextValueTime: %\".format(cur"}
+{"text": "(inVal) };\n\n // \"curTime: % nextValueTime: %\".format(curTime, nextValueTime).postln;\n while {\n nextValueTime <= (curTime + 0.0001);\n } {\n otherEvent = valueStream.next(inEvent);\n // otherEvent.debug(\"otherEvent\");\n nextValueTime = nextValueTime + otherEvent.delta.value;\n // nextValueTime.debug(\"nextValueTime updated\");\n };\n structEvent = otherEvent.copy.putAll(structEvent).postln;\n cleanup.update(structEvent);\n inVal = yield(structEvent);\n curTime = curTime + structEvent.delta.value;\n // curTime.debug(\"curTime\");\n };\n }\n}\n\n+Pattern {\n\n << { arg aPattern;\n // time-based pattern key merging\n ^PtimeMerge(this, aPattern)\n }\n\n}\n```\n\nExample usage:\n\n```supercollider\na = Pbind(\\degree, Pseq([1,2,3,4], 2), \\dur, 0.5);\nb = Pbind(\\instrument, Pseq([\\a,\\b,\\default], inf), \\dur, Pseq([2,0.5,1.5], inf));\n(a << b).play\n\n// ( 'instrument': a, 'degree': 1, 'dur': 0.5 )\n// ( 'instrument': a, 'degree': 2, 'dur': 0.5 )\n// ( 'instrument': a, 'degree': 3, 'dur':"}
+{"text": " 2, 'dur': 0.5 )\n// ( 'instrument': a, 'degree': 3, 'dur': 0.5 )\n// ( 'instrument': a, 'degree': 4, 'dur': 0.5 )\n// ( 'instrument': b, 'degree': 1, 'dur': 0.5 )\n// ( 'instrument': default, 'degree': 2, 'dur': 0.5 )\n// ( 'instrument': default, 'degree': 3, 'dur': 0.5 )\n// ( 'instrument': default, 'degree': 4, 'dur': 0.5 )\n```"}
+{"text": "SuperCollider forum — Arrays as arguments to SynthDef?\n\n@scztt also wrote this supernice post about passing envs to synths and patterns:\n\n Envelope passing for Synths and Patterns Code Tennis\n\n I work pretty heavily with Env’s passed as synth arguments - often I’ll just stick an envelope on every parameter I’d ever want to modulate, and then build a Pattern infrastructure to actually send the envelopes I want.\nBecause it’s come up recently on the forum, and because I think it’s super powerful - I spent an hour and came up with a pretty basic but complete distillation of how to use Env’s in a Pattern context, dynamically building them from simpler parameters to enable all kinds of nice..."}
+{"text": "SuperCollider forum — Discussion of Moderation Process and Principles\n\ndscheiba:\n\nA good way to respond to an, hopefully accidental, offense is to apologize, avoid this offending behavior and continue in a respectful, friendly and open exchange. This is the learning process.\n\nI’m sorry, but I think we said the same thing. I said, “Apologize and adjust behavior, prioritizing healing over defensiveness.”\n\nI agree that we should respect everyone’s honor and dignity. My comment was about something else. It would be contradictory to apply punishments that are worse regarding honor and dignity than the offense. We are talking about ethics, and this is a collective construction.\n\nI think we are saying more or less the same thing, maybe?"}
+{"text": "SuperCollider forum — Discussion of Moderation Process and Principles\n\ndscheiba:\n\nI don’t want to argue every time about basic rights, which are set via the CoC,\n\nI don’t recall any discussion around universal human rights or respectful communication encoded in the CoC. This is not a debate; it is a settled matter.\n\nI meant disagreements in general; I imagine they will relate to the forum’s typical topics.\n\nAm I missing something?"}
+{"text": "SuperCollider forum — Multiband Compressor?\n\nstill needs polishing:\n\nit’s actually stereo, but I forgot to change some names. BPF have 1/3 octave bandwidths, frequencies spaced 1/3 octave apart. too many to tune by hand, interesting to automate it somehow, or group them (3 or 4 together) if you want something ‘classical’\n\n```supercollider\nimport(\"effect.lib\");\nimport(\"filter.lib\");\nimport(\"music.lib\");\n\nnot(x) = abs(x - 1);\nmute = not(checkbox(\"[0] mute [tooltip: Mute the whole band]\"));\nbypass(switch, block) = select2(switch, _, block);\nbswitch = checkbox(\"[0] bypass [tooltip: Bypass the compressor, but not the bandpass filter]\");\n\nratio = hslider(\"[9] Ratio [tooltip: Compression ratio]\", 2, 1, 100, 1);\nattack = hslider(\"[A] Attack (sec) [tooltip: Time before the compressor starts to kick in]\", 0.012, 0, 1, 0.001);\nrelease = hslider(\"[B] Release (sec) [tooltip: Time before the compressor releases the sound]\", 1.25, 0, 10, 0.01);\nsafe = hslider(\"[6] Makeup-Threshold (db) [tooltip: Threshold correction, an anticlip measure]\", 2, 0, 10, 0.1);\n\n// Makeup gain sliders\nmakeup1 = hslider(\"[5]"}
+{"text": " 10, 0.1);\n\n// Makeup gain sliders\nmakeup1 = hslider(\"[5] Makeup1 (db) [tooltip: Post amplification and threshold]\", 13, -50, 50, 0.1);\nmakeup2 = hslider(\"[5] Makeup2 (db) [tooltip: Post amplification and threshold]\", 10, -50, 50, 0.1);\nmakeup3 = hslider(\"[5] Makeup3 (db) [tooltip: Post amplification and threshold]\", 4, -50, 50, 0.1);\nmakeup4 = hslider(\"[5] Makeup4 (db) [tooltip: Post amplification and threshold]\", 8, -50, 50, 0.1);\nmakeup5 = hslider(\"[5] Makeup5 (db) [tooltip: Post amplification and threshold]\", 11, -50, 50, 0.1);\nmakeup6 = hslider(\"[5] Makeup6 (db) [tooltip: Post amplification and threshold]\", 14, -50, 50, 0.1);\nmakeup7 = hslider(\"[5] Makeup7 (db) [tooltip: Post amplification and threshold]\", 16, -50, 50, 0.1);\nmakeup8 = hslider(\"[5] Makeup8 (db) [tooltip: Post amplification and threshold]\", 18, -50, 50, 0.1);\nmakeup9 = hslider(\"[5] Makeup9 (db) [tooltip: Post amplification and threshold]\", 20, -50, 50, 0.1);\nmakeup10 = hslider(\"[5] Makeup10 (db) [to"}
+{"text": "50, 50, 0.1);\nmakeup10 = hslider(\"[5] Makeup10 (db) [tooltip: Post amplification and threshold]\", 22, -50, 50, 0.1);\nmakeup11 = hslider(\"[5] Makeup11 (db) [tooltip: Post amplification and threshold]\", 24, -50, 50, 0.1);\nmakeup12 = hslider(\"[5] Makeup12 (db) [tooltip: Post amplification and threshold]\", 26, -50, 50, 0.1);\nmakeup13 = hslider(\"[5] Makeup13 (db) [tooltip: Post amplification and threshold]\", 28, -50, 50, 0.1);\nmakeup14 = hslider(\"[5] Makeup14 (db) [tooltip: Post amplification and threshold]\", 30, -50, 50, 0.1);\nmakeup15 = hslider(\"[5] Makeup15 (db) [tooltip: Post amplification and threshold]\", 32, -50, 50, 0.1);\nmakeup16 = hslider(\"[5] Makeup16 (db) [tooltip: Post amplification and threshold]\", 34, -50, 50, 0.1);\nmakeup17 = hslider(\"[5] Makeup17 (db) [tooltip: Post amplification and threshold]\", 36, -50, 50, 0.1);\nmakeup18 = hslider(\"[5] Makeup18 (db) [tooltip: Post amplification and threshold]\", 38, -50, 50, 0.1);\nmakeup19 = hslider(\"[5] Makeup19 (db) [tooltip:"}
+{"text": " 0.1);\nmakeup19 = hslider(\"[5] Makeup19 (db) [tooltip: Post amplification and threshold]\", 40, -50, 50, 0.1);\nmakeup20 = hslider(\"[5] Makeup20 (db) [tooltip: Post amplification and threshold]\", 42, -50, 50, 0.1);\nmakeup21 = hslider(\"[5] Makeup21 (db) [tooltip: Post amplification and threshold]\", 44, -50, 50, 0.1);\nmakeup22 = hslider(\"[5] Makeup22 (db) [tooltip: Post amplification and threshold]\", 46, -50, 50, 0.1);\nmakeup23 = hslider(\"[5] Makeup23 (db) [tooltip: Post amplification and threshold]\", 48, -50, 50, 0.1);\nmakeup24 = hslider(\"[5] Makeup24 (db) [tooltip: Post amplification and threshold]\", 50, -50, 50, 0.1);\nmakeup25 = hslider(\"[5] Makeup25 (db) [tooltip: Post amplification and threshold]\", 52, -50, 60, 0.1);\nmakeup26 = hslider(\"[5] Makeup26 (db) [tooltip: Post amplification and threshold]\", 54, -50, 60, 0.1);\nmakeup27 = hslider(\"[5] Makeup27 (db) [tooltip: Post amplification and threshold]\", 56, -50, 60, 0.1);\nmakeup28 = hslider(\"[5] Makeup28 (db) [tooltip"}
+{"text": ", 0.1);\nmakeup28 = hslider(\"[5] Makeup28 (db) [tooltip: Post amplification and threshold]\", 58, -50, 60, 0.1);\n\n// Define bandpass filters based on center frequencies and bandwidths\nbandpass1 = par(i, 2, bandpass(3, 25 - 5.8/2, 25 + 5.8/2));\nbandpass2 = par(i, 2, bandpass(3, 31.5 - 7.3/2, 31.5 + 7.3/2));\nbandpass3 = par(i, 2, bandpass(3, 40 - 9.2/2, 40 + 9.2/2));\nbandpass4 = par(i, 2, bandpass(3, 50 - 11.6/2, 50 + 11.6/2));\nbandpass5 = par(i, 2, bandpass(3, 63 - 14.5/2, 63 + 14.5/2));\nbandpass6 = par(i, 2, bandpass(3, 80 - 18.3/2, 80 + 18.3/2));\nbandpass7 = par(i, 2, bandpass(3, 100 - 23/2, 100 + 23/2));\nbandpass8 = par(i, 2, bandpass(3, 125 - 29/2, 125 + 29/2));\nbandpass9 = par(i, 2, bandpass(3, 160 - 37/2, 160 + 37/2));\nbandpass10 = par(i, 2, bandpass(3, 200 - 46/2, 200 + 46/2));\nbandpass11 = par(i, 2, bandpass(3, 250 - 58/2, 250 + 58/2));\nband"}
+{"text": "(i, 2, bandpass(3, 250 - 58/2, 250 + 58/2));\nbandpass12 = par(i, 2, bandpass(3, 315 - 73/2, 315 + 73/2));\nbandpass13 = par(i, 2, bandpass(3, 400 - 92/2, 400 + 92/2));\nbandpass14 = par(i, 2, bandpass(3, 500 - 116/2, 500 + 116/2));\nbandpass15 = par(i, 2, bandpass(3, 630 - 145/2, 630 + 145/2));\nbandpass16 = par(i, 2, bandpass(3, 800 - 183/2, 800 + 183/2));\nbandpass17 = par(i, 2, bandpass(3, 1000 - 230/2, 1000 + 230/2));\nbandpass18 = par(i, 2, bandpass(3, 1250 - 290/2, 1250 + 290/2));\nbandpass19 = par(i, 2, bandpass(3, 1600 - 370/2, 1600 + 370/2));\nbandpass20 = par(i, 2, bandpass(3, 2000 - 460/2, 2000 + 460/2));\nbandpass21 = par(i, 2, bandpass(3, 2500 - 580/2, 2500 + 580/2));\nbandpass22 = par(i, 2, bandpass(3, 3150 - 730/2, 3150 + 730/2));\nbandpass23 = par(i, 2, bandpass(3, 4000 - 920/2, 4000 + 920/2));\nbandpass24 = par(i, 2, bandpass(3, 5000 - 1160/2, 5000 + 1160"}
+{"text": "pass24 = par(i, 2, bandpass(3, 5000 - 1160/2, 5000 + 1160/2));\nbandpass25 = par(i, 2, bandpass(3, 6300 - 1450/2, 6300 + 1450/2));\nbandpass26 = par(i, 2, bandpass(3, 8000 - 1830/2, 8000 + 1830/2));\nbandpass27 = par(i, 2, bandpass(3, 10000 - 2300/2, 10000 + 2300/2));\nbandpass28 = par(i, 2, bandpass(3, 12500 - 2900/2, 12500 + 2900/2));\n\n// Makeup gains with smoothing and muting\nmakeupGain(bswitch, mute, makeup, safe) = mute * (not(bswitch) * (makeup - safe) : db2linear : smooth(0.999));\n\nMakeup1 = makeupGain(bswitch, mute, makeup1, safe);\nMakeup2 = makeupGain(bswitch, mute, makeup2, safe);\nMakeup3 = makeupGain(bswitch, mute, makeup3, safe);\nMakeup4 = makeupGain(bswitch, mute, makeup4, safe);\nMakeup5 = makeupGain(bswitch, mute, makeup5, safe);\nMakeup6 = makeupGain(bswitch, mute, makeup6, safe);\nMakeup7 = makeupGain(bswitch, mute, makeup7, safe);\nMakeup8 = makeupGain(bswitch, mute, makeup8, safe);\nMakeup9 = makeupGain(bswitch, mute"}
+{"text": "itch, mute, makeup8, safe);\nMakeup9 = makeupGain(bswitch, mute, makeup9, safe);\nMakeup10 = makeupGain(bswitch, mute, makeup10, safe);\nMakeup11 = makeupGain(bswitch, mute, makeup11, safe);\nMakeup12 = makeupGain(bswitch, mute, makeup12, safe);\nMakeup13 = makeupGain(bswitch, mute, makeup13, safe);\nMakeup14 = makeupGain(bswitch, mute, makeup14, safe);\nMakeup15 = makeupGain(bswitch, mute, makeup15, safe);\nMakeup16 = makeupGain(bswitch, mute, makeup16, safe);\nMakeup17 = makeupGain(bswitch, mute, makeup17, safe);\nMakeup18 = makeupGain(bswitch, mute, makeup18, safe);\nMakeup19 = makeupGain(bswitch, mute, makeup19, safe);\nMakeup20 = makeupGain(bswitch, mute, makeup20, safe);\nMakeup21 = makeupGain(bswitch, mute, makeup21, safe);\nMakeup22 = makeupGain(bswitch, mute, makeup22, safe);\nMakeup23 = makeupGain(bswitch, mute, makeup23, safe);\nMakeup24 = makeupGain(bswitch, mute, makeup24, safe);\nMakeup25 = makeupGain(bswitch, mute, makeup25, safe);\nMakeup26 = makeupGain(bswitch, mute, makeup26, safe);\nMakeup27 = make"}
+{"text": "6 = makeupGain(bswitch, mute, makeup26, safe);\nMakeup27 = makeupGain(bswitch, mute, makeup27, safe);\nMakeup28 = makeupGain(bswitch, mute, makeup28, safe);\n\ncompressorMono(bandpass, makeup, push) = bandpass : bypass(bswitch, compressor_mono(ratio, -push, attack, release)) : *(makeup);\n\n// Mono processing\ngcomp1 = vgroup(\"[1] C1\", compressorMono(bandpass1, Makeup1, makeup1));\ngcomp2 = vgroup(\"[1] C2\", compressorMono(bandpass2, Makeup2, makeup2));\ngcomp3 = vgroup(\"[1] C3\", compressorMono(bandpass3, Makeup3, makeup3));\ngcomp4 = vgroup(\"[1] C4\", compressorMono(bandpass4, Makeup4, makeup4));\ngcomp5 = vgroup(\"[1] C5\", compressorMono(bandpass5, Makeup5, makeup5));\ngcomp6 = vgroup(\"[1] C6\", compressorMono(bandpass6, Makeup6, makeup6));\ngcomp7 = vgroup(\"[1] C7\", compressorMono(bandpass7, Makeup7, makeup7));\ngcomp8 = vgroup(\"[1] C8\", compressorMono(bandpass8, Makeup8, makeup8));\ngcomp9 = vgroup(\"[1] C9\", compressorMono(bandpass9, Makeup9, makeup9));\ngcomp10"}
+{"text": "] C9\", compressorMono(bandpass9, Makeup9, makeup9));\ngcomp10 = vgroup(\"[1] C10\", compressorMono(bandpass10, Makeup10, makeup10));\ngcomp11 = vgroup(\"[1] C11\", compressorMono(bandpass11, Makeup11, makeup11));\ngcomp12 = vgroup(\"[1] C12\", compressorMono(bandpass12, Makeup12, makeup12));\ngcomp13 = vgroup(\"[1] C13\", compressorMono(bandpass13, Makeup13, makeup13));\ngcomp14 = vgroup(\"[1] C14\", compressorMono(bandpass14, Makeup14, makeup14));\ngcomp15 = vgroup(\"[1] C15\", compressorMono(bandpass15, Makeup15, makeup15));\ngcomp16 = vgroup(\"[1] C16\", compressorMono(bandpass16, Makeup16, makeup16));\ngcomp17 = vgroup(\"[1] C17\", compressorMono(bandpass17, Makeup17, makeup17));\ngcomp18 = vgroup(\"[1] C18\", compressorMono(bandpass18, Makeup18, makeup18));\ngcomp19 = vgroup(\"[1] C19\", compressorMono(bandpass19, Makeup19, makeup19));\ngcomp20 = vgroup(\"[1] C20\", compressorMono(bandpass20, Makeup20, makeup20));\ngcomp21 = vgroup(\"[1] C21\", compressorMono(bandpass21, Makeup21, makeup21));\ngcomp22 = vgroup(\"[1] C22"}
+{"text": "(bandpass21, Makeup21, makeup21));\ngcomp22 = vgroup(\"[1] C22\", compressorMono(bandpass22, Makeup22, makeup22));\ngcomp23 = vgroup(\"[1] C23\", compressorMono(bandpass23, Makeup23, makeup23));\ngcomp24 = vgroup(\"[1] C24\", compressorMono(bandpass24, Makeup24, makeup24));\ngcomp25 = vgroup(\"[1] C25\", compressorMono(bandpass25, Makeup25, makeup25));\ngcomp26 = vgroup(\"[1] C26\", compressorMono(bandpass26, Makeup26, makeup26));\ngcomp27 = vgroup(\"[1] C27\", compressorMono(bandpass27, Makeup27, makeup27));\ngcomp28 = vgroup(\"[1] C28\", compressorMono(bandpass28, Makeup28, makeup28));\n\nprocess = (_,_)<: hgroup(\"\", gcomp1, gcomp2, gcomp3, gcomp4, gcomp5, gcomp6, gcomp7, gcomp8, gcomp9, gcomp10, gcomp11, gcomp12, gcomp13, gcomp14, gcomp15, gcomp16, gcomp17, gcomp18, gcomp19, gcomp20, gcomp21, gcomp22, gcomp23, gcomp24, gcomp25, gcomp26, gcomp27, gcomp28) :>(_,_);\n```"}
+{"text": "SuperCollider forum — Building uGens on Windows\n\ni haven’t built these plugins on Windows but make won’t work here because you aren’t using a makefile generator in cmake. the last command should be cmake --build . --config , assuming this will build at all on Windows."}
+{"text": "SuperCollider forum — Sub-sample accurate events from phasor ramps\n\none A / B example of having a SinOsc modulating the phase of a pulsaret and one subsample accurate sin Osc modulating the phase of a pulsaret:\n\n /uploads/default/original/2X/9/927555a7c1b7e658f0898e618a2c789976b4eb04.mp3\n\n /uploads/default/original/2X/5/5f6cb4683e80bc2ddfd2168a935f232bd00a5281.mp3"}
+{"text": "SuperCollider forum — The SC Wiki\n\nMost of the restructuring has now taken place: Home · supercollider/supercollider Wiki · GitHub\n\nOne issue came up: it appears changing a wiki’s name obscures the wiki’s revision history by showing only 1 revision once the page is renamed. Changing the name back to it’s previous name then shows the full revision history. hmmm... GitHub bug? So I’ve noted the previous name in the commit message renamed pages that have any substantial history.\n\nHopefully the new structure makes it more navigable and also more obvious where there are content gaps or a need for revision and refactoring. So everyone feel free to tidy the wiki up now\n\nPlease also keep an eye out for external links out in the wild pointing to renamed wiki pages that may need to be updated. I had to rename some pages that had extra spaces, or to make them consistent with similarly themes pages (like FAQs). Pages renamed to conform to the sentence case style recommendation should still be ok.\n\nAlso renaming the topic to be more generally about anything related to the wiki."}
+{"text": "SuperCollider forum — The SC Wiki\n\nAs I understand, you need to be a member of the SC GitHub Organization to edit the wiki. To be added to the list of members, I believe you’d have to just contact someone with Owner status to add you.\n\n GitHub\n\nThe wiki wiki\n\n An audio server, programming language, and IDE for sound synthesis and algorithmic composition. - supercollider/supercollider\n\nThen you could update that statement about the GPL with more neutral language"}
+{"text": "SuperCollider forum — Supernova cpu usage with ParGroups\n\n@lucas\n\n lucas:\n\nFor one thread supernova (~70%) uses more cpu than scsynth (~60%) but with four threads (-T 4 option, not configurable from sclang) each thread uses the same amount of cpu (~70%) supposedly doing less work.\n\nHow do you measure the CPU usage?\n\nInstead of looking at numbers, you can try to create as many Synths as possible before hearing drop outs. Do this with -T 1 and -T 4 and compare the numbers."}
+{"text": "SuperCollider forum — Strange offset behaviour when plotting some .kr uGens\n\nVery strange indeed. Same with SinOsc instead of Impulse BTW\n\n```supercollider\n{\n var impulse = SinOsc.kr(300);\n\n var var1 = LFSaw.kr(300,1);\n var var2 = WhiteNoise.kr(1);\n\n var var3 = LFSaw.ar(300,1);\n var var4 = WhiteNoise.kr(0);\n\n [impulse, var1]\n}.plot(0.01)\n```\n\nIn general the init behaviour of many UGens is erratic, but this kind of dependency is even more curious."}
+{"text": "SuperCollider forum — Quark Versioning / Dependency Management\n\n@scztt Should Quark2 be implemented in supercollider? Are we using Quark2 to update the core library, and with it, Quark2 itself? Wouldn’t a tool that doesn’t depend on supercollider running be better?\n\nNever really understood why Quark wasn’t a separate program to begin with as you have to recompile the class library anyway.\n\nSome people have mentioned that install git on windows is a little more involved than elsewhere. Perhaps something standalone could be made, perhaps in go using GitHub - go-git/go-git: A highly extensible Git implementation in pure Go. ?\n\n scztt:\n\nBut, it’s VERY easy to map dependencies in the classlib, and dependencies between quarks and classlib functionality - most of this can be done by searching for references to classes at runtime.\n\nThought it might be fun to try and map the dependencies within the current scclasslibrary by looking for class names directly reference in the source code.\n\nI think splitting apart the existing class library without breaking anything will be harder that expected/require many class extensions which might make it harder to reason about the code.\n\nThe regex I’ve used will match things in comments (would be nice to have a sclang parser in sclang!), but seems pretty good. It also doesn’t matching things like thisProcess which implies a dependency on Main.\n\nObviously everything also depends on Object as well.\n\nHere is files that reference other files.\n\nsc\n\n```su"}
+{"text": "ything also depends on Object as well.\n\nHere is files that reference other files.\n\nsc\n\n```supercollider\n~getNicePath = {|str| str.asString.split($/)[6..].reduce('+/+') };\n\n~getMentionedClasses = {|class|\n [class.asSymbol, ~getNicePath.(class.filenameSymbol.asString)] ->\n File.readAllString(class.filenameSymbol.asString)\n .findRegexp(\"[ ({][A-Z][a-zA-Z0-9_]+\")\n .collect({|n|\n n[1]\n .reject([$ , $(, ${].includes(_) )\n .asSymbol\n })\n .reject({|n|\n n.asClass.isNil\n })\n .collect({|c|\n [c, ~getNicePath.(c.asClass.filenameSymbol)]\n })\n .asSet\n};\n\n~r = Class.allClasses\n.reject(_.isMetaClass)\n.collect({|c| ~getMentionedClasses.(c, ) })\n.asEvent;\n\nt = TreeView().front;\nt.columns_([\"Class\", \"File\"]);\n~r.keysValuesDo({|k, v|\n var i;\n t.addItem([k[0].asString, k[1].asString]);\n i = t.itemAt(t.numItems - 1);\n v.do({|ar|\n i.addChild([ar[0].asString, ar[1].asString])\n })\n});\nt.c"}
+{"text": ".addChild([ar[0].asString, ar[1].asString])\n })\n});\nt.canSort = true;\n```\n\n1718×682 107 KB\n\nHere is Classes referencing other classes\n\nsc\n\n```supercollider\n(\n\n~getNicePath = {|str| str.asString.split($/)[6..].reduce('+/+').asSymbol };\n\n~getFileConnections = {|class|\n ~getNicePath.(class.filenameSymbol.asString) ->\n File.readAllString(class.filenameSymbol.asString)\n .findRegexp(\"[ ({][A-Z][a-zA-Z0-9_]+\")\n .collect({|n|\n n[1]\n .reject([$ , $(, ${].includes(_) )\n .asSymbol\n })\n .reject({|n|\n n.asClass.isNil\n })\n .collect({|c|\n ~getNicePath.(c.asClass.filenameSymbol)\n })\n .asSet\n};\n\n~r = Class.allClasses\n.reject(_.isMetaClass)\n.collect({|c| ~getFileConnections.(c, ) })\n.asEvent({|a, b| (a ++ b).asSet });\n\nt = TreeView();\n\nt.columns = [\"File\", \"Count\" ];\n\n~r.keysValuesDo({|k, v|\n var i = t.addItem([k.asString, nil]);\n v.do({|c| i.addChild(["}
+{"text": ".addItem([k.asString, nil]);\n v.do({|c| i.addChild([c]) });\n i.setString(1, v.size.asString);\n});\n\nt.canSort = true;\n\nt.itemPressedAction({|a|\n a.postln\n});\n\nt.front;\n\n)\n```\n\n2871×682 127 KB\n\nAs graphs...\n\nDirectories referencing directories, the arrows means ‘references’, so an incoming arrow means ‘is a dependant’.\n\noutput5385×1211 994 KB\n\nAnd then, just for fun, classes...\n\noutputd1920×155 44.2 KB"}
+{"text": "SuperCollider forum — Calling Supercollider script from Windows batch file?\n\nmakdaddy48:\n\nI wasn’t quite sure where to put the cond.unhang statements, though.\n\nI think the first thing is to think through, and be clear about, the process you want.\n\nYour current example records the tracks concurrently. So you can’t assume that the recordings will finish in order. In that case, here’s an outline (a counter, used in a Condition function, and wait / signal):\n\n```supercollider\n(\ns.waitForBoot {\n var samples;\n var completed = 0;\n var cond = Condition { completed >= samples.size };\n\n // for demo purposes, this is just a 'time to finish'\n samples = /*... get stuff...*/ Array.fill(5, { 10.0.rand });\n\n samples.do { |time, i|\n // simulate some process that will finish later\n thisThread.clock.sched(time, {\n \"% finished\\n\".postf(i);\n completed = completed + 1;\n cond.signal;\n });\n };\n\n cond.wait; // this waits for *all* of them\n\n \"All done\".postln;\n};\n)\n```\n\nThat leaves the action function.\n\nIn my example, I watched for a signal from the EventStreamPlayer that the pattern was finished.\n\nBecause you’re using record for patterns, you don’t have access to the EventStreamPlayer. That’s probably why you couldn’t figure out where to unhang/signal. This is admittedly not easy to grasp at first – there are many kinds of processes in SC"}
+{"text": " This is admittedly not easy to grasp at first – there are many kinds of processes in SC which finish in different ways.\n\nWhat I would do here is to attach a cleanup to the pattern that you are recording. (Also beg pardon while I add spaces after commas – not required but IMO this is good for readability.)\n\n```supercollider\nplayer = Pbindf(m.p, \\instrument, \"play_mono\", \\buf, item, \\legato, 1.0);\n\nplayer = Pfset(nil, player, { cond.unhang /* or signal, for concurrent recording */ });\n\nplayer.record(outputfilename, \"WAV\", \"int16\", 2, nil, 0.2, TempoClock.default, Event.default, Server.default, 0, 2);\n```\n\nSide note: You might be able to simplify a little by removing rt. A waitForBoot code block is already running in a routine. (There would be one reason to launch another routine. The waitForBoot routine is running on AppClock, where timing may lag. When you need musical timing, that would call for a thread on a TempoClock – but, patterns run on TempoClock by default – so there’s not a strict need to run the pattern-controller on TempoClock.)\n\n makdaddy48:\n\nI get about 100ms of silence at the beginning of each recording.\n\nRecording requires some initialization, and this is asynchronous. It allocates some memory from the OS. There is no way to predict how long that will take. So, it has to be outside of the audio th"}
+{"text": " OS. There is no way to predict how long that will take. So, it has to be outside of the audio thread, and this means that a record convenience method cannot guarantee that recording will start precisely in sync with audio.\n\nThe other thing: Patterns play with s.latency delay by default. (See the Server Timing help file.) But it takes some time to initialize, so I guess you’re seeing server latency minus recording setup time.\n\nIt is possible to start recording in sync, but you have to take the process apart. I’ll wrap it up into a function (much of it copied from Pattern:record) that you can call in place of the record lines.\n\n```supercollider\n(\n~patternRec = { |pattern, path, headerFormat, sampleFormat, numChannels = 2, dur = nil, fadeTime = 0.2, clock(TempoClock.default), protoEvent(Event.default), server(Server.default), out = 0, outNumChannels|\n\n var buffer, nodeID, defname;\n\n pattern = if(dur.notNil) { Pfindur(dur, pattern) } { pattern };\n\n // recorder.recHeaderFormat = headerFormat;\n // recorder.recSampleFormat = sampleFormat;\n\n server.waitForBoot {\n var group, bus, free, monitor;\n\n // prepareForRecord\n buffer = Buffer.alloc(server, 32768, numChannels);\n buffer.write(path, headerFormat, sampleFormat, 0, leaveOpen: true);\n defname = SystemSynthDefs.generateTempName;\n S"}
+{"text": " 0, leaveOpen: true);\n defname = SystemSynthDefs.generateTempName;\n SynthDef(defname, { |bufnum, bus|\n var sig = In.ar(bus, numChannels);\n DiskOut.ar(bufnum, sig);\n }).add;\n\n fadeTime = (fadeTime ? 0).roundUp(buffer.numFrames / server.sampleRate);\n\n bus = Bus.audio(server, numChannels);\n group = Group(server);\n Monitor.new.play(bus.index, bus.numChannels, out, outNumChannels ? numChannels, group);\n\n // important!\n server.sync;\n\n free = {\n (type: \\off, id: nodeID, server: server, hasGate: false).play;\n {\n bus.free; group.free;\n buffer.free;\n server.sendMsg(\\d_free, defname);\n }.defer(server.latency);\n };\n\n Pprotect(\n Pfset(nil,\n Pseq([\n // start recording synth exactly in time with pattern\n (\n type: \\on, id: nodeID, instrument: defname,\n bus: bus, group: group, addAction: \\addAfter,\n delta: 0,\n callback: { nodeID = ~id }\n ),\n pattern <> (out: bus),\n (type: \\rest, delta: fadeTime)\n ], 1),\n free\n ),\n free // on error\n ).play(clock, protoEvent, quant: 0);\n }\n};\n)\n```\n\nIs that hard? ... yeah... you’ve accidentally stumbled into a use case where you need"}
+{"text": ")\n```\n\nIs that hard? ... yeah... you’ve accidentally stumbled into a use case where you need some fairly advanced types of control. There’s no way a beginner would figure this out alone.\n\nhjh"}
+{"text": "SuperCollider forum — Rastrum: Music Notation w/ LilyPond, MusicXML, GUIDO writers\n\nThanks for reporting this. Could you test once more with only the Unit-Lib quark disabled, leaving everything else unchanged?\n\nDuring class-library initialization, Rastrum only registers a startup function:\n\n```supercollider\n*initClass {\n StartUp.add {\n outputDirectory = Platform.userAppSupportDir +/+ \"rastrum-output\";\n lilypondPath = lilypondPath ?? { this.findLilypond };\n }\n}\n```\n\nThat code does not build a ControlSpec, call Warp or Spec, or touch Unit-Lib. So my current reading is: Rastrum may change class-library startup order enough to expose an initialization-order issue in Unit-Lib.\n\nUnless you see the problem even with this quark disabled, then we need more digging.\n\nLet me know\n\nEDIT: @prko , I checked their repo and there is an update 2 days ago. Maybe you could just update the Unit-Lib quark and see if that was the problem? Again, it is just a wild guess. If that doesn’t solve it, maybe you could give me more details about your setup."}
+{"text": "SuperCollider forum — Issues with Pbindef.set()\n\nRFluff:\n\nYou can’t gui a Pbind though\n\nThe pVarGui method produces a standard gui with the synthdef’s and/ or global metadata specs. So for a quick sequencing gui of the default instrument you can e.g. write:\n\n\\default.pVarGui.gui\n\nThen you can add and replace key-value/stream pairs, so this is almost like aPbind.gui. It is explained in Chapter 2 of miSCellaneous_lib’s help file “VarGui shortcut builds”. However I suppose this is one of those cases where an intendedly “convenient” solution, doing a number of things under the hood, turns out to be of questionable practical value.\n\nI have been working with Pbinds + VarGuis for many years and, on the contrary I hardly ever use pVarGui. I suppose the reason is that from case to case there are always very specific control demands and a generalised Pbind gui control couldn’t manage that, no matter how clever it would be ..."}
+{"text": "SuperCollider forum — Interactive pattern modification\n\nThis is working for me:\n\n(\n\n~degrees = Scale.majorPentatonic.degrees;\n\nPbind(\n\n\\degree, Pseq( Pfunc({~degrees}).asCollection.flatten, inf),\n\n\\root, 0,\n\n\\dur, 0.2\n\n).play;\n\n)\n\n~degrees = Scale.minorPentatonic.degrees;\n\n~degrees = [0, 1, 2, 3];\n\nSo we’re using Pfunc to get the degrees each time instead of setting it initially, which is ‘lazy’ so we should use Plazy instead to be conceptually clearer.\n\nThen I’m not sure, but it seems like your .asCollection code turns the Pfunc into a collection containing a collection of the degrees, rather than just a collection of the degrees, so it’s like this:\n\na = [[0, 1, 2, 3]]\n\nWhich is why we would hear the whole array play back each time as it’s iterating through the top level array and always finding [0, 1, 2, 3]... So we want to .flatten a, which turns [[]] into [].\n\nI’m not entirely certain of what’s going on under the hood, but the above seems to work for me."}
+{"text": "SuperCollider forum — Order of execution\n\n...didn’t know you could do that! I’ve only ever repeated keys to A/B possibilities... could have “new Pbind” check for repeated keys and fall back to “legacy Pbind” if so..."}
+{"text": "SuperCollider forum — Tanh with steepness and range parameters\n\nThanks for the advice and my apologies for dragging the discussion.\n\nIn non-linear circuits, tanh, as well as other functions and limiters/compressors, guarantee the stability of the system. The ability to manipulate some parameters of the transfer function opens the possibility of exploring unpredicted sonic territories.\n\nThe steepness parameter is just a multiplication. In order to keep the tanh centered in the 0 you have to use all those logarithms."}
+{"text": "SuperCollider forum — Playing Ndef with a Pbind/def of a synthdef going to a effect\n\nIf I remember well, putting the slot number at 10 or 100 is a good practice because it saves some slots between your source and your effect, or between each element in the audio chain. Your source will always take the first slot, so If you entered 000, you probably killed your source, which was the first element in the chain.\n\nThe practice of numbering things 10 by 10 or 100 by 100 comes from BASIC number lines if I’m correct (keeping spaces for in-between lines of code). Kinda funny to see that it is still used for some niche cases."}
+{"text": "SuperCollider forum — Buffer UGen: no buffer data\n\nGoing on with the tangent , in our laptop orchestra here we typically load thousands of samples at the beginning of each session. The goal is to have a large sound bank readily available during live coding improvisations. For example, we have been using Dirt Samples which has 2000+ short sound files ready to go and it’s easy to add as a Quark, and players often add their custom samples too.\n\nI wrote a little class called SCLOrkSamples to manage loading and organizing all samples. It uses an IdentityDictionary and does some housekeeping following an idiosyncratic naming convention that works for us — essentially I ignore file names and use parent folder names as the base name + a number; so all files inside a folder called ‘ab’ go into the dictionary with corresponding keys ab1, ab2, ab3, ab4... etc). If I recall correctly that’s more or less how Tidal Cycles deals with sample names, from which I took inspiration.\n\nAs a convention we also always save that big IdentityDictionary (created with know: true) under the global variable ‘d’, so that during live coding we can access any sample by name with d.ab1, d.ab2 etc. Also when we share code over the network during a performance, the same code is guaranteed to work on all players’ machines.\n\nI also added a simple GUI that lets players browse the entire collection alphabetically and audition samples before using them.\n\nThe increase in the number of buffers available (from the default 1024) is done elsewhere before booting the server, so it’s not shown in that file."}
+{"text": "SuperCollider forum — FM Synthesis algorithms\n\nFM7 hasn’t been added to Supriya’s API, and it’s highly unlikely that Josehpine will add it herself. She’s been sticking to the core UGens and functionality. I don’t have the time myself to do it, either."}
+{"text": "SuperCollider forum — Search for a specific string in a file, print the index\n\nThanks for the hint! I didn’t know about the existence of this. Seems quite appropriate for what I’m doing, but I’m not sure how I would make it communicate real-time with Supercollider, maybe OSC?\n\nThe thing of having the hyphenation happen in supercollider is to having a fast lane for writing → decomposing text → recomposing rhythms. TBH I’m not sure where i’m going ahhahahah, I’m checking out PyPhen to figure out how to make them talk together"}
+{"text": "SuperCollider forum — PmonoArtic crossfade and synthDef switch\n\nHello,\n\nThank you so much for reporting this issue on Github and trying to solve it.\n\n github.com/supercollider/supercollider\n\n Pdef with fading dies on some streams that generate (internal) cleanup, e.g. PmonoArtic\n\n opened 06:25AM - 21 May 20 UTC\n\n closed 10:29AM - 13 Jun 20 UTC\n\n eleses\n\n Environment\nSuperCollider version: 3.11\nSteps to reproduce\nThis was reported on the user forum, but seemingly not here yet:\nPdef(\\one).fadeTime_(2);\nPdef(\\one, PmonoArtic(\\default, \\dur, 0.2, \\freq, Pwhite(1,8)...\n\n bug\n\nI’ve downloaded the latest build of SC with the pull request that should solve this issue, but I still have problems with a lot of FAILURE IN SERVER /n_set Node XXXX not found...\n\nUnfortunately, I don’t have the knowledge why there is still this error ?\n\nMany thanks,\n\nChristophe"}
+{"text": "SuperCollider forum — Glitch/repater synth - porting from PureData\n\nmoscardo:\n\nwhen I change the delay duration - dragging with the mouse - the sound undergoes drifts in pitch.\n\nOne thing is that the Pd patch isn’t ramping the delay time – it’s just instantaneously jumping. (delread~ can’t smooth out delay time changes because it’s a control input, not a signal input. delread4~ can.)\n\nBut MouseY has a built in lag.\n\nSo at minimum, you might try disabling the lag by setting it to 0, and see if the sound is closer to the original.\n\nhjh"}
+{"text": "SuperCollider forum — Envgen.kr(Env.adsr\n\nI found it initially confusing that Env and EnvGen were seperate classes but its made more and more sense as I’ve gotten deeper into SC. Consider that there are other uses for an Env - they can be used by Streams for example. And you might want to select between several preset envelopes in a Synth, or use an envelope in several places...\n\nMaybe some of the confusion comes from language: Envelope Generator might be taken to mean “something that generates an Envelope” rather than “something that generates a signal from an Envelope”. I think the name PlayEnv would solve this (like PlayBuf). While we’re at it PlayBus might not be a bas idea either.\n\n(amazing explanation by James here as always btw)"}
+{"text": "SuperCollider forum — Resetting start count with PulseDivider?\n\nfollowing up on this example i’m trying to dynamically reshuffle the start positions of triggers (for an envelope), which seems to cause discontinuities because of too fast retriggering. (with a linear and steady start position for the triggers there’s no problem with clicks)\n\nwould it be possible to keep envelopes intact and and still dynamically reshuffle the start positions of triggers?\n\n```supercollider\n({\n var n=8;\n\n var freq=80;\n\n var btrig=Impulse.ar(freq);\n\n var division = n;\n\n var start = TIRand.ar(0,n-1,PulseDivider.ar(btrig,n)!8); //dynamically reshuffling start position of triggers causes clicks in envelope\n\n// var start = (1..n); //linear sequence triger offset\n\n var count = Demand.ar(btrig,0, Dseries(0, 1, inf));\n\n var trig=Trig1.ar(BinaryOpUGen('==', ((count+start+1)%(division)), 0), SampleDur.ir);\n\n var init= PulseCount.ar(trig)>0;\n\n init*SinOsc.ar(0,Sweep.ar(trig,freq/n).clip(0,1)*1pi);\n\n}.plot(1))\n```"}
+{"text": "SuperCollider forum — Emacs - syntax highlighting colors\n\nI think it may be better to file bugs with the supercollider emacs repository – I believe there are still active maintainers but they might not be following the forum closely.\n\nhjh"}
+{"text": "SuperCollider forum — Proposal: Condition timeouts\n\nIannis_Zannos:\n\nBut I am unfamiliar with the test suite and it will take me time to understand...\n\nThe comments about Condition are independent of the test suite. You don’t need to worry about that.\n\nhjh"}
+{"text": "SuperCollider forum — Saving a Preset Sequence of SynthDefs\n\npolina.v:\n\nCould not open file “/archive.sctxar” for writing\n\nThat’s some kind of problem with your SC installation. It normally tries to write in your Platform.userAppSupportDir.\n\n polina.v:\n\nthis would work outside of Ndefs?\n\nNodeSnapshot works for plain SynthDefs, with some limitations that if you overwrite a SynthDef locally it might not find that out; it tries to detect such problems by hashing the arg list of SynthDef. But NodeSnapshot just gives you a structure that you can walk over and save and later restore yourself. There’s no automatic restore function that I can see. (Maybe @scztt can chime in on that, because I’m guessing he uses it to actually save and restore the tree.)"}
+{"text": "SuperCollider forum — Saving a Preset Sequence of SynthDefs\n\nscztt:\n\nDid you install NodeSnapshot via Quarks, e.g. by using Quarks.install(\"https://github.com/scztt/NodeSnapshot.quark.git\")? Do you have the IconSet quark listed in your includes (Preferences → Interpreter)?\n\n@scztt cztt -\n\nI’m still having a little trouble getting this stuff installed.\n\nRan:\n\n```supercollider\nQuarks.install(\"https://github.com/scztt/IconSet.quark\");\n\nMaterial.fetch;\n```\n\nNow getting:\n\n```supercollider\nERROR: Couldn't find icon with name 'ic_check_box' in paths: /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/android/svg/production/ic_check_box_24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/font/svg/production/ic_check_box_24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/ios/svg/production/ic_check_box_24px.svg, /Users/polvo/Library/A"}
+{"text": "/ic_check_box_24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/png/svg/production/ic_check_box_24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/src/svg/production/ic_check_box_24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/update/svg/production/ic_check_box_24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/android/svg/production/ic_check_box_26x24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/font/svg/production/ic_check_box_26x24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/ios/svg/production/ic_check_box_26x24px.svg, /Users/polvo/Library/Application Support/SuperC"}
+{"text": ".svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/png/svg/production/ic_check_box_26x24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/src/svg/production/ic_check_box_26x24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/update/svg/production/ic_check_box_26x24px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/android/svg/production/ic_check_box_48px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/font/svg/production/ic_check_box_48px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/ios/svg/production/ic_check_box_48px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/m"}
+{"text": "vo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/png/svg/production/ic_check_box_48px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/src/svg/production/ic_check_box_48px.svg, /Users/polvo/Library/Application Support/SuperCollider/downloaded-quarks/material-design-icons/update/svg/production/ic_check_box_48px.svg\n```"}
+{"text": "SuperCollider forum — Quick stereo pan question\n\nThe “sine wave” you may be hearing could be a subtle ringing in the ears, or the hum of surrounding electricity.\n\nHearing it within white noise could be an auditory illusion, while also being visually imperceptible.\n\nI recommend using a saw wave, instead of white noise."}
+{"text": "SuperCollider forum — ASIO bad times. For windows users. HELP!\n\nIn recent versions of SC, you should be able to set inDevice to the “channels in” entry and outDevice to the “channels out” entry.\n\nhttp://doc.sccode.org/Reference/AudioDeviceSelection.html#Windows\n\nhjh"}
+{"text": "SuperCollider forum — Sclang evolution, and influency of modern languages on its development\n\nA quickie about this\n\n scztt:\n\n- A type\n\n- A hidden storage array of unknown size.\n\nSo the only information we really HAVE to use for dispatch is the type.\n\nSo Lists and Arrays are not types, nor a pair of List of Something (or course), they are just slots, right?\n\nI mean: sclang has a type system and offers a lot more flexibility and capability, but it’s hidden. The emphasis here isn’t to just discern the correctness of the code.\n\n(I’m trying to avoid the idea of a mere type-checker, you got it of course)\n\nLists and Arrays out from the type system appear as a serious compromise. (You agree? )\n\nWhat if evolving the language in a way that lets us define types and those play nice with the primitive ones? Imagine this making you rethink how you see functions and their interactions. It’s not just about making things correct; it’s about opening up new ways to think and solve problems. (You already showed it’s possible)\n\nAnd for performance reasons, you can even deal with types until a certain point where they are useful in this way, and then erase them. That is, once your program starts running, all that type of info gets tossed out the window (type erasure), including “what type” of lists, arrays, etc.\n\n(It’s a pretty open question)\n\nEDIT: Also, the idea of type classes (which would mean a fancy type system), is not that mysterious, one can understand it as just functions that at compile time evaluate type info into expressions. And, stretching a little bit, if you can go type ↔"}
+{"text": " time evaluate type info into expressions. And, stretching a little bit, if you can go type ↔ expression, you have a code generation system."}
+{"text": "SuperCollider forum — Basic questions about unixCmd and runInTerminal\n\nSam_Pluta:\n\nSo, this doesn’t work for me:\n\n\"flac \".unixCmd\n\nbut this does:\n\n\"/usr/local/Cellar/flac/1.3.3/bin/flac \".unixCmd\n\nand this does:\n\n“/usr/local/Cellar/flac/1.3.3/bin/flac -d /Users/spluta/Downloads/Mahler3B.flac”.unixCmd\n\nFor me, all of these are working, even the first one."}
+{"text": "SuperCollider forum — Are variables thread safe in sclang?\n\nThe Routines in sclang are actually coroutines. This is actually made clear in some classlib comments...\n\n```supercollider\nObject {\n // coroutine support\n yield {\n _RoutineYield\n ^this.primitiveFailed\n }\n}\n```\n\n...but in less comp-sci terms in the SC help files.\n\n(Edit: actually the Routine help says, somewhat confusingly\n\nRoutines can be used to implement co-routines as found in Scheme and some other languages.\n\nBut I really don’t see how SC Routines differ from actual coroutines, so that they would have to be “used to implement” those.)\n\nSo as mentioned above the only context switches happen when you explicitly yield (and variations, yieldAndReset, alwaysYield) and when when you call next (and less often synonyms like value/run/resume directly) on a Routine. Those are pretty much the only times when switchToThread is called in the underlying C++ implementation.\n\nOf course those calls can be nested in some other function calls (e.g. embedInStream), so it’s not always obvious where that context-switching happens, but for the most part it is.\n\n(Aside: it’s basically impossible to port the classlib “as is” to a language without coroutine support. See e.g. paper on ScalaCollider .)\n\nAlso Routines/Threads have their own Environment, which is actually a little difficult to change from “the outside”, i.e. from another scland Thread. (Stack frames cannot be changed with “hack"}
+{"text": " outside”, i.e. from another scland Thread. (Stack frames cannot be changed with “hacks” from within SC lang as fas as I know; they can only be inspected by creating copies, e.g. DebugFrame created by getBackTrace.) So only the heap-stored objects are usually “at risk” of being changed from another Thread/Routine, i.e. the local Thread vars and and environment (usually) will be pointing to the same objects after a context switch, but the “contents” of these objects may have changed. But then that’s not really a different problem from when you e.g. call library function that executes on the same Thread as the caller but changes some heap-stored objects."}
+{"text": "SuperCollider forum — Speech to midi converter?\n\nI’m not very familiar with this, but extracting the top frequencies can be done without that specialized ugen, albeit it might be slower with the general purpose ones. I’ve toyed with PV_LocalMax in the past. (Sorry no time to post code right now.)"}
+{"text": "SuperCollider forum — Is there an order-preserving Environment quark?\n\nRFluff:\n\nWhat you are saying here is that SC should prefer duck typing tests to nominal typing tests.\n\nI think, in general, yes. James McCartney more than once expressed a distaste for isKindOf checks. But it’s also true that the following pattern, for too many classes, would be method clutter.\n\n```supercollider\n+ Dictionary {\n isDictionary { ^true }\n}\n\n+ Object {\n isDictionary { ^false }\n}\n```\n\nDictionary is used fairly generally and has distinct characteristics. I’m not sure now why it didn’t make the cut for this.\n\nhjh"}
+{"text": "SuperCollider forum — Ndef argument, min/max\n\njamshark70:\n\nQuarks.at(“JITLibExtensions”).localPath.openOS\n\nThat does not work for me due to the way I have quarks installed? Would there be another way?\n\nThanks"}
+{"text": "SuperCollider forum — Strategies for Makeup Gain inside of Synths (or actually: Different Ways to Scale Values)\n\nSam_Pluta:\n\nThere are many ways to skin a cat. I came up with this one this morning. Works with pwm and sine.\n\nThis is a very nice oscillator Sam! Thank you for sharing.\n\nPWM on a sine wave is awesome, and the interpolation between wave shapes is interesting. It’s very different to the filtering approach I’ve been using and it’s nice to not have to pass through a triangle."}
+{"text": "SuperCollider forum — How to set/get values when writing Classes?\n\nI’ve read the documentation (Writing Classes, Messages, etc), but couldn’t figure out what I’m actually doing.\n\nI’m trying to create a GUI Quark, and I want to use a Class to store a palette, i.e. storing information like the border size. Then I’d like other classes to fetch those values and use them when instancing Objects.\n\nSo here is the Class with the palette :\n\n```supercollider\nGM {\n classvar <>mainColor;\n\n *initClass {\n mainColor = Color(0.75, 0, 0.333);\n }\n}\n```\n\nThen a custom UserView :\n\n```supercollider\nGMUserView : UserView {\n\n classvar <>mainColor;\n\n *initClass {\n Class.initClassTree(GM);\n }\n\n init {\n mainColor = GM.mainColor;\n }\n}\n```\n\nWhen trying to access GMUserView().mainColor, it yields a “Message not understood” error, but the .mainColor still appears in the documentation Class Methods.\n\nI can see that I’m not fully understanding setters/getters, because I also had a problem with <>variable which was solved by declaring the message (string { ^myString }).\n\nIf anyone knows what documentation I lack, it would be helpful to me to read it,\n\nMany thanks,\n\nSimon"}
+{"text": "SuperCollider forum — Custom Class as a key in an identity dictionary isn't working?\n\nThis works, but seems dumb...\n\n```supercollider\nKeyTest {\n classvar keyTestIdentityStore;\n var symbol;\n *initClass { keyTestIdentityStore = () }\n *new {|sym|\n if(keyTestIdentityStore.includesKey(sym).not, {\n keyTestIdentityStore[sym] = super.newCopyArgs(sym);\n keyTestIdentityStore[sym].freeze;\n });\n\n ^keyTestIdentityStore[sym]\n }\n asSymbol { ^symbol }\n\n prBinaryOpOnSymbol {|other, opsym|\n ^this.asSymbol.perform(opsym, other.asSymbol)\n }\n == {|other| ^this.prBinaryOpOnSymbol(other, '==')}\n != {|other| ^this.prBinaryOpOnSymbol(other, '!=')}\n ==={|other| ^this.prBinaryOpOnSymbol(other, '===')}\n !=={|other| ^this.prBinaryOpOnSymbol(other, '!==')}\n < {|other| ^this.prBinaryOpOnSymbol(other, '<')}\n > {|other| ^this.prBinaryOpOnSymbol(other, '>')}\n <= {|other| ^this.prBinaryOpOnSymbol(other, '<=')}\n >= {|other| ^"}
+{"text": "this.prBinaryOpOnSymbol(other, '<=')}\n >= {|other| ^this.prBinaryOpOnSymbol(other, '>=')}\n\n hash{ ^symbol.hash }\n basicHash{ ^symbol.basicHash }\n identityHash{ ^symbol.identityHash }\n}\n```\n\nEdit: made the cached keys frozen"}
+{"text": "SuperCollider forum — Custom Class as a key in an identity dictionary isn't working?\n\nGenerally, IdentityDictionary and Events should be viewed as a (faster) specialization of Dictionary and they are primarily designed to be used with Symbol keys.\n\nPersonally I would only use IdentityDictionary if\n\na) my keys are only symbols and numbers or\n\nb) my objects may have a custom equality operator and I really want object identity."}
+{"text": "SuperCollider forum — MIDIFunc.noteOn, while SynthDef is playing on its own\n\nThanks for the linlin tip, and sorry to be that newb. I managed to make everything work, that’s great. The idea was to add some notes layout to the current value (middle C in your example). It works. My only problem is when I use the classic\n\n(\n\nMIDIFunc.noteOn({ |veloc, num, chan, src| Array.newClear(128)[num] = Synth.new(\\latex, [\\freq, num.midicps,\\dur1, 0.1 ]);\n\n});\n\n)\n\nThat creates a new synth for every note played is to be able to set the SynthDef params while playing and without adding a new layout of synth. If i do:\n\n(\n\nMIDIFunc.noteOn({ |veloc, num, chan, src| Array.newClear(128)[num] = Synth.new(\\latex, [\\freq, num.midicps,\\dur1, 0.1 etc... ]);\n\n});\n\nIt launch a new synth abose the one that’s playing.\n\nAnd if I do:\n\n(\n\nMIDIFunc.noteOn({ |veloc, num, chan, src| Array.newClear(128)[num] = Synth.new(\\saw, [\\freq, num.midicps]);\n\n});\n\nx=Synth(\\saw);\n\nx.set(\\dur1, 0.5);\n\nIt doesn’t update the SynthDef value of the ones created by the MIDIFunc\n\nHow can I do?\n\nThanks"}
+{"text": "SuperCollider forum — MIDIFunc.noteOn, while SynthDef is playing on its own\n\nraphael:\n\nI didn’t find any example of that online.\n\nAgain, I’d highly recommend stepping back a bit and going carefully through the tutorial series. Maybe “tutorials are boring” but in the tutorials, many of these questions are answered.\n\nhttp://doc.sccode.org/Tutorials/Getting-Started/10-SynthDefs-and-Synths.html#Creating%20Variety%20with%20SynthDefs\n\nThe most common way of creating varia[tion] is through putting arguments into the UGen Graph Function. This allows you to set different values when the synth is created.\n\nSo that section illustrates SynthDef arguments. Then, the next section demonstrates .set.\n\nhjh"}
+{"text": "SuperCollider forum — Other than Pseq(Array.rand(), inf) [MIDIOut]\n\nThank you for your reply! Regarding Pbindef, would this replace Pbind? Or would it replace Pdefn? Here’s an example of how I’ve been writing it thus far:\n\nPdefn(\\legato, Pseq(Array.rand(1, 0.1, 1), inf)); Pdefn(\\notes, Pn(Plazy({Pseq((55..66).rand, 11.rand)}, 1))); Pdefn(\\tempo, 9); Pdefn(\\amp, Pseq(Array.rand(1, 0.5, 1), inf)); a.stop; a = Pbind(\\type, \\midi, \\chan, 1, \\midicmd, \\noteOn, \\midiout, m, \\tempo, Pdefn(\\tempo), \\midinote, Pdefn(\\notes), \\amp, Pdefn(\\amp), \\legato, Pdefn(\\legato)).trace.play;\n\nRegarding Pn + Plazy: as you can see I’ve only been able to figure out how to yield a random pattern of fixed length—seemingly determined by the specified note range?—that repeats anywhere between 0 and 11 times before changing the note order of the previous pattern. I’m seeking to not only randomize the amount of pattern repetitions, but also its size. For example, the pattern size could be 7 notes and repeat 4 times, the next evaluation would yield a 2 note pattern that repeats 9 times, and so on."}
+{"text": "SuperCollider forum — Arbitrarily high-order IIR filters\n\nWell, so let’s read an actual book. In theory, those words are not the same.\n\nHowever, if you see the code, you can do similar things with them (it seems that is the case).\n\nHowever, the implementation is not quite the same regarding real-time safety, seamless coefficients without interrupting the audio stream, and TDF-II, which reduces memory usage and improves numerical stability. One implementation is more optimized for real-time audio processing.\n\nWhere is that SC community always at the edge? No more?"}
+{"text": "SuperCollider forum — Subdivide phase by Demand sequence and add swing\n\nhey,\n\nits unfortunately not solving anything related to this thread. The solution i have suggested there is still the best i could come up with. But im currently working on a pulsar / grain Ugen in gen which has no problems with multichannel expansion (asynchronous overlapping grains or sequencing of events at audio rate) and is capable of heavy modulation per grain (cross feedback FM) and anti-aliased which i will export to SC.\n\nIm currently just trying to get more possibilites out of audio rate sequencing and figuring out some interesting design decisions for sequencing granular events. It turns out that SC is really nice for prototyping using some plots.\n\nIm currently working on an audio rate sequencing suite in gen which will be exported as Ugens to SC with some of my approaches\n\nreally cool to see you @mousaique @QQQQ participating. It currently seems to be a rather unpopular topic in SC. But i just keep posting my stuff Probably better to start a blog."}
+{"text": "SuperCollider forum — Subdivide phase by Demand sequence and add swing\n\n@mousaique @QQQQ would you be more interested in buffered waveforms + buffered grain envelopes / windows or stateless modulatable window functions + sinusoidal carrier waveforms? Could you tell me about your specific use cases ? With my experiments I found out that the higher the trigger rate, the more the window shape contributes to the overall sound and the carrier waveform itself isn’t that important. So my idea is to have cross feedback fm with sinusoids and additional onepole filters in the feedback path to shape the modulation and an additional modulatable function for the frequency trajectory per grain and a modulatable tilted tukey window for the grain window (that’s already working, currently just trying to figure out the anti-Aliasing and make some design decisions) But everything else is also possible.\n\nI also found out that its desirable to have modulatable shapes on a micro scale per grain and additional modulation on a macro scale of the same params. These additional modulations would be no problem to implement directly in SC then with subdividing a phase for different modulation rates.\n\nBut thats where some of my sequencing ideas could come into play. Still working on a universal shift register with a self modulating feedback path for chaotic behaviour for modulation."}
+{"text": "SuperCollider forum — Splitting very large arrays\n\nThanks for that, Sam.\n\nThe thing is that, while your example works perfectly, SC crashes when it tries to do it with a much larger array, with millions of items.\n\nMaybe there’s a good way to turn that sound file storing all the data into text outside of SC? Any ideas?\n\nThanks!!"}
+{"text": "SuperCollider forum — Different RandSeed for the same SynthDef\n\njulian:\n\n```supercollider\n(\n{\n var a, b;\n RandID.ir(0);\n RandSeed.ir(0,1789);\n a = LFNoise1.ar(2000);\n RandID.ir(1);\n RandSeed.ir(0,1789);\n b = LFNoise1.ar(2000);\n [a, b]\n}.plot\n)\n```\n\nI’ve checked the sources, and in principle, it would work if we call the RandID for every block:\n\n```supercollider\n(\n{\n var a, b;\n RandID.kr(0);\n RandSeed.ir(0,1789);\n a = LFNoise1.kr(200);\n RandID.kr(1);\n RandSeed.ir(0,1789);\n b = LFNoise1.kr(200);\n [a, b] // should be the same\n}.plot(0.5)\n)\n```\n\nThe problem seems to be in the setting of the RandID:\n\n github.com\n\n supercollider/supercollider/blob/2db872ad2a42ff85726566149855ecdb60d65b77/server/plugins/NoiseUGens.cpp#L798\n\n```supercollider\n\n RandID_next(unit, 1);\n }\n\n void RandID_next(RandID* unit, int inNumSamples) {\n float id = ZIN0(0);\n\n if (id != unit->m_id) {\n unit->m_id = id;\n uint"}
+{"text": "!= unit->m_id) {\n unit->m_id = id;\n uint32 iid = (uint32)id;\n if (iid < unit->mWorld->mNumRGens) {\n unit->mParent->mRGen = unit->mWorld->mRGen + iid;\n }\n }\n ZOUT0(0) = 0.f;\n }\n\n ////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n void LinRand_Ctor(LinRand* unit) {\n float lo = ZIN0(0);\n float hi = ZIN0(1);\n\n```\n\nBut this would have to be checked. I can’t do this myself at the moment."}
+{"text": "SuperCollider forum — Implementing \"All pass reverberator\" by M.R. Schroeder\n\nAs an aside, allpass filters of various kinds and orders can be used to build other filters, e.g., lowpass / highpass, shelving, peaking, notching, combing.\n\nThe classic paper on the topic is:\n\nP. A. Regalia, S. K. Mitra and P. P. Vaidyanathan, “The digital all-pass filter: a versatile signal processing building block,” in Proceedings of the IEEE, vol. 76, no. 1, pp. 19-37, Jan. 1988, doi: 10.1109/5.3286."}
+{"text": "SuperCollider forum — Error selecting program in block\n\nmorgon:\n\nIs ~fx still useful in the error handling branch (maybe to get more details on the error condition)\n\nYou wouldn’t get any details, no. The reason for the failure is posted to the console though.\n\nand ~fx can no longer be used?\n\nYou can try another plugin\n\nI have to admit that I personally don’t really do any error handling when opening plugins. It’s not like plugins will just refuse to open randomly. Once the plugin has been probed successfully, I can just assume it will always work. If something goes wrong for some unexpected reason, the console will tell me anyway."}
+{"text": "SuperCollider forum — Should SuperCollider Show Full Floating-Point Precision? Time for a Change?\n\nsmoge:\n\nRyū float-to-string conversion\n\nFor reference, I mentioned this one in the other post: GitHub - ulfjack/ryu: Converts floating point numbers to decimal strings · GitHub"}
+{"text": "SuperCollider forum — IDE throwing \"prSetEdited\" errors\n\nHi,\n\nI got regularly my IDE throwing “prSetEdited” errors.\n\nUsually when starting the IDE.\n\n```supercollider\nWARNING: Attempted to modify missing Text Mirror for Document {caf6d83d-8600-42a0-b0c3-49b8c508b15b}\nERROR: Message 'prSetEdited' not understood.\nRECEIVER:\n nil\nARGS:\n Integer 1\nCALL STACK:\n DoesNotUnderstandError:reportError\n arg this = \n Nil:handleError\n arg this = nil\n arg error = \n Thread:handleError\n arg this = \n arg error = \n Object:throw\n arg this = \n Object:doesNotUnderstand\n arg this = nil\n arg selector = 'prSetEdited'\n arg args = [*1]\n Process:interpretCmdLine\n arg this = \n^^ The preceding error dump is for ERROR: Message 'prSetEdited' not understood.\nRECEIVER: nil\n```\n\nToday I got another similar one when closing a file:\n\n```supercollider\nWARNING: Attempted to modify missing Text Mirror for Doc"}
+{"text": "supercollider\nWARNING: Attempted to modify missing Text Mirror for Document {caf6d83d-8600-42a0-b0c3-49b8c508b15b}\nWARNING: Attempted to modify missing Text Mirror for Document {caf6d83d-8600-42a0-b0c3-49b8c508b15b}\nWARNING: Attempted to modify missing Text Mirror for Document {caf6d83d-8600-42a0-b0c3-49b8c508b15b}\nWARNING: Attempted to modify missing Text Mirror for Document {caf6d83d-8600-42a0-b0c3-49b8c508b15b}\nWARNING: Attempted to modify missing Text Mirror for Document {caf6d83d-8600-42a0-b0c3-49b8c508b15b}\nERROR: Message 'closed' not understood.\nRECEIVER:\n nil\nARGS:\nCALL STACK:\n DoesNotUnderstandError:reportError\n arg this = \n Nil:handleError\n arg this = nil\n arg error = \n Thread:handleError\n arg this = \n arg error = \n Object:throw\n arg this = \n Object:d"}
+{"text": "bject:throw\n arg this = \n Object:doesNotUnderstand\n arg this = nil\n arg selector = 'closed'\n arg args = [*0]\n Process:interpretCmdLine\n arg this = \n^^ The preceding error dump is for ERROR: Message 'closed' not understood.\nRECEIVER: nil\n```\n\nAny idea what could cause that ?\n\nI don’t observe any wrong behaviour after those errors. But I just wonder if I’m the only one facing this.\n\nI’m using 3.11.2 on Windows10. And it’s a fresh installation. No extensions, no quarks, ...\n\nPS: For the error on close I got today, I had my keyboard shortcuts and some of my class files copied to this new installation, in the meantime."}
+{"text": "SuperCollider forum — Mixing kontrol rate and audio rate in a same UGen\n\nrdd:\n\nThe graph file format has a slot for the calculation rate of each output of each Ugen, as well as a slot for the calculation rate of the Ugen itself, suggesting you can have control-rate outputs at an audio-rate Ugen?\n\nThis is very interesting, I was not aware of this! Thanks a lot for bringing this up!\n\nThe Class Library doesn’t currently support this, at least not directly, because MultiOutUGen.initOutputs uses a single rate argument for all outputs. You could, however, write your own initOutputs method that supports different rates for the individual outputs.\n\nBut here’s the big catch: scsynth and supernova do not actually support different output rates! They do store the actual rates in the Unit output specs, but when they instantiate a Synth, the calc rate of each output wire gets bashed to the Unit calc rate:\n\n github.com\n\n supercollider/supercollider/blob/db7eed2a17c361503dbc7f70a557874b6001e3cd/server/scsynth/SC_Graph.cpp#L425-L445\n\n```supercollider\n\n if (unitCalcRate == calc_FullRate) {\n OutputSpec* outputSpec = unitSpec->mOutputSpec;\n for (uint32 j = 0; j < numOutputs; ++j, ++wire, ++outputSpec) {\n wire->mFromUnit = unit;\n wire->mCalcRate = calc_FullRate;\n "}
+{"text": "FromUnit = unit;\n wire->mCalcRate = calc_FullRate;\n wire->mBuffer = bufspace + outputSpec->mBufferIndex;\n unitOutput[j] = wire;\n unitOutBuf[j] = wire->mBuffer;\n }\n calcUnits[calcCtr++] = unit;\n } else {\n for (uint32 j = 0; j < numOutputs; ++j, ++wire) {\n wire->mFromUnit = unit;\n wire->mCalcRate = unitCalcRate;\n wire->mBuffer = &wire->mScalarValue;\n unitOutput[j] = wire;\n unitOutBuf[j] = wire->mBuffer;\n }\n if (unitCalcRate == calc_BufRate) {\n calcUnits[calcCtr++] = unit;\n }\n\n```\n\nNote L.429 and L.438!\n\n github.com\n\n supercollider/supercollider/blob/db7eed2a17c361503dbc7f70a557874b6001e3cd/server/supernova/sc/sc_ugen_factory.cpp#L81-L100\n\n```supercollider\n\n for (size_t i = 0; i != output_count; ++i) {\n Wire* w = allocator.alloc();\n\n w->mFromUn"}
+{"text": " Wire* w = allocator.alloc();\n\n w->mFromUnit = unit;\n w->mCalcRate = unit->mCalcRate;\n\n w->mBuffer = nullptr;\n w->mScalarValue = 0;\n\n if (unit->mCalcRate == 2) {\n /* allocate a new buffer */\n assert(unit_spec.buffer_mapping[i] >= 0);\n std::size_t buffer_id = unit_spec.buffer_mapping[i];\n unit->mOutBuf[i] = buffer_base + buffer_length * buffer_id;\n w->mBuffer = unit->mOutBuf[i];\n } else\n unit->mOutBuf[i] = &w->mScalarValue;\n\n unit->mOutput[i] = w;\n }\n\n```\n\nNote L.85!\n\nAs a consequence, the UGen would crash if the Unit calc rate was calc_FullRate, but one or more outputs are specified as calc_BufRate or calc_ScalarRate. This is because in the UGen spec the buffer index is set to -1 for non-audio wires, so Unit_new would assign bogus audio buffers! (Supernova would at least abort in debug mode with the failed assertion in L.92.)\n\nI guess the behavior of Scsynth and Supernova could be changed, we’d just need"}
+{"text": ")\n\nI guess the behavior of Scsynth and Supernova could be changed, we’d just need to be careful about backwards compatibility. In particular, in the Client implementation you would only be able to mix different output rates in recent enough SC versions. This can be done with a simple runtime version check. You just have to make sure that you don’t accidentally use a newer SynthDef in an older SC version.\n\nI’ll open a ticket on GitHub and – if I have time – also a PR.\n\n@Stephane_Letz For you this would mean that you could use regular (audio-rate) Ugen outputs, hoping that you would be able to use proper control outputs in the future. For users it shouldn’t make a difference, they should just assume that the outputs are control-rate."}
+{"text": "SuperCollider forum — Server ready but not running\n\nOkay, are you compiling from source? If so it might be that the plugins need recompiling too. If not, you could try removing all of them (temporarily) and see what happens."}
+{"text": "SuperCollider forum — Server ready but not running\n\ntry temporarily moving everything out of /usr/local/share/SuperCollider/Extensions and ./local/share/SuperCollider/Extensions. I think whats happening is its stuck loading a library that is incompatible."}
+{"text": "SuperCollider forum — Map value range of midi control bus\n\njordan:\n\nIn the context of this thread, thinking it terms of NamedControls makes programatically adding new controls based off of symbols a very simple issue,\n\nYes exactly, in the context of this thread - Named Control works well.\n\nJust like the how the context of working on well defined problems, with clear objectives as a member of a team is very different to the context of doing fast, messy, exploratory creative work on your own.\n\nI’m not a teacher, so I can only comment anecdotally. But it seems to me that something else that makes learning easier is low friction. And ‘best practices’ can counter intuitively, add friction and make something more intimidating than it needs to be. People get worried if they are doing something the ‘right way’ instead of just focusing on solving the problem.\n\nAs we gain confidence we can decide for ourselves if the cost of a best practice is going to be worth the gains in out unique context.\n\nAnd sure there are times when a fundamental misunderstanding is hampering someones ability to solve a problem. But it’s totally possible to provide insight into a fundamental mechanism/conceptual idea without the blanket statements that always, inevitably come with caveats."}
+{"text": "SuperCollider forum — Recording Patterns to a MIDI file\n\nOne question about the code above with 3 Pdefs to play midi and synth with one pattern driving both.\n\nThis all works, especially with the SynthDef example.\n\nHowever, when instead try and do the same with a NodeProxy, using NodeProxy Roles, The MIDI is not being triggered:\n\n```supercollider\nm = MIDIOut(0, MIDIClient.destinations[0].uid); \\\\ this is actually in my linux startup.scd\n(\nNdef(\\a1, { | out, freq |\n var env = EnvGen.kr(Env.perc(0.01, releaseTime: Rand(0.0, 2.0), doneAction: 2));\n // freq = freq.midicps;\n Out.ar(out, LFSaw.ar(freq!2, 0, SinOsc.kr(LFPulse.kr(550, 0.5, 1)), 0, 0.3)) * env }\n);\n);\n\n(\nPdef(\\a1midi, Pbind(\\type, \\midi, \\midiout, m, \\midicmd, \\noteOn, \\chan, 0,));\nPdef(\\a1synth, Pbind(\\out, Pfunc(Ndef(\\a1).bus.index), \\group, Pfunc(Ndef(\\a1).group)));\nPdef(\\a1src,\n Pbind(\n \\degree, Pseq([1,4,5,7], inf),\n \\octave, Pshuf([2,3,4],inf),\n \\dur, Pseq([Pbjorklund2(2, 5, 3), Rest(2)],"}
+{"text": "f),\n \\dur, Pseq([Pbjorklund2(2, 5, 3), Rest(2)], inf),\n \\amp, 0.3\n));\n);\n\n(\nPdef(\\a1, Ppar([\n Pdef(\\a1midi),\n Pdef(\\a1synth),\n ])\n <> PtimeClutch(Pdef(\\a1src))\n);\n);\n\nNdef(\\a1)[1] = \\xset -> Pdef(\\a1);\n```\n\nSo, when I do that \\xset on slot 1 of the Ndef it does play as expected, but no MIDI events are being triggered.\n\nIf I exec, Pdef(\\a1).play it does what it should but doesn’t obviously use the Ndef for the synth - and of course running them both is nowhere near in sync or the same."}
+{"text": "SuperCollider forum — How to perform a FFT on a full sound file?\n\nDindoleon:\n\nUnfortunately, the .read method doesn’t seem to exist inside the Signal class ? I can find a .readNew method (source), but it lacks documentation, and neither the path of the file as a String, as a PathName or, obviously, as a SoundFile worked as an argument.\n\nAs @Sam_Pluta has mentioned, Signal.read can be found in SignalBox. Lots of fun stuff here!"}
+{"text": "SuperCollider forum — How to perform a FFT on a full sound file?\n\nThank you all for the detailed answers and all the different ways to manipulate FFT !\n\nI managed to build my own spectrogram, plotting an FFT Buffer content (so for now, just beginning to understand the basic FFT implementation), and I am really excited about all the possibilities I can see emerging from this practice.\n\nI also got the motivation to go deeper into SC’s underlying concept, and took the time to read the class files, i.e. .sc files, that I was a bit afraid to look at at first.\n\nOff topic, one remark, without any offense intended : Quarks names and contents are difficult to interpret. Without josh explicitly mentioning that there are some FFT tools inside the ‘JoshMisc’ quark, I think I would never had it installed. Same with SignalBox. The only interface I use to discover Quarks is the built-in IDE interface, which only provides names, which in turn are not always directly related to the Quarks content.\n\nBut I understand how little time we have to fully document everything, or structure them so that they fit only a particular need. I think the best way to discover Quarks is to go on Github and to begin reading the code, but it might difficult for newcomers or beginners, especially because the class syntax is not the same as the sclang topside syntax. At least it was how I felt about those, only daring using them after about 4 years of sclang usage.\n\nThat’s my way of saying that human interaction is the best knowledge transmission vector and that I’m grateful you took time to link"}
+{"text": " saying that human interaction is the best knowledge transmission vector and that I’m grateful you took time to link the tools you develop and use .\n\nRegards,\n\nSimon"}
+{"text": "SuperCollider forum — L-System Dictionary Sublist Help\n\nelgiano:\n\n\\A → [ [ 1,2,3 ], [ 4,5,6 ] ]\n\nthis multidimensional Array gives me chords\n\nand ufortunately i found another mistake.\n\nwith:\n\nProductionrules \\A → “AB” and \\B → “A”, Axiom: A\n\nand Pitch Mapping like this:\n\n\\A → [1,2,3],\n\n\\B → [4,5,6],\n\nyou always get the same order:\n\n[ 1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 1, 2, 3, 4, 5, 6 ...etc...]\n\ni would like to have the following:\n\nwhen A is called its picking the first item in the Array not always sequencing the entire Array before moving on to B.\n\nso when A is called it should pick the first item, when B is then called it should pick its first item, when now A is called again it should pick the second item ...etc... otherwise you always get the same sequences in different chains but not a mutated sequence.\n\ndo you have a solution for this?"}
+{"text": "SuperCollider forum — L-System Dictionary Sublist Help\n\nelgiano:\n\nit’s not possible to call collect on Strings if you don’t return only single characters.\n\nYou can use collectAs to use one type of collection as the source, and return a different type: string.collectAs({ ... might return anything, not only characters... }, Array).\n\nhjh"}
+{"text": "SuperCollider forum — Restart Envelopes without creating new SynthDef instance\n\nThat’s very cool!\n\nI don’t think I need to get quite so fancy, for this particular project, but good to know what’s possible."}
+{"text": "SuperCollider forum — Sorting an array containing duplicate elements by the inverse number of element occurrences\n\nThanks for your suggestion. asEvent is very good because it reduces unnecessary information in the post window.\n\n```supercollider\n(\n~occurrences = { |array|\n array.asSet.asArray\n .collect { |uniqueItem, uniqueIndex|\n Dictionary[\\uniqueItem->uniqueItem, \\occurrence->array.occurrencesOf(uniqueItem)]\n }.sortBy(\\occurrence)\n .reverse.collect { |item| item.atAll([\\uniqueItem, \\occurrence]).asEvent }\n .do {|item| item.postcs }\n}\n);\n\n~occurrences.([3, 2, [2], 2, [2], 1, 1, 1])\n```"}
+{"text": "SuperCollider forum — Building a Racket client for Scsynth\n\nI finally found the language of my dreams in Racket, but I was disappointed to learn there wasn’t any fully working SC client, so I’m trying to make one myself starting from the OSC messaging level, but I’m having some trouble finding resources on that level. Basically, all I could find contains more or less the same info you can find here:\n\nhttps://doc.sccode.org/Reference/Server-Command-Reference.html\n\nThis leaves me with some questions:\n\n- how do I call a single UGen with an OSC message? I only see message /s_new for instantiating a new synth.\n\n- how do I build a SynthDef from the Racket client? I’ve read some comments saying it’s particularly difficult, many clients keep doing it from Sclang. Would it be easier perhaps to write a Racket macro that generates the Sclang code and sends it to the server as a string?\n\nAnother possibilty is porting Rohan Drape’s R6 Scheme client, if he’d be okay with that, though I don’t know if he visits this forum."}
+{"text": "SuperCollider forum — How to use multiple Psegs for one parameter?\n\nI’d use a structure like this:\n\n```supercollider\nPchain(\n Pbind( /* other unrelated parameters */ ),\n Pseq([\n Pfindur(20, Pbind( /* one Pwhite pair */ )),\n Pfindur(20, Pbind( /* second pair */ )\n ], inf)\n)\n```\n\nThat is, the 2 Pwhite sequences will need to be bound together and terminated by Pfindur – but this should be isolated from other parameters that aren’t following a timed flow of control.\n\nAlso, that structure assumes that \\dur will be one of the pairs under Pfindur. If it’s one of the “other parameters,” then the two arguments to Pchain should be swapped.\n\nhjh"}
+{"text": "SuperCollider forum — List of exit codes?\n\n7068696c:\n\nThis works on scsynth, but when I evaluate Server.supernova and try to boot the server with Ctrl+b, then I get the aforementioned exotic exit code.\n\nWhen you boot scsynth, does it end up using \"ASIO : ASIO4ALL\" as the input device as well? How many inputs do you end up having? (The chosen device will be indicated in the post window)"}
+{"text": "SuperCollider forum — Watch the state of a Routine from outside\n\nIn my case there still exist the problem, that next routines start playing although the last ones are not completely quit yet. I think it is better that I share my whole code, so you can test it yourself and hear the result. The result I want is in the last routine, to hear the next section as soon as the previous one has completely stopped sounding. Here is my repository:\n\n GitHub\n\nGitHub - teymuri/muenchen\n\n Contribute to teymuri/muenchen development by creating an account on GitHub.\n\nYou can evaluate the blocks top to bottom."}
+{"text": "SuperCollider forum — Ever incrementing time loop\n\nSo you should definitely have a go at using Task for this as it will give you lots of flexibility... but you can just do the whole thing on the server... I’ve assumed you are splitting into equal slices, which isn’t the most musical idea, but it does work quite well. This could also be improved by adding some overlap.\n\nMove mouse from left to right slowly, if you jump to the end, it sort of takes of moment to sort itself out.\n\n```supercollider\ns.options.memSize = 8192 * 32; // if you have a lot of slices, this might need to be increased\ns.boot;\n~b = Buffer.read(s, Platform.resourceDir +/+ \"sounds/a11wlk01.wav\");\n\nSynthDef('drift', {\n var numSlices = 8;\n var positionsInBuf = numSlices.collect{ |n| n / numSlices };\n var timeOfEachSlice = BufDur.kr(~b) * numSlices.reciprocal;\n var lerpFactor = MouseX.kr();\n var lerp = 0.blend(positionsInBuf, lerpFactor);\n var triggerPerLoop = Impulse.kr( max(lerp.last * BufDur.kr(~b), timeOfEachSlice).reciprocal );\n var delayTime = lerp * BufDur.kr(~b) ;\n var triggerForSlice = DelayN.kr(triggerPerLoop, BufDur.kr(~b), delayTime.poll);\n var"}
+{"text": "riggerPerLoop, BufDur.kr(~b), delayTime.poll);\n var snd = GrainBuf.ar(\n 1,\n trigger: triggerForSlice,\n dur: timeOfEachSlice,\n sndbuf: ~b,\n pos: positionsInBuf,\n );\n Out.ar(0, (Mix.ar(snd).tanh)!2) // watch ears when lerpFactor == 0\n}).add;\n\nt = Synth('drift')\n```"}
+{"text": "SuperCollider forum — Ever incrementing time loop\n\nRainer:\n\nCould you perhaps write a very quick function that would help?\n\nI have to admit here that I have no idea how a function would help, because the usage is already just about as convenient as it could possibly be: set tempo (once) in the preparatory block of code, and after that, rhythmic values orient around a scale in which 1.0 represents one beat.\n\nThere’s an example like this in the tutorial series – last example in this page: 16. Sequencing with Patterns | SuperCollider 3.12.2 Help (actually it’s my example ). I’ll admit that it doesn’t directly explain the rhythmic values, but it does include a cheeky pedagogical question:\n\n```supercollider\n// before you play:\n// what do you anticipate '\\delta, 1' will do?\nk = Pbind(\\instrument, \\kik, \\delta, 1, \\preamp, 4.5, \\amp, 0.32).play(quant: 1);\n```\n\n... which would lead to the inference that 1 is being defined in this example as a rhythmic value which westerners would commonly call a quarter note.\n\nhjh"}
+{"text": "SuperCollider forum — X&Y values in Document\n\nHere’s something I recently discovered,\n\n***\n\n```supercollider\n((\n Document.current.mouseDownAction_\n\n (\n Document.current.mouseUpAction_\n\n {\n |doc x y modifiers buttonNumber clickCount|\n\n [\n \\doc -> doc // document instance\n ,\n \\x -> x\n ,\n \\y -> y\n ,\n \\mods -> modifiers // holding down ctrl etc....\n ,\n 'button#' -> buttonNumber // zero for left click\n ,\n 'click#' -> clickCount\n ,\n $\\n\n ]\n\n .\n\n printAll\n }\n\n .\n\n mouseUpAction\n )\n))\n```"}
+{"text": "SuperCollider forum — Evaluate & copy\n\nThis can be done in NeoVim using SCNvim.luaEval method\n\nhere’s a method for example which puts an object as String in register d for pasting\n\n```supercollider\n+Object {\n registerD {\n SCNvim.luaeval(\n \"vim.fn.setreg('d',{\\\"%\\\"})\".format(this.asString) // register 'd' for Durs\n );\n \"% yanked to register d\".format(this.asString).postln\n }\n}\n```\n\nIts straighforward to insert into document also"}
+{"text": "SuperCollider forum — Flucoma how to save and load fitted kdtree?\n\nI’m running through the plotter-5-complete.scd. I did search through the flucoma discourse site, but it didn’t yield much. What I want to do is to do a join on the ~indices, which have the sample time of when the algorithm detected a hit, and the fitted kdtree ~tree, which has a 2-tuple of the features, on the index number “1”,“28”, etc. Also I want to query the ~tree dataset where I can say give me points “12” to “45”. Because the kdtree structure has a strange tree structure in the json dump, which i assume is how it is represented in the fluiddataset for a kdtree ( ~tree.print doesn’t work ), the datasetquery methods don’t seems to be able to handle something of that type."}
+{"text": "SuperCollider forum — Dispatched if\n\nI wonder, shouldn’t compileIfMsg check that the first argument is, in fact, a Boolean, and only optimize in that case? (I.e. only Boolean>>if is special cased?)\n\nAnd also, shouldn’t UGen>>if send value to each of its operands? I.e.\n\n```supercollider\n+UGen {\n if { |trueBlock falseBlock|\n var trueUgen = trueBlock.value;\n var falseUgen = falseBlock.value;\n ^(this * (trueUgen - falseUgen)) + falseUgen;\n }\n}\n```\n\nI think then this would work as expected?\n\nI’ve not edited compileIfMsg but with above if definition the below selects appropriately? (The var x; is enough to prevent inlining...)\n\n```supercollider\n(LFNoise1.kr(1) > 0).if {\n var x; SinOsc.ar(440, 0)\n} {\n Saw.ar(440)\n} * 0.1\n```\n\nBest,\n\nR"}
+{"text": "SuperCollider forum — Index Modulation in FM-Synthesis\n\nYou are right - I’ve been out of dsp for too long. My statement for sure didn’t do anything to clear up the situation\n\nI wanted to add some calculations, but I’d better wait until I’m more awake to double check it makes sense..."}
+{"text": "SuperCollider forum — Ramp and stay at highest value\n\nthis is doing the glissando effect i was searching for. But im not sure what to put in the SynthDef instead of MouseX and in the MidiDef to Control the smooth addition of harmonics via MIDI CC.\n\nI was trying this and also looking at Lag and VarLag (not sure if these are right for this instance):\n\n```supercollider\nsig = LPF.ar(sig, Line.kr(freq, freq * numHarm));\n```\n\n```supercollider\nMIDIdef.cc(\\numHarm, {\n | val, num, chan, src |\n var numHarm;\n numHarm = val.linlin(0, 127, 1.0, 30.0);\n ~drone.set(\\numHarm, numHarm);\n}, 18);\n```\n\nThis is not working.\n\nI Think Im generally stuck with combining LFOs, Ramps etc. for modulation, additional harmonics, triggerRate, freq etc. in the SynthDef with Patterns or Routines and Midi CC at the same time. thanks alot for your help"}
+{"text": "SuperCollider forum — How to sync between clock and running synth\n\nWe commonly assume that the soundcard’s sample clock is accurate.\n\nIt isn’t.\n\nSeeing that much drift after 80 seconds is extremely unusual though. I typically see 2-5 samples/second difference. I’m estimating up to 20 samples/second difference for you.\n\nCould you take a running average of s.actualSampleRate?\n\nhjh"}
+{"text": "SuperCollider forum — Cut groups with patterns\n\nIf you have synths that require a gate then I would probably use a mixer:\n\n```supercollider\n(\nt = TempoClock.default;\nt.tempo = 30/60;\ns.waitForBoot{\n var mixer;\n var bus1 = Bus.audio(s);\n var bus2 = Bus.audio(s);\n\n SynthDef(\\testPM, {|freq, amp, bus, gate = 1|\n var env, sig;\n env = EnvGen.kr(Env.asr(), gate, doneAction: 2);\n sig = SinOsc.ar(freq, SinOsc.ar(freq*2, 0, 2pi*env)) * amp * env;\n Out.ar(bus, sig);\n }).add;\n\n SynthDef(\\mix, {|bus|\n Out.ar(0, In.ar(bus)!2);\n }).add;\n\n mixer = Synth(\\mix, [bus: bus1]);\n\n Pbind(\n \\cut, Pfunc({mixer.set(\\bus, bus1)}),\n \\instrument, \\testPM,\n \\bus, bus1,\n \\note, -24,\n \\amp, 0.1,\n \\dur, Prand([Rest(0.25), 0.25, 0.25, 0.75, 0.125, 0.25], inf)\n ).play(quant: 1);\n\n Pbind(\n \\cut, Pfunc({mixer.set(\\bus, bus2)}),\n \\instrument, \\testPM,\n \\bus, bus2,\n \\note, 24,\n \\amp, 0.05,\n \\dur, Prand(["}
+{"text": " \\bus, bus2,\n \\note, 24,\n \\amp, 0.05,\n \\dur, Prand([0.5, 0.5, 0.75, 0.25, 0.125], inf)\n ).play(quant: 1);\n};\n)\n```"}
+{"text": "SuperCollider forum — Sample player?\n\nI don’t know of any quarks doing all you are asking but it’s easy to build a synthdef doing that - especially if you are talking about ‘normal’ sampler operation in which playback rate and pitch are linked, ie. no time-stretching. The hardest part by far (in my experience) is a good crossfading mechanism for looped played back. For single shot samples everything is easy. For looped playback I have used this design which I modified to suit my needs. The crossfading works really well: Looping sampler with crossfading"}
+{"text": "SuperCollider forum — Tracking key-values over time\n\nspacetimed:\n\nA solution that doesn’t reinvent the wheel might be to make use of a state management system in another language for all of this data stuff and then just communicate the changes in value at any given time via OSC for SC to make sound with\n\nHmm I’ll try to remain a bit lighterweight for now. I’ve used OSC in the past to communicate between processes but it may be a bit of overkill for what I’m trying to do here (which is just an experiment anway).\n\n dkmayer:\n\nI think it shouldn’t be too hard with a compound data structure involving PriorityQueue.\n\nAfter looking at the docs for PriorityQueue, I’m not sure it is my best option here. (But very cool that I got to know it exists!) It seems to allow for forward iteration only, and only allows iteration by popping stuff in order. Unless I start to mess with its private methods I’m not sure it will be what I need. I think I’ll stick to an array for now. As events are added chronologically, the array will automatically remain sorted by time, and it should therefore be fairly easy (or at least possible ) to do a binary search to find an array index corresponding to a time value.\n\n cian:\n\nYou will want to use a binary search.\n\nThanks, this is a nice idea for speedup of what I considered the most problematic part in my proposed approach.\n\n cian:\n\nProblems you will run into. At some point you will run out of space if this program is running constantly. If it isn’t running constantly just make sure this isn’t going to be a problem for you.\n\nTrue. Although probably it’s possible to squash the oldest ev"}
+{"text": " going to be a problem for you.\n\nTrue. Although probably it’s possible to squash the oldest events into some “initial state” to remain below a configurable maximum size if I hit that problem. But anyway I don’t expect to collect Gigabytes of information (certainly not in my initial experiments).\n\nThanks all for the nice ideas so far!\n\nI’ll update this thread when I make some progress."}
+{"text": "SuperCollider forum — Async ops (again)\n\nSpacechild1:\n\nWe can’t change the existing methods, so we have to duplicate them, which would further bloat the codebase.\n\nImho, this would be worth the breaking change due to the amount of confusion new users understandably have over this issue.\n\nIt is peculiar that evaluating each line individually has a different behaviour from evaluating a block - that I think is the most surprising and difficult to understand when starting.\n\n jamshark70:\n\nI sort of remember that this code sketch needed a lot of Object methods supporting this...?\n\nSort of, ideally you’d just set doesnotunderstand, but methods like size need to sync on buffer so I reimplemented all of object letting you pass a function to evaluate before every method, allowing the promise to wait itself when first used.\n\nWith out making a sperate thread for each executetion block it gets a little more complex as methods like printing to the console might need to sync.\n\n Spacechild1:\n\nSecond, by returning Promises/Tasks you can wait on multiple operations in parallel.\n\nI don’t see the benefit of this because you are actually just waiting on them sequentially.\n\nAuto promises just wait in the order you use them. True, this isn’t explicit, but for server communication which usually happens very fast, I don’t think that matters as much.\n\nAnother point about promises is that they hide there held class - there’s no promise of T - which makes documentation a little harder to look up. In the autopromise I did a silly thing and overloaded the class method so it deferred to its held, I thought this would"}
+{"text": "opromise I did a silly thing and overloaded the class method so it deferred to its held, I thought this would causes bugs, but could find any?!\n\nYou could also turn a promise into an auto promise with a method call pretty easily!\n\nYou could also go the other way, and convert from an autopromise to a promise.\n\nThe benefit of autopromise is that it requires only small changes to the code and doesn’t change the method signature, nor how the user uses the return object - it doesn’t break everything.\n\nThis means that if all current methods returned an autopromise (which doesn’t break anything), and the user wants a normal promise, they could just ask for. This is a change that we can have today."}
+{"text": "SuperCollider forum — Mutable Instruments Braids(& other) UGen SC ports frequency input instead of midi\n\nI think I understand what you are asking now. As understand it, you want to find out how to convert the ET53 frequencies to integer numbers. If this is what you want, maybe this can be helpful:\n\n```supercollider\n~offset = 440.cpsmidi - 432.cpsmidi // 0.31766653633429\nt = Tuning.et53;\nt.ratios;\n\n/// first 5 frequencies of ET53 starting at 432 Hz\n\n~et53notes = 5.collect{|i| 432 * t.ratios[i] } // [ 432.0, 437.68690978674, 443.44868286728, 449.28630475273, 455.20077392761 ]\n\n~nns = ~et53notes.cpsmidi + ~offset // [ 69.0, 69.226415094339, 69.452830188677, 69.679245283016, 69.905660377355 ]\n~midiratio = t[1]; // ET12 midiratio: 1.midiratio = 1.0594630943591, ET53 midiratio: t[1] = 1.0131641430249;\n~nns.collect{|n, i| ( n - ~nns[0] / ~midiratio ).round(0.0000001) } // [ 0.0, 1.0, 2.0, 3.0, 4.0 ]\n```\n\nAn easier way is simply to create a"}
+{"text": " 1.0, 2.0, 3.0, 4.0 ]\n```\n\nAn easier way is simply to create a lookup table for frequencies (maybe with some rounding) and then do ~loopUpTable.indexOf(~somefreq) to get the scale degree. Or maybe this freqToDegree method is already there in SC and can adapt to tunings, I didn’t check.\n\nOr am I misunderstanding the whole thing?"}
+{"text": "SuperCollider forum — Noticeable latency/delay in playing Pdef\n\nOOOhhhh, I didn’t think the default quant was 1, rather than 0. Just tried it and it works! Thanks!\n\nGuess I should’ve dig deeper in the Pdef help file"}
+{"text": "SuperCollider forum — Wavetable and discovery\n\nDavon666:\n\n({EnvGen.kr(Env([0,0,0,0,1,1,1,0],[0,0,0,t.beatDur/2,0, t.beatDur/2,0,0],6,6,0),Trig.kr(1,490))}.plot(duration:2))\n\nI would still recommend against trying to run a long LFO completely in the server, when you want it to stay tempo-locked with patterns in the language. (If not tempo-locked, then the long LFO is no problem – but this thread is about a tempo-locked control signal.)\n\nSwitching to ar means that it won’t drift as quickly, but it will still drift.\n\nDriving the envelope from the language means that it will definitely stay in sync.\n\nIf you’re happy with the solution that sort of works for a while (but eventually won’t be working that well), that’s your choice. For myself, I prefer the one that always works.\n\n```supercollider\ns.boot;\n\n(\nSynthDef(\\kick, { |out, freq = 55, aFreq = 300, aTime = 0.08,\n dec = 0.3, sus = 0.7, rel = 0.08, amp = 0.1, preamp = 3|\n var eg = EnvGen.ar(Env([0, 1, sus, 0], [0.005, dec, rel], -4), doneAction: 2);\n var feg = EnvGen.ar(Env([aFreq, freq], [aTime], \\exp));\n var sig = amp * tanh(SinOsc.ar(f"}
+{"text": "], [aTime], \\exp));\n var sig = amp * tanh(SinOsc.ar(feg) * preamp);\n Out.ar(out, (sig * eg).dup);\n}).add;\n\nSynthDef(\\shape, { |out, beatDur = 1, gate = 1|\n var halfBeat = beatDur * 0.5;\n var innerGate = Trig1.kr(Impulse.kr(beatDur.reciprocal), beatDur - 0.01);\n var sig = EnvGen.kr(\n Env([0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, halfBeat, 0, halfBeat, 0, 0], 6, 6, 0),\n innerGate\n );\n FreeSelf.kr(gate <= 0);\n Out.kr(out, sig);\n}).add;\n\nSynthDef(\\pad, { |out, gate = 1, freq = 440, detun = 1.008, amp = 0.1,\n ffreq = 8000, ffreqMod = 1, ffreqModMul = 1,\n atk = 0.1, dec = 0.3, sus = 0.5, rel = 0.3|\n var n = 7;\n var freqs = freq * Array.fill(n, { detun ** Rand(-1, 1) });\n var sig = Splay.ar(Saw.ar(freqs));\n var eg = EnvGen.ar(Env.adsr(atk, dec, sus, rel), gate, doneAction: 2);\n ffreq = (ffreq * ((ffreqMod * ffreqModMul) + 1)).clip(20, 20000);\n sig ="}
+{"text": "(ffreqMod * ffreqModMul) + 1)).clip(20, 20000);\n sig = LPF.ar(LPF.ar(sig, ffreq), ffreq);\n Out.ar(out, sig * (amp * eg));\n}).add;\n);\n\nTempoClock.tempo = 104/60;\n\nPdef(\\kick).quant = -1;\nPdef(\\kick, Pbind(\\instrument, \\kick, \\dur, 1, \\amp, 0.2, \\freq, 50, \\aFreq, 200, \\aTime, 0.05, \\dec, 0.15)).play;\n\nb = Bus.control(s, 1);\nb.set(1);\n\na = Synth(\\pad, [amp: 0.2, ffreq: 1000, ffreqMod: b.asMap, ffreqModMul: 3]);\n\n// not recommended: use one 'shape' synth running forever\n// after some minutes this will probably have drifted\nTempoClock.schedAbs(TempoClock.nextTimeOnGrid(-1), {\n s.makeBundle(0.2, {\n c = Synth(\\shape, [out: b, beatDur: TempoClock.beatDur]);\n });\n});\n\nc.free; // before the next bit\n\n// I prefer: one synth per shape trigger\n// this is always 100% in tempo because it's running on the same clock\nPdef(\\shape).quant = -1;\nPdef(\\shape, Pbind(\\instrument, \\shape, \\out, b, \\beatDur, Pfunc { TempoClock.beatDur }, \\dur, 1, \\legato, 1))."}
+{"text": "func { TempoClock.beatDur }, \\dur, 1, \\legato, 1)).play;\n```\n\nAlso, the “one synth” approach is likely to break if you change tempo, but the Pdef(\\shape) approach will be more robust.\n\nhjh"}
+{"text": "SuperCollider forum — Wavetable and discovery\n\nHere’s a technique I’ve used in the past for this, maybe it point in a helpful direction (sorry, for some reason my server isn’t launching rn, so this is untested and a bit rough )\n\n```supercollider\nSynthDef(\\clock, {\n var setTime, tempo, time, sig, rateMax;\n\n setTime = \\setTime.tr(0);\n tempo = \\tempo.kr(1);\n rateMax = 1.05 * tempo;\n\n time = Phasor.ar(\n setTime,\n SampleDur.ir * tempo,\n 0,\n inf,\n setTime\n ).poll;\n\n time = Slew.ar(\n time,\n up:rateMax, dn:rateMax\n );\n\n sig = SinOsc.ar(0, time.mod(2pi));\n //sig = IEnvGen.ar(Env.adsr, time * 3)\n\n Out.ar(\\out.kr, sig);\n}).add;\n\nPdef(\\lfoSync, Pmono(\n \\clock,\n \\out, ~someBus,\n \\dur, 1,\n \\tempo, 1,\n \\setTime, Ptime() * Pfunc({ ~tempo })\n));\n```\n\nThe idea here:\n\n- Use a Phasor to drive your LFO or other periodic thing - example has either a SinOsc or an envelope.\n\n- Provide a trigger input, \\setTime, which resets the phasor to a new time. This re-syncs your synth’s time to your pattern time if they drift.\n\n- Use Slew to rate-limit the phasor to a"}
+{"text": "’s time to your pattern time if they drift.\n\n- Use Slew to rate-limit the phasor to a LITTLE BIT faster than your desired speed.\n\n- Drive the whole thing with a Pmono - so, every \\dur beats you’re sending a setTime which tells the Synth what time it SHOULD be at.\n\nThe synth should be roughly in-sync with your pattern / sclang tempo - but of course it will not stay perfectly in sync forever (the language + server, as James has pointed out, are two slightly different clocks). \\setTime will periodically re-sync the clock to the correct time - but probably you don’t want this re-sync to jump discontinuously to the new value, because it would cause a click etc. So, the Slew limits the rate-of-change of time to a little faster than the speed you expect, so it will catch up or slow down slightly when it’s out of sync.\n\nOf course, if rateMax is low and your clocks are drifting a lot, it’s possible time will never catch up. And, if rateMax is high, then it might speed up quickly enough that it’s discontinuous in an audible way - this simply has to be tuned by ear.\n\nThe \\dur of your pattern here is simply controlling how often you resync your clock - this can also simply be tuned to the context. It might be that you only need to re-sync once every 10 seconds and everything works fine - or maybe need very tight sync and 0.1 sounds better - again, probably tune by ear.\n\nAs an overall architectural concept, I’ll have a \\clock synth output the time straight to a bus, and then have"}
+{"text": " architectural concept, I’ll have a \\clock synth output the time straight to a bus, and then have individual other synths read that time and drive their own LFO’s / envelopes / etc with it. Once you’ve got something that works, wrap it up as a Pdef and drop it in any patch or setup where you need a clock to drive other synths.\n\nOne final caveat: this example as it is MAY fun afoul of server latency - the language sends messages to the server expecting that they will be executed slightly in the future, so that timing is consistent. If this works but you’re hearing that “everything is slightly out of sync”, this is the likely culprit: just add a fixed offset to your time at the end, e.g. time = time + \\latency.kr(0) - probably this will just need to be the server latency, but again something that should really just be done by ear in the end."}
+{"text": "SuperCollider forum — Function for both M/S and L/R panning\n\nHi,\n\nDon’t quite know what you are trying to achieve here. Could you elaborate?\n\nIf you wanted to boost or cut either the side or mid I’d do something like this:\n\n```supercollider\n~msBal = {\n |lr, dbInput|\n var db = (\\midDb: 0, \\sideDb: 0) ++ dbInput;\n var amps = [db.midDb, db.sideDb].dbamps;\n var msIn = [lr[0] + lr[1], lr[0] - lr[1]];\n var msOut = msIn * amps * -6.dbamp; // -6 is needed to compensate for the ms conversion.\n [msOut[0] + msOut[1], msOut[0] - msOut[1]];\n};\n\n// examples\n\nx = {\n var lr = Pan2.ar(PinkNoise.ar(-15.dbamp), LFNoise2.kr(1));\n var msBalanced = ~msBal.(lr, (\\sideDb: 5)); // boost side by 5db\n //var msBalanced = ~msBal.(lr, (\\midDb: -5)); // cut mid by -5db\n //var msBalanced = ~msBal.(lr, (\\midDb: -15, sideDb: 2.5)); // cut mid by -15db and boost side by 2.5db\n msBalanced\n}.play;\n```\n\nJust a thing with the function you have written, it doesn’t return anything and you should refrain from modifying the inputs"}
+{"text": "Just a thing with the function you have written, it doesn’t return anything and you should refrain from modifying the inputs. It will make things easier in the long run if you avoid these two things.\n\nDon’t worry about efficiency, not only will this sort of thing will have near zero impact, but you shouldn’t even worry about efficiency until the code is too slow.\n\nJ"}
+{"text": "SuperCollider forum — Why not make presamples an argument?\n\nThanks James.\n\nI guess I’ve never really understood why a UGen should set it’s output out to the initial sample during Ctor.\n\nBut that’s more of a question about the graph engine in SuperCollider."}
+{"text": "SuperCollider forum — Does SC build with Visual Studio 2019?\n\nOK, got it! That fix hasn’t yet been moved to the 3.11 branch, but it is in develop if you don’t mind building that instead. You can also cherry-pick the commit yourself as a temporary workaround."}
+{"text": "SuperCollider forum — Stuttering sample playback using OSC on OS X\n\nDid you get stuttering only with this example ?\n\nDid you check with other audio applications ?\n\nThere’s a known issue with stuttering on built-in out - I have a MacBook Pro from 2018, it’s only usable with interface actually."}
+{"text": "SuperCollider schelp — HelpSource/Classes/AbstractGridLines.schelp\n\nAbstractGridLines —\nCalculates the numerical values suitable for grid lines to be used for plotting or other UI elements.\nCategory: GUI>Accessories\nSee also: Classes/GridLines, Classes/LinearGridLines, Classes/ExponentialGridLines, Classes/DrawGrid, Classes/ControlSpec, Classes/Plotter, Reference/plot\n\n\n\n```supercollider\nAbstractGridLines\n```\n and its subclasses are strategy objects that find suitable intervals for plotting grid lines and labels. The data range and warping behavior (e.g. linear or exponential) are derived from the corresponding ControlSpec. The instance methods of\n```supercollider\nAbstractGridLines\n```\n are used by DrawGrid (which is in turn used by Plotter) for getting logically spaced intervals that span the data for drawing grid lines on a plot.\n\n```supercollider\nAbstractGridLines\n```\n shouldn't be instantiated directly. Instead, the GridLines factory class or the ControlSpec#-grid method should be used to return the appropriate\n```supercollider\nAbstractGridLines\n```\n subclass for the given spec.\n\n```supercollider\n\\freq.asSpec.grid\n```\n\nSubclasses of\n```supercollider\nAbstractGridLines\n```\n correspond to the range and warp behav"}
+{"text": "supercollider\nAbstractGridLines\n```\n correspond to the range and warp behavior of their assigned\n```supercollider\nControlSpec\n```\n. For example,\n```supercollider\nLinearGridLines\n```\n and\n```supercollider\nExponentialGridLines\n```\n represent data on a linear and exponential scale, respectively.\n\n```supercollider\n(\n// LinearGridLines\nvar linGrid = ControlSpec(0, 100, \\lin, units: \"Time\").grid;\n// ExponentialGridLines\nvar expGrid = \\freq.asSpec.grid;\n\nDrawGrid.test(linGrid, expGrid);\n)\n```\n\nThis default implementation does not know anything about the data is displaying:\n\n```supercollider\nDrawGrid.test(nil, \\midinote.asSpec.grid);\n```\n\nA theoretical\n```supercollider\nMidinoteGridLines\n```\n could be written that labels these correctly, shows octaves and individual notes depending on the current zoom. Or a `DegreeGridLines` could draw pitch degree grid lines behind a frequency plot.\n\nNote that the\n```supercollider\nAbstractGridLines\n```\n does not know which axis it is to be used on and could also be used in polar plots or in 3D rendering.\n\n## new\n\n- spec:\nA ControlSpec that defines the numerical range, warp, and step.\n\nReturns: An instance of this class.\n\nNote:\n```supercollider\nAbstract"}
+{"text": "\n\nReturns: An instance of this class.\n\nNote:\n```supercollider\nAbstractGridLines\n```\n shouldn't be instantiated directly. Instead, the GridLines factory class or the ControlSpec#-grid method should be used to return the appropriate\n```supercollider\nAbstractGridLines\n```\n subclass.\n\n## spec\nGet/set the\n```supercollider\nControlSpec\n```\n that defines the numerical range, warp, and step.\n\nReturns: A ControlSpec.\n\n## asGrid\nReturn this object.\n\n```supercollider\nnil.asGrid\n```\n returns a\n```supercollider\nBlankGridLines\n```\n (a subclass of\n```supercollider\nAbstractGridLines\n```\n) which produces no drawn lines. So if\n```supercollider\nnil\n```\n is passed to the grid argument of\n```supercollider\nDrawGrid\n```\n, no lines are drawn on the corresponding axis.\n\n## niceNum\nRounds a value to a logical \"nice number\" that is within the same order of magnitude. See the discussion below for details.\n\n- val:\nThe value you'd like to make nicer.\n\n- round:\nA boolean. Roughly speaking, rounding will allow the returned number to be above or below the input val (similar to a\n```supercollider\nround\n```\n operation), while when\n```supercollider\nfalse\n```\n the returned number will tend to be higher than val (similar to\n```supercollider\nceil\n```\n).\n\nReturns: The nice number.\n\n"}
+{"text": "ilar to\n```supercollider\nceil\n```\n).\n\nReturns: The nice number.\n\nThis method is used to support internal calculations for determining grid line values, though it may be useful for other applications.\n\nObserve the rounding behavior:\n\n```supercollider\n(\nvar g = GridLines([0, 10000].asSpec);\n\"in val / rounded / not rounded\".postln;\n10.collect{ 10000.rand }.sort.do({ |x|\n postf(\"% / % / %\\n\", x, g.niceNum(x, true), g.niceNum(x, false))\n})\n)\n```\n\nThe implementation is based on: https://www.sciencedirect.com/book/9780080507538/graphics-gems##A. S. Glassner, Ed., Graphics Gems. San Diego: Morgan Kaufmann, 1990 .\n\n## looseRange\nReturns the logical minimum and maximum that will contain the min and max, determed internally using #-niceNum.\n\n- min:\nMinimum value to include in the returned range.\n\n- max:\nMaximum value to include in the returned range.\n\n- ntick:\nThe number of lines (\"ticks\") you would like within the range of\n```supercollider\n[min, max]\n```\n, default:\n```supercollider\n5\n```\n.\n\nReturns: An Array with the lower and upper bounds of the range containing your min and max, i.e.\n```supercollider\n[rangeMin, rangeMax]\n```\n.\n\n## getParams\n\nSpecifically for use by DrawGrid.\nThis returns a Dictionary with keys:\n"}
+{"text": "Params\n\nSpecifically for use by DrawGrid.\nThis returns a Dictionary with keys:\n```supercollider\n'lines'\n```\n, an array of values where lines should be drawn, and\n```supercollider\n'labels'\n```\n, an array of 2-element arrays\n```supercollider\n[value, \"formatted label\"]\n```\n for each line.\n\nNote that the highest and lowest values returned don't necessarily contain your valueMin and valueMax, but rather represent the values where grid lines will be drawn by\n```supercollider\nDrawGrid\n```\n (endcap lines are subsequently drawn at the data/grid bounds).\n\n- valueMin:\nMinimum value of the data to be plotted. The lowest grid line value returned may be higher than this value.\n\n- valueMax:\nMaximum value of the data to be plotted. The highest grid line value returned may be lower than this value.\n\n- pixelMin:\nLower bound of the grid's range, in pixels. Used to calculate the size of the available grid space when determining grid values based on tickSpacing (if numTicks is\n```supercollider\nnil\n```\n).\n\n- pixelMax:\nUpper bound of the grid's range, in pixels. Used to calculate the size of the available grid space when determining grid values based on tickSpacing (if numTicks is\n```supercollider\nnil\n```\n).\n\n- numTicks:\nExplicit number of ticks you would like to see on the graph (though the result is approximate). Set to\n```supercollider\nnil\n```\n if you'd like the number of ticks to be found automatically,"}
+{"text": "\n```supercollider\nnil\n```\n if you'd like the number of ticks to be found automatically, based on pixelMin, pixelMax, and tickSpacing.\n\n- tickSpacing:\nMinimum distance between ticks (in pixels). This value is only used when numTicks is\n```supercollider\nnil\n```\n.\n\nReturns: A Dictionary.\n\n## formatLabel\nFormat a numerical value for display as text, rounded to a desired precision.\n\n- val:\nThe value to round and convert to a text label.\n\n- numDecimalPlaces:\nNumber of decimal places to represent in the returned\n```supercollider\nString\n```\n.\n\nReturns: A String."}
+{"text": "SuperCollider schelp — HelpSource/Classes/BufRd.schelp\n\nBufRd —\nBuffer reading oscillator.\nSee also: Classes/BufWr\nCategory: UGens>Buffer\n\n\n\nRead the content of a buffer at an index.\n\nIn comparison to PlayBuf :\nPlayBuf plays through the buffer by itself, BufRd only moves its read point by the phase input and\ntherefore has no pitch input. BufRd has variable interpolation.\n\n## ar, kr\n\n- numChannels:\nNumber of channels that the buffer will be. This must be a fixed\ninteger. The architecture of the SynthDef cannot change after it\nis compiled.\nNote:\nIf you supply a\n```supercollider\nbufnum\n```\n of a buffer that has a\ndifferent\n```supercollider\nnumChannels\n```\n than you have specified to\nthe BufRd, it will post a warning and output the channels it can. \n\n- bufnum:\nThe index of the buffer to use.\n\n- phase:\nAudio rate modulateable index into the buffer.\nWarning: The phase argument only offers precision for addressing 2**24 samples (about 6.3 minutes at 44100Hz). \n\n- loop:\n1 means true, 0 means false. This is modulateable.\n\n- interpolation:\n1 means no interpolation, 2 is linear, 4 is cubic interpolation.\n(The numbers one, two, and four correspond to the number of consecutive\nsamples needed to compute each type of interpolation.)\nAny other values for this argument will silently defa"}
+{"text": "\nsamples needed to compute each type of interpolation.)\nAny other values for this argument will silently default to cubic interpolation.\n\nExamples:\n\n```supercollider\n(\n// read a whole sound into memory\ns = Server.local;\n// note: not *that* columbia, the first one\nb = Buffer.read(s, ExampleFiles.child);\n)\n\n// use any AUDIO rate ugen as an index generator\n\n{ BufRd.ar(1, b, SinOsc.ar(0.1) * BufFrames.ir(b)) }.play;\n{ BufRd.ar(1, b, LFNoise1.ar(1) * BufFrames.ir(b)) }.play;\n{ BufRd.ar(1, b, LFNoise1.ar(10) * BufFrames.ir(b)) }.play;\n{ BufRd.ar(1, b, LFTri.ar(0.1) + LFTri.ar(0.23) * BufFrames.ir(b)) }.play;\n// original duration\n{ BufRd.ar(1, b, LFSaw.ar(BufDur.ir(b).reciprocal).range(0, BufFrames.ir(b))) }.play;\n\n// use a phasor index into the file\n\n{ BufRd.ar(1, b, Phasor.ar(0, BufRateScale.kr(b), 0, BufFrames.kr(b))) }.play;\n\n// change rate and interpolation\n(\nx = { |rate = 1, inter = 2|\n BufRd.ar(1, b, Phasor.ar(0, BufRateScale.kr(b"}
+{"text": "fRd.ar(1, b, Phasor.ar(0, BufRateScale.kr(b) * rate, 0, BufFrames.kr(b)), 1, inter)\n}.play;\n);\n\nx.set(\\rate, 0.9);\nx.set(\\rate, 0.6);\nx.set(\\inter, 1);\nx.set(\\inter, 0);\n\n// write into the buffer with a BufWr\n(\ny = { |rate = 1|\n var in;\n in = SinOsc.ar(LFNoise1.kr(2, 300, 400), 0, 0.1);\n BufWr.ar(in, b, Phasor.ar(0, BufRateScale.kr(b) * rate, 0, BufFrames.kr(b)));\n 0.0 // quiet\n}.play;\n);\n\n// read it with a BufRd\n(\nx = { |rate = 1|\n BufRd.ar(1, b, Phasor.ar(0, BufRateScale.kr(b) * rate, 0, BufFrames.kr(b)))\n}.play;\n);\n\nx.set(\\rate, 5);\ny.set(\\rate, 2.0.rand);\nx.set(\\rate, 2);\n\nb.free\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/BufSampleRate.schelp\n\nBufSampleRate —\nBuffer sample rate.\nSee also: Classes/BufChannels, Classes/BufDur, Classes/BufFrames, Classes/BufRateScale, Classes/BufSamples\nCategory: UGens>Buffer>Info\n\n\nReturns the buffer's current sample rate.\n\n## kr, ir\n\n- bufnum:\nBuffer index.\n\nReturns:\nthe buffer's current sample rate.\n\nWarning:\nThe\n```supercollider\n.ir\n```\n method is not the safest choice.\nSince a buffer can be reallocated at any time, using\n\n```supercollider\n.ir\n```\n will not track the changes.\n\nExamples:\n\n```supercollider\nb = Buffer.read(s, ExampleFiles.child);\n\n// compares a 1102.5 Hz sine tone (11025 * 0.1, left) with a 1100 Hz tone (right)\n// the apollo sample has a sample rate of 11.025 kHz\n(\n{\n var freq;\n freq = [BufSampleRate.kr(b) * 0.1, 1100];\n SinOsc.ar(freq, 0, 0.1)\n}.play;\n);\n\nb.free;\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/Dbufrd.schelp\n\nDbufrd —\nBuffer read demand ugen\nCategory: UGens>Buffer, UGens>Demand\nSee also: Classes/Dbufwr\n\n## new\n- bufnum:\nbuffer number to read from\n- phase:\nindex into the buffer\n- loop:\nwhen phase exceeds number of frames in buffer, loops when set to 1 (default :1)\n\nall inputs can be either demand ugen or any other ugen.\n\nExamples:\n\n```supercollider\nb = Buffer.alloc(s, 24, 1);\nb.setn(0, { exprand(200, 500) } ! b.numFrames);\nb.getn(0, b.numFrames, { |x| x.postln })\n\n(\n{ var indexPattern;\n indexPattern = Dseq([Dseq([0, 3, 5, 0, 3, 7, 0, 5, 9], 3), Dbrown(0, 23, 1, 5)], inf);\n SinOsc.ar(\n Demand.kr(Dust.kr(10), 0, Dbufrd(b, indexPattern))\n ) * 0.1\n}.play;\n);\n\n// buffer as a time pattern\n\nc = Buffer.alloc(s, 24, 1);\nc.setn(0, { [1, 0.5, 0.25].choose } ! c.numFrames);\nc.getn(0, c.numFrames, { |x| x.postln })\n\n(\n{ var indexPattern;\n indexPattern = Dseq([Dseq([0, 3"}
+{"text": "\n(\n{ var indexPattern;\n indexPattern = Dseq([Dseq([0, 3, 5, 0, 3, 7, 0, 5, 9], 3), Dbrown(0, 23, 1, 5)], inf);\n SinOsc.ar(\n Duty.kr(\n Dbufrd(c, Dseries(0, 1, inf)) * 0.5,\n 0,\n Dbufrd(b, indexPattern)\n )\n ) * 0.1\n}.play;\n);\n\n// free buffers\n\nb.free; c.free;\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/DegreeToKey.schelp\n\nDegreeToKey —\nConvert signal to modal pitch.\nCategory: UGens>Conversion\n\n\n\nThe input signal value is truncated to an integer value and used as an\nindex into an octave repeating table of note values. Indices wrap around\nthe table and shift octaves as they do.\n\n## ar, kr\n\n- bufnum:\n\nIndex of the buffer which contains the steps for each scale\ndegree.\n\n- in:\n\nThe input signal.\n\n- octave:\n\nThe number of steps per octave in the scale.\n\n- mul:\n\nOutput will be multiplied by this value.\n\n- add:\n\nThis value will be added to the output.\n\nExamples:\n\n```supercollider\n(\n// modal space\n// mouse x controls discrete pitch in dorian mode\nvar scale, buffer;\nscale = FloatArray[0, 2, 3.2, 5, 7, 9, 10]; // dorian scale\nbuffer = Buffer.alloc(s, scale.size, 1, { |b| b.setnMsg(0, scale) });\n\nplay({\n var mix;\n\n mix =\n\n // lead tone\n SinOsc.ar(\n (\n DegreeToKey.kr(\n buffer.bufnum,\n MouseX.kr(0, 15), // mouse indexes into scale\n 12, // 12 notes per octave\n 1, // mul = 1\n 72 // offset by 72 notes\n )\n + LFNoise1.kr([3, 3], 0.04) // add some low f"}
+{"text": " )\n + LFNoise1.kr([3, 3], 0.04) // add some low freq stereo detuning\n ).midicps, // convert midi notes to hertz\n 0,\n 0.1)\n\n // drone 5ths\n + RLPF.ar(LFPulse.ar([48, 55].midicps, 0.15),\n SinOsc.kr(0.1, 0, 10, 72).midicps, 0.1, 0.1);\n\n // add some 70's euro-space-rock echo\n CombN.ar(mix, 0.31, 0.31, 2, 1, mix)\n})\n)\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/HiliteGradient.schelp\n\nHiliteGradient —\nA linear color fade between an outside and an inside color\nCategory: GUI>Accessories\nSee also: Classes/Color, Classes/Gradient\n\n\nA linear color fade between an outside and an inside color.\n\nNote: The use of HiliteGradient is not supported yet in Qt GUI. When HiliteGradient is used in place of Color, the average gradient color will be used instead. \n\n## new\n- color1:\nAn instance of Color.\n- color2:\nAn instance of Color.\n- direction:\n\n```supercollider\n\\h\n```\n or\n```supercollider\n\\v\n```\n for horizontal and vertical respectively. Default value is\n```supercollider\n\\v\n```\n.\n- steps:\nThe resolution of the gradient. Default value is 64.\n- frac:\nThe center of the gradient. Default value is 0.33, i.e. off center toward the top on a vertical gradient.\n\nExamples:\n\n```supercollider\n// basic usage\n(\nw = Window.new.front;\nv = CompositeView(w, Rect(50, 50, 200, 50));\nv.background = HiliteGradient(Color.gray, Color.white);\n);\n\n// change direction and resolution\n(\nw = Window.new.front;\nw.view.background = HiliteGradient(Color.red, Color.white, \\h, 12, 0.5);\n);\n\n// almost un"}
+{"text": "(Color.red, Color.white, \\h, 12, 0.5);\n);\n\n// almost unnoticeable variations can be pleasant\n(\nw = Window.new.front;\nv = CompositeView(w, Rect(50, 50, 300, 300));\nc = Color.rand;\nd = c.vary(0.15);\nv.background = HiliteGradient(c, d, \\v);\n[c, d].postln\n);\n\n(\nvar w, k, c, d, e, c1, c2, f, g;\nw = Window.new.front;\nk = Slider2D(w, Rect(50, 50, 300, 300));\nf = {\n c = Color.rand;\n d = c.vary(0.5);\n e = d.vary(0.5);\n};\ng = {\n c1 = d.hueBlend(e, k.y).round(0.01);\n c2 = c.hueBlend(e, k.x).round(0.01);\n k.background = HiliteGradient(c1, c2, \\v)\n};\nf.value; g.value;\nk.action = g;\nk.mouseUpAction = { [c1, c2].postln };\nk.keyDownAction = f; // hit any key for new color\n)\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/LFNoise0.schelp\n\nLFNoise0 —\nStep noise\nSee also: Classes/LFClipNoise, Classes/LFDClipNoise, Classes/LFDNoise0, Classes/LFDNoise1, Classes/LFDNoise3, Classes/LFNoise1, Classes/LFNoise2\nCategory: UGens>Generators>Stochastic\n\n\n\nGenerates random values at a rate given by the nearest integer division\nof the sample rate by the\n```supercollider\nfreq\n```\n argument.\n\n## ar, kr\n\n- freq:\nApproximate rate at which to generate random values.\n\n- mul:\nOutput will be multiplied by this value.\n\n- add:\nThis value will be added to the output.\n\nExamples:\n\n```supercollider\n{ LFNoise0.ar(1000, 0.25) }.play;\n\n// modulate frequency\n\n{ LFNoise0.ar(XLine.kr(1000, 10000, 10), 0.25) }.play;\n\n// as frequency modulator\n(\n{ SinOsc.ar(\n LFNoise0.ar(4, 400, 450),\n 0, 0.2\n )\n}.play;\n)\n\n// freq is the rate of starting points\n{ var freq = 1000; [LFNoise0.ar(freq), Impulse.ar(freq)] }.plot\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/LinCongN.schelp\n\nLinCongN —\nLinear congruential chaotic generator\nCategory: UGens>Generators>Chaotic\nSee also: Classes/LinCongL, Classes/LinCongC\n\n\nA non-interpolating sound generator based on the difference equation:\n\n`\n x(n+1) = (a * x(n) + c) % m\n`\n\nThe output signal is automatically scaled to a range of [-1, 1].\n\nsclang code translation:\n\n```supercollider\n(\nvar a = 1.1, c = 0.13, m = 1, xi = 0, size = 64;\nplot(size.collect { xi = (a * xi + c) % m });\n)\n```\n\n## ar\n- freq:\nIteration frequency in Hertz\n- a:\nMultiplier amount\n- c:\nIncrement amount\n- m:\nModulus amount\n- xi:\nInitial value of x\n- mul:\n- add:\n\nExamples:\n\n```supercollider\n// default initial params\n{ LinCongN.ar(MouseX.kr(20, SampleRate.ir)) * 0.2 }.play(s);\n```\n\n```supercollider\n// randomly modulate params\n(\n{ LinCongN.ar(\n LFNoise2.kr(1, 1e4, 1e4),\n LFNoise2.kr(0.1, 0.5, 1.4),\n LFNoise2.kr(0.1, 0.1, 0.1),\n LFNoise2.kr(0.1)\n) * 0.2 }.play(s);\n)\n```\n\n```supercoll"}
+{"text": ".kr(0.1)\n) * 0.2 }.play(s);\n)\n```\n\n```supercollider\n// as frequency control...\n(\n{\nSinOsc.ar(\n LinCongN.ar(\n 40,\n LFNoise2.kr(0.1, 0.1, 1),\n LFNoise2.kr(0.1, 0.1, 0.1),\n LFNoise2.kr(0.1),\n 0, 500, 600\n )\n) * 0.4 }.play(s);\n)\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/OnePole.schelp\n\nOnePole —\nOne pole filter.\nSee also: Classes/OneZero\nCategory: UGens>Filters>Linear\n\n\n\nA one pole filter. Implements the formula:\n\n```supercollider\nout(i) = ((1 - abs(coef)) * in(i)) + (coef * out(i-1)).\n```\n\n## ar, kr\n\n- in:\n\nThe input signal.\n\n- coef:\n\nFeedback coefficient. Should be between -1 and +1\n\n- mul:\n\nOutput will be multiplied by this value.\n\n- add:\n\nThis value will be added to the output.\n\nExamples:\n\n```supercollider\n{ OnePole.ar(WhiteNoise.ar(0.5), 0.95) }.play\n\n{ OnePole.ar(WhiteNoise.ar(0.5), -0.95) }.play\n\n{ OnePole.ar(WhiteNoise.ar(0.5), Line.kr(-0.99, 0.99, 10)) }.play\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/PV_MagSmear.schelp\n\nPV_MagSmear —\nAverage magnitudes across bins.\nCategory: UGens>FFT\n\n\n\nAverage a bin's magnitude with its neighbors.\n\n## new\n\n- buffer:\n\nFFT buffer.\n\n- bins:\n\nNumber of bins to average on each side of bin. As this number\nrises, so will CPU usage.\n\nExamples:\n\n```supercollider\ns.boot;\n\n(\nb = Buffer.alloc(s, 2048, 1);\nc = Buffer.read(s, ExampleFiles.child);\n);\n\n(\nSynthDef(\"help-magSmear\", { |out = 0, bufnum = 0|\n var in, chain;\n in = LFSaw.ar(500, 0, Decay2.ar(Impulse.ar(2, 0, 0.2), 0.01, 2));\n chain = FFT(bufnum, in);\n chain = PV_MagSmear(chain, MouseX.kr(0, 100));\n Out.ar(out, 0.5 * IFFT(chain).dup);\n}).play(s, [\\out, 0, \\bufnum, b.bufnum]);\n);\n\n(\nSynthDef(\"help-magSmear2\", { |out = 0, bufnum = 0, soundBufnum = 2|\n var in, chain;\n in = PlayBuf.ar(1, soundBufnum, BufRateScale.kr(soundBufnum), loop: 1);\n chain = FFT(bufnum, in);\n chain = PV_Mag"}
+{"text": "ufnum), loop: 1);\n chain = FFT(bufnum, in);\n chain = PV_MagSmear(chain, MouseX.kr(0, 100));\n Out.ar(out, 0.5 * IFFT(chain).dup);\n}).play(s, [\\out, 0, \\bufnum, b.bufnum, \\soundBufnum, c.bufnum]);\n)\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/PV_PhaseShift.schelp\n\nPV_PhaseShift —\nShift phase.\nSee also: Classes/FFT, Classes/IFFT, Classes/PV_PhaseShift90, Classes/PV_PhaseShift270, Classes/PV_Diffuser\nCategory: UGens>FFT\n\n\n\nShift phase of all bins.\n\n## new\n\n- buffer:\n\nFFT buffer.\n\n- shift:\n\nPhase shift in radians.\n\n- integrate:\n\nIf greater than zero, integrate the phase-shift across calls (for an accumulating phase shift).\n\nExamples:\n\n```supercollider\ns.boot;\n\n(\nSynthDef(\"help-phaseShift\", { |out = 0|\n var in, chain;\n in = SinOsc.ar(500);\n chain = FFT(LocalBuf(2048), in);\n chain = PV_PhaseShift(chain, LFNoise2.kr(1, 180, 180));\n Out.ar(out, 0.1 * IFFT(chain).dup);\n}).play(s);\n)\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/PageLayout.schelp\n\nPageLayout —\na Window with a FlowView on it for use in ObjectGui's MVC model\nCategory: GUI\nSee also: Classes/ObjectGui, Classes/FlowView, Classes/Window, Classes/NotificationCenter\n\n\nThis class encapsulates the common task of creating a Window, adding a FlowView (CompositeView with a FlowLayout on it). It also supports the MVC model by registering controllers that are then removed (sent the .remove message) when the Window closes. Additionally it can resize itself to fit the contents.\n\n## new\nCreate a Window with a FlowView on it. The PageLayout object can be treated like a Window or like a View.\n\n- title:\nWindow title\n\n- bounds:\nBounds or nil. Default of nil will size the window to the entire screen size. Use .resizeToFit to shrink the window to the content size.\n\n- margin:\nFlowLayout margin.\n\n- background:\nBackground color\n\n- scroll:\nboolean: add scroll bars or not.\n\n- front:\nboolean: whether to immediately display the window, bringing it to the front. default is true. You may choose to first add your views to the window and then front it which is useful for large slow GUIs\n\nReturns: a PageLayout\n\n## window\nthe Window object\n\nReturns: a Window\n\n## view\nthe top most v"}
+{"text": "\n## window\nthe Window object\n\nReturns: a Window\n\n## view\nthe top most view on the Window\n\nReturns: a View\n\n## isClosed\nboolean: has the window been closed ?\n\nReturns: boolean\n\n## onClose\nJust as for Window, this method is called when the PageLayout's window is closed. The actual Window's onClose method is used to trigger clean up operations, releasing dependencies and will also call this onClose function.\n\nReturns: get/set onClose handler\n\n## asView\nreturns the top view\n\nReturns: a View\n\n## asFlowView\n\n- bounds:\nif bounds are nil then it returns self, as a PageLayout is compatible with FlowView. If bounds are supplied then a child FlowView is placed and returned\n\nReturns: self or a new FlowView\n\n## bounds\ninner bounds of the top level view.\n\nReturns: a Rect\n\n## asPageLayout\nSimilar to asFlowView, this message converts nil and various other objects to a PageLayout. This is already a PageLayout, so it returns self.\n\n- name:\nIgnored. If the receiver had been nil then the name would be the Window name.\n\n- bounds:\nIgnored. Would have been used to size the PageLayout\n\nReturns: self\n\n## startRow\ncompatible with FlowView\n\nReturns: self\n\n## indentedRemaining\ncompatible with FlowView\n\nReturns: self\n\n## checkNotClosed\nis"}
+{"text": "ing\ncompatible with FlowView\n\nReturns: self\n\n## checkNotClosed\nisClosed.not\n\nReturns: boolean\n\n## front\nbring Window to the front\n\nReturns: self\n\n## hide\nHide window\n\nReturns: self\n\n## show\nShow the window if it was previously hidden.\n\nReturns: self\n\n## close\nClose the window, releasing any dependencies and calling the onClose handler.\n\nReturns: self\n\n## refresh\nRefresh the top level view\n\nReturns: self\n\n## background\nset background color of top level view\n\n- c:\ncolor\n\nReturns: self\n\n## removeOnClose\nRegister an object, usually a ObjectGui subclass or an Updater so that when the Window closes the .remove message will be sent to it. This will cause the object to release its dependencies on its Model. This means the ObjectGui (or other controller object) will stop getting update messages and will stop trying to update the View which has just been closed along with the Window. It also means that if there is no link to the Model and no longer any Views that held links to the controller object, that the controller is now unreferenced and will be garbage collected.\n\n- dependant:\nthe object that wishes to be sent .remove on closing the window\n\nReturns: self\n\n## resizeToFit\nResize the top FlowView to fit its contents and then resize the Window to fit that.\n\n- reflow:\nboolean: FlowView can relay all of"}
+{"text": "ize the Window to fit that.\n\n- reflow:\nboolean: FlowView can relay all of its child views in cases where the bounds have changed or views have been removed. This puts them all back in place one by one for the updated bounds. So this may result in smaller over all bounds, after which the window is shrunk.\n\n- center:\nboolean: after resizing, re-center the window in the screen.\n\nReturns: self\n\n## reflowAll\nsee FlowView reflowAll\n\nReturns: self\n\n## fullScreen\ngo Full screen\n\nReturns: self\n\n## endFullScreen\nend full screen\n\nReturns: self\n\n## FlowView extensions\n\n## flow\nPlace a new FlowView on the window\n\n- func:\nA handler that recieves the new FlowView as argument\n\n- bounds:\nBounds of the FlowView\n\nReturns: (returnvalue)\n\n## vert\n(describe method here)\n\n- func:\n(describe argument here)\n\n- bounds:\n(describe argument here)\n\n- spacing:\n(describe argument here)\n\nReturns: (returnvalue)\n\n## horz\n(describe method here)\n\n- func:\n(describe argument here)\n\n- bounds:\n(describe argument here)\n\n- spacing:\n(describe argument here)\n\nReturns: (returnvalue)\n\n## comp\n(describe method here)\n\n- func:\n(describe argument here)\n\n- bounds:\n(describe argument here)\n\n"}
+{"text": "c:\n(describe argument here)\n\n- bounds:\n(describe argument here)\n\nReturns: (returnvalue)\n\n## scroll\n(describe method here)\n\n- ...: args\n(describe argument here)\n\nReturns: (returnvalue)\n\nExamples:\n\n```supercollider\nPageLayout.new\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/PathName.schelp\n\nPathName —\nfile and directory path utilities\nSee also: Classes/File, Classes/String\nCategory: Files\n\n\nPathName is a utility class for manipulating file names and paths. It expects a path to a file, and lets you access parts of that file path.\n\nNote:\nMost classes in SC that operate on files generally expect paths to be Strings, not an instance of PathName. Use\n```supercollider\n.fullPath\n```\n to convert PathName to a String expected in most cases.\n\n## new\n\n- path:\na String which likely contains one or more / as typical for folder separation. ~ will be converted to your fully addressed home directory, as per String#-standardizePath.\n\n```supercollider\nPathName.new(\"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken\");\n```\n\n## tmp\nGet or set the global temp directory as a String. This is used by Buffer, etc. By default this is\n```supercollider\nPlatform.defaultTempDir\n```\n.\n\n## fileName\nreturns just the name of the file itself; i.e. everything after the last slash in the full path.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken\");\nmyPath.fileName.postln;\n)\n```\n\n## fileNameWithoutExtension\nreturns the name of the file itself without"}
+{"text": "n;\n)\n```\n\n## fileNameWithoutExtension\nreturns the name of the file itself without the file extension.\n\n## extension\nreturns the file extension, i.e. everything after the last full-stop in the #-fileName.\n\n## pathOnly\nreturns the full path up to the file name itself; i.e. everything up to and including the last slash. This is handy e.g. for storing several files in the same folder.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken\");\nmyPath.pathOnly.postln;\n)\n```\n\n## isAbsolutePath, asAbsolutePath, isRelativePath, asRelativePath\nyou MUST have correctly initialized the scroot classvar for this to know what it is relative to !\n\n## folderName\nreturns only the name of the folder that the file is in; i.e. everything in between the last but one and the last slash.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken\");\nmyPath.folderName.postln;\n)\n```\n\n## fullPath\nreturns the full path name that PathName contains.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken\");\nmyPath.fullPath.postln;\n)\n```\n\n## entries\nreturns a list of all the files+fold"}
+{"text": "Path.postln;\n)\n```\n\n## entries\nreturns a list of all the files+folders inside the folder represented by this path.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"./\");\nmyPath.entries.postln;\n)\n```\n\n## files\nreturns a list of all the files in the folder represented by this path.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"./\");\nmyPath.files.postln;\n)\n```\n\n## folders\nreturns a list of all the subfolders of the folder represented by this path.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"./\");\nmyPath.folders.postln;\n)\n```\n\n## isFile\nreturns a Boolean indicating whether or not the path represents a file (not a folder).\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"./\");\nmyPath.isFile.postln;\n)\n```\n\n## isFolder\nreturns a Boolean indicating whether or not the path represents a folder (not a file).\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"./\");\nmyPath.isFolder.postln;\n)\n```\n\n## filesDo\nIterates over all files found in the pathname, including ones in subfolders.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"./\");\nmyPath.filesDo"}
+{"text": "\nvar myPath;\nmyPath = PathName.new(\"./\");\nmyPath.filesDo{ |afile| afile.postln };\n)\n```\n\n## allFolders\nreturns a list of all the folder names contained in the pathname itself.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken\");\nmyPath.allFolders.postln;\n)\n```\n\n## diskName\nif path is an absolute path, returns the disk name; else a blank string.\n\n```supercollider\n(\nvar myPath;\nmyPath = PathName.new(\"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken\");\nmyPath.diskName.postln;\n);\n\n( // note the / at the start\nvar myPath;\nmyPath = PathName.new(\"/MyDisk/SC 2.2.8 f/Sounds/FunkyChicken\");\nmyPath.diskName.postln;\n)\n```\n\n## +/+\nPath concatenation operator - useful for avoiding doubling-up slashes unnecessarily.\n\n```supercollider\n(PathName(\"/somewhere\") +/+ PathName(\"over/the/rainbow\")).postln;\n(PathName(\"/somewhere\") +/+ PathName(\"/over/the/rainbow\")).postln;\n```\n\n## endNumber\nreturns a number at the end of PathName. Returns zero if there is no number.\n\n```supercollider\nPathName(\"floating"}
+{"text": "ame. Returns zero if there is no number.\n\n```supercollider\nPathName(\"floating1\").endNumber.postln;\nPathName(\"floating\").endNumber.postln;\n```\n\n## noEndNumbers\nreturns #-fullPath without any numbers at the end.\n\n```supercollider\nPathName(\"floating1\").noEndNumbers.postln;\nPathName(\"floating\").noEndNumbers.postln;\n```\n\n## nextName\ngenerates a sensible next name for a file by incrementing a number at the end of PathName, or by adding one if there is none. This is useful for recording files with consecutive names, and e.g. to generate a new filename when you don't want to overwrite an existing file with the current name.\n\n```supercollider\nPathName(\"floating34\").nextName.postln;\nPathName(\"floating\").nextName.postln;\nPathName(\"floating12_3A4X_56.7\").nextName.postln;\n```\n\nExamples:\n\nHere is an example that uses many instance methods. Just pick any file to see all the parts of its path.\n\n```supercollider\n(\nFileDialog.new(\n { |ok, path|\n var myPathName;\n if (ok,\n {\n myPathName = PathName.new(path);\n\n \"New PathName object: \".postc;\n myPathName.postln;\n\n \"fileName only: \".postc;\n myPathName.fileName.postln;\n\n \"path up to file only"}
+{"text": ".postc;\n myPathName.fileName.postln;\n\n \"path up to file only: \".postc;\n myPathName.pathOnly.postln;\n\n \"folder Name: \".postc;\n myPathName.folderName.postln;\n }\n )\n }\n)\n)\n```\n\nChoose a soundfile to put into the library, using its foldername and filename.\n\n```supercollider\n(\nFileDialog.new(\n { |ok, path|\n var myPathName, myFile;\n if (ok,\n {\n myPathName = PathName.new(path);\n\n // read your file from disk, e.g. a soundFile/\n\n myFile = SoundFile.new;\n if (myFile.openRead(path),\n {\n Library.put(\n [myPathName.folderName.asSymbol, myPathName.fileName.asSymbol],\n myFile);\n (\"Check Library.global\" + myPathName.folderName + \"please.\").postln;\n },\n { (\"Could not read soundfile\" + path ++ \".\").postln }\n );\n myFile.close;\n }\n )\n }\n)\n)\n```\n\nSave three tables in the same folder. Note: The file name chosen in the dialog is ignored! The files are always named table1, table2, table3.\n\n```supercollider\n(\nvar table1, table2, table3;\n\ntable1 = Wavetable.sineFill(1024, [1, 2, 3]);\ntable2 = Signal.newCle"}
+{"text": "avetable.sineFill(1024, [1, 2, 3]);\ntable2 = Signal.newClear.asWavetable;\ntable3 = Wavetable.sineFill(1024, Array.rand(64, 0.0, 1.0));\n\nFileDialog.new(\n { |ok, path|\n var myPathName, myPathOnly;\n if (ok,\n {\n myPathName = PathName.new(path);\n myPathOnly = myPathName.pathOnly;\n (\"writing files tables1-3 to\"+myPathOnly).postln;\n table1.write(myPathOnly ++ \"table1\");\n table2.write(myPathOnly ++ \"table2\");\n table3.write(myPathOnly ++ \"table3\");\n }\n )\n }\n)\n)\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/Pfset.schelp\n\nPfset —\nInsert an environment into the event prototype before evaluating the supplied pattern\nSee also: Classes/Pset\nCategory: Streams-Patterns-Events>Patterns>Data Sharing\n\n\nGood for setting default values or loading server objects.\n\n## new\n\n- func:\nUse environment variable syntax (e.g.,\n```supercollider\n ~x = 0\n```\n) to store values in the internal environment. These values are copied into the event prototype before running the supplied pattern.\n- pattern:\nAn event pattern (such as Pbind).\n- cleanupFunc:\nOptional. A function to evaluate when the pattern is stopped, or when the supplied pattern runs out of values. For example, if you loaded a Buffer in the initializer function, you could free it in the\n```supercollider\ncleanupFunc\n```\n.\n\nExamples:\n\n```supercollider\n(\nvar a, b;\na = Pfset({\n ~legato = 0.3;\n ~detune = rrand(0, 30);\n}, Pbind(\\dur, 0.5));\nx = a.asStream;\n9.do({ x.next(Event.new).postln });\n)\n```\n\nPfset does not override values placed into the event by the inner pattern:\n\n```supercollider\n(\nvar a, b;\na = Pfset({\n ~dur = 0.3;\n}, Pbind(\\dur, 0.5));\nx = a.asStream;\n9.do({ x.next("}
+{"text": "ind(\\dur, 0.5));\nx = a.asStream;\n9.do({ x.next(Event.new).postln });\n)\n```\n\nSound example\n\n```supercollider\n(\nSynthDef(\\sinegrain,\n { |out = 0, freq = 440, sustain = 0.02|\n var env;\n env = EnvGen.kr(Env.perc(0.001, sustain), 1, doneAction: Done.freeSelf);\n Out.ar(out, SinOsc.ar(freq, 0, env * 0.1))\n }).add;\n);\n\n(\na = Pbind(\\dur, 0.5, \\instrument, \\sinegrain, \\x, Pfunc { rrand(500, 600) });\na = Pfset({ ~freq = { ~x.postln * 2 }; ~legato = 3 }, a);\na.play;\n)\n```"}
+{"text": "SuperCollider schelp — HelpSource/Classes/Synth.schelp\n\nSynth —\nClient-side representation of a synth node on the server\nCategory: Server>Nodes, Server>Abstractions\nSee also: Classes/Node, Classes/SynthDef\n\n\n\nA Synth is the client-side representation of a synth node on the server. A Synth represents a single sound producing unit. What it does is defined in a SynthDef, which specifies what UGens are used and how they are patched together.\nIt also specifies what inputs and outputs the Synth will have. A SynthDef is thus a kind of fixed pattern, upon which Synths are be based. (Despite this, a given SynthDef can provide a surprising amount of variation.) For more detail on SynthDefs, their construction, and how to send them to a server, see the SynthDef help file.\n\nFor more on the important distinction between client objects and server nodes, see ClientVsServer. For information on creating nodes without using objects, see NodeMessaging.\n\n## Order of Execution\nOrder of execution is a crucial issue when creating Synths which interact with each other.\n\n```supercollider\n sound -> filter\n```\n\nIf a sound is to be passed through a filter, the synth that does the filtering must be later in the order of execution than the synth which is its input. The computer must calculate a buffer's worth of sound, and then the computer moves on to calculate a buffer's worth of the filtered version of that sound.\n\nThe actual interconnection between synth nodes is accomplished with buses."}
+{"text": "red version of that sound.\n\nThe actual interconnection between synth nodes is accomplished with buses. See Bus and Server-Architecture for details.\n\nSee the Order-of-execution help file for a more detailed discussion of this important topic.\n\n## Bundling\n\nSome of the methods below have two versions: a regular one which sends its corresponding message to the server immediately, and one which returns the message in an Array so that it can be added to a bundle.\nIt is also possible to capture the messages generated by the regular methods using Server's automated bundling capabilities. See Server and Bundled-Messages for more details.\n\nSynth is a subclass of Node, and thus many of its most useful and important methods are documented in the Node help file.\n\n## Creation with Immediate Instantiation on the Server\n## new\nCreate and return a new Synth object, and immediately start the corresponding synth node on the server.\n\n- defName:\nA String or Symbol specifying the name of the SynthDef to use in creating the Synth.\n\n- args:\nAn optional Array specifying initial values for the SynthDef's arguments (controls). These are specified in pairs of control name or index and value. If names are used they can be specified with either Strings or Symbols. e.g.\n```supercollider\n [\\frequency, 440, \\amplitude, 1, ...]\n```\n.\nValues that are arrays are sent using OSC array type-tags ($[ and $]). These values will be assigned to subsequent controls.\n\n- target:\nA target for this Synth. If target is not a Group or Synth, it will be convert"}
+{"text": "\n\n- target:\nA target for this Synth. If target is not a Group or Synth, it will be converted as follows: If it is a Server, it will be converted to the default_group of that server. If it is nil, to the default_group of the default Server. If it is an integer, it is created relative to a group with that id.\n\n- addAction:\none of the following Symbols:\n\n- \\addToHead || (the default) add at the head of the group specified by target\n- \\addToTail || add at the tail of the group specified by target\n- \\addAfter || add immediately after target in its server's node order\n- \\addBefore || add immediately before target in its server's node order\n- \\addReplace || replace target and take its place in its server's node order\n\nNote: A Synth is not a valid target for \\addToHead and \\addToTail.\n\n```supercollider\ns.boot;\n// create a Synth at the head of the default Server's default group\n// based on the SynthDef \"default\"\nx = Synth.new(\"default\");\ns.queryAllNodes; // note the default group (ID 1)\nx.free;\n\n// Using an arrayed control\n// run this block first to make the SynthDef\n(\nSynthDef(\"help-synth\", { |freq = #[440, 450, 460], out = 0|\n Out.ar(out, Mix(SinOsc.ar(freq, 0, 0.1)));\n}).add;\n);\n\n// then this a short while later\nx = Synth(\"help-synth\", [freq: [500, 501, 510]]);\n"}
+{"text": "\nx = Synth(\"help-synth\", [freq: [500, 501, 510]]);\n\nx = Synth(\"help-synth\", [freq: [500, 501, 510]]);\nx.set(\\freq, [1, 2, 3] * 400 + [1, 2, 3], \\out, 1);\nx.set(\\freq, [3] * 400 + [1, 2, 3], \\out, 1);\nx.free;\n```\n\n## newPaused\nAs\n```supercollider\nnew\n```\n above, but creates a node which is paused. This can be started by calling\n```supercollider\nrun\n```\n on it.\n\n```supercollider\ns.boot;\nx = Synth.newPaused(\"default\");\ns.queryAllNodes; // see I'm here\nx.run; // true is the default\nx.run(false); // pause me again\nx.free;\n```\n\n## grain\nA convenience method which will create a synth node with an node ID of -1. Such a node cannot be messaged after creation. As such this method does not create an object, and returns nil. For details of its arguments see\n```supercollider\nnew\n```\n above.\nReturns: nil\n\n## Convenience methods for add actions\nThe following convenience methods correspond to the add actions of\n```supercollider\nSynth.new\n```\n :\n\n## after\nCreate and return a Synth and add it immediately after aNode.\n\n## before\nCreate and return a Synth and add it immediately before aNode.\n\n## head\nCreate and return a Synth. If\n```supercollider\naGroup\n```\n is a Group add it at the head of that group. If it is a S"}
+{"text": "\n```supercollider\naGroup\n```\n is a Group add it at the head of that group. If it is a Server, add it at the head of the default_group of that server. If it is nil, add it at the head of the default_group of the default server. If it is an integer, it is created relative to a group with that id.\n\n## tail\nCreate and return a Synth. If\n```supercollider\naGroup\n```\n is a Group add it at the tail of that group. If it is a Server, add it at the tail of the default_group of that server. If it is nil, add it at the tail of the default_group of the default server. If it is an integer, it is created relative to a group with that id.\n\n## replace\nCreate and return a Synth and use it to replace\n```supercollider\nnodeToReplace\n```\n, taking its place in its server's node order.\n\n## Creation without Instantiation on the Server\n\nFor use in message bundles it is also possible to create a Synth object in the client app without immediately creating a synth node on the server. Once done one can call methods which create messages to add to a bundle, which when sent to the server will instantiate the synth.\n\n## basicNew\nCreate and return a Synth object without creating a synth node on the server.\n- defName:\nA String or Symbol specifying the name of the SynthDef to use in creating the Synth.\n- server:\nAn optional instance of Server. If nil this will default to the default Server.\n- nodeID:\nAn optional node ID number. If not supplied one will be generated by the Server's NodeIDAllocator. Normally you should not"}
+{"text": " number. If not supplied one will be generated by the Server's NodeIDAllocator. Normally you should not need to supply an ID.\n\n```supercollider\ns.boot;\nx = Synth.basicNew(\"default\", s); // Create without sending\ns.sendBundle(nil, x.newMsg); // Now send a message; create at the head of s' default group\ns.queryAllNodes;\nx.free;\n```\n\nAfter creation, use instance methods\n```supercollider\nnewMsg, addToHeadMsg, addToTailMsg, addBeforeMsg, addAfterMsg, addReplaceMsg\n```\n to instantiate this synth on the server. See #instancemethods#Instance Methods below.\n\nSynth is a subclass of Node, and thus many of its most useful and important methods are documented in the Node help file.\n\n## defName\nReturns: the name of this Synth's SynthDef.\n\n## Creation without Instantiation on the Server\nUse class method\n```supercollider\nbasicNew\n```\n to create a Synth without instantiating it on the server. Then use the following instance methods:\n## newMsg\nSee *new above for details of addActions and args.\nReturns: a message of the type s_new which can be bundled. When sent to the server this message will instantiate this synth. If target is nil, it will default to the default_group of the Server specified in *basicNew when this Synth was created. The default addAction is \\addToHead.\n\n## addToHeadMsg\nSee *new above for details on args.\nReturns:"}
+{"text": "ToHead.\n\n## addToHeadMsg\nSee *new above for details on args.\nReturns: a message of the type s_new which can be bundled. When sent to the server this message will instantiate this synth. If aGroup is a Group it will be added at the head of that group. If it is nil, it will be added at the head of the default_group of this Synth's server (as specified when *basicNew was called).\n\n## addToTailMsg\nSee *new above for details on args.\nReturns: a message of the type s_new which can be bundled. When sent to the server this message will instantiate this synth. If aGroup is a Group it will be added at the tail of that group. If it is nil, it will be added at the tail of the default_group of this Synth's server (as specified when *basicNew was called).\n\n## addBeforeMsg\nSee *new above for details on args.\nReturns: a message of the type s_new which can be bundled. When sent to the server this message will instantiate this synth, immediately before aNode.\n\n## addAfterMsg\nSee *new above for details on args.\nReturns: a message of the type s_new which can be bundled. When sent to the server this message will instantiate this synth, immediately after aNode.\n\n## addReplaceMsg\nSee *new above for details on args.\nReturns: a message of the type s_new which can be bundled. When sent to the server this message will instantiate this synth, replacing nodeToReplace in the server's node order.\n\n## Control\nFor further methods of controlling Synths (set, map, etc.), see the Node"}
+{"text": "## Control\nFor further methods of controlling Synths (set, map, etc.), see the Node helpfile.\n\n## get, getMsg\nQuery the server for the current value of a Control (argument).\n- index:\na control name or index\n- action:\na Function which will be evaluated with the value passed as an argument when the reply is received.\n\n```supercollider\ns.boot;\n(\nSynthDef(\"help-Synth-get\", { |out, freq = 440|\n Out.ar(out, SinOsc.ar(freq, 0, 0.1));\n}).add;\n);\nx = Synth(\"help-Synth-get\");\nx.set(\\freq, 220 + 440.rand);\nx.get(\\freq, { |value| (\"freq is now:\" + value + \"Hz\").postln });\nx.free;\n```\n\n## getn, getnMsg\nQuery the server for the current values of a sequential range of Controls (arguments).\n- index:\na control name or index\n- count:\nthe number of sequential controls to query, starting at index.\n- action:\na Function which will be evaluated with an Array containing the values passed as an argument when the reply is received.\n\n## set\nSet the values of one or more Controls.\n\nExample:\n\n```supercollider\nx.set(\\freq, 440, \\amp, 0.5)\n```\n\n## seti\nSet part of an arrayed control.\n- ...: args\nA sequence of name, index, value triplets.\n\n- name || The name of the arrayed control\n- index || The index into the array\n- value || The new value"}
+{"text": "- name || The name of the arrayed control\n- index || The index into the array\n- value || The new value to set, can be an array to set a range of elements.\n\nNote:\nThe synthdef has to be .add'ed, so that it is stored in the SynthDescLib.\n\nExample:\n\n```supercollider\n(\ns.waitForBoot({\n SynthDef(\\helpSeti, { |out, freqs = #[100, 150, 200, 250]|\n Out.ar(out, SinOsc.ar(freqs.poll, 0, 0.1).sum ! 2)\n }).add;\n s.sync;\n x = Synth(\\helpSeti);\n})\n);\nx.seti(\\freqs, 2, 600); // set only the third element\nx.seti(\\freqs, 1, [400, 410]); // set second and third element\nx.free;\n```\n\nExamples:\n\n```supercollider\ns.boot;\n(\n// send a synth def to server\nSynthDef(\"tpulse\", { |out = 0, freq = 700, sawFreq = 440.0|\n Out.ar(out, SyncSaw.ar(freq, sawFreq, 0.1));\n}).add;\n);\n\n// Here the defaults for *new will result in a Synth at the head of the default group\n// of the default Server. This will use the SynthDef's default arguments;\ny = Synth.new(\"tpulse\");\ny.free;\n\n// The same done explicitly\ny = Synth.new(\"tpulse\", nil, s, \\addToHead);\ny.free;\n\n// With some arguments\ny"}
+{"text": "pulse\", nil, s, \\addToHead);\ny.free;\n\n// With some arguments\ny = Synth.new(\"tpulse\", [\\freq, 350, \\sawFreq, 220]);\ny.free;\n\n// make a new synth\ny = Synth(\"tpulse\");\n\n// pause\ny.run(false);\n\ny.run(true);\n\n// set a control by argument name\ny.set(\"freq\", 200);\n\n// or by index\ny.set(2, 100.0);\n\n// modulate out to bus number 1 (the right speaker)\ny.set(0, 1);\n\n// multiple set commands in one message\ny.set(\"out\", 0, \"freq\", 300);\n\n// free the synth from the server\ny.free;\n```\n\n## Filtering\n\n```supercollider\n(\n// first collect some things to play with\nSynthDef(\"moto-rev\", { |out = 0|\n var x;\n x = RLPF.ar(LFPulse.ar(SinOsc.kr(0.2, 0, 10, 21), [0, 0.1], 0.1),\n 100, 0.1).clip2(0.4);\n Out.ar(out, x);\n}).add;\n\nSynthDef(\"bubbles\", { |out = 0|\n var f, zout;\n f = LFSaw.kr(0.4, 0, 24, LFSaw.kr([8, 7.23], 0, 3, 80)).midicps;\n zout = CombN.ar(SinOsc.ar(f, 0, 0.04), 0.2, 0.2, 4); // echoing sine wave\n Out.ar(out, zout);\n}).add;\n\nSynthDef(\"rlpf\", { |out"}
+{"text": "ave\n Out.ar(out, zout);\n}).add;\n\nSynthDef(\"rlpf\", { |out = 0, ffreq = 600, rq = 0.1|\n ReplaceOut.ar(out, RLPF.ar(In.ar(out), ffreq, rq))\n}).add;\n\nSynthDef(\"wah\", { |out, rate = 1.5, cfreq = 1400, mfreq = 1200, rq = 0.1|\n var zin, zout;\n\n zin = In.ar(out, 2);\n cfreq = Lag3.kr(cfreq, 0.1);\n mfreq = Lag3.kr(mfreq, 0.1);\n rq = Ramp.kr(rq, 0.1);\n zout = RLPF.ar(zin, LFNoise1.kr(rate, mfreq, cfreq), rq, 10).distort\n * 0.15;\n\n // replace the incoming bus with the effected version\n ReplaceOut.ar(out, zout);\n\n}).add;\n\nSynthDef(\"modulate\", { |out = 0, freq = 1, center = 440, plusMinus = 110|\n Out.kr(out, SinOsc.kr(freq, 0, plusMinus, center));\n}).add;\n);\n\n// execute these one at a time\n\n// y is playing on bus 0\ny = Synth(\"moto-rev\", [\"out\", 0]);\n\n// z is reading from bus 0 and replacing that; It must be *after* y\nz = Synth.after(y, \"wah\", [\"out\", 0]);\n\n// stop the wah-ing\nz.run(false);\n\n// resume the wah-ing\nz.run(true);\n\n// add a r"}
+{"text": ".run(false);\n\n// resume the wah-ing\nz.run(true);\n\n// add a rlpf after that, reading and writing to the same buss\nx = Synth.after(z, \"rlpf\", [\"out\", 0]);\n\n// create another rlpf after x\nt = Synth.after(x, \"rlpf\", [\"out\", 0]);\n\nx.set(\"ffreq\", 400);\n\nx.set(\\ffreq, 800); // Symbols work for control names too\n\n// Now let's modulate x's ffreq arg\n// First get a control Bus\nb = Bus.control(s, 1);\n\n// now the modulator, *before* x\nm = Synth.before(x, \"modulate\", [\\out, b]);\n\n// now map x's ffreq to b\nx.map(\"ffreq\", b);\n\nm.set(\"freq\", 4, \"plusMinus\", 20);\n\nx.free;\nz.free;\nm.free;\n\n// now place another synth after y, on the same bus\n// they both write to the buss, adding their outputs\nr = Synth.after(y, \"bubbles\", [\"out\", 0]);\n\ny.free;\n\nr.free;\n\n// look at the Server window\n// still see 4 UGens and 1 synth?\n// you can't hear me, but don't forget to free me\nt.free;\n```"}
+{"text": "SuperCollider schelp — HelpSource/Guides/Intro-to-Objects.schelp\n\nIntroduction to Objects\nIntroduction to objects and messages\nCategory: Language>OOP\nSee also: Reference/Classes, Classes/Class, Classes/Object, Reference/Messages, Guides/Polymorphism\n\n# Objects and Messages\n\nThe SuperCollider language is an object oriented language. All entities in the language are objects.\nAn object is something that has data, representing the object's state, and a set of operations that can be performed on the object. All objects are instances of some class which describes the structure of the object and its operations.\nObjects in SuperCollider include numbers, character strings, object collections, unit generators, wave samples, points, rectangles, graphical windows, graphical buttons, sliders and much more.\n\nOperations upon objects are invoked by messages. A message is a request for an object, called the receiver, to perform one of its operations. The means by which the operation is performed is determined by the object's class.\nObjects of different classes may implement the same message in different ways, each appropriate to the class of the object. For example all objects understand the\n```supercollider\nvalue\n```\n message.\nMany objects simply return themselves in response to\n```supercollider\nvalue\n```\n, but other objects such as functions and streams first evaluate themselves and return the result of that evaluation.\nThe ability for different objects to react differently to the same message is known as polymorphism and is perhaps the most important concept in object oriented programming since it allows the object's behaviour to be abstract from the point of view of the user"}
+{"text": " concept in object oriented programming since it allows the object's behaviour to be abstract from the point of view of the user of the object (the client).\n\nThe set of messages to which an object responds to is known as its interface. A set of messages that implement a specific kind behaviour is known as a protocol.\nAn object's interface may include several protocols which allow the object to interact in several different contexts.\nFor example all objects implement the 'dependancy' protocol which allow the object to notify other dependant objects that the object has changed and that the dependant should do any necessary action to update itself.\n\nAn object's internal state may only be changed by sending it messages. This allows the implementation of the object to be hidden from the client.\nThe advantage to this is that the client does not depend on the object's implementation and that that implementation can be changed without having to change the client.\n\nSee Messages for more information about messages.\n\n# Classes, Instance Variables, Methods\n\nAn object's class contains the description of the object's data and operations. A class also describes how to create an object which is an instance of that class.\n\nAn object's data is contained in its instance variables. These are named variables that describe the object's state.\nThe values of the instance variables are themselves objects. For example, instances of class Point have instance variables named 'x' and 'y' which contain the coordinate values of the Point.\n\nAn instance variable is only directly accessible from within the class itself. The author of a class may decide to expose instance variable access to clients by adding getter and/or setter messages to the class.\n\nA method is a description of the operations necessary to implement a message for a particular class. The methods in a class tell how to implement messages sent to its instances.\nA class contains"}
+{"text": "ment a message for a particular class. The methods in a class tell how to implement messages sent to its instances.\nA class contains a method definition for each message to which its instances respond. Methods generally fall into several categories. Some methods inquire about some property of the receiver.\nOthers ask the receiver to make some change to its internal state. Still others may ask the receiver to return some computed value.\n\nSee Classes for more details about instance and class variables and methods.\n\n# Summary of Terminology\n\n- object || something that has data, representing the object's state, and a set of operations that can be performed on the object.\n- message || a request for an object to perform an operation.\n- receiver || the object to which a message is sent.\n- class || a description of the state and behaviour of a set of objects.\n- interface || the set of messages to which an object responds.\n- protocol || a set of messages that implement a specific kind of behaviour.\n- polymorphism || the ability for different kinds of objects to respond differently to the same message.\n- method || a description of the operations necessary to implement a message for a particular class.\n- instance || one of the objects described by a class.\n- instance variable || a part of an object's internal state"}
+{"text": "SuperCollider schelp — HelpSource/Guides/ListComprehensions.schelp\n\nList Comprehensions\nCategory: Language, Collections\nlist comprehensions and generator expressions\n\n# Introduction\n\nList comprehensions are a syntactic feature of functional programming languages like Miranda, Haskell, and Erlang which were later copied into Python.\nYou can search the web for \"list comprehensions\" or \"generator expressions\" to learn more.\nBasically list comprehensions are for getting a series of solutions to a problem.\n\nin SC these are just a syntax macro for a longer expression. read this as \"all [x,y] for x in 1..5, y in 1..x, such that x+y is prime\" :\n\n```supercollider\nall {:[x,y], x <- (1..5), y <- (1..x), (x+y).isPrime }\n```\n\nreturns:\n\n```supercollider\n[ [ 1, 1 ], [ 2, 1 ], [ 3, 2 ], [ 4, 1 ], [ 4, 3 ], [ 5, 2 ] ]\n```\n\nthe list comprehension above is equivalent to the following code:\n\n```supercollider\nall(Routine.new({ (1..5).do {|x| (1..x).do {|y| if ((x+y).isPrime) {[x,y].yield} }}}));\n```\n\n..but much more concise and much easier to keep in your head than writing it out.\n\nIn the list comprehension compiler, simple series like\n```supercollider\n(1..5)\n```\n and\n```supercollider\n(1..x)\n```\n are treated as special cases and implemented as loops rather than making a collection.\n\nA list comprehension in SC is re"}
+{"text": " as special cases and implemented as loops rather than making a collection.\n\nA list comprehension in SC is really a Routine. You can use the\n```supercollider\nall\n```\n message to collect all of the Routine's results into a list.\n\n# A few examples\n\n```supercollider\nall {: x/(x+1), x <- (1..5) }\n\n[ 0.5, 0.66666666666667, 0.75, 0.8, 0.83333333333333 ]\n```\n\n```supercollider\nall {:[x,y], x <- (1..3), y <- [\\a,\\b,\\c] }\n\n[ [ 1, a ], [ 1, b ], [ 1, c ], [ 2, a ], [ 2, b ], [ 2, c ], [ 3, a ], [ 3, b ], [ 3, c ] ]\n```\n\n```supercollider\nall {:[x,y], x <- (0..3), y <- (x..0) }\n\n[ [ 0, 0 ], [ 1, 1 ], [ 1, 0 ], [ 2, 2 ], [ 2, 1 ], [ 2, 0 ], [ 3, 3 ], [ 3, 2 ], [ 3, 1 ], [ 3, 0 ] ]\n```\n\n```supercollider\nall {:y, x <- (1..4), y <- (x..1) }\n\n[ 1, 2, 1, 3, 2, 1, 4, 3, 2, 1 ]\n```\n\n```supercollider\n(\nvar intervals;\n// a function to generate intervals between all pairs of notes in a chord voicing\nintervals = {|chord|\n all {: chord[i+gap] - chord[i],\n gap <- (1 .. chord.lastIndex),\n i <- (0 "}
+{"text": "] - chord[i],\n gap <- (1 .. chord.lastIndex),\n i <- (0 .. chord.lastIndex - gap)\n }\n};\n\nintervals.([0,4,7,10]).postln;\nintervals.([0,1,3,7]).postln;\n);\n\n[ 4, 3, 3, 7, 6, 10 ]\n[ 1, 2, 4, 3, 6, 7 ]\n```\n\n```supercollider\nall {:[y, z], x<-(0..30), var y = x.nthPrime, var z = 2 ** y - 1, z.asInteger.isPrime.not }\n[ [ 11, 2047 ], [ 23, 8388607 ], [ 29, 536870911 ] ] // mersenne numbers which are no primes\n```\n\n# Qualifier Clauses\n\nA list comprehension begins with\n```supercollider\n {:\n```\n and contains a body followed by several qualifier clauses separated by commas.\n\n```supercollider\n{: body , qualifiers }\n```\n\nThere are several types of qualifier clauses that can appear after the body.\n\n## generator clause\n\nThe basic clause is the generator clause. Its syntax is\n\n```supercollider\nname <- expr\n```\n\nThe expression should be something that can respond meaningfully to 'do' such as a collection or a stream.\nThe name takes on each value of the expression.\nThe name is a local variable whose scope extends to all clauses to the right. The name is also in scope in the body.\n\n```supercollider\nall {: x, x <- (1..3) }\n\n[ 1, 2, 3 ]\n```\n\n```supercollider"}
+{"text": " x, x <- (1..3) }\n\n[ 1, 2, 3 ]\n```\n\n```supercollider\nall {: x, x <- [\\a, \\b, \\c] }\n\n[ a, b, c ]\n```\n\n```supercollider\nall {: x, x <- (1!3)++(2!2)++3 }\n\n[ 1, 1, 1, 2, 2, 3 ]\n```\n\nmultiple generators act like nested loops.\n\n```supercollider\nall {: [x,y], x <- (1..2), y <- (10,20..30) }\n\n[ [ 1, 10 ], [ 1, 20 ], [ 1, 30 ], [ 2, 10 ], [ 2, 20 ], [ 2, 30 ] ]\n```\n\ngenerators can depend on previous values.\n\n```supercollider\nall {: x, x <- (1..3), y <- (1..x) }\n\n[ 1, 2, 2, 3, 3, 3 ]\n```\n\n```supercollider\nall {: x, x <- (1..3), y <- (1..4-x) }\n\n[ 1, 1, 1, 2, 2, 3 ]\n```\n\n## guard clause\n\nA guard clause is simply an expression. It should return a boolean value.\n\n```supercollider\nexpr\n```\n\nThe guard acts as a filter on the results and constrains the search.\n\n```supercollider\nall {: x, x <- (0..10), x.odd }\n\n[ 1, 3, 5, 7, 9 ]\n```\n\n```supercollider\nx.odd\n```\n is the guard and causes all even numbers to be skipped.\n\n```supercollider\nall {: x, x <- (0..30), (x % 5 == 0) || x.isPowerOfT"}
+{"text": "lider\nall {: x, x <- (0..30), (x % 5 == 0) || x.isPowerOfTwo }\n\n[ 0, 1, 2, 4, 5, 8, 10, 15, 16, 20, 25, 30 ]\n```\n\nyou can have multiple guards.\n\n```supercollider\nall {: [x,y], x <- (0..10), (x % 5 == 0) || x.isPowerOfTwo, y <- (1..2), (x+y).even }\n\n[ [ 0, 2 ], [ 1, 1 ], [ 2, 2 ], [ 4, 2 ], [ 5, 1 ], [ 8, 2 ], [ 10, 2 ] ]\n```\n\n## var clause\n\nA var clause lets you create a new variable binding that you can use in your expressions.\nThe scope of the name extends to all clauses to the right and in the body.\n\n```supercollider\nvar name = expr\n```\n\nUnlike the generator clause, the name is bound to a single value, it doesn't iterate.\n\n```supercollider\nall {: z, x <- (1..20), var z = (x*x-x) div: 2, z.odd }\n\n[ 1, 3, 15, 21, 45, 55, 91, 105, 153, 171 ]\n```\n\n## side effect clause\n\nThis clause lets you insert code to do some side effect like printing.\n\n```supercollider\n\\\n```\n expr\n\n```supercollider\nall {: z, x <- (1..20), var z = (x*x-x) div: 2,\n```\n [x,z].postln, z.even }\n\n## termination clause\n\nThe termination clause is for stopping further searching for results. Once the expression becomes false,\nthe routine halts."}
+{"text": "ause is for stopping further searching for results. Once the expression becomes false,\nthe routine halts.\n\n```supercollider\n:while expr\n```\n\nusing a guard\n\n```supercollider\nall {: z, x <- (1..20), var z = (x*x-x) div: 2,\n```\n [x,z].postln, z < 50 }\n\nusing a termination clause. this one stops searching, so does less work than the above.\n\n```supercollider\nall {: z, x <- (1..20), var z = (x*x-x) div: 2,\n```\n [x,z].postln, :while z < 50 }\n\n# Constrained Search\n\nlist comprehensions can solve constrained combinatorial problems like this one:\n\nBaker, Cooper, Fletcher, Miller, and Smith live on different floors of an apartment house that contains only five floors.\nBaker does not live on the top floor. Cooper does not live on the bottom floor.\nFletcher does not live on either the top or the bottom floor. Miller lives on a higher floor than does Cooper.\nSmith does not live on a floor adjacent to Fletcher's. Fletcher does not live on a floor adjacent to Cooper's.\nWhere does everyone live?\n\n```supercollider\n(\nz = {: [baker, cooper, fletcher, miller, smith] ,\n var floors = (1..5),\n baker <- floors, baker != 5, // Baker does not live on the top floor.\n // remove baker's floor from the list.\n // var creates a new scope, so the '"}
+{"text": " floor.\n // remove baker's floor from the list.\n // var creates a new scope, so the 'floors' on the left is a new binding.\n var floors = floors.removing(baker),\n cooper <- floors, cooper != 1, // Cooper does not live on the bottom floor.\n var floors = floors.removing(cooper), // remove cooper's floor from the list.\n fletcher <- floors, (fletcher != 5) && (fletcher != 1) // Fletcher does not live on either top or bottom floor.\n && (absdif(fletcher, cooper) > 1), // Fletcher does not live on a floor adjacent to Cooper's.\n var floors = floors.removing(fletcher), // remove fletcher's floor\n miller <- floors, miller > cooper, // Miller lives on a higher floor than does Cooper.\n var floors = floors.removing(miller), // remove miller's floor\n smith <- floors, absdif(fletcher, smith) > 1 // Smith does not live on a floor adjacent to Fletcher's.\n};\n);\n\nz.next; // [3, 2, 4, 5, 1 ]\nz.next; // nil. only one solution\n```\n\ncombinatorial problems can take a lot of time to run.\nyou can reorder the above tests to make it run faster. generally you want to search the most constrained variables first.\nthe most constrained person above is fletcher, so they should be searched first, then cooper, etc.\n\n# Grammar\n\nHere is the BNF grammar for"}
+{"text": "ched first, then cooper, etc.\n\n# Grammar\n\nHere is the BNF grammar for list comprehensions in SC.\n\n```supercollider\n[ ] - optional\n{ } - zero or more\n\n\n```\n= \"{:\" ',' \"}\"\n\n ::= \n\n ::= { \";\" }\n\n ::= { ',' }\n\n ::= | | | | \n\n ::= \"<-\" \n\n ::= \n\n ::= \"var\" \"=\" \n\n ::= \"::\" \n\n ::= \":while\" \n\n# Code Generation\n\nFor each of the above clauses, here is how the code is generated. The body acts as the innermost qualifier.\nBy understanding these translations, you can better understand how scoping and control flow work in list comprehensions.\n\n- generator ||\n```supercollider\nexpr.do {|name| ..next qualifier.. }\n```\n\n- guard ||\n```supercollider\nif (expr) { ..next qualifier.. }\n```\n\n- binding ||\n```supercollider\n{|name| ..next qualifier.. }.value(expr)\n```\n\n- side effect ||\n```supercol"}
+{"text": "| ..next qualifier.. }.value(expr)\n```\n\n- side effect ||\n```supercollider\nexpr ; ..next qualifier..\n```\n\n- termination ||\n```supercollider\nif (expr) { ..next qualifier.. }{ nil.alwaysYield }\n```"}
+{"text": "SuperCollider schelp — HelpSource/Guides/UGens-and-Synths.schelp\n\nUnit Generators and Synths\nIntroduction to some fundamental concepts\nCategory: Server>Nodes\n\nA unit generator is an object that processes or generates sound. There are many classes of unit generators, all of which derive from the class UGen.\n\nUnit generators in SuperCollider can have many inputs, but always have a single output. Unit generator classes which would naturally have several outputs such as a panner, return an array of unit generators when instantiated. The convention of having only a single output per unit generator allows the implementation of multiple channels by using arrays of unit generators. (See Multichannel-Expansion for more details.)\n\n# Instantiation. Audio Rate, Control Rate\n\nA unit generator is created by sending the 'ar' or 'kr' message to the unit generator's class object. The 'ar' message creates a unit generator that runs at audio rate. The 'kr' message creates a unit generator that runs\nat control rate. Control rate unit generators are used for low frequency or slowly changing control signals. Control rate unit generators produce only a single sample per control cycle and therefore use less processing power than audio rate unit generators.\n\nThe input parameters for a unit generator are given in the documentation for that class.\n\n```supercollider\nFSinOsc.ar(800, 0.0, 0.2); // create a sine oscillator at 800 Hz, phase 0.0, amplitude 0.2\n```\n\nA unit generator's signal inputs can be other unit generators, scalars, or arrays of"}
+{"text": "2\n```\n\nA unit generator's signal inputs can be other unit generators, scalars, or arrays of unit generators and scalars.\n\n# SynthDefs and Synths\n\nIn order to play a unit generator one needs to compile it in a SynthDef and play it on the server in a Synth. A synth node is a container for one or more unit generators that execute together. A SynthDef is like a kind of pattern for creating synth nodes on the server.\n\n```supercollider\ns.boot; // boot the server\n\n// compile and send this def\nSynthDef.new(\"FSinOsc-test\", { Out.ar(0, FSinOsc.ar(800, 0, 0.2)) }).send(s); // out channel 0\n\n// now create a Synth object which represents a synth node on the server\nx = Synth.new(\"FSinOsc-test\");\n\n// free the synth\nx.free;\n```\n\nThe synth node created above could also be created using 'messaging style', thus saving the overhead of a clientside Synth object:\n\n```supercollider\nn = s.nextNodeID;\ns.sendMsg(\"/s_new\", \"FSinOsc-test\", n);\ns.sendMsg(\"/n_free\", n);\n```\n\nBecause any expression returns its value, we can nest the first two lines above for convenience. (See Expression-Sequence for more detail.)\n\n```supercollider\ns.sendMsg(\"/s_new\", \"FSinOsc-test\", n = s.nextNodeID;);\ns.sendMsg(\"/n_free\", n);\n```\n\nIt is VERY important and"}
+{"text": "odeID;);\ns.sendMsg(\"/n_free\", n);\n```\n\nIt is VERY important and useful to understand the messaging structure which underlies the clientside Synth, Group, Buffer, and Bus objects. See NodeMessaging, Server_Tutorial, and ClientVsServer for more detail.\n\nAs a convenience the 'play' method of class Function will compile a SynthDef and create and play a synth using the function for you. With this method an Out ugen will be created for you if you do not do so explicitly.\n\n```supercollider\n{ FSinOsc.ar(800, 0, 0.2) }.play; // create and play a sine oscillator at 800 Hz\n```\n\n# Building Patches\n\nYou can do math operations on unit generators and the result will be another unit generator. Doing math on unit generators is not doing any signal calculation itself - it is building the network of unit generators that will execute once they are played in a Synth. This is the essential thing to understand: Synthesis networks, or in other words signal flow graphs are created by executing expressions of unit generators. The following expression creates a flow graph whose root is an instance of BinaryOpUGen which performs the '+' operation. Its inputs are the FSinOsc and BrownNoise unit generators.\n\n```supercollider\nFSinOsc.ar(800, 0.0, 0.2) + BrownNoise.ar(0.2); // press enter and look at the post window\n\n{FSinOsc.ar(800, 0.0, 0.2) + BrownNoise.ar(0.2)}.play; // play it\n```"}
+{"text": "SuperCollider schelp — HelpSource/Reference/Literals.schelp\n\nLiterals\nvalues with a direct syntactic representation\nSee also: Classes/Number, Classes/Integer, Classes/Float, Classes/SimpleNumber, Classes/String, Classes/Array, Classes/Symbol\nCategory: Language\n\nLiterals are values which have a direct syntactic representation.\nThe following sections describe the types of literals that can be represented.\n\n# Numbers\n\n## Integers\nAn integer is any series of digits optionally preceded by a minus sign:\n\n```supercollider\n-13\n666\n2112\n96\n```\n\nThey can also also be expressed in hexadecimal with the prefix\n```supercollider\n0x\n```\n and\neither uppercase or lowercase letters:\n\n```supercollider\n0xa // 10\n-0xd // -13\n0x29A // 666\n0x840 // 2112\n0x60 // 96\n```\n\n## Floats\nA float, or floating-point number, is one or more decimal digits, followed by a\ndecimal point, followed by one or more decimal digits.\nYou must have digits on both sides of the decimal point.\nIn SuperCollider, floating-point numbers are always 64-bit, except within a\nFloatArray.\n\nExamples of floats:\n\n```supercollider\n0.39\n98.6\n1.0\n-0.5\n```\n\nExponential notation is also supported:\n\n```supercollider\n1.2e4\n1E-4\n```\n\nThe keyword\n```supercollider\npi\n```\n can also be used by itself"}
+{"text": "\n1E-4\n```\n\nThe keyword\n```supercollider\npi\n```\n can also be used by itself, or appended to a float or\ninteger to create a floating point constant:\n\n```supercollider\npi\n2pi\n0.5pi\n-0.25pi\n```\n\nThe keyword\n```supercollider\ninf\n```\n represents infinity, and is also treated as an instance\nof Float.\n\n```supercollider\ninf // and beyond!\n-inf\n```\n\n## Radix\nNumbers can also be written in radices other than base 10 up to base 36.\nThe radix is specified in base 10, followed by the letter 'r', followed by the\nvalue written in that radix using characters 0-9 and A-Z (or a-z) for digit\nvalues from 0 to 35. For example, you can write hexadecimal numbers as follows:\n\n```supercollider\n16rF // 15\n16ra9 // 169\n36rZIGZAG // 2147341480\n```\n\nBinary numbers can be written as follows:\n\n```supercollider\n2r01101011\n```\n\nFloating point values may also be specified in any base. However, only\nuppercase letters may be used past the decimal point for bases greater than 10.\nThis eliminates ambiguity: if lowercase letters were allowed,\n\n```supercollider\n36rA.bitNot\n```\n might be a function call, or it might be\n\n```supercollider\n36rA.BITNOT == 10.320080118934\n```\n.\n\n```supercollider\n12r4a.ab // wrong\n12r4a.AB // works\n12r4A.AB // better\n```\n\nHexidecimal numbers notated with\n```supercollider\n0x\n```\n may only be"}
+{"text": " // better\n```\n\nHexidecimal numbers notated with\n```supercollider\n0x\n```\n may only be expressed as integers.\n\n## Scale Degrees\nInteger numbers as scale degrees supports accidentals notation by adding the suffixes s for sharp and b for flat.\nAccidentals are represented as floating point values,\nwhere each 0.1 of difference to the nearest integer corresponds to 100 cents (i.e., a semitone in 12TET).\nWhile the digit to the left of the decimal separator is a degree, and thus is affected by tuning and scale,\nthe digits to the right are not, and are always in cents. (See Scale#-degreeToRatio)\n\n```supercollider\n2s == 2.1 // scale degree two, sharp\n2b == 1.9 // scale degree two, flat\n2ss == 2.2 // scale degree two, double sharp\n2bb == 1.8 // scale degree two, double flat\n```\n\nUp to four:\n\n```supercollider\n2ssss == 2.4\n2bbbb == 1.6\n```\n\nWith negative scale degrees it reverses:\n\n```supercollider\n-2s == -1.9\n-2b == -2.1\n-2ss == -1.8\n-2bb == -2.2\n```\n\nAccidentals can also specify cents deviation up to 499 cents:\n\n```supercollider\n2b50 == 1.95 // scale degree two, fifty cents flat\n2s204 == 2.204 // scale degree two, 204 cents sharp\n```\n\n# Characters\n\nCharacters are preceded by a dollar sign:\n\n```supercollider"}
+{"text": "\n# Characters\n\nCharacters are preceded by a dollar sign:\n\n```supercollider\n$A\n$B\n$C\n$.\n$$\n```\n\nAs in C and Java, backslash ('\\') is the escape character.\nEscaping has two main purposes. First, to insert non-printing characters into a\nString. Secondly, to allow a String or Symbol delimiter to be included in the\ncontents. For String, double-quote marks indicate the beginning and ending of\nthe String literal. To put a double-quote in the middle of the string, the\nnormal meaning of double-quote must be suspended (\"escaped\"), as in\n\n```supercollider\n\"He repeated, \\\"Madam, I'm Adam,\\\" only this time he had said it backward.\"\n```\n\nIn all cases, the \\ as an escape character does not appear in the String or\nSymbol. This is a frequent source of confusion for Windows file paths:\ne.g.,\n```supercollider\n\"C:\\Users\\Somebody\\SuperCollider\"\n```\n translates into\n`C:UsersSomebodySuperCollider`. The way to notate a literal backslash\ninside a String or Symbol is with a double-backslash:\n\n```supercollider\n\"C:\\\\Users\\\\Somebody\\\\SuperCollider\"\n```\n. (Note, however, that it is\npreferable to write file paths using forward slashes, regardless of platform:\n\n```supercollider\n\"C:/Users/Somebody/SuperCollider\"\n```\n.\n\nThe following are the recognized escape characters"}
+{"text": "/Users/Somebody/SuperCollider\"\n```\n.\n\nThe following are the recognized escape characters in SuperCollider. A\nbackslash before any other character will simply produce that character.\n\n```supercollider\n$\\t // tab (horizontal tab)\n$\\f // form feed\n$\\v // vertical tab\n$\\n // newline (linefeed)\n$\\r // carriage return\n$\\\\ // backslash`\n$ // the space\n```\n\n# Symbols and Strings\n\n## Symbols\nA symbol can be written in two ways. One method is to enclose the contents in\nsingle quotes. Any printing character may be used within a symbol except for\nnon-space whitespace characters (\n```supercollider\n\\f, \\n, \\r, \\t, \\v\n```\n). Any single quotes\nwithin the symbol must be escaped (\n```supercollider\n\\'\n```\n).\n\n```supercollider\n'x'\n'aiff'\n'BigSwiftyAndAssoc'\n'nowhere here'\n'somewhere there'\n'.+o*o+.'\n'\\'symbol_within_a_symbol\\''\n```\n\nA second way of notating symbols is by prefixing the word with a backslash.\nThis is only legal if the symbol consists of a single word (a sequence\nof alphanumeric and/or underscore characters).\n\n```supercollider\n\\x\n\\aiff\n\\Big_Swifty_And_Assoc\n\\not really a symbol // illegal\n```\n\nYou can also specify integer symbols this way, but if the symbol starts with a digit, it cannot contain letters.\n\n```"}
+{"text": "```\n\nYou can also specify integer symbols this way, but if the symbol starts with a digit, it cannot contain letters.\n\n```supercollider\n\\1234;\n\\892342534;\n\\3456meow // now illegal\n```\n\n## Strings\n\nStrings are written in double quotes:\n\n```supercollider\n\"This is a string.\"\n```\n\nIf two or more strings are lexically adjacent, then they combine into a larger string:\n\n```supercollider\na = \"st\" \"ri\" \"ng\"\na.size // 6\n```\n\nStrings may span more than one line. The newline characters become part of the string:\n\n```supercollider\na = \"st\nri\nng\n\"\na.size // 9\n```\n\nNote:\nSince version 3.15, the newline character is guarented to be '\\n' regardless of the contents of the source file.\n\nThe SuperCollider IDE uses UTF-8 to decode and display strings.\nSee String#Character encodings##String for more information.\n\n# Identifiers\n\nNames of methods and variables begin with a lower case alphabetic character,\nfollowed by zero or more alphanumeric or underscore characters.\n\n```supercollider\nvar abc, z123, trigger_func;\nvar 1var; // not legal\nvar _hmm; // not legal\nvar hmm_; // Although this is legal, avoid it, since setter functions in\n // SuperCollider typically end with underscores.\n```\n\n# Class Names\n\nClass names always begin with a capital letter followed by zero or more\nalphanumeric or underscore characters.\n\n```supercollider\nObject\nP"}
+{"text": " or more\nalphanumeric or underscore characters.\n\n```supercollider\nObject\nPoint\nSynth\nSinOsc\nPan2\nMyClass_LikesUnderscores // legal\nMyClass_ // legal, but avoid\n```\n\n# Special Values\n\nThe singular instances of the classes True, False and Nil can\nbe expressed with keywords\n```supercollider\ntrue\n```\n,\n```supercollider\nfalse\n```\n, and\n```supercollider\nnil\n```\n.\n\n```supercollider\nx = true;\ny = false;\nz = nil;\n```\n\n# Arrays\n\nArrays of literals are created at compile time and are written with a # preceding the array as follows:\n\n```supercollider\n#[1, 2, 'abc', \"def\", 4]\n```\n\nLiteral Arrays must be used as is and may not be altered at run time.\n\nIn literal Arrays names are interpreted as symbols. This is not the case in regular Arrays, where they are interpreted as variable names:\n\n```supercollider\n#[foo, bar] // this is legal; an Array of Symbols\n[foo, bar] // this is only legal if foo and bar have been declared as variables\n```\n\nArrays and other collections may also be created dynamically which is explained in Collection.\nUsing a literal Array is faster than building an array dynamically every time you need it.\n\nWhen nesting literal arrays, only the outermost literal array needs the '#' character.\n\n```supercollider\n#[[1, 2, 3], [4, 5, 6]]\n```\n\nLiteral Arrays can be useful for things such as tables of const"}
+{"text": "], [4, 5, 6]]\n```\n\nLiteral Arrays can be useful for things such as tables of constants, for example note names:\n\n```supercollider\n(\n// build a table of note names\nvar table = ();\nvalue {\n var semitones = [0, 2, 4, 5, 7, 9, 11];\n var naturalNoteNames = [\"c\", \"d\", \"e\", \"f\", \"g\", \"a\", \"b\"];\n\n (0..9).do {|o|\n naturalNoteNames.do {|c, i|\n var n = (o + 1) * 12 + semitones[i];\n table[(c ++ o).asSymbol] = n;\n table[(c ++ \"s\" ++ o).asSymbol] = n + 1;\n table[(c ++ \"ss\" ++ o).asSymbol] = n + 2;\n table[(c ++ \"b\" ++ o).asSymbol] = n - 1;\n table[(c ++ \"bb\" ++ o).asSymbol] = n - 2;\n };\n };\n};\n\n// translate note names to midi keys\ntable.atAll(#[c4, e4, gs4, c5, e5, gs5, c6])\n)\n```\n\n# Compiler limits\n\nThere is no theoretical limit on the number of literals in a single function, if those literals are used as freestanding objects. (Of course, there remains the practical limits of system memory and the processor time required to keep track of all the objects.)\n\nThe following are a special category of literal, called selectors.\n\n- Class names\n- Method names\n- Function definitions (enclosed in curly braces\n```supercollider\n{ }\n```\n)\n\nHere, there are four"}
+{"text": "losed in curly braces\n```supercollider\n{ }\n```\n)\n\nHere, there are four selectors:\n```supercollider\nSinOsc\n```\n,\n```supercollider\nar\n```\n,\n```supercollider\nplay\n```\n and the entire function containing SinOsc.\n\n```supercollider\n{ SinOsc.ar(440, 0, 0.1) }.play;\n```\n\nA single function may contain no more than 256 selectors. If this limit is exceeded, a compiler error is printed:\n\n`ERROR: Selector table too big: too many classes, method selectors or function definitions in this function. Simplify the function.`\n\nNote:\nCode submitted for interactive execution is first compiled into a function. A very large block of code, spanning several thousand lines, may run into this limitation if it doesn't break down the tasks into smaller functions. In general, code is easier to maintain if it is reasonably modular, with small functions handling clearly-defined parts of the problem. This error message is a signal that the code has become too complex for a loose or \"flat\" code structure.\n\n## What counts as \"inside the function\"?\n\nSelectors are counted only toward the function definition currently being compiled.\n\n```supercollider\n{ x.foo };\n\n{ x.bar };\n```\n\nBoth functions contain exactly one selector. They are separate functions. The use of \"foo\" in one function doesn't affect the number of selectors in another function.\n\n```supercollider\n{\n var f = { |n|\n if(n > 1) { n * f.value(n-1) } { 1 }\n };\n\n f.value(10);\n}.value;\n```\n\nThe outer function includes only the selector\n```s"}
+{"text": "\n };\n\n f.value(10);\n}.value;\n```\n\nThe outer function includes only the selector\n```supercollider\nvalue\n```\n. The other selectors —\n```supercollider\n>\n```\n,\n```supercollider\n*\n```\n,\n```supercollider\n-\n```\n — belong to the inner function definition and don't affect the outer function's number of selectors.\n\nSo, one possible easy way to work around the limitation is to break up a large block of code into several functions that are value'd successively:\n\n```supercollider\n{\n ... a bunch of code ...\n}.value;\n\n{\n ... a bunch of code ...\n}.value;\n\n{\n ... a bunch of code ...\n}.value;\n```"}
+{"text": "SuperCollider schelp — HelpSource/Tutorials/A-Practical-Guide/PG_02_Basic_Vocabulary.schelp\n\nPattern Guide 02: Basic Vocabulary\nCommon patterns to generate streams of single values\nSee also: Tutorials/A-Practical-Guide/PG_01_Introduction, Tutorials/A-Practical-Guide/PG_03_What_Is_Pbind\nCategory: Streams-Patterns-Events>A-Practical-Guide, Tutorials>Pattern-Guide\n\n# Basic Vocabulary: Generating values\n\nBefore getting to the really cool things patterns can do, we need to build up a basic vocabulary. We'll start with some words, then move into phrases in the next tutorial.\n\nSome of the patterns will be demonstrated with a Pbind construct. This is a taste of things to come — sequencing sonic events using patterns. Don't worry about how Pbind works just yet... all in good time.\n\nLet's start with a very quick reference of some basic patterns. More complete descriptions follow this list. The list might seem long at first, but concentrate your attention on the patterns called \"primary patterns\". They are the most basic, and commonly used.\n\nAgain, the purpose is to start learning the vocabulary of patterns — like learning new words when studying a human language. You can always come back and look at the rest later.\n\nFor more information on any of these patterns, select the class name and use the help key for your editor to open its help file.\n\n# Quick reference\n\n## Primary Patterns\n\n-\n```supercollider\nPseq(list,"}
+{"text": "uick reference\n\n## Primary Patterns\n\n-\n```supercollider\nPseq(list, repeats, offset)\n```\n || Play through the entire list\n```supercollider\nrepeats\n```\n times. Like\n```supercollider\nlist.do\n```\n.\n-\n```supercollider\nPrand(list, repeats)\n```\n || Choose items from the list randomly (same as\n```supercollider\nlist.choose\n```\n).\n-\n```supercollider\nPxrand(list, repeats)\n```\n || Choose randomly, but never repeat the same item twice in immediate succession.\n-\n```supercollider\nPshuf(list, repeats)\n```\n || Shuffle the list in random order, and use the same random order\n```supercollider\nrepeats\n```\n times. Like\n```supercollider\nlist.scramble\n```\n.\n-\n```supercollider\nPwrand(list, weights, repeats)\n```\n || Choose randomly, according to weighted probabilities (same as\n```supercollider\nlist.wchoose(weights)\n```\n).\n\n-\n```supercollider\nPseries(start, step, length)\n```\n || Arithmetic series (addition).\n-\n```supercollider\nPgeom(start, grow, length)\n```\n || Geometric series (multiplication).\n\n-\n```supercollider\nPwhite(lo, hi, length)\n```\n || Random numbers, equal distribution (\"white noise\"). Like\n```supercollider\nrrand(lo, hi)\n```\n .\n-\n```supercollider\nPexprand(lo, hi, length)\n```\n"}
+{"text": "i)\n```\n .\n-\n```supercollider\nPexprand(lo, hi, length)\n```\n || Random numbers, exponential distribution. Like\n```supercollider\nexprand(lo, hi)\n```\n .\n-\n```supercollider\nPbrown(lo, hi, step, length)\n```\n || Brownian motion, arithmetic scale (addition).\n\n-\n```supercollider\nPfunc(nextFunc, resetFunc)\n```\n || Get the stream values from a user-supplied function.\n-\n```supercollider\nPfuncn(func, repeats)\n```\n || Get values from the function, but stop after\n```supercollider\nrepeats\n```\n items.\n-\n```supercollider\nProut(routineFunc)\n```\n || Use the function like a routine. The function should return values using\n```supercollider\n.yield\n```\n or\n```supercollider\n.embedInStream\n```\n.\n\n## Additional List Patterns\n\n-\n```supercollider\nPser(list, repeats, offset)\n```\n || Play through the list as many times as needed, but output only\n```supercollider\nrepeats\n```\n items.\n-\n```supercollider\nPslide(list, repeats, len, step, start, wrapAtEnd)\n```\n || Play overlapping segments from the list.\n\n-\n```supercollider\nPwalk(list, stepPattern, directionPattern, startPos)\n```\n || Random walk over the list.\n\n-\n```supercollider\nPlace(list, repeats, offset)\n```\n || Interl"}
+{"text": "\n-\n```supercollider\nPlace(list, repeats, offset)\n```\n || Interlace any arrays found in the main list.\n-\n```supercollider\nPpatlace(list, repeats, offset)\n```\n || Interlace any patterns found in the main list.\n-\n```supercollider\nPtuple(list, repeats)\n```\n || Collect the list items into an array as the return value.\n\n## Additional Random Number Generators\n\n-\n```supercollider\nPgbrown(lo, hi, step, length)\n```\n || Brownian motion, geometric scale (multiplication).\n\n-\n```supercollider\nPbeta(lo, hi, prob1, prob2, length)\n```\n || Beta distribution, where\n```supercollider\nprob1 = α\n```\n (alpha) and\n```supercollider\nprob2 = β\n```\n (beta).\n-\n```supercollider\nPcauchy(mean, spread, length)\n```\n || Cauchy distribution.\n-\n```supercollider\nPgauss(mean, dev, length)\n```\n || Guassian (normal) distribution.\n-\n```supercollider\nPhprand(lo, hi, length)\n```\n || Returns the greater of two equal-distribution random numbers.\n-\n```supercollider\nPlprand(lo, hi, length)\n```\n || Returns the lesser of two equal-distribution random numbers.\n-\n```supercollider\nPmeanrand(lo, hi, length)\n```\n || Returns the average of two equal-distribution random numbers, i.e.,\n```"}
+{"text": ", length)\n```\n || Returns the average of two equal-distribution random numbers, i.e.,\n```supercollider\n(x + y) / 2\n```\n.\n-\n```supercollider\nPpoisson(mean, length)\n```\n || Poisson distribution.\n\n-\n```supercollider\nPprob(distribution, lo, hi, length, tableSize)\n```\n || Arbitrary distribution, based on a probability table.\n\n# Functional descriptions of patterns\n\n## List Patterns\n\nThe most obvious thing one would want to do with a pattern is to give it a list of values and have it read them out in order. You have a couple of choices, which differ in their handling of the\n```supercollider\nrepeats\n```\n parameter.\n\n-\n```supercollider\nPseq(list, repeats, offset)\n```\n || Play through the entire list\n```supercollider\nrepeats\n```\n times.\n-\n```supercollider\nPser(list, repeats, offset)\n```\n || Play through the list as many times as needed, but output only\n```supercollider\nrepeats\n```\n items.\n\n```supercollider\nPseq(#[1, 2, 3], 4).asStream.all; // 12 items = 4 repeats * 3 items\nPser(#[1, 2, 3], 4).asStream.all; // 4 items only\n```\n\nPseq is an obvious choice for streaming out known pitch and rhythm values.\n\nBefore playing a Pbind pattern such as this, make sure the server is booted.\n\n```supercollider\ns.boot;\n\n(\np = Pbind(\n \\degree, Pseq(#[0, 0"}
+{"text": "ider\ns.boot;\n\n(\np = Pbind(\n \\degree, Pseq(#[0, 0, 4, 4, 5, 5, 4], 1),\n \\dur, Pseq(#[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1], 1)\n).play;\n)\n```\n\nTo stop the examples in this file, use the \"stop\" keyboard shortcut (cmd-. on macOS, alt-. on Windows, check documentation for other editors). Or:\n\n```supercollider\np.stop;\n```\n\nA variation, Pslide, plays overlapping segments of the input list.\n\n-\n```supercollider\nPslide(list, repeats, len, step, start, wrapAtEnd)\n```\n || Play overlapping segments from the list.\n\n-\n```supercollider\nrepeats\n```\n || number of segments\n-\n```supercollider\nlen\n```\n || length of each segment\n-\n```supercollider\nstep\n```\n || is how far to step the start of each segment from previous.\n-\n```supercollider\nstart\n```\n || what index to start at.\n-\n```supercollider\nwrapAtEnd\n```\n || if true (default), indexing wraps around if goes past beginning or end. If false, the pattern stops if it hits a nil element or goes outside the list bounds.\n\nIf\n```supercollider\nstep == 1\n```\n, then the first segment is at\n```supercollider\nstart\n```\n, the second at\n```supercollider\nstart + 1\n```\n, and so on.\n\n```supercollider\nPslide("}
+{"text": "percollider\nstart + 1\n```\n, and so on.\n\n```supercollider\nPslide(#[1, 2, 3, 4, 5, 6, 7, 8], 10, 3, 1, 0, false).asStream.all;\n\n// or, to show the segments as separate arrays\nPslide(#[1, 2, 3, 4, 5, 6, 7, 8], 10, 3, 1, 0, false).clump(3).asStream.all;\n\n// Flock of Seagulls!\n(\np = Pbind(\n \\degree, Pslide((-6, -4 .. 12), 8, 3, 1, 0),\n \\dur, Pseq(#[0.1, 0.1, 0.2], inf),\n \\sustain, 0.15\n).play;\n)\n```\n\n## Random-order list patterns\n\n-\n```supercollider\nPrand(list, repeats)\n```\n || Choose items from the list randomly (same as\n```supercollider\nlist.choose\n```\n).\n\n```supercollider\n// Prand: given scale degrees (pentatonic) with equal probability of each\n(\np = Pbind(\n \\degree, Prand([0, 1, 2, 4, 5], inf),\n \\dur, 0.25\n).play;\n)\n```\n\n-\n```supercollider\nPxrand(list, repeats)\n```\n || Choose randomly, but never repeat the same item twice in immediate succession.\n\n```supercollider\n// Pxrand: same as above but never repeats a pitch twice in a row\n(\np = Pbind(\n \\degree, Pxrand([0, 1, 2, 4, 5], inf),\n \\dur, 0.25\n).play;\n)\n```\n\n-\n```su"}
+{"text": ", 2, 4, 5], inf),\n \\dur, 0.25\n).play;\n)\n```\n\n-\n```supercollider\nPshuf(list, repeats)\n```\n || Shuffle the list in random order, and use the same random order\n```supercollider\nrepeats\n```\n times. Like\n```supercollider\nlist.scramble\n```\n.\n\n```supercollider\n// Pshuf: randomly ordered once and repeated\n(\np = Pbind(\n \\degree, Pshuf([0, 1, 2, 4, 5], inf),\n \\dur, 0.25\n).play;\n)\n```\n\n-\n```supercollider\nPwrand(list, weights, repeats)\n```\n || Choose randomly, according to weighted probabilities (same as\n```supercollider\nlist.wchoose(weights)\n```\n).\n\n```supercollider\n// Pwrand: these probabilities favor triadic notes from scale degrees\n(\np = Pbind(\n \\degree, Pwrand((0..7), [4, 1, 3, 1, 3, 2, 1].normalizeSum, inf),\n \\dur, 0.25\n).play;\n)\n```\n\n-\n```supercollider\nPwalk(list, stepPattern, directionPattern, startPos)\n```\n || Random walk over the list. This pattern is a bit more complicated; see its Pwalk##help file for details.\n\n## Interlacing values and making arrays\n\nThese are opposing operations: interlacing means splitting arrays and merging them into a stream of single values, and arrays can be made out of single-value streams as well.\n\n-\n```supercollider\nPlace(list, repeats, offset)\n```"}
+{"text": "reams as well.\n\n-\n```supercollider\nPlace(list, repeats, offset)\n```\n || Take one from each item in the main array item in succession. Hard to explain, easier to see:\n\n```supercollider\nPlace([0, [1, 2], [3, 4, 5]], 3).asStream.all;\n--> [ 0, 1, 3, 0, 2, 4, 0, 1, 5 ]\n```\n\nIf we turn this into a matrix and read vertically, the original arrays are clearly visible:\n\n```supercollider\nPlace([0, [1, 2], [3, 4, 5]], 3).clump(3).do(_.postln);\n\n[ 0, 1, 3 ] // leftmost column: 0 from first Place item\n[ 0, 2, 4 ] // second column: alternates between 1 and 2, from second Place item\n[ 0, 1, 5 ] // third column: 3, 4, 5 from third Place item\n```\n\n-\n```supercollider\nPpatlace(list, repeats, offset)\n```\n || Take one value from each sub-pattern in order.\n\n```supercollider\n// Hanon exercise\n(\np = Pbind(\n \\degree, Ppatlace([\n Pseries(0, 1, 8), // first, third etc. notes\n Pseries(2, 1, 7) // second, fourth etc. notes\n ], inf),\n \\dur, 0.25\n).play;\n)\n```\n\nThat's also a taste of things to come: Patterns can be nested.\n\n-\n```supercollider\nPtuple(list, repeats)\n```\n || Get one value from each item in the array, and return all of them as an array of values.\n\n"}
+{"text": "ats)\n```\n || Get one value from each item in the array, and return all of them as an array of values.\n\n```supercollider\n// Chords\n// \\degree receives [7, 9, 4], then [6, 7, 4] successively, expanded to chords on the server\n(\np = Pbind(\n \\degree, Ptuple([\n Pseries(7, -1, 8),\n Pseq([9, 7, 7, 7, 4, 4, 2, 2], 1),\n Pseq([4, 4, 4, 2, 2, 0, 0, -3], 1)\n ], 1),\n \\dur, 1\n).play;\n)\n```\n\n## Arithmetic and geometric series\n\nNow, let's move to patterns that produce values mathematically, without using a predefined list.\n\n-\n```supercollider\nPseries(start, step, length)\n```\n || Arithmetic series, successively adding\n```supercollider\nstep\n```\n to the starting value, returning a total of\n```supercollider\nlength\n```\n items.\n-\n```supercollider\nPgeom(start, grow, length)\n```\n || Geometric series, successively multiplying the current value by\n```supercollider\ngrow\n```\n.\n\n```supercollider\n// Use Pseries for a scale and Pgeom for an accelerando\n(\np = Pbind(\n \\degree, Pseries(-7, 1, 15),\n \\dur, Pgeom(0.5, 0.89140193218427, 15)\n).play;\n)\n```\n\nThird-party extension alert : If you want an arithmetic or geometric series to start at one number and end at another specific number, the step size/multiplier must be calculated from the endpoints and"}
+{"text": " to start at one number and end at another specific number, the step size/multiplier must be calculated from the endpoints and the number of items desired. The ddwPatterns quark includes a convenience method,\n```supercollider\nfromEndpoints\n```\n, for both Pseries and Pgeom that performs this calculation. It's necessary to give an exact number of repeats, at least two and less than infinity.\n\n```supercollider\np = Pgeom.fromEndpoints(0.5, 0.1, 15); // error if ddwPatterns not installed\np.postcs;\n```\n\nPrints:\n\n```supercollider\nPgeom(0.5, 0.89140193218427, 15)\n```\n\n## Random numbers and probability distributions\n\n-\n```supercollider\nPwhite(lo, hi, length)\n```\n || Produces\n```supercollider\nlength\n```\n random numbers with equal distribution ('white' refers to white noise).\n-\n```supercollider\nPexprand(lo, hi, length)\n```\n || Same, but the random numbers have an exponential distribution, favoring lower numbers. This is good for frequencies, and also durations (because you need more notes with a shorter duration to balance the weight of longer notes).\n-\n```supercollider\nPbrown(lo, hi, step, length)\n```\n || Brownian motion. Each value adds a random\n```supercollider\nstep\n```\n to the previous value, where the\n```supercollider\nstep\n```\n has an equal distribution between\n```supercollider\n-step\n```\n and\n```supercollider\n+step\n```\n."}
+{"text": "\n```supercollider\n-step\n```\n and\n```supercollider\n+step\n```\n.\n-\n```supercollider\nPgbrown(lo, hi, step, length)\n```\n || Brownian motion on a geometric scale. Each value multiplies a random\n```supercollider\nstep\n```\n factor to the previous value.\n\n-\n```supercollider\nPbeta(lo, hi, prob1, prob2, length)\n```\n || Beta distribution, where\n```supercollider\nprob1 = α\n```\n (alpha) and\n```supercollider\nprob2 = β\n```\n (beta).\n-\n```supercollider\nPcauchy(mean, spread, length)\n```\n || Cauchy distribution.\n-\n```supercollider\nPgauss(mean, dev, length)\n```\n || Gaussian (normal) distribution.\n-\n```supercollider\nPhprand(lo, hi, length)\n```\n || Returns the greater of two equal-distribution random numbers.\n-\n```supercollider\nPlprand(lo, hi, length)\n```\n || Returns the lesser of two equal-distribution random numbers.\n-\n```supercollider\nPmeanrand(lo, hi, length)\n```\n || Returns the average of two equal-distribution random numbers, i.e.,\n```supercollider\n(x + y) / 2\n```\n.\n-\n```supercollider\nPpoisson(mean, length)\n```\n || Poisson distribution.\n\n-\n```supercollider\nPprob(distribution, lo, hi, length, tableSize)\n"}
+{"text": "-\n```supercollider\nPprob(distribution, lo, hi, length, tableSize)\n```\n || Given an array of relative probabilities across the desired range (a histogram) representing an arbitrary distribution, generates random numbers corresponding to that distribution.\n\nTo see a distribution, make a histogram out of it.\n\n```supercollider\nPmeanrand(0.0, 1.0, inf).asStream.nextN(10000).histo(200, 0.0, 1.0).plot;\n```\n\n## Catchall Patterns\n\nNot everything is pre-written as a pattern class. These patterns let you embed custom logic.\n\n-\n```supercollider\nPfunc(nextFunc, resetFunc)\n```\n || The next value is the return value from evaluating\n```supercollider\nnextFunc\n```\n. If\n```supercollider\n.reset\n```\n is called on a stream made from this pattern,\n```supercollider\nresetFunc\n```\n is evaluated. The stream will run indefinitely until\n```supercollider\nnextFunc\n```\n returns\n```supercollider\nnil\n```\n.\n\n-\n```supercollider\nPfuncn(func, repeats)\n```\n || Like Pfunc, output values come from evaluating the function. Pfuncn, however, returns exactly\n```supercollider\nrepeats\n```\n values and then stops. The default number of repeats is 1.\n\n-\n```supercollider\nProut(routineFunc)\n```\n || Use the\n```supercollider\nroutineFunc\n```\n in a routine. The stream's output values are"}
+{"text": " the\n```supercollider\nroutineFunc\n```\n in a routine. The stream's output values are whatever this function\n```supercollider\n.yield\n```\ns. Prout ends when it yields\n```supercollider\nnil\n```\n.\n\nNext, we'll look at the central pattern for audio sequencing: Pbind.\n\nPrevious: A-Practical-Guide/PG_01_Introduction\n\nNext: A-Practical-Guide/PG_03_What_Is_Pbind"}
+{"text": "SuperCollider schelp — HelpSource/Tutorials/A-Practical-Guide/PG_04_Words_to_Phrases.schelp\n\nPattern Guide 04: Words to Phrases\nNesting patterns, arranging music in terms of phrases\nSee also: Tutorials/A-Practical-Guide/PG_03_What_Is_Pbind, Tutorials/A-Practical-Guide/PG_05_Math_on_Patterns\nCategory: Streams-Patterns-Events>A-Practical-Guide, Tutorials>Pattern-Guide\n\n# From words to phrases\n\nA single pattern by itself is not so exciting. But patterns can be used together to get more complex results.\n\n## Patterns within list patterns\n\nWe saw list patterns ( Pseq, Prand, etc.) that returned numbers from a preset list, either in the order given or rearranged randomly. The list may also include other patterns. When a list pattern encounters another pattern in its list, the inner pattern is embedded into the stream. That is, the inner pattern takes over until it runs out of values to return. Then, control returns to the outer list pattern. This is like calling a function in the middle of another function.\n\nThere is no preset limit to the number of levels of embedding.\n\nIf a single pattern is like a word, a list pattern that uses other patterns could be more like a sentence or phrase. You can alternate between different behaviors, either in a predictable order as in the example below, or randomly by using one of the random-order list patterns.\n\n```supercollider\n// Scale segments, in the sequence: up, up, down (repeat)\n(\nTempoClo"}
+{"text": "ider\n// Scale segments, in the sequence: up, up, down (repeat)\n(\nTempoClock.default.tempo = 1;\np = Pbind(\n \\degree, Pseq([\n Pseries({ rrand(0, 7) }, 1, { rrand(4, 8) }), // up (step = 1)\n Pseries({ rrand(0, 7) }, 1, { rrand(4, 8) }), // up (step = 1)\n Pseries({ rrand(7, 14) }, -1, { rrand(4, 8) }) // down (step = -1)\n ], inf),\n \\dur, 0.125\n).play;\n);\n\np.stop;\n```\n\nBut it gets even more fun — list patterns don't care whether they're enclosing value patterns (as in the previous example) or event patterns. That means you can write a set of Pbind-style patterns, each one representing a phrase, and string them together. This next example is longer, but that's only because of a larger number of phrase patterns. The structure is very simple, though:\n```supercollider\nPxrand([Pbind(), Pmono(), Pmono()...], inf)\n```\n . Some of the phrases are written with Pmono to slide between notes.\n\n```supercollider\n(\nSynthDef(\\bass, { |out, freq = 440, gate = 1, amp = 0.5, slideTime = 0.17, ffreq = 1100, width = 0.15,\n detune = 1.005, preamp = 4|\n var sig,\n env = Env.adsr(0.01, 0.3, 0.4, 0.1);\n freq = Lag.kr(freq, slideTime);\n sig ="}
+{"text": ".4, 0.1);\n freq = Lag.kr(freq, slideTime);\n sig = Mix(VarSaw.ar([freq, freq * detune], 0, width, preamp)).distort * amp\n * EnvGen.kr(env, gate, doneAction: Done.freeSelf);\n sig = LPF.ar(sig, ffreq);\n Out.ar(out, sig ! 2)\n}).add;\n);\n\n(\nTempoClock.default.tempo = 132/60;\np = Pxrand([\n Pbind( // repeated notes\n \\instrument, \\bass,\n \\midinote, 36,\n \\dur, Pseq([0.75, 0.25, 0.25, 0.25, 0.5], 1),\n \\legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], 1),\n \\amp, 0.5, \\detune, 1.005\n ),\n Pmono(\\bass, // octave jump\n \\midinote, Pseq([36, 48, 36], 1),\n \\dur, Pseq([0.25, 0.25, 0.5], 1),\n \\amp, 0.5, \\detune, 1.005\n ),\n Pmono(\\bass, // tritone jump\n \\midinote, Pseq([36, 42, 41, 33], 1),\n \\dur, Pseq([0.25, 0.25, 0.25, 0.75], 1),\n \\amp, 0.5, \\detune, 1.005\n ),\n Pmono(\\bass, // diminished triad\n \\midinote, Pseq([36, 39, 36, 42"}
+{"text": ", // diminished triad\n \\midinote, Pseq([36, 39, 36, 42], 1),\n \\dur, Pseq([0.25, 0.5, 0.25, 0.5], 1),\n \\amp, 0.5, \\detune, 1.005\n )\n], inf).play(quant: 1);\n);\n\np.stop;\n```\n\nShortcut notation : Just like you can concatenate arrays with ++, you can also concatenate patterns the same way. Writing\n```supercollider\npattern1 ++ pattern2\n```\n is the same as writing\n```supercollider\nPseq([pattern1, pattern2], 1)\n```\n .\n\n## Some ways to string together patterns\n\n- Sequentially || Each sub-pattern follows the next in the same order every time. Use Pseq or Pser.\n\n- Randomized order || Sub-patterns in completely random order ( Prand ), random order with no repeats ( Pxrand ), or random order according to a set of probabilities ( Pwrand ). Pshuf creates one random ordering and uses it repeatedly.\n\n- Direct array indexing || Patterns can be chosen in arbitrary order by index. This gives you more control than Pwrand. Both Pindex and Pswitch can be used for this.\n\n```supercollider\n// scale degree segments, every fifth choice is odd-numbered only (descending)\n(\nvar n = 10,\n scaleSegments = Array.fill(n, { |i|\n if(i.odd) {\n Pseries(11, -1, rrand(5, 10))\n } {\n Pseries(rrand(-4, 4), 1, i+2)\n }\n });\n"}
+{"text": "5, 10))\n } {\n Pseries(rrand(-4, 4), 1, i+2)\n }\n });\n\nTempoClock.default.tempo = 1;\np = Pbind(\n \\degree, Pswitch(scaleSegments, Pseq([Pwhite(0, n-1, 4), Pwhite(0, n-1, 1).select(_.odd)], inf)),\n \\dur, 0.125\n).play;\n);\n\np.stop;\n```\n\n- Finite state machine (Pfsm, Pdfsm) || A finite state machine is a way of associating an item with its possible successors. It is closer to a \"grammar\" than purely random selection. Pfsm defines a finite state machine as a set of possible \"entry points,\" followed by a list of the possible \"states\" of the machine and, for each state, a list of the possible states that may follow the current state. States may be single values or patterns, meaning that phrases can be linked to other phrases that \"make sense\" in succession (and unwanted transitions can be prevented).\n\nIf this sounds a bit like a Markov chain, that's because the Pfsm implementation is a special case of a Markov chain where there is an equal probability of choosing the next state from the valid successors. In a Markov chain, the probabilities are weighted according to analysis of a real-world data stream.\n\nThe Pfsm help file includes very good examples of organizing single values and pattern phrases. Also see A-Practical-Guide/PG_Cookbook06_Phrase_Network for an application of Pfsm to generate a corny jazz solo.\n\nThe name Pdfsm stands for \"deterministic finite state machine,\" where there is no random selection"}
+{"text": "\n\nThe name Pdfsm stands for \"deterministic finite state machine,\" where there is no random selection.\n\nNote:\nThird-party extension alert : A good Markov chain implementation for SuperCollider exists in the MathLib quark.\n\n## Library of named sub-patterns\n\nOne very effective way to manage phrases is to make a library, or more precisely Dictionary, of sub-patterns, and then call them up one at a time. Psym is the pattern to do this. The advantage here is that you can store the phrases in a separate place, while the pattern that you actually play is much simpler and describes the musical intent at a much higher level.\n\n```supercollider\n// Uses the bass SynthDef above\n(\n~phrases = (\n repeated: Pbind(\n \\instrument, \\bass,\n \\midinote, 36,\n \\dur, Pseq([0.75, 0.25, 0.25, 0.25, 0.5], 1),\n \\legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], 1),\n \\amp, 0.5, \\detune, 1.005\n ),\n octave: Pmono(\\bass,\n \\midinote, Pseq([36, 48, 36], 1),\n \\dur, Pseq([0.25, 0.25, 0.5], 1),\n \\amp, 0.5, \\detune, 1.005\n ),\n tritone: Pmono(\\bass,\n \\midinote, Pseq([36, 42, 41, 33], 1),\n \\dur, Pseq([0.25, 0.25, 0.25, 0.75], 1),\n \\amp, 0.5, \\detune"}
+{"text": "[0.25, 0.25, 0.25, 0.75], 1),\n \\amp, 0.5, \\detune, 1.005\n ),\n dim: Pmono(\\bass,\n \\midinote, Pseq([36, 39, 36, 42], 1),\n \\dur, Pseq([0.25, 0.5, 0.25, 0.5], 1),\n \\amp, 0.5, \\detune, 1.005\n )\n);\n\nTempoClock.default.tempo = 128/60;\n\n// the higher level control pattern is really simple now\np = Psym(Pxrand(#[repeated, octave, tritone, dim], inf), ~phrases).play;\n);\n\np.stop;\n```\n\nA complicated pattern with lots of embedding can be hard to read because it's more work to separate note-level details from the larger structure. The pattern choosing the phrases —\n```supercollider\nPxrand(#[repeated, octave, tritone, dim], inf)\n```\n — is self-explanatory, however, and Psym fills in the details transparently.\n\nNote:\nBecause of some special handling needed for event patterns, there are two versions of Psym. Psym handles event patterns, while Pnsym is for value patterns. Think of it this way: Pbind can be contained within Psym, but it contains Pnsym.\n\n```supercollider\n( Psym ( Pbind ( Pnsym ) ) )\n```\n\n- Good: ||\n\n-\n```supercollider\nPsym(**, (pattern1: Pbind(**))\n```\n\n-\n```supercollider\nPbind(\\some"}
+{"text": "pattern1: Pbind(**))\n```\n\n-\n```supercollider\nPbind(\\someValue, Pnsym(**, (pattern1: Pwhite(**)))\n```\n\n- Bad: ||\n\n-\n```supercollider\nPbind(\\someValue, Psym(**, (pattern1: Pwhite(**)))\n```\n\n## Switching between patterns for individual values\n\nIn the examples above, if a list pattern encounters another pattern in its input values, the subpattern is embedded in its entirety before the list pattern is allowed to continue. Sometimes you might want to get just one value out of the subpattern, and then choose a different subpattern on the next event. Pswitch, Psym and Pnsym have cousins that do exactly this: Pswitch1, Psym1 and Pnsym1.\n\n```supercollider\n// random pitches in two distinct ranges; use a coin toss to decide which for this event\n// 70% low, 30% high\n(\nTempoClock.default.tempo = 1;\np = Pbind(\n \\degree, Pswitch1([Pwhite(7, 14, inf), Pwhite(-7, 0, inf)], Pfunc { 0.7.coin.binaryValue }),\n \\dur, 0.25\n).play;\n);\n\np.stop;\n```\n\nCompare to the following:\n\n```supercollider\n(\np = Pbind(\n \\degree, Pswitch([Pwhite(7, 14, inf), Pwhite(-7, 0, inf)], Pfunc { 0.7.coin.binaryValue }),\n \\dur, 0.25\n).play;\n);\n\np.stop;\n```\n\nW"}
+{"text": "aryValue }),\n \\dur, 0.25\n).play;\n);\n\np.stop;\n```\n\nWith Pswitch, one of the items is chosen from the list and keeps playing until it's finished. But the length of both Pwhite patterns is infinite, so whichever one is chosen first retains control. Pswitch1 does the coin toss on every event and embeds just one item.\n\nPsym1 and Pnsym1 behave similarly, choosing the name to look up the pattern for each event.\n\n## Related: Conditional patterns\n\nPif supports this kind of structure: If the next value from a Boolean pattern is true, return the next item from pattern A, otherwise take it from pattern B. Another way to write the Pswitch1 example is to use a Boolean test directly on Pwhite, instead of writing a Pfunc for the coin toss. This might be clearer to read. However, this works only when there are two alternatives. Pswitch1 and Psym1 allow any number of choices.\n\n```supercollider\n(\nTempoClock.default.tempo = 1;\np = Pbind(\n // translation: if(0.7.coin) { rrand(-7, 0) } { rrand(7, 14 }\n \\degree, Pif(Pwhite(0.0, 1.0, inf) < 0.7, Pwhite(-7, 0, inf), Pwhite(7, 14, inf)),\n \\dur, 0.25\n).play;\n);\n\np.stop;\n```\n\nWe will see in A-Practical-Guide/PG_06e_Language_Control that Pif can be used on values that were previously calculated in the Pbind. It adds considerably to the intelligence Pbind can manage, when its value streams are aware of other values in"}
+{"text": " Pbind. It adds considerably to the intelligence Pbind can manage, when its value streams are aware of other values in the event.\n\nPrevious: A-Practical-Guide/PG_03_What_Is_Pbind\n\nNext: A-Practical-Guide/PG_05_Math_on_Patterns"}
+{"text": "SuperCollider schelp — HelpSource/Tutorials/A-Practical-Guide/PG_Cookbook06_Phrase_Network.schelp\n\nPattern Guide Cookbook 06: Phrase Network\nSequencing by a network of phrases, Articulating notes with PmonoArtic\nSee also: Tutorials/A-Practical-Guide/PG_Cookbook05_Using_Samples, Tutorials/A-Practical-Guide/PG_Cookbook07_Rhythmic_Variations\nCategory: Streams-Patterns-Events>A-Practical-Guide, Tutorials>Pattern-Guide\n\n# Sequencing by a network of phrases\n# Articulating notes with PmonoArtic\n\nTwo for one here!\n\nMost conventional synthesizers have a mode where playing a note while the previous note is still sustaining slides from one note to the other. The PmonoArtic pattern does this based on the event's sustain value. The delta value is the number of beats until the next event; sustain is the number of beats until the note releases. If sustain is shorter than delta, the note should cut off early and the next event should produce a new synth.\n\nThe example uses Pfsm (finite state machine) to arrange a set of predefined phrases in a partially randomized order. Each phrase is followed by a list pointing to the phrases that could legitimately follow the current phrase. That is, it might make musical sense to go from phrase 1 to phrase 2, but not from 1 to 3. Defining the successors for 1 appropriately makes sure that a nonsense transition will not be made.\n\nThis is a long example, but it's only because there are l"}
+{"text": "ately makes sure that a nonsense transition will not be made.\n\nThis is a long example, but it's only because there are lots of phrases. The structure is very simple: just a set of phrases chosen in succession by Pfsm.\n\nNote:\nThird-party extension alert : In this example, the selection of the next phrase is explicitly weighted by repeating array elements, such as\n```supercollider\n#[1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5]\n```\n. A more elegant way to do this is using the WeighBag class in the MathLib quark.\n\n```supercollider\n// the following are equivalent:\na = #[1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5];\n({ a.choose } ! 100).histo(5, 1, 5);\n\na = WeighBag.with((1..5), #[4, 2, 2, 2, 1]);\n({ a.wchoose } ! 100).histo(5, 1, 5);\n```\n\n## Example\n\n```supercollider\n(\n// this SynthDef has a strong attack, emphasizing the articulation\nSynthDef(\\sawpulse, { |out, freq = 440, gate = 0.5, plfofreq = 6, mw = 0, ffreq = 2000, rq = 0.3, freqlag = 0.05, amp = 1|\n var sig, plfo, fcurve;\n plfo = SinOsc.kr(plfofreq, mul:mw, add:1);\n freq = Lag.kr(freq, freqlag) * plfo;\n fcurve = EnvGen.kr(Env.adsr(0, 0."}
+{"text": " * plfo;\n fcurve = EnvGen.kr(Env.adsr(0, 0.3, 0.1, 20), gate);\n fcurve = (fcurve - 1).madd(0.7, 1) * ffreq;\n sig = Mix.ar([Pulse.ar(freq, 0.9), Saw.ar(freq*1.007)]);\n sig = RLPF.ar(sig, fcurve, rq)\n * EnvGen.kr(Env.adsr(0.04, 0.2, 0.6, 0.1), gate, doneAction: Done.freeSelf)\n * amp;\n Out.ar(out, sig ! 2)\n}).add;\n);\n\n(\nTempoClock.default.tempo = 128/60;\n\n// Pmul does only one thing here: take ~amp from each event\n// and replace it with ~amp * 0.4\np = Pmul(\\amp, 0.4, Pfsm([\n #[0, 3, 1], // starting places\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([78, 81, 78, 76, 78, 76, 72, 71, 69, 66], 1),\n \\dur, Pseq(#[0.25, 1.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], 1),\n \\sustain, Pseq(#[0.3, 1.2, 0.3, 0.2, 0.3, 0.2, 0.3, 0.2, 0.3, 0.2],1 ),\n \\amp, Pseq(#[1, 0.5, 0.75, 0.5, 0.75, 0.5, 0.75, 0"}
+{"text": "seq(#[1, 0.5, 0.75, 0.5, 0.75, 0.5, 0.75, 0.5, 0.75, 0.5], 1),\n \\mw, Pseq([0, 0.03, Pseq(#[0], inf)], 1)\n ), #[1, 2, 3, 4, 7],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([64, 66, 69, 71, 72, 73], 1),\n \\dur, Pseq(#[0.25], 6),\n \\sustain, Pseq(#[0.3, 0.2, 0.2, 0.2, 0.3, 0.2], 1),\n \\amp, Pseq(#[1, 0.5, 0.5, 0.5, 0.5, 0.5], 1),\n \\mw, 0\n ), #[1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([69, 71, 69, 66, 64, 69, 71, 69], 1),\n \\dur, Pseq(#[0.125, 0.625, 0.25, 0.25, 0.25, 0.25, 0.25, 0.75], 1),\n \\sustain, Pseq(#[0.2, 0.64, 0.2, 0.2, 0.2, 0.3, 0.3, 0.75], 1),\n \\amp, Pseq(#[0.5, 0.75, 0.5, 0.5, 0.5, 1, 0.5, 0.5], 1),\n \\mw, 0\n ), #[0, 1, 1, 1, 1, 3, 3, 3, 3, 5],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq(["}
+{"text": ", 5],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([72, 73, 76, 72, 71, 69, 66, 71, 69], 1),\n \\dur, Pseq(#[0.25, 0.25, 0.25, 0.083, 0.083, 0.084, 0.25, 0.25, 0.25], 1),\n \\sustain, Pseq(#[0.3, 0.2, 0.2, 0.1, 0.07, 0.07, 0.2, 0.3, 0.2], 1),\n \\amp, Pseq(#[1, 0.5, 0.5, 1, 0.3, 0.3, 0.75, 0.75, 0.5], 1),\n \\mw, 0\n ), #[1, 1, 1, 1, 3, 3, 4, 4, 4],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([64, 66, 69, 71, 72, 73, 71, 69, 66, 71, 69, 66, 64, 69], 1),\n \\dur, Pseq(#[0.25, 0.25, 0.25, 0.25, 0.125, 0.375, 0.166, 0.166, 0.168,\n 0.5, 0.166, 0.166, 0.168, 0.5], 1),\n \\sustain, Pseq(#[0.3, 0.2, 0.2, 0.2, 0.14, 0.4, 0.2, 0.2, 0.2, 0.6, 0.2, 0.2, 0.2, 0.5],1),\n \\amp, Pseq(#[0.5, 0.5, 0.6, 0.8, 1, 0.5, 0.5, 0.5, 0.5, 1,\n 0"}
+{"text": ", 0.6, 0.8, 1, 0.5, 0.5, 0.5, 0.5, 1,\n 0.5, 0.5, 0.5, 0.45], 1),\n \\mw, 0\n ), #[0, 1, 1, 1, 1, 3, 3, 5],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([72, 73, 76, 78, 81, 78, 83, 81, 84, 85], 1),\n \\dur, Pseq(#[0.25, 0.25, 0.25, 0.25, 0.5, 0.5, 0.5, 0.5, 0.125, 1.125], 1),\n \\sustain, Pseq(#[0.3, 0.2, 0.2, 0.2, 0.95, 0.25, 0.95, 0.25, 0.2, 1.13], 1),\n \\amp, Pseq(#[0.7, 0.5, 0.5, 0.5, 0.7, 0.5, 0.8, 0.5, 1, 0.5], 1),\n \\mw, Pseq([Pseq(#[0], 9), 0.03], 1)\n ), #[6, 6, 6, 8, 9, 10, 10, 10, 10, 11, 11, 13, 13],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([83, 81, 78, 83, 81, 78, 76, 72, 73, 78, 72, 72, 71], 1),\n \\dur, Pseq(#[0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,\n 0.25, 2], 1),\n \\sustain, Pseq(#[0.3, 0.3,"}
+{"text": ".25,\n 0.25, 2], 1),\n \\sustain, Pseq(#[0.3, 0.3, 0.2, 0.3, 0.3, 0.3, 0.2, 0.3, 0.2, 0.3, 0.2, 0.3, 2], 1),\n \\amp, Pseq(#[0.5, 0.5, 0.5, 0.8, 0.5, 0.5, 0.5, 0.8, 0.5, 0.8, 0.5,\n 1, 0.4], 1),\n \\mw, Pseq([Pseq([0], 12), 0.03], 1)\n ), #[0, 7, 7, 7, 7, 7, 3, 3, 3, 3],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([69, 71, 72, 71, 69, 66, 64, 69, 71], 1),\n \\dur, Pseq(#[0.25, 0.25, 0.25, 0.25, 0.166, 0.167, 0.167, 0.25, 0.25], 1),\n \\sustain, Pseq(#[0.2, 0.2, 0.3, 0.2, 0.2, 0.2, 0.14, 0.3, 0.2], 1),\n \\amp, Pseq(#[0.5, 0.5, 0.8, 0.5, 0.5, 0.5, 0.5, 0.8, 0.5], 1)\n ), #[3, 3, 3, 4, 4, 5],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([84, 85, 84, 84, 88, 84, 83, 81, 83, 81, 78, 76, 81, 83], 1),\n \\dur, Pseq(#[0.125, 0.535,"}
+{"text": "6, 81, 83], 1),\n \\dur, Pseq(#[0.125, 0.535, 0.67, 1.92, 0.25, 0.166, 0.167, 0.167,\n 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], 1),\n \\sustain, Pseq(#[0.2, 3.12, 0.2, 0.2, 0.2, 0.2, 0.2, 0.15, 0.3, 0.2, 0.2, 0.2,\n 0.3, 0.2], 1),\n \\amp, Pseq(#[1, 0.8, 0.8, 0.8, 1, 1, 0.8, 0.8, 1, 0.8, 0.8, 0.8,\n 1, 0.8], 1),\n \\mw, Pseq([0, 0.005, 0.005, 0.06, Pseq(#[0], 10)], 1)\n ), #[10, 10, 10, 11, 11, 11, 11, 12, 12, 12],\n\n // same as #4, 8va\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq(([64, 66, 69, 71, 72, 73, 71, 69, 66, 71, 69, 66, 64, 69]+12), 1),\n \\dur, Pseq(#[0.25, 0.25, 0.25, 0.25, 0.125, 0.375, 0.166, 0.166, 0.168,\n 0.5, 0.166, 0.166, 0.168, 0.5], 1),\n \\sustain, Pseq(#[0.3, 0.2, 0.2, 0.2, 0.14, 0.4, 0.2, 0.2, 0.2, 0.6, 0.2, 0.2, 0.2, 0"}
+{"text": ".4, 0.2, 0.2, 0.2, 0.6, 0.2, 0.2, 0.2, 0.5],1),\n \\amp, Pseq(#[0.5, 0.5, 0.6, 0.8, 1, 0.5, 0.5, 0.5, 0.5, 1,\n 0.5, 0.5, 0.5, 0.45], 1),\n \\mw, 0\n ), #[11, 11, 11, 11, 11, 12, 12],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([81, 84, 83, 81, 78, 76, 81, 83], 1),\n \\dur, Pseq(#[0.25], 8),\n \\sustain, Pseq(#[0.2, 0.3, 0.3, 0.2, 0.3, 0.2, 0.3, 0.2], 1),\n \\amp, Pseq(#[0.5, 1, 0.5, 0.5, 0.6, 0.5, 0.8, 0.5], 1),\n \\mw, 0\n ), #[0, 9, 9, 11, 11, 12, 12, 12, 12, 12],\n\n // same as #1, 8va\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq(([64, 66, 69, 71, 72, 73]+12), 1),\n \\dur, Pseq(#[0.25], 6),\n \\sustain, Pseq(#[0.3, 0.2, 0.2, 0.2, 0.3, 0.2], 1),\n \\amp, Pseq(#[1, 0.5, 0.5, 0.5, 0.5, 0.5], 1),\n \\mw, 0\n ), #[6, 6, 8, 9, 9, 9, 9, 10, 10, 10, 10, 13, 13, 13],\n\n "}
+{"text": " #[6, 6, 8, 9, 9, 9, 9, 10, 10, 10, 10, 13, 13, 13],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([78, 81, 83, 78, 83, 84, 78, 84, 85], 1),\n \\dur, Pseq(#[0.25, 0.25, 0.5, 0.25, 0.25, 0.5, 0.25, 0.25, 1.75], 1),\n \\sustain, Pseq(#[0.2, 0.3, 0.2, 0.2, 0.3, 0.2, 0.2, 0.3, 1.75], 1),\n \\amp, Pseq(#[0.4, 0.8, 0.5, 0.4, 0.8, 0.5, 0.4, 1, 0.8], 1),\n \\mw, Pseq([Pseq([0], 8), 0.03], 1)\n ), #[8, 13, 13],\n\n PmonoArtic(\\sawpulse,\n \\midinote, Pseq([88, 84, 83, 81, 83, 81, 78, 76, 81, 83], 1),\n \\dur, Pseq(#[0.25, 0.166, 0.167, 0.167,\n 0.25, 0.25, 0.25, 0.25, 0.25, 0.25], 1),\n \\sustain, Pseq(#[0.2, 0.2, 0.2, 0.15, 0.3, 0.2, 0.2, 0.2,\n 0.3, 0.2], 1),\n \\amp, Pseq(#[1, 1, 0.8, 0.8, 1, 0.8, 0.8, 0.8,\n 1, 0.8], 1),\n \\mw, 0\n ), #[10]\n], inf)).play;\n);"}
+{"text": ",\n 1, 0.8], 1),\n \\mw, 0\n ), #[10]\n], inf)).play;\n);\n\np.stop;\n```\n\nPrevious: A-Practical-Guide/PG_Cookbook05_Using_Samples\n\nNext: A-Practical-Guide/PG_Cookbook07_Rhythmic_Variations"}
+{"text": "SuperCollider classlib — SCClassLibrary/Common/Control/OSCBundle.sc\n\n```supercollider\n\n add { arg msg; messages = messages.add(msg) }\n addAll { arg mgs; messages = messages.addAll(mgs) }\n addPrepare { arg msg; preparationMessages = preparationMessages.add(msg) }\n addCancel { arg msg; messages = messages.add(msg); removeOnCancel = removeOnCancel.add(msg) }\n\n // the sound starts at: (next beat + latency) when the preparation is finished\n // the client side task starts at: preparationTime + next beat\n // next beat is 0 if no clock is passed in.\n // eventstreams e.g. take into account the latency internally\n\n schedSend { arg server, clock, quant;\n server = server ?? { Server.default };\n this.doPrepare(server, {\n if(quant.isNil or: { clock.isNil }) {\n this.prSend(server, server.latency)\n } {\n clock.schedAbs(quant.nextTimeOnGrid(clock), {\n this.prSend(server, server.latency);\n });\n };\n });\n }\n\n send { arg server, time, timeOfRequest;\n server = server ?? { Server.default };\n timeOfRequest = timeOfRequest ?? {Main.elapsedTime};\n this.doPrepare(server, { this.prSend(server, time,timeOfRequest) })\n }\n // see atTime helpfile\n "}
+{"text": ", { this.prSend(server, time,timeOfRequest) })\n }\n // see atTime helpfile\n sendAtTime { arg server, atTime, timeOfRequest; // offset by preparation\n server = server ?? { Server.default };\n atTime.schedBundle(this,server,timeOfRequest ?? { Main.elapsedTime});\n }\n\n doPrepare { arg server, onComplete;\n if(preparationMessages.isNil) { ^onComplete.value };\n\n Routine.run {\n server.sync(Condition.new, preparationMessages);\n onComplete.value;\n };\n }\n\n cancel {\n if(removeOnCancel.notNil) {\n messages.removeAll(removeOnCancel);\n }\n }\n\n // private //\n\n prSend { arg server, delta,timeOfRequest;\n if(messages.notNil, {\n if(removeOnCancel.notNil) { messages = messages.collect { |x| x.value } };\n server.listSendBundle(delta ?? { server.latency }, messages);\n })\n }\n\n}\n\nMixedBundle : OSCBundle {\n\n var func;\n\n value { this.subclassResponsibility(thisMethod) }\n\n valueArray {arg args; ^this.value(*args) } // needed to work in FunctionLists\n\n}\n\n///////////////////// OSC\n\nOSCMessageDispatcher : AbstractWrappingDispatcher {\n\n wrapFunc {|funcProxy|\n var func, srcID, recvPort, arg"}
+{"text": "rapFunc {|funcProxy|\n var func, srcID, recvPort, argTemplate;\n func = funcProxy.func;\n srcID = funcProxy.srcID;\n recvPort = funcProxy.recvPort;\n argTemplate = funcProxy.argTemplate;\n if(argTemplate.notNil, { func = OSCArgsMatcher(argTemplate, func)});\n ^case(\n { srcID.notNil && recvPort.notNil }, { OSCFuncBothMessageMatcher(srcID, recvPort, func) },\n { srcID.notNil }, { OSCFuncAddrMessageMatcher(srcID, func) },\n { recvPort.notNil }, { OSCFuncRecvPortMessageMatcher(recvPort, func) },\n { func }\n );\n }\n\n getKeysForFuncProxy {|funcProxy| ^[funcProxy.path];}\n\n value {|msg, time, addr, recvPort| active[msg[0]].value(msg, time, addr, recvPort);}\n\n register {\n thisProcess.addOSCRecvFunc(this);\n registered = true;\n }\n\n unregister {\n thisProcess.removeOSCRecvFunc(this);\n registered = false;\n }\n\n typeKey { ^('OSC unmatched').asSymbol }\n\n}\n\nOSCMessagePatternDispatcher"}
+{"text": "C unmatched').asSymbol }\n\n}\n\nOSCMessagePatternDispatcher : OSCMessageDispatcher {\n\n value {|msg, time, addr, recvPort|\n var pattern;\n pattern = msg[0];\n active.keysValuesDo({|key, func|\n if(key.matchOSCAddressPattern(pattern), {func.value(msg, time, addr, recvPort);});\n })\n }\n\n typeKey { ^('OSC matched').asSymbol }\n\n}\n\nOSCFunc : AbstractResponderFunc {\n classvar <>defaultDispatcher, <>defaultMatchingDispatcher, traceFunc, traceRunning = false;\n var messageType;\n\n *new {|messageType| ^super.new.messageType_(messageType) }\n\n getKeysForFuncProxy {|funcProxy| ^(funcProxy.msgNum ? (0..127)).asArray;} // noteNum, etc.\n\n value {|src, chan, num, val| active[num].value(val, num, chan, src);}\n\n register {\n MIDIIn.perform(messageType.asSetter, MIDIIn.perform(messageType.asGetter).addFunc(this));\n registered = true;\n }\n\n unregister {\n MIDIIn.perform(messageType.asSetter, MIDIIn.perform(messageType.asGetter).removeFunc(this));\n registered = false;\n }\n\n // wrapper objects based on arg type and testing requirements\n wrapFunc {|funcProxy|\n var func, chan, srcID, argTemplate;\n func = funcProxy.func;\n chan = funcProxy.chan;\n srcID = funcProxy.srcID;\n argTemplate = funcProxy.argTemplate;\n if(argTemplate.notNil, { func = MIDIValueMatcher(argTemplate, func)}"}
+{"text": "notNil, { func = MIDIValueMatcher(argTemplate, func)});\n ^case(\n { srcID.notNil && chan.isArray }, {MIDIFuncBothCAMessageMatcher(chan, srcID, func)},\n { srcID.notNil && chan.notNil }, {MIDIFuncBothMessageMatcher(chan, srcID, func)},\n { srcID.notNil }, {MIDIFuncSrcMessageMatcher(srcID, func)},\n { chan.isArray }, {MIDIFuncChanArrayMessageMatcher(chan, func)},\n { chan.notNil }, {MIDIFuncChanMessageMatcher(chan, func)},\n { func }\n );\n }\n\n typeKey { ^('MIDI ' ++ messageType).asSymbol }\n}\n\n// for \\touch, \\program, \\bend\nMIDIMessageDispatcherNV : MIDIMessageDispatcher {\n\n getKeysForFuncProxy {|funcProxy| ^(funcProxy.chan ? (0..15)).asArray;} // chan\n\n value {|src, chan, val| active[chan].value(val, chan, src);}\n\n // wrapper objects based on arg type and testing requirements\n wrapFunc {|funcProxy|\n var func, chan, srcID, argTemplate;\n func = funcProxy.func;\n chan = funcPro"}
+{"text": "ID, argTemplate;\n func = funcProxy.func;\n chan = funcProxy.chan;\n srcID = funcProxy.srcID;\n argTemplate = funcProxy.argTemplate;\n if(argTemplate.notNil, { func = MIDIValueMatcher(argTemplate, func)});\n ^case(\n { srcID.notNil }, {MIDIFuncSrcMessageMatcherNV(srcID, func)},\n { func }\n );\n }\n}\n\n// for \\sysex\nMIDISysexDispatcher : MIDIMessageDispatcher {\n\n getKeysForFuncProxy { |funcProxy| ^(funcProxy.srcID ? \\all).asArray }\n\n value {|srcID, data|\n active[srcID].value(data, srcID);\n active[\\all].value(data, srcID);\n }\n\n wrapFunc {|funcProxy|\n var func, srcID, argTemplate;\n func = funcProxy.func;\n srcID = funcProxy.srcID;\n argTemplate = funcProxy.argTemplate;\n if(argTemplate.notNil, { func = MIDIValueMatcher(argTemplate, func)});\n ^func;\n }\n}\n\n// sysrt with data\nMIDISysDataDispatcher : MIDIMessageDispatcher {\n\n register {\n var hook;\n // select the correct"}
+{"text": "her : MIDIMessageDispatcher {\n\n register {\n var hook;\n // select the correct low-level hook.\n hook = switch(messageType,\n \\sysex, {\\sysex},\n \\mtcQF, {\\smpte},\n {\\sysrt}\n );\n MIDIIn.perform(hook.asSetter, MIDIIn.perform(hook.asGetter).addFunc(this));\n registered = true;\n }\n\n unregister {\n var hook;\n // select the correct low-level hook.\n hook = switch(messageType,\n \\sysex, {\\sysex},\n \\mtcQF, {\\smpte},\n {\\sysrt}\n );\n MIDIIn.perform(hook.asSetter, MIDIIn.perform(hook.asGetter).removeFunc(this));\n registered = false;\n }\n\n getKeysForFuncProxy {|funcProxy| ^(funcProxy.msgNum ? (0..15)).asArray;} // noteNum, etc.\n\n value {|srcID, index, data|\n active[index].value(data, srcID, index);\n }\n\n wrapFunc {|funcProxy|\n var func, srcID, argTemplate;\n func = funcProxy.func;\n srcID = funcProxy.srcID;\n argTemplate = funcProxy.argTemplate;\n if(argTemplate.notNil, { func = MIDIValueMatcher(arg"}
+{"text": "\n if(argTemplate.notNil, { func = MIDIValueMatcher(argTemplate, func)});\n ^case(\n { srcID.notNil }, {MIDIFuncSrcSysMessageMatcherND(srcID, func)},\n { func }\n );\n }\n}\n\nMIDISysDataDropIndDispatcher : MIDISysDataDispatcher {\n\n value {|srcID, index, data|\n active[index].value(data, srcID);\n }\n\n}\n\nMIDISysNoDataDispatcher : MIDISysDataDispatcher {\n\n value {|srcID, index|\n active[index].value(srcID);\n }\n\n wrapFunc {|funcProxy|\n var func, srcID;\n func = funcProxy.func;\n srcID = funcProxy.srcID;\n ^case(\n { srcID.notNil }, {MIDIFuncSrcSysMessageMatcher(srcID, func)},\n { func }\n );\n }\n}\n\nMIDIMTCtoSMPTEDispatcher : MIDISysexDispatcher {\n\n value {|srcID, index, data|\n active[srcID].value(srcID, index, data);\n active[\\all].value(srcID, index, data);\n }\n\n wrapFunc {|funcProxy|\n var func, srcID, argTemplate;\n func = funcProxy.func;"}
+{"text": "ar func, srcID, argTemplate;\n func = funcProxy.func;\n srcID = funcProxy.srcID;\n argTemplate = funcProxy.argTemplate;\n if(argTemplate.notNil, { func = MIDIValueMatcher(argTemplate, func)});\n func = MIDISMPTEAssembler(func);\n ^func;\n }\n}\n\n// thanks to nescivi for code from MTC class!!\nMIDISMPTEAssembler : AbstractMessageMatcher {\n var defaultDispatchers, traceFuncs, traceRunning = false, sysIndices;\n var 1, \\songPosition->2, \\songSelect->3, \\tuneRequest->6, \\midiClock->8, \\tick->9, \\start->10, \\continue->11, \\"}
+{"text": "idiClock->8, \\tick->9, \\start->10, \\continue->11, \\stop->12, \\activeSense->14, \\reset->15];\n [\\noteOn, \\noteOff, \\control, \\polytouch].do({|type|\n defaultDispatchers[type] = MIDIMessageDispatcher(type);\n traceFuncs[type] = {|src, chan, num, val|\n \"MIDI Message Received:\\n\\ttype: %\\n\\tsrc: %\\n\\tchan: %\\n\\tnum: %\\n\\tval: %\\n\\n\".postf(type, src, chan, num, val);\n };\n });\n [\\sysex].do({|type|\n defaultDispatchers[type] = MIDISysexDispatcher(type);\n traceFuncs[type] = {|src, data|\n \"MIDI Message Received:\\n\\ttype: %\\n\\tsrc: %\\n\\tdata: %\\n\\n\".postf(type, src, data);\n };\n });\n [\\mtcQF].do({|type|\n defaultDispatchers[type] = MIDISysDataDispatcher(type);\n traceFuncs[type] = {|src, ind, data|\n \"MIDI Message Received:\\n\\ttype: %\\n\\tindex: %\\n\\tsrc: %\\n\\tdata: %\\n\\n\".postf(type, ind, src, data);\n };\n });\n [\\smp"}
+{"text": "\\n\\n\".postf(type, ind, src, data);\n };\n });\n [\\smpte].do({|type|\n defaultDispatchers[type] = MIDIMTCtoSMPTEDispatcher(type);\n/* traceFuncs[type] = {|src, ind, data|\n \"MIDI Message Received:\\n\\ttype: %\\n\\tsrc: %\\n\\tdata: %\\n\\n\".postf(type, src, data);\n };*/ // unneeded? Just trace raw MTC\n });\n [\\songPosition, \\songSelect].do({|type|\n defaultDispatchers[type] = MIDISysDataDropIndDispatcher(type);\n traceFuncs[type] = {|src, ind, data|\n if(ind == sysIndices[type], {\n \"MIDI Message Received:\\n\\ttype: %\\n\\tsrc: %\\n\\tdata: %\\n\\n\".postf(type, src, data);\n });\n };\n });\n [\\sysrt].do({|type|\n defaultDispatchers[type] = MIDISysDataDispatcher(type);\n traceFuncs[type] = {|src, ind, data|\n \"MIDI Message Received:\\n\\ttype: %\\n\\tindex: %\\n\\tsrc: %\\n\\tdata: %\\n\\n\".postf(type, ind, src, data);\n };// maybe unneeded\n });\n [\\tuneRequest, \\m"}
+{"text": " src, data);\n };// maybe unneeded\n });\n [\\tuneRequest, \\midiClock, \\tick, \\start, \\continue, \\stop, \\activeSense, \\reset].do({|type|\n defaultDispatchers[type] = MIDISysNoDataDispatcher(type);\n traceFuncs[type] = {|src, ind|\n if(ind == sysIndices[type], {\n \"MIDI Message Received:\\n\\ttype: %\\n\\tsrc: %\\n\\n\".postf(type, src);\n });\n };\n });\n [\\touch, \\program, \\bend].do({|type|\n defaultDispatchers[type] = MIDIMessageDispatcherNV(type);\n traceFuncs[type] = {|src, chan, num|\n \"MIDI Message Received:\\n\\ttype: %\\n\\tsrc: %\\n\\tchan: %\\n\\tnum: %\\n\\n\".postf(type, src, chan, num);\n };\n });\n }\n\n *trace {|bool = true|\n if(bool, {\n if(traceRunning.not, {\n [\\noteOn, \\noteOff, \\control, \\polytouch, \\touch, \\program, \\bend, \\sysex].do({|type|\n MIDIIn.addFuncTo(type, traceFuncs[type]);\n });\n [\\tuneRequest, \\midiClock, \\tick, \\start, \\continue, \\stop,"}
+{"text": "tuneRequest, \\midiClock, \\tick, \\start, \\continue, \\stop, \\activeSense, \\reset, \\songPosition, \\songSelect].do({|type|\n MIDIIn.addFuncTo(\\sysrt, traceFuncs[type]);\n });\n [\\mtcQF].do({|type|\n MIDIIn.addFuncTo(\\smpte, traceFuncs[type]);\n });\n CmdPeriod.add(this);\n traceRunning = true;\n });\n }, {\n [\\noteOn, \\noteOff, \\control, \\polytouch, \\touch, \\program, \\bend, \\sysex].do({|type|\n MIDIIn.removeFuncFrom(type, traceFuncs[type]);\n });\n [\\tuneRequest, \\midiClock, \\tick, \\start, \\continue, \\stop, \\activeSense, \\reset, \\songPosition, \\songSelect].do({|type|\n MIDIIn.removeFuncFrom(\\sysrt, traceFuncs[type]);\n });\n [\\mtcQF].do({|type|\n MIDIIn.removeFuncFrom(\\smpte, traceFuncs[type]);\n });\n CmdPeriod.remove(this);\n traceRunning = false;\n });\n }\n\n *cmdPeriod { this.trace(false) }\n\n *new { arg func, msgNum, chan, msgType, srcID, argTem"}
+{"text": " *new { arg func, msgNum, chan, msgType, srcID, argTemplate, dispatcher;\n ^super.new.init(func, msgNum, chan, msgType, srcID, argTemplate, dispatcher ? defaultDispatchers[msgType]);\n }\n\n *cc { arg func, ccNum, chan, srcID, argTemplate, dispatcher;\n ^this.new(func, ccNum, chan, \\control, srcID, argTemplate, dispatcher);\n }\n\n *noteOn { arg func, noteNum, chan, srcID, argTemplate, dispatcher;\n ^this.new(func, noteNum, chan, \\noteOn, srcID, argTemplate, dispatcher);\n }\n\n *noteOff { arg func, noteNum, chan, srcID, argTemplate, dispatcher;\n ^this.new(func, noteNum, chan, \\noteOff, srcID, argTemplate, dispatcher);\n }\n\n *polytouch { arg func, noteNum, chan, srcID, argTemplate, dispatcher;\n ^this.new(func, noteNum, chan, \\polytouch, srcID, argTemplate, dispatcher);\n }\n\n *touch { arg func, chan, srcID, argTemplate, dispatcher;\n ^this.new(func, nil, chan, \\touch, srcID, argTemplate, dispatcher);\n "}
+{"text": "unc, nil, chan, \\touch, srcID, argTemplate, dispatcher);\n }\n\n *bend { arg func, chan, srcID, argTemplate, dispatcher;\n ^this.new(func, nil, chan, \\bend, srcID, argTemplate, dispatcher);\n }\n\n *program { arg func, chan, srcID, argTemplate, dispatcher;\n ^this.new(func, nil, chan, \\program, srcID, argTemplate, dispatcher);\n }\n\n ///// system messages\n\n *sysex { arg func, srcID, argTemplate, dispatcher;\n ^this.new(func, nil, nil, \\sysex, srcID, argTemplate, dispatcher);\n }\n\n // system common\n\n // does this need to be registered on the SMPTE hook? Yes!\n *mtcQuarterFrame {arg func, srcID, argTemplate, dispatcher;\n ^this.new(func, nil, nil, \\mtcQF, srcID, argTemplate, dispatcher); // actually index 1 sysrt, but on smpte hook\n }\n\n *smpte {arg func, srcID, argTemplate, dispatcher;\n ^this.new(func, nil, nil, \\smpte, srcID, argTemplate, dispatcher); // actually index 1 sysrt, but on smpte hook\n }\n\n *songPosition {arg func, srcID, argTemplate, dispatcher;\n ^this"}
+{"text": "Position {arg func, srcID, argTemplate, dispatcher;\n ^this.new(func, 2, nil, \\songPosition, srcID, argTemplate, dispatcher);\n }\n\n *songSelect {arg func, srcID, argTemplate, dispatcher;\n ^this.new(func, 3, nil, \\songSelect, srcID, argTemplate, dispatcher);\n }\n\n *tuneRequest {arg func, srcID, dispatcher;\n ^this.new(func, 6, nil, \\tuneRequest, srcID, nil, dispatcher);\n }\n\n *midiClock {arg func, srcID, dispatcher;\n ^this.new(func, 8, nil, \\midiClock, srcID, nil, dispatcher);\n }\n\n // system realtime\n\n // generic\n *sysrt { arg func, index, srcID, argTemplate, dispatcher;\n ^this.new(func, index, nil, \\sysrt, srcID, argTemplate, dispatcher);\n }\n\n *tick {arg func, srcID, dispatcher;\n ^this.new(func, 9, nil, \\tick, srcID, nil, dispatcher);\n }\n\n *start {arg func, srcID, dispatcher;\n ^this.new(func, 10, nil, \\start, srcID, nil, dispatcher);\n }\n\n *continue {arg func, srcID, dispatcher;\n "}
+{"text": "cher);\n }\n\n *continue {arg func, srcID, dispatcher;\n ^this.new(func, 11, nil, \\continue, srcID, nil, dispatcher);\n }\n\n *stop {arg func, srcID, dispatcher;\n ^this.new(func, 12, nil, \\stop, srcID, nil, dispatcher);\n }\n\n *activeSense {arg func, srcID, dispatcher;\n ^this.new(func, 14, nil, \\activeSense, srcID, nil, dispatcher);\n }\n\n *reset {arg func, srcID, dispatcher;\n ^this.new(func, 15, nil, \\reset, srcID, nil, dispatcher);\n }\n\n init {|argfunc, argmsgNum, argchan, argType, argsrcID, argtempl, argdisp|\n msgNum = argmsgNum ? msgNum;\n msgNum = msgNum.isNumber.if({ msgNum.asInteger }, msgNum);\n msgNum = msgNum.isCollection.if({ msgNum.collect(_.asInteger) }, msgNum);\n chan = argchan ? chan;\n srcID = argsrcID ? srcID;\n func = argfunc ? func;\n msgType = argType ? msgType;\n dispatcher = argdisp ? dispatcher;\n argTemplate = argtempl ? argTemplate;\n this.enable;"}
+{"text": "? dispatcher;\n argTemplate = argtempl ? argTemplate;\n this.enable;\n allFuncProxies.add(this);\n }\n\n // swap out func and wait\n learn {|learnVal = false|\n // check for cc or noteon?\n var learnFunc;\n /*this.remove(func);*/\n learnFunc = this.learnFunc(learnVal);\n this.disable;\n this.init(learnFunc); // keep old args if specified, so we can learn from particular channels, srcs, etc.\n }\n\n learnFunc {|learnVal|\n var oldFunc, learnFunc;\n oldFunc = func; // old funk is ultimately better than new funk\n if([\\control, \\noteOn, \\noteOff, \\polytouch].includes(msgType), {\n ^{|val, num, chan, srcID|\n \"MIDIFunc learned: type: %\\tnum: %\\tval: %\\tchan: %\\tsrcID: %\\t\\n\".postf(msgType, num, val, chan, srcID);\n this.disable;\n this.remove(learnFunc);\n oldFunc.value(val, num, chan, srcID);// do first action\n this.init(oldFunc, num, chan, msgType, srcID, if(learnVal, val, nil));\n }\n });\n\n // noNum\n if([\\touch, \\program, \\bend].includes(msgType), {\n ^{|val, chan, srcID|\n \"MIDIFun"}
+{"text": "es(msgType), {\n ^{|val, chan, srcID|\n \"MIDIFunc learned: type: %\\tval: %\\tchan: %\\tsrcID: %\\t\\n\".postf(msgType, val, chan, srcID);\n this.disable;\n this.remove(learnFunc);\n oldFunc.value(val, chan, srcID);// do first action\n this.init(oldFunc, nil, chan, msgType, srcID, if(learnVal, val, nil));\n }\n });\n\n // sys with Data\n if([\\mtcQF, \\smpte, \\songPosition, \\songSelect, \\sysrt].includes(msgType), {\n ^{|val, srcID, index|\n \"MIDIFunc learned: type: %\\tnum: %\\tval: %\\tsrcID: %\\t\\n\".postf(msgType, index, val, srcID);\n this.disable;\n this.remove(learnFunc);\n oldFunc.value(val, srcID, index);// do first action\n this.init(oldFunc, index, nil, msgType, srcID, if(learnVal, val, nil));\n }\n });\n\n // sys no Data\n if([\\tuneRequest, \\midiClock, \\tick, \\start, \\continue, \\stop, \\activeSense, \\reset].includes(msgType), {\n ^{|srcID, index|\n \"MIDIFunc learned: type: %\\tnum: %\\tsrcID: %\\t\\n\".p"}
+{"text": "\n \"MIDIFunc learned: type: %\\tnum: %\\tsrcID: %\\t\\n\".postf(msgType, index, srcID);\n this.disable;\n this.remove(learnFunc);\n oldFunc.value(srcID, index);// do first action\n this.init(oldFunc, index, nil, msgType, srcID, nil);\n }\n });\n\n // sysex\n if(msgType == \\sysex, {\n ^{|val, srcID|\n \"MIDIFunc learned: type: %\\tdata: %\\tsrcID: %\\t\\n\".postf(msgType, val, srcID);\n this.disable;\n this.remove(learnFunc);\n oldFunc.value(val, srcID);// do first action\n this.init(oldFunc, nil, nil, msgType, srcID, if(learnVal, val, nil));\n }\n });\n\n \"msgType: % not standard, cannot learn\".format(msgType).warn;\n }\n\n // post pretty\n printOn { arg stream; stream << this.class.name << \"(\" <<* [msgType, msgNum, chan, argTemplate] << \")\" }\n\n}\n\nMIDIdef : MIDIFunc {\n classvar <>all; // same as other def classes, do we need a setter really?\n var specialSynthDef, 2/dbRange\n\n // linear\n SynthDef(\"system_freqScope0\", { arg in=0, fftBufSize = 2048, scopebufnum=1, rate=4, dbFactor = 0.02;\n var phase = 1 - (rate * fftBufSize.reciprocal);\n var signal, chain, phasor, numSamples, mul;\n var fftbufnum = LocalBuf(fftBufSize, 1);\n mul = 0.00285;\n numSamples = (BufSamples.ir(fftbufnum) - 2) * 0.5; // 1023 (bufsize=2048)\n signal = In.ar(in);\n chain = FFT(fftbufnum, signal, h"}
+{"text": ")\n signal = In.ar(in);\n chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);\n chain = PV_MagSmear(chain, 1);\n // -1023 to 1023, 0 to 2046, 2 to 2048 (skip first 2 elements DC and Nyquist)\n phasor = LFSaw.ar(rate/BufDur.ir(fftbufnum), phase, numSamples, numSamples + 2);\n phasor = phasor.round(2); // the evens are magnitude\n ScopeOut.ar( ((BufRd.ar(1, fftbufnum, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum);\n }, [\\kr, \\ir, \\ir, \\ir, \\kr]).add;\n SynthDef(\"system_freqScope0_shm\", { arg in=0, fftBufSize = 2048, scopebufnum=1, rate=4, dbFactor = 0.02;\n var phase = 1 - (rate * fftBufSize.reciprocal);\n var signal, chain, phasor, numSamples, mul;\n var fftbufnum = LocalBuf(fftBufSize, 1);\n mul = 0.00285;\n numSamples = (BufSamples.ir(fftbufnum) - 2) * 0.5; // 1023 (bufsize=2048)\n signal = In.ar(in);\n chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);\n chain = PV_MagSmear("}
+{"text": ", signal, hop: 0.75, wintype:1);\n chain = PV_MagSmear(chain, 1);\n // -1023 to 1023, 0 to 2046, 2 to 2048 (skip first 2 elements DC and Nyquist)\n phasor = LFSaw.ar(rate/BufDur.ir(fftbufnum), phase, numSamples, numSamples + 2);\n phasor = phasor.round(2); // the evens are magnitude\n ScopeOut2.ar( ((BufRd.ar(1, fftbufnum, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum, fftBufSize/rate);\n }, [\\kr, \\ir, \\ir, \\ir, \\kr]).add;\n\n // logarithmic\n SynthDef(\"system_freqScope1\", { arg in=0, fftBufSize = 2048, scopebufnum=1, rate=4, dbFactor = 0.02;\n var phase = 1 - (rate * fftBufSize.reciprocal);\n var signal, chain, phasor, halfSamples, mul;\n var fftbufnum = LocalBuf(fftBufSize, 1);\n mul = 0.00285;\n halfSamples = BufSamples.ir(fftbufnum) * 0.5;\n signal = In.ar(in);\n chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);\n chain = PV_MagSmear(chain, 1);\n phasor = halfSamples.pow(LFSaw"}
+{"text": "_MagSmear(chain, 1);\n phasor = halfSamples.pow(LFSaw.ar(rate/BufDur.ir(fftbufnum), phase, 0.5, 0.5)) * 2; // 2 to bufsize\n phasor = phasor.round(2); // the evens are magnitude\n ScopeOut.ar( ((BufRd.ar(1, fftbufnum, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum);\n }, [\\kr, \\ir, \\ir, \\ir, \\kr]).add;\n\n SynthDef(\"system_freqScope1_shm\", { arg in=0, fftBufSize = 2048, scopebufnum=1, rate=4, dbFactor = 0.02;\n var phase = 1 - (rate * fftBufSize.reciprocal);\n var signal, chain, phasor, halfSamples, mul;\n var fftbufnum = LocalBuf(fftBufSize, 1);\n mul = 0.00285;\n halfSamples = BufSamples.ir(fftbufnum) * 0.5;\n signal = In.ar(in);\n chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);\n chain = PV_MagSmear(chain, 1);\n phasor = halfSamples.pow(LFSaw.ar(rate/BufDur.ir(fftbufnum), phase, 0.5, 0.5)) * 2; // 2 to bufsize\n phasor = phasor.round(2); // the ev"}
+{"text": ", 0.5)) * 2; // 2 to bufsize\n phasor = phasor.round(2); // the evens are magnitude\n ScopeOut2.ar( ((BufRd.ar(1, fftbufnum, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum, fftBufSize/rate);\n }, [\\kr, \\ir, \\ir, \\ir, \\kr]).add;\n\n // These next two are based on the original two, but adapted by Dan Stowell\n // to calculate the frequency response between two channels\n SynthDef(\"system_freqScope0_magresponse\", { arg in=0, fftBufSize = 2048, scopebufnum=1, rate=4, dbFactor = 0.02, in2=1;\n var phase = 1 - (rate * fftBufSize.reciprocal);\n var signal, chain, phasor, numSamples, mul;\n var signal2, chain2, divisionbuf;\n var fftbufnum = LocalBuf(fftBufSize, 1);\n mul = 0.00285;\n numSamples = (BufSamples.ir(fftbufnum) - 2) * 0.5; // 1023 (bufsize=2048)\n signal = In.ar(in);\n signal2 = In.ar(in2);\n chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);\n divisionbuf = LocalBuf(BufFrames.ir(fftbufnum));\n chain2 = FFT(divisionbuf, signal2, hop: 0."}
+{"text": "tbufnum));\n chain2 = FFT(divisionbuf, signal2, hop: 0.75, wintype:1);\n // Here we perform complex division to estimate the freq response\n chain = PV_Div(chain2, chain);\n chain = PV_MagSmear(chain, 1);\n // -1023 to 1023, 0 to 2046, 2 to 2048 (skip first 2 elements DC and Nyquist)\n phasor = LFSaw.ar(rate/BufDur.ir(fftbufnum), phase, numSamples, numSamples + 2);\n phasor = phasor.round(2); // the evens are magnitude\n ScopeOut.ar( ((BufRd.ar(1, divisionbuf, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum);\n }, [\\kr, \\ir, \\ir, \\ir, \\kr, \\ir]).add;\n\n SynthDef(\"system_freqScope0_magresponse_shm\", { arg in=0, fftBufSize = 2048, scopebufnum=1, rate=4, dbFactor = 0.02, in2=1;\n var phase = 1 - (rate * fftBufSize.reciprocal);\n var signal, chain, phasor, numSamples, mul;\n var signal2, chain2, divisionbuf;\n var fftbufnum = LocalBuf(fftBufSize, 1);\n mul = 0.00285;\n numSamples = (BufSamples.ir(fftbufnum) - 2) * 0.5; // 1023 (bufsize"}
+{"text": "ufSamples.ir(fftbufnum) - 2) * 0.5; // 1023 (bufsize=2048)\n signal = In.ar(in);\n signal2 = In.ar(in2);\n chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);\n divisionbuf = LocalBuf(BufFrames.ir(fftbufnum));\n chain2 = FFT(divisionbuf, signal2, hop: 0.75, wintype:1);\n // Here we perform complex division to estimate the freq response\n chain = PV_Div(chain2, chain);\n chain = PV_MagSmear(chain, 1);\n // -1023 to 1023, 0 to 2046, 2 to 2048 (skip first 2 elements DC and Nyquist)\n phasor = LFSaw.ar(rate/BufDur.ir(fftbufnum), phase, numSamples, numSamples + 2);\n phasor = phasor.round(2); // the evens are magnitude\n ScopeOut2.ar( ((BufRd.ar(1, divisionbuf, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum, fftBufSize/rate);\n }, [\\kr, \\ir, \\ir, \\ir, \\kr, \\ir]).add;\n\n SynthDef(\"system_freqScope1_magresponse\", { arg in=0, fftBufSize = 2048, scopebufnum=1, rate=4, dbFactor = 0.02, in2=1;\n var phase = 1 - (rate * fftBufSize."}
+{"text": " = 0.02, in2=1;\n var phase = 1 - (rate * fftBufSize.reciprocal);\n var signal, chain, phasor, halfSamples, mul;\n var signal2, chain2, divisionbuf;\n var fftbufnum = LocalBuf(fftBufSize, 1);\n mul = 0.00285;\n halfSamples = BufSamples.ir(fftbufnum) * 0.5;\n signal = In.ar(in);\n signal2 = In.ar(in2);\n chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);\n divisionbuf = LocalBuf(BufFrames.ir(fftbufnum));\n chain2 = FFT(divisionbuf, signal2, hop: 0.75, wintype:1);\n // Here we perform complex division to estimate the freq response\n chain = PV_Div(chain2, chain);\n chain = PV_MagSmear(chain, 1);\n phasor = halfSamples.pow(LFSaw.ar(rate/BufDur.ir(fftbufnum), phase, 0.5, 0.5)) * 2; // 2 to bufsize\n phasor = phasor.round(2); // the evens are magnitude\n ScopeOut.ar( ((BufRd.ar(1, divisionbuf, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum);\n }, [\\kr, \\ir, \\ir, \\ir, \\kr, \\ir]).add;\n\n SynthDef(\"system"}
+{"text": "\\kr, \\ir, \\ir, \\ir, \\kr, \\ir]).add;\n\n SynthDef(\"system_freqScope1_magresponse_shm\", { arg in=0, fftBufSize = 2048, scopebufnum=1, rate=4, dbFactor = 0.02, in2=1;\n var phase = 1 - (rate * fftBufSize.reciprocal);\n var signal, chain, phasor, halfSamples, mul;\n var signal2, chain2, divisionbuf;\n var fftbufnum = LocalBuf(fftBufSize, 1);\n mul = 0.00285;\n halfSamples = BufSamples.ir(fftbufnum) * 0.5;\n signal = In.ar(in);\n signal2 = In.ar(in2);\n chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);\n divisionbuf = LocalBuf(BufFrames.ir(fftbufnum));\n chain2 = FFT(divisionbuf, signal2, hop: 0.75, wintype:1);\n // Here we perform complex division to estimate the freq response\n chain = PV_Div(chain2, chain);\n chain = PV_MagSmear(chain, 1);\n phasor = halfSamples.pow(LFSaw.ar(rate/BufDur.ir(fftbufnum), phase, 0.5, 0.5)) * 2; // 2 to bufsize\n phasor = phasor.round(2); // the evens are magnitude\n ScopeOut2.ar("}
+{"text": "asor = phasor.round(2); // the evens are magnitude\n ScopeOut2.ar( ((BufRd.ar(1, divisionbuf, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum, fftBufSize/rate);\n }, [\\kr, \\ir, \\ir, \\ir, \\kr, \\ir]).add;\n }\n\n initFreqScope { arg parent, bounds, argServer;\n server = argServer ? Server.default;\n if (this.shmScopeAvailable) {\n scope = ScopeView.new(parent, bounds);\n scope.server = server;\n scope.fill = false;\n } {\n scope = SCScope(parent, bounds);\n };\n\n active = false;\n inBus = 0;\n dbRange = 96;\n dbFactor = 2/dbRange;\n rate = 4;\n freqMode = 0;\n bufSize = 2048;\n ServerQuit.add(this, server);\n ^this;\n }\n\n allocBuffers {\n if (this.shmScopeAvailable) {\n scopebuf = ScopeBuffer.alloc(server);\n scope.bufnum = scopebuf.bufnum;\n } {\n Buffer.alloc(server, bufSize/4, 1, { |sbuf|\n scope.bufnum = sbuf.bufnum;\n scopebuf = sbuf;\n });\n };\n }\n\n freeBuffers {\n if (scopebuf.notNil) {\n "}
+{"text": " });\n };\n }\n\n freeBuffers {\n if (scopebuf.notNil) {\n scopebuf.free; scopebuf = nil;\n };\n }\n\n start {\n var defname, args;\n\n if (synth.notNil) { synth.free };\n if (scopebuf.isNil) { this.allocBuffers };\n\n defname = specialSynthDef ?? {\n \"system_freqScope\" ++ freqMode.asString ++ if (this.shmScopeAvailable) {\"_shm\"} {\"\"}\n };\n args = [\\in, inBus, \\dbFactor, dbFactor, \\rate, 4, \\fftBufSize, bufSize,\n \\scopebufnum, scopebuf.bufnum] ++ specialSynthArgs;\n synth = Synth.tail(RootNode(server), defname, args);\n if (scope.isKindOf(ScopeView)) { scope.start };\n }\n\n kill {\n this.active_(false);\n this.freeBuffers;\n ServerQuit.remove(this, server);\n }\n\n active_ { |bool|\n if (bool) {\n ServerTree.add(this, server);\n if (server.serverRunning) {\n active = bool;\n this.doOnServerTree;\n ^this\n }\n } {\n ServerTree.remove(this, server);\n if (server.serverRunning and: active) {\n if (scope.isKindOf(ScopeView)) { scope.stop };\n synth."}
+{"text": " if (scope.isKindOf(ScopeView)) { scope.stop };\n synth.free;\n synth = nil;\n };\n };\n active = bool;\n ^this\n }\n\n doOnServerTree {\n synth = nil;\n if (active) { this.start; }\n }\n\n doOnServerQuit {\n var thisScope = scope;\n defer {\n thisScope.stop;\n };\n scopebuf = synth = nil;\n }\n\n inBus_ { arg num;\n inBus = num;\n if(active, {\n synth.set(\\in, inBus);\n });\n ^this\n }\n\n dbRange_ { arg db;\n dbRange = db;\n dbFactor = 2/db;\n if(active, {\n synth.set(\\dbFactor, dbFactor);\n });\n }\n\n freqMode_ { arg mode;\n freqMode = mode.asInteger.clip(0,1);\n if(active, {\n this.start;\n });\n }\n\n specialSynthArgs_ {|args|\n specialSynthArgs = args;\n if(args.notNil and:{active}){\n synth.set(*specialSynthArgs);\n }\n }\n\n special { |defname, extraArgs|\n this.specialSynthDef_(defname);\n this.specialSynthArgs_(extraArgs);\n if(active, {\n this.start;\n });\n }\n\n *response { |parent, bounds, bus1, bus2, freqMode = 1|\n var scope = this.new(parent, bounds, bus1.server).inB"}
+{"text": "qMode = 1|\n var scope = this.new(parent, bounds, bus1.server).inBus_(bus1.index);\n var synthDefName = \"system_freqScope%_magresponse%\".format(freqMode, if (scope.shmScopeAvailable) {\"_shm\"} {\"\"});\n\n ^scope.special(synthDefName, [\\in2, bus2])\n }\n\n doesNotUnderstand { arg selector ... args;\n ^scope.performList(selector, args);\n }\n\n shmScopeAvailable {\n ^server.isLocal\n // and: { server.inProcess.not }\n }\n}\n\nFreqScope {\n classvar 1.0, {\n freqLabel[i].string_( kfreq.asString.keep(4) ++ \"k\" )\n },{\n freqLabel[i].string_( (kfreq*1000).asInteger.asString)\n });\n });\n };\n\n setDBLabelVals = { arg db;\n dbLabel.size.do({ arg i;\n dbLabel[i].string = (i * db/(dbLabel.size-1)).asInteger.neg.asString;\n });\n };\n\n window = Window(\"Freq Analyzer\", resizable: false)\n .bounds_(rect.resizeBy(pad[0] + pad[1] + 4, pad[2] + pad[3] + 4))\n .moveToBottom;\n\n freqLabel.size.do({ arg i;\n freqLabel[i] = StaticText(window, Rect(pad[0] - (freqLabelDist*0.5) + (i*freqLabelDist), pad[2] - 10, freqLabelDist, 10))\n .font_(font)\n .align_(\\center)\n ;\n StaticText(window, Rect(pad[0] + (i*freqLabelDist), pad[2], 1, rect.height))\n .string_(\"\")\n ;\n });\n\n dbLabel.size.do({ arg i;\n dbLabel[i] ="}
+{"text": ";\n });\n\n dbLabel.size.do({ arg i;\n dbLabel[i] = StaticText(window, Rect(0, pad[2] + (i*dbLabelDist), pad[0], 10))\n .font_(font)\n .align_(\\left)\n ;\n StaticText(window, Rect(pad[0], dbLabel[i].bounds.top, rect.width, 1))\n .string_(\"\")\n ;\n });\n\n scope = FreqScopeView(window, rect.moveBy(pad[0], pad[2]), server);\n scope.xZoom_((scope.bufSize*0.25) / width);\n\n setFreqLabelVals.value(scope.freqMode, 2048);\n setDBLabelVals.value(scope.dbRange);\n\n Button(window, Rect(pad[0] + rect.width, pad[2], pad[1], 16))\n .states_([[\"stop\", Color.white, Color.green(0.5)], [\"start\", Color.white, Color.red(0.5)]])\n .action_({ arg view;\n if(view.value == 0, {\n scope.active_(true);\n },{\n scope.active_(false);\n });\n })\n .font_(font)\n .canFocus_(false)\n ;\n\n StaticText(window, Rect(pad[0] + rect.width, pad[2]+20, pad[1], 10))\n .string_(\"BusIn\")\n .font_(font)\n ;\n\n "}
+{"text": ", pad[1], 10))\n .string_(\"BusIn\")\n .font_(font)\n ;\n\n NumberBox(window, Rect(pad[0] + rect.width, pad[2]+30, pad[1], 14))\n .action_({ arg view;\n view.value_(view.value.asInteger.clip(0, server.options.numAudioBusChannels));\n scope.inBus_(view.value);\n })\n .value_(busNum)\n .font_(font)\n ;\n\n StaticText(window, Rect(pad[0] + rect.width, pad[2]+48, pad[1], 10))\n .string_(\"FrqScl\")\n .font_(font)\n ;\n PopUpMenu(window, Rect(pad[0] + rect.width, pad[2]+58, pad[1], 16))\n .items_([\"lin\", \"log\"])\n .action_({ arg view;\n scope.freqMode_(view.value);\n setFreqLabelVals.value(scope.freqMode, 2048);\n })\n .canFocus_(false)\n .font_(font)\n .valueAction_(1)\n ;\n\n StaticText(window, Rect(pad[0] + rect.width, pad[2]+76, pad[1], 10))\n .string_(\"dbCut\")\n .font_(font)\n ;\n PopUpMenu(window, Rect(pad[0] + rect.width, pad[2]+86, pad[1], 16))\n .items_(Array.series"}
+{"text": "width, pad[2]+86, pad[1], 16))\n .items_(Array.series(12, 12, 12).collect({ arg item; item.asString }))\n .action_({ arg view;\n scope.dbRange_((view.value + 1) * 12);\n setDBLabelVals.value(scope.dbRange);\n })\n .canFocus_(false)\n .font_(font)\n .value_(7)\n ;\n\n scope\n .inBus_(busNum)\n .active_(true)\n .style_(1)\n .waveColors_([scopeColor.alpha_(1)])\n .canFocus_(false)\n ;\n\n if (bgColor.notNil) {\n scope.background_(bgColor)\n };\n\n window.onClose_({\n scope.kill;\n scopeOpen = false;\n }).front;\n instance = super.newCopyArgs(scope, window);\n ^instance\n }\n}\n```"}
+{"text": "SuperCollider classlib — SCClassLibrary/JITLib/Patterns/Psym.sc\n\n```supercollider\n *new { arg pattern, dict;\n ^super.new(pattern).dict_(dict)\n }\n\n storeArgs { ^[pattern,dict] }\n\n lookupClass { ^Pdef }\n\n lookUp { arg key;\n ^(dict ?? { this.lookupClass.all }).at(key.asSymbol) ?? { this.lookupClass.default }\n }\n\n embedInStream { arg inval;\n var str, outval, pat;\n str = pattern.asStream;\n while {\n outval = str.next(inval);\n outval.notNil\n } {\n pat = this.getPattern(outval);\n inval = pat.embedInStream(inval);\n };\n ^inval\n\n }\n\n getPattern { arg key;\n ^if(key.isSequenceableCollection) {\n this.lookupClass.parallelise(\n key.collect {|each|\n this.lookUp(each)\n }\n );\n } {\n this.lookUp(key)\n }\n }\n\n}\n\nPnsym : Psym {\n lookupClass { ^Pdefn }\n}\n\nPtsym : Psym {\n var <>quant, <>dur, <>tolerance;\n\n *new { arg pattern, dict, quant, dur, tolerance = 0.001;\n ^super.newCopyArgs(pattern, dict, quant, dur, tolerance)\n }\n\n storeArgs { ^[ pattern, dict, quant, dur, tolerance ] }\n\n embedInStream { arg inv"}
+{"text": "gs { ^[ pattern, dict, quant, dur, tolerance ] }\n\n embedInStream { arg inval;\n var outval, pat, quantVal, durVal;\n var str = pattern.asStream;\n var quantStr = quant.asStream;\n var durStr = dur.asStream;\n\n while {\n outval = str.next(inval);\n quantVal = quantStr.next(inval) ? quantVal;\n durVal = durStr.next(inval) ? durVal;\n outval.notNil\n } {\n pat = Psync(this.getPattern(outval), quantVal, durVal, tolerance);\n inval = pat.embedInStream(inval);\n };\n ^inval\n\n }\n}\n\nPnsym1 : Pnsym {\n\n embedInStream { arg inval;\n\n var which, outval, pat, currentStream;\n var str = pattern.asStream;\n var streams = IdentityDictionary.new;\n\n while {\n which = str.next(inval);\n which.notNil\n } {\n pat = this.getPattern(which);\n currentStream = streams.at(pat);\n if(currentStream.isNil) {\n currentStream = pat.asStream;\n streams.put(pat, currentStream);\n };\n outval = currentStream.next(inval);\n outval ?? { ^inval };\n inval = outval.yield\n };\n ^inval\n\n }\n}\n\nPsym1 : Psym {\n\n embedInStream { arg inval;\n\n var which, outval, pat, currentStream;\n var str = pattern.asStream;\n var streams = IdentityD"}
+{"text": " outval, pat, currentStream;\n var str = pattern.asStream;\n var streams = IdentityDictionary.new;\n var cleanup = EventStreamCleanup.new;\n\n while {\n which = str.next(inval);\n which.notNil\n } {\n if(which.isSequenceableCollection) {\n Error(\"Psym1 cannot embed arrayed keys: %\\n\".format(which)).throw;\n };\n pat = this.lookUp(which);\n currentStream = streams.at(pat);\n if(currentStream.isNil) {\n currentStream = pat.asStream;\n streams.put(pat, currentStream);\n };\n outval = currentStream.next(inval);\n if(outval.isNil) { ^cleanup.exit(inval) };\n\n cleanup.update(outval);\n inval = outval.yield\n };\n\n ^cleanup.exit(inval);\n }\n}\n```"}
+{"text": "SuperCollider patch — examples/GUI examples/ColorBrowser.scd\n\nColor Browser (c) 2007 Tom Hall . 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 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public L\n\n```supercollider\n// Color Browser\n// (c) 2007 Tom Hall .\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free So"}
+{"text": " copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n\n// !! Evaluate the X Windows color data (x = [...]) below first !!\n\n// Make a GUI with a button for each X Window color\n// Pressing the buttons selects a colr and posts its name and 8-bit values\n// Closing the window makes a new window with selected colors (one time only)\n\n(\nvar colorWindow, sortFn, screenBounds, btnWidth;\ncolorWindow = {arg colors, btnWidth=60, fontSize=9, bounds, inclGrey=false, winOnClose=true;\n var w, color, colArr, prevCol, colName, btn, txtCol, isGrey, colsCollect = []; \n bounds = bounds ? Rect(10, 10, 252, 240);\n w = Window(\"Color browser\", bounds, scroll: true);\n w.view.decorator = FlowLayout(w.view.bounds, Point(0,0), Point(0,0));\n colors.do({ arg colAssoc, i;\n color = colAssoc.value;\n colArr = color.asArray;\n colName = colAssoc.key.asString;\n if(colArr != prevCol, { \n if (inclGrey.not, {\n isGrey = colName.containsi(\"gray\") or: {colName.containsi(\"grey\")};\n }, {\n isGrey = false; "}
+{"text": " or: {colName.containsi(\"grey\")};\n }, {\n isGrey = false; \n });\n if (isGrey.not, {\n txtCol = if(colArr.sum < 2.45, {Color.white}, {Color.black});\n btn = Button(w, Rect(0,0, btnWidth, (btnWidth/3).round)); \n btn.font = Font(\"Helvetica\", fontSize);\n btn.states = [[\"\", txtCol, color],[colName, txtCol, color]];\n btn.action_({ arg butt;\n var name, val256;\n name = colors[i].key;\n val256 = (colors[i].value.asArray * 255).keep(3);\n format(\"% %\",name , val256).postln;\n colsCollect = colsCollect.add(colors[i]);\n });\n });\n });\n prevCol = colArr; \n });\n // Make a final window with selected colors\n if (winOnClose, {\n w.onClose = {\n var winHeight, sortedCols;\n if (colsCollect.notEmpty, {\n winHeight = colsCollect.size.round(2)/2 * 67;\n sortedCols = colsCollect.sort({ arg a, b; (a.value.asArray.sum) > (b.value.asArray.sum)});\n colorWindow.value(sortedCols, 200, 11, Rect(200, 200, 412, winHeight), true, false);\n sortedCols.asCompileString.postln;\n });\n };\n });"}
+{"text": " true, false);\n sortedCols.asCompileString.postln;\n });\n };\n });\n w.front;\n};\n\n// sort colors by intensity\nsortFn = { arg a, b; (a.value.asArray.sum) > (b.value.asArray.sum)};\n\n// calculate window and button sizes relatve to screen resolution\nscreenBounds = Window.screenBounds.extent.asArray;\n// 508 colors including grey scale\nbtnWidth = (((screenBounds[0]*screenBounds[1])/508).sqrt * 1.6).floor.round;\n\n// make the GUI (includes greys)\ncolorWindow.value(x.sort(sortFn), btnWidth, (btnWidth/8).round, Rect(0, 0, screenBounds[0], screenBounds[1]), true);\n\n// Other layouts\n//colorWindow.value(x.sort(sortFn)) // small, excludes greys, with scrollbar\n//colorWindow.value(x.sort(sortFn), 56, 6, Rect(5, 40, 672, 628)) // excludes greys\n//colorWindow.value(x.sort(sortFn), 200, 11, Rect(200, 200, 412, 400)) // bigger buttons, excludes greys\n//colorWindow.value(x.sort(sortFn), 1000, 48, Rect(100, 100, 1012, 670)) // big buttons, excludes greys\n\n);\n\n// X Windows colors\n// see http://en.wikipedia.org/wiki/X11_color_names\n\n(\nx = [\n 'alice blue' -> Color.new"}
+{"text": "wiki/X11_color_names\n\n(\nx = [\n 'alice blue' -> Color.new255(240, 248, 255),\n 'AliceBlue' -> Color.new255(240, 248, 255),\n 'antique white' -> Color.new255(250, 235, 215),\n 'AntiqueWhite' -> Color.new255(250, 235, 215),\n 'AntiqueWhite1' -> Color.new255(255, 239, 219),\n 'AntiqueWhite2' -> Color.new255(238, 223, 204),\n 'AntiqueWhite3' -> Color.new255(205, 192, 176),\n 'AntiqueWhite4' -> Color.new255(139, 131, 120),\n 'aquamarine' -> Color.new255(127, 255, 212),\n 'aquamarine1' -> Color.new255(127, 255, 212),\n 'aquamarine2' -> Color.new255(118, 238, 198),\n 'aquamarine3' -> Color.new255(102, 205, 170),\n 'aquamarine4' -> Color.new255(69, 139, 116),\n 'azure' -> Color.new255(240, 255, 255),\n 'azure1' -> Color.new255(240, 255, 255),\n 'azure2' -> Color.new255(224, 238, 238),\n 'azure3' -> Color.new255(193, 205, 205),\n 'azure4' -> Color.new255(131, 139, 139),"}
+{"text": " 205, 205),\n 'azure4' -> Color.new255(131, 139, 139),\n 'beige' -> Color.new255(245, 245, 220),\n 'bisque' -> Color.new255(255, 228, 196),\n 'bisque1' -> Color.new255(255, 228, 196),\n 'bisque2' -> Color.new255(238, 213, 183),\n 'bisque3' -> Color.new255(205, 183, 158),\n 'bisque4' -> Color.new255(139, 125, 107),\n 'black' -> Color.new255(0, 0, 0),\n 'blanched almond' -> Color.new255(255, 235, 205),\n 'BlanchedAlmond' -> Color.new255(255, 235, 205),\n 'blue' -> Color.new255(0, 0, 255),\n 'blue violet' -> Color.new255(138, 43, 226),\n 'blue1' -> Color.new255(0, 0, 255),\n 'blue2' -> Color.new255(0, 0, 238),\n 'blue3' -> Color.new255(0, 0, 205),\n 'blue4' -> Color.new255(0, 0, 139),\n 'BlueViolet' -> Color.new255(138, 43, 226),\n 'brown' -> Color.new255(165, 42, 42),\n 'brown1' -> Color.new255(255, 64, 64),\n 'brown2"}
+{"text": "\n 'brown1' -> Color.new255(255, 64, 64),\n 'brown2' -> Color.new255(238, 59, 59),\n 'brown3' -> Color.new255(205, 51, 51),\n 'brown4' -> Color.new255(139, 35, 35),\n 'burlywood' -> Color.new255(222, 184, 135),\n 'burlywood1' -> Color.new255(255, 211, 155),\n 'burlywood2' -> Color.new255(238, 197, 145),\n 'burlywood3' -> Color.new255(205, 170, 125),\n 'burlywood4' -> Color.new255(139, 115, 85),\n 'cadet blue' -> Color.new255(95, 158, 160),\n 'CadetBlue' -> Color.new255(95, 158, 160),\n 'CadetBlue1' -> Color.new255(152, 245, 255),\n 'CadetBlue2' -> Color.new255(142, 229, 238),\n 'CadetBlue3' -> Color.new255(122, 197, 205),\n 'CadetBlue4' -> Color.new255(83, 134, 139),\n 'chartreuse' -> Color.new255(127, 255, 0),\n 'chartreuse1' -> Color.new255(127, 255, 0),\n 'chartreuse2' -> Color.new255(118, 238, 0),\n 'chartreuse3' -> Color."}
+{"text": " Color.new255(118, 238, 0),\n 'chartreuse3' -> Color.new255(102, 205, 0),\n 'chartreuse4' -> Color.new255(69, 139, 0),\n 'chocolate' -> Color.new255(210, 105, 30),\n 'chocolate1' -> Color.new255(255, 127, 36),\n 'chocolate2' -> Color.new255(238, 118, 33),\n 'chocolate3' -> Color.new255(205, 102, 29),\n 'chocolate4' -> Color.new255(139, 69, 19),\n 'coral' -> Color.new255(255, 127, 80),\n 'coral1' -> Color.new255(255, 114, 86),\n 'coral2' -> Color.new255(238, 106, 80),\n 'coral3' -> Color.new255(205, 91, 69),\n 'coral4' -> Color.new255(139, 62, 47),\n 'cornflower blue' -> Color.new255(100, 149, 237),\n 'CornflowerBlue' -> Color.new255(100, 149, 237),\n 'cornsilk' -> Color.new255(255, 248, 220),\n 'cornsilk1' -> Color.new255(255, 248, 220),\n 'cornsilk2' -> Color.new255(238, 232, 205),\n 'cornsilk3' -> Color.new255(205, 200, 177),\n 'cornsilk4' -"}
+{"text": "ilk3' -> Color.new255(205, 200, 177),\n 'cornsilk4' -> Color.new255(139, 136, 120),\n 'cyan' -> Color.new255(0, 255, 255),\n 'cyan1' -> Color.new255(0, 255, 255),\n 'cyan2' -> Color.new255(0, 238, 238),\n 'cyan3' -> Color.new255(0, 205, 205),\n 'cyan4' -> Color.new255(0, 139, 139),\n 'dark goldenrod' -> Color.new255(184, 134, 11),\n 'dark green' -> Color.new255(0, 100, 0),\n 'dark khaki' -> Color.new255(189, 183, 107),\n 'dark olive green' -> Color.new255(85, 107, 47),\n 'dark orange' -> Color.new255(255, 140, 0),\n 'dark orchid' -> Color.new255(153, 50, 204),\n 'dark salmon' -> Color.new255(233, 150, 122),\n 'dark sea green' -> Color.new255(143, 188, 143),\n 'dark slate blue' -> Color.new255(72, 61, 139),\n 'dark slate gray' -> Color.new255(47, 79, 79),\n 'dark slate grey' -> Color.new255(47, 79, 79),\n 'dark turquoise' -> Color.new255(0, 206, 209),\n 'dark violet' -> Color.new255(14"}
+{"text": ".new255(0, 206, 209),\n 'dark violet' -> Color.new255(148, 0, 211),\n 'DarkGoldenrod' -> Color.new255(184, 134, 11),\n 'DarkGoldenrod1' -> Color.new255(255, 185, 15),\n 'DarkGoldenrod2' -> Color.new255(238, 173, 14),\n 'DarkGoldenrod3' -> Color.new255(205, 149, 12),\n 'DarkGoldenrod4' -> Color.new255(139, 101, 8),\n 'DarkGreen' -> Color.new255(0, 100, 0),\n 'DarkKhaki' -> Color.new255(189, 183, 107),\n 'DarkOliveGreen' -> Color.new255(85, 107, 47),\n 'DarkOliveGreen1' -> Color.new255(202, 255, 112),\n 'DarkOliveGreen2' -> Color.new255(188, 238, 104),\n 'DarkOliveGreen3' -> Color.new255(162, 205, 90),\n 'DarkOliveGreen4' -> Color.new255(110, 139, 61),\n 'DarkOrange' -> Color.new255(255, 140, 0),\n 'DarkOrange1' -> Color.new255(255, 127, 0),\n 'DarkOrange2' -> Color.new255(238, 118, 0),\n 'DarkOrange3' -> Color.new255(205, 102, 0),\n 'DarkOrange4' -> Col"}
+{"text": "' -> Color.new255(205, 102, 0),\n 'DarkOrange4' -> Color.new255(139, 69, 0),\n 'DarkOrchid' -> Color.new255(153, 50, 204),\n 'DarkOrchid1' -> Color.new255(191, 62, 255),\n 'DarkOrchid2' -> Color.new255(178, 58, 238),\n 'DarkOrchid3' -> Color.new255(154, 50, 205),\n 'DarkOrchid4' -> Color.new255(104, 34, 139),\n 'DarkSalmon' -> Color.new255(233, 150, 122),\n 'DarkSeaGreen' -> Color.new255(143, 188, 143),\n 'DarkSeaGreen1' -> Color.new255(193, 255, 193),\n 'DarkSeaGreen2' -> Color.new255(180, 238, 180),\n 'DarkSeaGreen3' -> Color.new255(155, 205, 155),\n 'DarkSeaGreen4' -> Color.new255(105, 139, 105),\n 'DarkSlateBlue' -> Color.new255(72, 61, 139),\n 'DarkSlateGray' -> Color.new255(47, 79, 79),\n 'DarkSlateGray1' -> Color.new255(151, 255, 255),\n 'DarkSlateGray2' -> Color.new255(141, 238, 238),\n 'DarkSlateGray3' -> Color.new255(12"}
+{"text": "141, 238, 238),\n 'DarkSlateGray3' -> Color.new255(121, 205, 205),\n 'DarkSlateGray4' -> Color.new255(82, 139, 139),\n 'DarkSlateGrey' -> Color.new255(47, 79, 79),\n 'DarkTurquoise' -> Color.new255(0, 206, 209),\n 'DarkViolet' -> Color.new255(148, 0, 211),\n 'deep pink' -> Color.new255(255, 20, 147),\n 'deep sky blue' -> Color.new255(0, 191, 255),\n 'DeepPink' -> Color.new255(255, 20, 147),\n 'DeepPink1' -> Color.new255(255, 20, 147),\n 'DeepPink2' -> Color.new255(238, 18, 137),\n 'DeepPink3' -> Color.new255(205, 16, 118),\n 'DeepPink4' -> Color.new255(139, 10, 80),\n 'DeepSkyBlue' -> Color.new255(0, 191, 255),\n 'DeepSkyBlue1' -> Color.new255(0, 191, 255),\n 'DeepSkyBlue2' -> Color.new255(0, 178, 238),\n 'DeepSkyBlue3' -> Color.new255(0, 154, 205),\n 'DeepSkyBlue4' -> Color.new255(0, 104, 139),\n 'dim gray' -> Color.new255(105"}
+{"text": ".new255(0, 104, 139),\n 'dim gray' -> Color.new255(105, 105, 105),\n 'dim grey' -> Color.new255(105, 105, 105),\n 'DimGray' -> Color.new255(105, 105, 105),\n 'DimGrey' -> Color.new255(105, 105, 105),\n 'dodger blue' -> Color.new255(30, 144, 255),\n 'DodgerBlue' -> Color.new255(30, 144, 255),\n 'DodgerBlue1' -> Color.new255(30, 144, 255),\n 'DodgerBlue2' -> Color.new255(28, 134, 238),\n 'DodgerBlue3' -> Color.new255(24, 116, 205),\n 'DodgerBlue4' -> Color.new255(16, 78, 139),\n 'firebrick' -> Color.new255(178, 34, 34),\n 'firebrick1' -> Color.new255(255, 48, 48),\n 'firebrick2' -> Color.new255(238, 44, 44),\n 'firebrick3' -> Color.new255(205, 38, 38),\n 'firebrick4' -> Color.new255(139, 26, 26),\n 'floral white' -> Color.new255(255, 250, 240),\n 'FloralWhite' -> Color.new255(255, 250, 240),\n 'forest green' -> Color.new255(34, 139, 34),\n 'ForestGre"}
+{"text": "\n 'forest green' -> Color.new255(34, 139, 34),\n 'ForestGreen' -> Color.new255(34, 139, 34),\n 'gainsboro' -> Color.new255(220, 220, 220),\n 'ghost white' -> Color.new255(248, 248, 255),\n 'GhostWhite' -> Color.new255(248, 248, 255),\n 'gold' -> Color.new255(255, 215, 0),\n 'gold1' -> Color.new255(255, 215, 0),\n 'gold2' -> Color.new255(238, 201, 0),\n 'gold3' -> Color.new255(205, 173, 0),\n 'gold4' -> Color.new255(139, 117, 0),\n 'goldenrod' -> Color.new255(218, 165, 32),\n 'goldenrod1' -> Color.new255(255, 193, 37),\n 'goldenrod2' -> Color.new255(238, 180, 34),\n 'goldenrod3' -> Color.new255(205, 155, 29),\n 'goldenrod4' -> Color.new255(139, 105, 20),\n 'gray' -> Color.new255(190, 190, 190),\n 'gray0' -> Color.new255(0, 0, 0),\n 'gray1' -> Color.new255(3, 3, 3),\n 'gray10' -> Color.new255(26, 26, 26),\n 'gray100' -> Color.new255(255, 255, 255),\n "}
+{"text": " 26, 26),\n 'gray100' -> Color.new255(255, 255, 255),\n 'gray11' -> Color.new255(28, 28, 28),\n 'gray12' -> Color.new255(31, 31, 31),\n 'gray13' -> Color.new255(33, 33, 33),\n 'gray14' -> Color.new255(36, 36, 36),\n 'gray15' -> Color.new255(38, 38, 38),\n 'gray16' -> Color.new255(41, 41, 41),\n 'gray17' -> Color.new255(43, 43, 43),\n 'gray18' -> Color.new255(46, 46, 46),\n 'gray19' -> Color.new255(48, 48, 48),\n 'gray2' -> Color.new255(5, 5, 5),\n 'gray20' -> Color.new255(51, 51, 51),\n 'gray21' -> Color.new255(54, 54, 54),\n 'gray22' -> Color.new255(56, 56, 56),\n 'gray23' -> Color.new255(59, 59, 59),\n 'gray24' -> Color.new255(61, 61, 61),\n 'gray25' -> Color.new255(64, 64, 64),\n 'gray26' -> Color.new255(66, 66, 66),\n 'gray27' -> Color.new255(69, 69, 69),\n 'gray28' -> Color.new255(71, 71, 71),\n 'gray29' -> Color"}
+{"text": "28' -> Color.new255(71, 71, 71),\n 'gray29' -> Color.new255(74, 74, 74),\n 'gray3' -> Color.new255(8, 8, 8),\n 'gray30' -> Color.new255(77, 77, 77),\n 'gray31' -> Color.new255(79, 79, 79),\n 'gray32' -> Color.new255(82, 82, 82),\n 'gray33' -> Color.new255(84, 84, 84),\n 'gray34' -> Color.new255(87, 87, 87),\n 'gray35' -> Color.new255(89, 89, 89),\n 'gray36' -> Color.new255(92, 92, 92),\n 'gray37' -> Color.new255(94, 94, 94),\n 'gray38' -> Color.new255(97, 97, 97),\n 'gray39' -> Color.new255(99, 99, 99),\n 'gray4' -> Color.new255(10, 10, 10),\n 'gray40' -> Color.new255(102, 102, 102),\n 'gray41' -> Color.new255(105, 105, 105),\n 'gray42' -> Color.new255(107, 107, 107),\n 'gray43' -> Color.new255(110, 110, 110),\n 'gray44' -> Color.new255(112, 112, 112),\n 'gray45' -> Color.new255(115, 115, 115),\n 'gray46' ->"}
+{"text": "gray45' -> Color.new255(115, 115, 115),\n 'gray46' -> Color.new255(117, 117, 117),\n 'gray47' -> Color.new255(120, 120, 120),\n 'gray48' -> Color.new255(122, 122, 122),\n 'gray49' -> Color.new255(125, 125, 125),\n 'gray5' -> Color.new255(13, 13, 13),\n 'gray50' -> Color.new255(127, 127, 127),\n 'gray51' -> Color.new255(130, 130, 130),\n 'gray52' -> Color.new255(133, 133, 133),\n 'gray53' -> Color.new255(135, 135, 135),\n 'gray54' -> Color.new255(138, 138, 138),\n 'gray55' -> Color.new255(140, 140, 140),\n 'gray56' -> Color.new255(143, 143, 143),\n 'gray57' -> Color.new255(145, 145, 145),\n 'gray58' -> Color.new255(148, 148, 148),\n 'gray59' -> Color.new255(150, 150, 150),\n 'gray6' -> Color.new255(15, 15, 15),\n 'gray60' -> Color.new255(153, 153, 153),\n 'gray61' -> Color.new255(156, 156, 156),\n 'gray62' -> Color.new255(158, 158, 158),\n 'gray"}
+{"text": "6),\n 'gray62' -> Color.new255(158, 158, 158),\n 'gray63' -> Color.new255(161, 161, 161),\n 'gray64' -> Color.new255(163, 163, 163),\n 'gray65' -> Color.new255(166, 166, 166),\n 'gray66' -> Color.new255(168, 168, 168),\n 'gray67' -> Color.new255(171, 171, 171),\n 'gray68' -> Color.new255(173, 173, 173),\n 'gray69' -> Color.new255(176, 176, 176),\n 'gray7' -> Color.new255(18, 18, 18),\n 'gray70' -> Color.new255(179, 179, 179),\n 'gray71' -> Color.new255(181, 181, 181),\n 'gray72' -> Color.new255(184, 184, 184),\n 'gray73' -> Color.new255(186, 186, 186),\n 'gray74' -> Color.new255(189, 189, 189),\n 'gray75' -> Color.new255(191, 191, 191),\n 'gray76' -> Color.new255(194, 194, 194),\n 'gray77' -> Color.new255(196, 196, 196),\n 'gray78' -> Color.new255(199, 199, 199),\n 'gray79' -> Color.new255(201, 201, 201),\n 'gray8' -> Color.new255(20, 20, 20),"}
+{"text": "(201, 201, 201),\n 'gray8' -> Color.new255(20, 20, 20),\n 'gray80' -> Color.new255(204, 204, 204),\n 'gray81' -> Color.new255(207, 207, 207),\n 'gray82' -> Color.new255(209, 209, 209),\n 'gray83' -> Color.new255(212, 212, 212),\n 'gray84' -> Color.new255(214, 214, 214),\n 'gray85' -> Color.new255(217, 217, 217),\n 'gray86' -> Color.new255(219, 219, 219),\n 'gray87' -> Color.new255(222, 222, 222),\n 'gray88' -> Color.new255(224, 224, 224),\n 'gray89' -> Color.new255(227, 227, 227),\n 'gray9' -> Color.new255(23, 23, 23),\n 'gray90' -> Color.new255(229, 229, 229),\n 'gray91' -> Color.new255(232, 232, 232),\n 'gray92' -> Color.new255(235, 235, 235),\n 'gray93' -> Color.new255(237, 237, 237),\n 'gray94' -> Color.new255(240, 240, 240),\n 'gray95' -> Color.new255(242, 242, 242),\n 'gray96' -> Color.new255(245, 245, 245),\n 'gray97"}
+{"text": "\n 'gray96' -> Color.new255(245, 245, 245),\n 'gray97' -> Color.new255(247, 247, 247),\n 'gray98' -> Color.new255(250, 250, 250),\n 'gray99' -> Color.new255(252, 252, 252),\n 'green' -> Color.new255(0, 255, 0),\n 'green yellow' -> Color.new255(173, 255, 47),\n 'green1' -> Color.new255(0, 255, 0),\n 'green2' -> Color.new255(0, 238, 0),\n 'green3' -> Color.new255(0, 205, 0),\n 'green4' -> Color.new255(0, 139, 0),\n 'GreenYellow' -> Color.new255(173, 255, 47),\n 'grey' -> Color.new255(190, 190, 190),\n 'grey0' -> Color.new255(0, 0, 0),\n 'grey1' -> Color.new255(3, 3, 3),\n 'grey10' -> Color.new255(26, 26, 26),\n 'grey100' -> Color.new255(255, 255, 255),\n 'grey11' -> Color.new255(28, 28, 28),\n 'grey12' -> Color.new255(31, 31, 31),\n 'grey13' -> Color.new255(33, 33, 33),\n 'grey14' -> Color.new255(36, 36, 36),\n 'grey15' -> Color.new255(38, 38, 3"}
+{"text": "5(36, 36, 36),\n 'grey15' -> Color.new255(38, 38, 38),\n 'grey16' -> Color.new255(41, 41, 41),\n 'grey17' -> Color.new255(43, 43, 43),\n 'grey18' -> Color.new255(46, 46, 46),\n 'grey19' -> Color.new255(48, 48, 48),\n 'grey2' -> Color.new255(5, 5, 5),\n 'grey20' -> Color.new255(51, 51, 51),\n 'grey21' -> Color.new255(54, 54, 54),\n 'grey22' -> Color.new255(56, 56, 56),\n 'grey23' -> Color.new255(59, 59, 59),\n 'grey24' -> Color.new255(61, 61, 61),\n 'grey25' -> Color.new255(64, 64, 64),\n 'grey26' -> Color.new255(66, 66, 66),\n 'grey27' -> Color.new255(69, 69, 69),\n 'grey28' -> Color.new255(71, 71, 71),\n 'grey29' -> Color.new255(74, 74, 74),\n 'grey3' -> Color.new255(8, 8, 8),\n 'grey30' -> Color.new255(77, 77, 77),\n 'grey31' -> Color.new255(79, 79, 79),\n 'grey32' -> Color.new255(82, 82, 82),\n 'grey33"}
+{"text": "),\n 'grey32' -> Color.new255(82, 82, 82),\n 'grey33' -> Color.new255(84, 84, 84),\n 'grey34' -> Color.new255(87, 87, 87),\n 'grey35' -> Color.new255(89, 89, 89),\n 'grey36' -> Color.new255(92, 92, 92),\n 'grey37' -> Color.new255(94, 94, 94),\n 'grey38' -> Color.new255(97, 97, 97),\n 'grey39' -> Color.new255(99, 99, 99),\n 'grey4' -> Color.new255(10, 10, 10),\n 'grey40' -> Color.new255(102, 102, 102),\n 'grey41' -> Color.new255(105, 105, 105),\n 'grey42' -> Color.new255(107, 107, 107),\n 'grey43' -> Color.new255(110, 110, 110),\n 'grey44' -> Color.new255(112, 112, 112),\n 'grey45' -> Color.new255(115, 115, 115),\n 'grey46' -> Color.new255(117, 117, 117),\n 'grey47' -> Color.new255(120, 120, 120),\n 'grey48' -> Color.new255(122, 122, 122),\n 'grey49' -> Color.new255(125, 125, 125),\n 'grey5' -> Color.new255(13, 13, 13),\n '"}
+{"text": "5, 125, 125),\n 'grey5' -> Color.new255(13, 13, 13),\n 'grey50' -> Color.new255(127, 127, 127),\n 'grey51' -> Color.new255(130, 130, 130),\n 'grey52' -> Color.new255(133, 133, 133),\n 'grey53' -> Color.new255(135, 135, 135),\n 'grey54' -> Color.new255(138, 138, 138),\n 'grey55' -> Color.new255(140, 140, 140),\n 'grey56' -> Color.new255(143, 143, 143),\n 'grey57' -> Color.new255(145, 145, 145),\n 'grey58' -> Color.new255(148, 148, 148),\n 'grey59' -> Color.new255(150, 150, 150),\n 'grey6' -> Color.new255(15, 15, 15),\n 'grey60' -> Color.new255(153, 153, 153),\n 'grey61' -> Color.new255(156, 156, 156),\n 'grey62' -> Color.new255(158, 158, 158),\n 'grey63' -> Color.new255(161, 161, 161),\n 'grey64' -> Color.new255(163, 163, 163),\n 'grey65' -> Color.new255(166, 166, 166),\n 'grey66' -> Color.new255(168, 168, 168),\n 'grey67' -> Color.new255(171,"}
+{"text": "new255(168, 168, 168),\n 'grey67' -> Color.new255(171, 171, 171),\n 'grey68' -> Color.new255(173, 173, 173),\n 'grey69' -> Color.new255(176, 176, 176),\n 'grey7' -> Color.new255(18, 18, 18),\n 'grey70' -> Color.new255(179, 179, 179),\n 'grey71' -> Color.new255(181, 181, 181),\n 'grey72' -> Color.new255(184, 184, 184),\n 'grey73' -> Color.new255(186, 186, 186),\n 'grey74' -> Color.new255(189, 189, 189),\n 'grey75' -> Color.new255(191, 191, 191),\n 'grey76' -> Color.new255(194, 194, 194),\n 'grey77' -> Color.new255(196, 196, 196),\n 'grey78' -> Color.new255(199, 199, 199),\n 'grey79' -> Color.new255(201, 201, 201),\n 'grey8' -> Color.new255(20, 20, 20),\n 'grey80' -> Color.new255(204, 204, 204),\n 'grey81' -> Color.new255(207, 207, 207),\n 'grey82' -> Color.new255(209, 209, 209),\n 'grey83' -> Color.new255(212, 212, 212),\n 'grey84' -> Color.new25"}
+{"text": " Color.new255(212, 212, 212),\n 'grey84' -> Color.new255(214, 214, 214),\n 'grey85' -> Color.new255(217, 217, 217),\n 'grey86' -> Color.new255(219, 219, 219),\n 'grey87' -> Color.new255(222, 222, 222),\n 'grey88' -> Color.new255(224, 224, 224),\n 'grey89' -> Color.new255(227, 227, 227),\n 'grey9' -> Color.new255(23, 23, 23),\n 'grey90' -> Color.new255(229, 229, 229),\n 'grey91' -> Color.new255(232, 232, 232),\n 'grey92' -> Color.new255(235, 235, 235),\n 'grey93' -> Color.new255(237, 237, 237),\n 'grey94' -> Color.new255(240, 240, 240),\n 'grey95' -> Color.new255(242, 242, 242),\n 'grey96' -> Color.new255(245, 245, 245),\n 'grey97' -> Color.new255(247, 247, 247),\n 'grey98' -> Color.new255(250, 250, 250),\n 'grey99' -> Color.new255(252, 252, 252),\n 'honeydew' -> Color.new255(240, 255, 240),\n 'honeydew1' -> Color.new255(24"}
+{"text": "255(240, 255, 240),\n 'honeydew1' -> Color.new255(240, 255, 240),\n 'honeydew2' -> Color.new255(224, 238, 224),\n 'honeydew3' -> Color.new255(193, 205, 193),\n 'honeydew4' -> Color.new255(131, 139, 131),\n 'hot pink' -> Color.new255(255, 105, 180),\n 'HotPink' -> Color.new255(255, 105, 180),\n 'HotPink1' -> Color.new255(255, 110, 180),\n 'HotPink2' -> Color.new255(238, 106, 167),\n 'HotPink3' -> Color.new255(205, 96, 144),\n 'HotPink4' -> Color.new255(139, 58, 98),\n 'indian red' -> Color.new255(205, 92, 92),\n 'IndianRed' -> Color.new255(205, 92, 92),\n 'IndianRed1' -> Color.new255(255, 106, 106),\n 'IndianRed2' -> Color.new255(238, 99, 99),\n 'IndianRed3' -> Color.new255(205, 85, 85),\n 'IndianRed4' -> Color.new255(139, 58, 58),\n 'ivory' -> Color.new255(255, 255, 240),\n 'ivory1' -> Color.new255(255, 255, 240),\n 'ivory2' -> Color."}
+{"text": "' -> Color.new255(255, 255, 240),\n 'ivory2' -> Color.new255(238, 238, 224),\n 'ivory3' -> Color.new255(205, 205, 193),\n 'ivory4' -> Color.new255(139, 139, 131),\n 'khaki' -> Color.new255(240, 230, 140),\n 'khaki1' -> Color.new255(255, 246, 143),\n 'khaki2' -> Color.new255(238, 230, 133),\n 'khaki3' -> Color.new255(205, 198, 115),\n 'khaki4' -> Color.new255(139, 134, 78),\n 'lavender' -> Color.new255(230, 230, 250),\n 'lavender blush' -> Color.new255(255, 240, 245),\n 'LavenderBlush' -> Color.new255(255, 240, 245),\n 'LavenderBlush1' -> Color.new255(255, 240, 245),\n 'LavenderBlush2' -> Color.new255(238, 224, 229),\n 'LavenderBlush3' -> Color.new255(205, 193, 197),\n 'LavenderBlush4' -> Color.new255(139, 131, 134),\n 'lawn green' -> Color.new255(124, 252, 0),\n 'LawnGreen' -> Color.new255(124, 252, 0),\n 'lemon chiffon' -> Color.new255(255, 250, 205),\n 'L"}
+{"text": "\n 'lemon chiffon' -> Color.new255(255, 250, 205),\n 'LemonChiffon' -> Color.new255(255, 250, 205),\n 'LemonChiffon1' -> Color.new255(255, 250, 205),\n 'LemonChiffon2' -> Color.new255(238, 233, 191),\n 'LemonChiffon3' -> Color.new255(205, 201, 165),\n 'LemonChiffon4' -> Color.new255(139, 137, 112),\n 'light blue' -> Color.new255(173, 216, 230),\n 'light coral' -> Color.new255(240, 128, 128),\n 'light cyan' -> Color.new255(224, 255, 255),\n 'light goldenrod' -> Color.new255(238, 221, 130),\n 'light goldenrod yellow' -> Color.new255(250, 250, 210),\n 'light gray' -> Color.new255(211, 211, 211),\n 'light grey' -> Color.new255(211, 211, 211),\n 'light pink' -> Color.new255(255, 182, 193),\n 'light salmon' -> Color.new255(255, 160, 122),\n 'light sea green' -> Color.new255(32, 178, 170),\n 'light sky blue' -> Color.new255(135, 206, 250),\n 'light slate blue' -> Color.new255(132, 112, 255),\n 'light slate gray' -> Color.new255(119, 136,"}
+{"text": "2, 112, 255),\n 'light slate gray' -> Color.new255(119, 136, 153),\n 'light slate grey' -> Color.new255(119, 136, 153),\n 'light steel blue' -> Color.new255(176, 196, 222),\n 'light yellow' -> Color.new255(255, 255, 224),\n 'LightBlue' -> Color.new255(173, 216, 230),\n 'LightBlue1' -> Color.new255(191, 239, 255),\n 'LightBlue2' -> Color.new255(178, 223, 238),\n 'LightBlue3' -> Color.new255(154, 192, 205),\n 'LightBlue4' -> Color.new255(104, 131, 139),\n 'LightCoral' -> Color.new255(240, 128, 128),\n 'LightCyan' -> Color.new255(224, 255, 255),\n 'LightCyan1' -> Color.new255(224, 255, 255),\n 'LightCyan2' -> Color.new255(209, 238, 238),\n 'LightCyan3' -> Color.new255(180, 205, 205),\n 'LightCyan4' -> Color.new255(122, 139, 139),\n 'LightGoldenrod' -> Color.new255(238, 221, 130),\n 'LightGoldenrod1' -> Color.new255(255, 236, 139),\n 'LightGoldenrod2' -> Color.new255(238, 220"}
+{"text": "36, 139),\n 'LightGoldenrod2' -> Color.new255(238, 220, 130),\n 'LightGoldenrod3' -> Color.new255(205, 190, 112),\n 'LightGoldenrod4' -> Color.new255(139, 129, 76),\n 'LightGoldenrodYellow' -> Color.new255(250, 250, 210),\n 'LightGray' -> Color.new255(211, 211, 211),\n 'LightGrey' -> Color.new255(211, 211, 211),\n 'LightPink' -> Color.new255(255, 182, 193),\n 'LightPink1' -> Color.new255(255, 174, 185),\n 'LightPink2' -> Color.new255(238, 162, 173),\n 'LightPink3' -> Color.new255(205, 140, 149),\n 'LightPink4' -> Color.new255(139, 95, 101),\n 'LightSalmon' -> Color.new255(255, 160, 122),\n 'LightSalmon1' -> Color.new255(255, 160, 122),\n 'LightSalmon2' -> Color.new255(238, 149, 114),\n 'LightSalmon3' -> Color.new255(205, 129, 98),\n 'LightSalmon4' -> Color.new255(139, 87, 66),\n 'LightSeaGreen' -> Color.new255(32, 178, 170),\n 'LightSkyBlue' -> Color.new255("}
+{"text": "5(32, 178, 170),\n 'LightSkyBlue' -> Color.new255(135, 206, 250),\n 'LightSkyBlue1' -> Color.new255(176, 226, 255),\n 'LightSkyBlue2' -> Color.new255(164, 211, 238),\n 'LightSkyBlue3' -> Color.new255(141, 182, 205),\n 'LightSkyBlue4' -> Color.new255(96, 123, 139),\n 'LightSlateBlue' -> Color.new255(132, 112, 255),\n 'LightSlateGray' -> Color.new255(119, 136, 153),\n 'LightSlateGrey' -> Color.new255(119, 136, 153),\n 'LightSteelBlue' -> Color.new255(176, 196, 222),\n 'LightSteelBlue1' -> Color.new255(202, 225, 255),\n 'LightSteelBlue2' -> Color.new255(188, 210, 238),\n 'LightSteelBlue3' -> Color.new255(162, 181, 205),\n 'LightSteelBlue4' -> Color.new255(110, 123, 139),\n 'LightYellow' -> Color.new255(255, 255, 224),\n 'LightYellow1' -> Color.new255(255, 255, 224),\n 'LightYellow2' -> Color.new255(238, 238, 209),\n 'LightYellow3' -> Color.new255"}
+{"text": "new255(238, 238, 209),\n 'LightYellow3' -> Color.new255(205, 205, 180),\n 'LightYellow4' -> Color.new255(139, 139, 122),\n 'lime green' -> Color.new255(50, 205, 50),\n 'LimeGreen' -> Color.new255(50, 205, 50),\n 'linen' -> Color.new255(250, 240, 230),\n 'magenta' -> Color.new255(255, 0, 255),\n 'magenta1' -> Color.new255(255, 0, 255),\n 'magenta2' -> Color.new255(238, 0, 238),\n 'magenta3' -> Color.new255(205, 0, 205),\n 'magenta4' -> Color.new255(139, 0, 139),\n 'maroon' -> Color.new255(176, 48, 96),\n 'maroon1' -> Color.new255(255, 52, 179),\n 'maroon2' -> Color.new255(238, 48, 167),\n 'maroon3' -> Color.new255(205, 41, 144),\n 'maroon4' -> Color.new255(139, 28, 98),\n 'medium aquamarine' -> Color.new255(102, 205, 170),\n 'medium blue' -> Color.new255(0, 0, 205),\n 'medium orchid' -> Color.new255(186, 85, 211),\n 'medium purple' -> Color.new255(147, 112, 2"}
+{"text": "6, 85, 211),\n 'medium purple' -> Color.new255(147, 112, 219),\n 'medium sea green' -> Color.new255(60, 179, 113),\n 'medium slate blue' -> Color.new255(123, 104, 238),\n 'medium spring green' -> Color.new255(0, 250, 154),\n 'medium turquoise' -> Color.new255(72, 209, 204),\n 'medium violet red' -> Color.new255(199, 21, 133),\n 'MediumAquamarine' -> Color.new255(102, 205, 170),\n 'MediumBlue' -> Color.new255(0, 0, 205),\n 'MediumOrchid' -> Color.new255(186, 85, 211),\n 'MediumOrchid1' -> Color.new255(224, 102, 255),\n 'MediumOrchid2' -> Color.new255(209, 95, 238),\n 'MediumOrchid3' -> Color.new255(180, 82, 205),\n 'MediumOrchid4' -> Color.new255(122, 55, 139),\n 'MediumPurple' -> Color.new255(147, 112, 219),\n 'MediumPurple1' -> Color.new255(171, 130, 255),\n 'MediumPurple2' -> Color.new255(159, 121, 238),\n 'MediumPurple3' -> Color.new255(137, 104, 205),\n 'MediumPurple4' -> Color.new255("}
+{"text": "255(137, 104, 205),\n 'MediumPurple4' -> Color.new255(93, 71, 139),\n 'MediumSeaGreen' -> Color.new255(60, 179, 113),\n 'MediumSlateBlue' -> Color.new255(123, 104, 238),\n 'MediumSpringGreen' -> Color.new255(0, 250, 154),\n 'MediumTurquoise' -> Color.new255(72, 209, 204),\n 'MediumVioletRed' -> Color.new255(199, 21, 133),\n 'midnight blue' -> Color.new255(25, 25, 112),\n 'MidnightBlue' -> Color.new255(25, 25, 112),\n 'mint cream' -> Color.new255(245, 255, 250),\n 'MintCream' -> Color.new255(245, 255, 250),\n 'misty rose' -> Color.new255(255, 228, 225),\n 'MistyRose' -> Color.new255(255, 228, 225),\n 'MistyRose1' -> Color.new255(255, 228, 225),\n 'MistyRose2' -> Color.new255(238, 213, 210),\n 'MistyRose3' -> Color.new255(205, 183, 181),\n 'MistyRose4' -> Color.new255(139, 125, 123),\n 'moccasin' -> Color.new255(255, 228, 181),\n 'navajo white' -> Color.new255(255, 222"}
+{"text": "5, 228, 181),\n 'navajo white' -> Color.new255(255, 222, 173),\n 'NavajoWhite' -> Color.new255(255, 222, 173),\n 'NavajoWhite1' -> Color.new255(255, 222, 173),\n 'NavajoWhite2' -> Color.new255(238, 207, 161),\n 'NavajoWhite3' -> Color.new255(205, 179, 139),\n 'NavajoWhite4' -> Color.new255(139, 121, 94),\n 'navy' -> Color.new255(0, 0, 128),\n 'navy blue' -> Color.new255(0, 0, 128),\n 'NavyBlue' -> Color.new255(0, 0, 128),\n 'old lace' -> Color.new255(253, 245, 230),\n 'OldLace' -> Color.new255(253, 245, 230),\n 'olive drab' -> Color.new255(107, 142, 35),\n 'OliveDrab' -> Color.new255(107, 142, 35),\n 'OliveDrab1' -> Color.new255(192, 255, 62),\n 'OliveDrab2' -> Color.new255(179, 238, 58),\n 'OliveDrab3' -> Color.new255(154, 205, 50),\n 'OliveDrab4' -> Color.new255(105, 139, 34),\n 'orange' -> Color.new255(255, 165, 0),\n 'orange red' -> Color."}
+{"text": "ange' -> Color.new255(255, 165, 0),\n 'orange red' -> Color.new255(255, 69, 0),\n 'orange1' -> Color.new255(255, 165, 0),\n 'orange2' -> Color.new255(238, 154, 0),\n 'orange3' -> Color.new255(205, 133, 0),\n 'orange4' -> Color.new255(139, 90, 0),\n 'OrangeRed' -> Color.new255(255, 69, 0),\n 'OrangeRed1' -> Color.new255(255, 69, 0),\n 'OrangeRed2' -> Color.new255(238, 64, 0),\n 'OrangeRed3' -> Color.new255(205, 55, 0),\n 'OrangeRed4' -> Color.new255(139, 37, 0),\n 'orchid' -> Color.new255(218, 112, 214),\n 'orchid1' -> Color.new255(255, 131, 250),\n 'orchid2' -> Color.new255(238, 122, 233),\n 'orchid3' -> Color.new255(205, 105, 201),\n 'orchid4' -> Color.new255(139, 71, 137),\n 'pale goldenrod' -> Color.new255(238, 232, 170),\n 'pale green' -> Color.new255(152, 251, 152),\n 'pale turquoise' -> Color.new255(175, 238, 238),\n 'pale violet red' -> Color.new255(219,"}
+{"text": "5, 238, 238),\n 'pale violet red' -> Color.new255(219, 112, 147),\n 'PaleGoldenrod' -> Color.new255(238, 232, 170),\n 'PaleGreen' -> Color.new255(152, 251, 152),\n 'PaleGreen1' -> Color.new255(154, 255, 154),\n 'PaleGreen2' -> Color.new255(144, 238, 144),\n 'PaleGreen3' -> Color.new255(124, 205, 124),\n 'PaleGreen4' -> Color.new255(84, 139, 84),\n 'PaleTurquoise' -> Color.new255(175, 238, 238),\n 'PaleTurquoise1' -> Color.new255(187, 255, 255),\n 'PaleTurquoise2' -> Color.new255(174, 238, 238),\n 'PaleTurquoise3' -> Color.new255(150, 205, 205),\n 'PaleTurquoise4' -> Color.new255(102, 139, 139),\n 'PaleVioletRed' -> Color.new255(219, 112, 147),\n 'PaleVioletRed1' -> Color.new255(255, 130, 171),\n 'PaleVioletRed2' -> Color.new255(238, 121, 159),\n 'PaleVioletRed3' -> Color.new255(205, 104, 137),\n 'PaleVioletRed4' -> Color.new255(139, 71, 93),"}
+{"text": "7),\n 'PaleVioletRed4' -> Color.new255(139, 71, 93),\n 'papaya whip' -> Color.new255(255, 239, 213),\n 'PapayaWhip' -> Color.new255(255, 239, 213),\n 'peach puff' -> Color.new255(255, 218, 185),\n 'PeachPuff' -> Color.new255(255, 218, 185),\n 'PeachPuff1' -> Color.new255(255, 218, 185),\n 'PeachPuff2' -> Color.new255(238, 203, 173),\n 'PeachPuff3' -> Color.new255(205, 175, 149),\n 'PeachPuff4' -> Color.new255(139, 119, 101),\n 'peru' -> Color.new255(205, 133, 63),\n 'pink' -> Color.new255(255, 192, 203),\n 'pink1' -> Color.new255(255, 181, 197),\n 'pink2' -> Color.new255(238, 169, 184),\n 'pink3' -> Color.new255(205, 145, 158),\n 'pink4' -> Color.new255(139, 99, 108),\n 'plum' -> Color.new255(221, 160, 221),\n 'plum1' -> Color.new255(255, 187, 255),\n 'plum2' -> Color.new255(238, 174, 238),\n 'plum3' -> Color.new255(205, 150, 205),\n "}
+{"text": "4, 238),\n 'plum3' -> Color.new255(205, 150, 205),\n 'plum4' -> Color.new255(139, 102, 139),\n 'powder blue' -> Color.new255(176, 224, 230),\n 'PowderBlue' -> Color.new255(176, 224, 230),\n 'purple' -> Color.new255(160, 32, 240),\n 'purple1' -> Color.new255(155, 48, 255),\n 'purple2' -> Color.new255(145, 44, 238),\n 'purple3' -> Color.new255(125, 38, 205),\n 'purple4' -> Color.new255(85, 26, 139),\n 'red' -> Color.new255(255, 0, 0),\n 'red1' -> Color.new255(255, 0, 0),\n 'red2' -> Color.new255(238, 0, 0),\n 'red3' -> Color.new255(205, 0, 0),\n 'red4' -> Color.new255(139, 0, 0),\n 'rosy brown' -> Color.new255(188, 143, 143),\n 'RosyBrown' -> Color.new255(188, 143, 143),\n 'RosyBrown1' -> Color.new255(255, 193, 193),\n 'RosyBrown2' -> Color.new255(238, 180, 180),\n 'RosyBrown3' -> Color.new255(205, 155, 155),\n 'RosyBrown4' -> Color.new25"}
+{"text": ".new255(205, 155, 155),\n 'RosyBrown4' -> Color.new255(139, 105, 105),\n 'royal blue' -> Color.new255(65, 105, 225),\n 'RoyalBlue' -> Color.new255(65, 105, 225),\n 'RoyalBlue1' -> Color.new255(72, 118, 255),\n 'RoyalBlue2' -> Color.new255(67, 110, 238),\n 'RoyalBlue3' -> Color.new255(58, 95, 205),\n 'RoyalBlue4' -> Color.new255(39, 64, 139),\n 'saddle brown' -> Color.new255(139, 69, 19),\n 'SaddleBrown' -> Color.new255(139, 69, 19),\n 'salmon' -> Color.new255(250, 128, 114),\n 'salmon1' -> Color.new255(255, 140, 105),\n 'salmon2' -> Color.new255(238, 130, 98),\n 'salmon3' -> Color.new255(205, 112, 84),\n 'salmon4' -> Color.new255(139, 76, 57),\n 'sandy brown' -> Color.new255(244, 164, 96),\n 'SandyBrown' -> Color.new255(244, 164, 96),\n 'sea green' -> Color.new255(46, 139, 87),\n 'SeaGreen' -> Color.new255(46, 139, 87),"}
+{"text": ", 87),\n 'SeaGreen' -> Color.new255(46, 139, 87),\n 'SeaGreen1' -> Color.new255(84, 255, 159),\n 'SeaGreen2' -> Color.new255(78, 238, 148),\n 'SeaGreen3' -> Color.new255(67, 205, 128),\n 'SeaGreen4' -> Color.new255(46, 139, 87),\n 'seashell' -> Color.new255(255, 245, 238),\n 'seashell1' -> Color.new255(255, 245, 238),\n 'seashell2' -> Color.new255(238, 229, 222),\n 'seashell3' -> Color.new255(205, 197, 191),\n 'seashell4' -> Color.new255(139, 134, 130),\n 'sienna' -> Color.new255(160, 82, 45),\n 'sienna1' -> Color.new255(255, 130, 71),\n 'sienna2' -> Color.new255(238, 121, 66),\n 'sienna3' -> Color.new255(205, 104, 57),\n 'sienna4' -> Color.new255(139, 71, 38),\n 'sky blue' -> Color.new255(135, 206, 235),\n 'SkyBlue' -> Color.new255(135, 206, 235),\n 'SkyBlue1' -> Color.new255(135, 206, 255),\n 'SkyBl"}
+{"text": "yBlue1' -> Color.new255(135, 206, 255),\n 'SkyBlue2' -> Color.new255(126, 192, 238),\n 'SkyBlue3' -> Color.new255(108, 166, 205),\n 'SkyBlue4' -> Color.new255(74, 112, 139),\n 'slate blue' -> Color.new255(106, 90, 205),\n 'slate gray' -> Color.new255(112, 128, 144),\n 'slate grey' -> Color.new255(112, 128, 144),\n 'SlateBlue' -> Color.new255(106, 90, 205),\n 'SlateBlue1' -> Color.new255(131, 111, 255),\n 'SlateBlue2' -> Color.new255(122, 103, 238),\n 'SlateBlue3' -> Color.new255(105, 89, 205),\n 'SlateBlue4' -> Color.new255(71, 60, 139),\n 'SlateGray' -> Color.new255(112, 128, 144),\n 'SlateGray1' -> Color.new255(198, 226, 255),\n 'SlateGray2' -> Color.new255(185, 211, 238),\n 'SlateGray3' -> Color.new255(159, 182, 205),\n 'SlateGray4' -> Color.new255(108, 123, 139),\n 'SlateGrey' -> Color.new255(112, 128, 144),\n 'snow' -> Color.new255(255,"}
+{"text": ".new255(112, 128, 144),\n 'snow' -> Color.new255(255, 250, 250),\n 'snow1' -> Color.new255(255, 250, 250),\n 'snow2' -> Color.new255(238, 233, 233),\n 'snow3' -> Color.new255(205, 201, 201),\n 'snow4' -> Color.new255(139, 137, 137),\n 'spring green' -> Color.new255(0, 255, 127),\n 'SpringGreen' -> Color.new255(0, 255, 127),\n 'SpringGreen1' -> Color.new255(0, 255, 127),\n 'SpringGreen2' -> Color.new255(0, 238, 118),\n 'SpringGreen3' -> Color.new255(0, 205, 102),\n 'SpringGreen4' -> Color.new255(0, 139, 69),\n 'steel blue' -> Color.new255(70, 130, 180),\n 'SteelBlue' -> Color.new255(70, 130, 180),\n 'SteelBlue1' -> Color.new255(99, 184, 255),\n 'SteelBlue2' -> Color.new255(92, 172, 238),\n 'SteelBlue3' -> Color.new255(79, 148, 205),\n 'SteelBlue4' -> Color.new255(54, 100, 139),\n 'tan' -> Color.new255(210, 180, 140),\n 'tan1' -> Color.new255(255, 165"}
+{"text": "5(210, 180, 140),\n 'tan1' -> Color.new255(255, 165, 79),\n 'tan2' -> Color.new255(238, 154, 73),\n 'tan3' -> Color.new255(205, 133, 63),\n 'tan4' -> Color.new255(139, 90, 43),\n 'thistle' -> Color.new255(216, 191, 216),\n 'thistle1' -> Color.new255(255, 225, 255),\n 'thistle2' -> Color.new255(238, 210, 238),\n 'thistle3' -> Color.new255(205, 181, 205),\n 'thistle4' -> Color.new255(139, 123, 139),\n 'tomato' -> Color.new255(255, 99, 71),\n 'tomato1' -> Color.new255(255, 99, 71),\n 'tomato2' -> Color.new255(238, 92, 66),\n 'tomato3' -> Color.new255(205, 79, 57),\n 'tomato4' -> Color.new255(139, 54, 38),\n 'turquoise' -> Color.new255(64, 224, 208),\n 'turquoise1' -> Color.new255(0, 245, 255),\n 'turquoise2' -> Color.new255(0, 229, 238),\n 'turquoise3' -> Color.new255(0, 197, 205),\n 'turquoise4' -> Color.new255(0, 134, 139),"}
+{"text": "7, 205),\n 'turquoise4' -> Color.new255(0, 134, 139),\n 'violet' -> Color.new255(238, 130, 238),\n 'violet red' -> Color.new255(208, 32, 144),\n 'VioletRed' -> Color.new255(208, 32, 144),\n 'VioletRed1' -> Color.new255(255, 62, 150),\n 'VioletRed2' -> Color.new255(238, 58, 140),\n 'VioletRed3' -> Color.new255(205, 50, 120),\n 'VioletRed4' -> Color.new255(139, 34, 82),\n 'wheat' -> Color.new255(245, 222, 179),\n 'wheat1' -> Color.new255(255, 231, 186),\n 'wheat2' -> Color.new255(238, 216, 174),\n 'wheat3' -> Color.new255(205, 186, 150),\n 'wheat4' -> Color.new255(139, 126, 102),\n 'white' -> Color.new255(255, 255, 255),\n 'white smoke' -> Color.new255(245, 245, 245),\n 'WhiteSmoke' -> Color.new255(245, 245, 245),\n 'yellow' -> Color.new255(255, 255, 0),\n 'yellow green' -> Color.new255(154, 205, 50),\n 'yellow1' -> Color.new255(255, 255, 0),\n 'yellow"}
+{"text": " 50),\n 'yellow1' -> Color.new255(255, 255, 0),\n 'yellow2' -> Color.new255(238, 238, 0),\n 'yellow3' -> Color.new255(205, 205, 0),\n 'yellow4' -> Color.new255(139, 139, 0),\n 'YellowGreen' -> Color.new255(154, 205, 50)\n]\n)\n```"}
+{"text": "SuperCollider patch — examples/between_languages/fortran_supercollider.scd\n\nFortran http://en.wikibooks.org/wiki/Fortran/Fortran_examples\n\n```supercollider\n// Fortran\n// http://en.wikibooks.org/wiki/Fortran/Fortran_examples\n/*\nfunction gauss_sparse(num_iter, tol, b, A, x, actual_iter)\n\n! This function solves a system of equations (Ax = b) by using the Gauss-Seidel Method\n\n implicit none\n\n real :: gauss_sparse\n\n! Input: its value cannot be modified from within the function\n integer, intent(in) :: num_iter\n real, intent(in) :: tol\n real, intent(in), dimension(1:) :: b\n real, intent(in), dimension(1:,1:) :: A\n\n! Input/Output: its input value is used within the function, and can be modified\n real, intent(inout), dimension(1:) :: x\n\n! Output: its value is modified from within the function, only if the argument is required\n integer, optional, intent(out) :: actual_iter\n\n! Locals\n integer :: i, n, iter\n real :: tol_max, xk\n\n! Initialize values\n n = ubound(b, dim = 1) ! Size of array, obtained using ubound intrinsic function\n tol_max = 2. * tol\n iter = 0\n\n! Compute solution until convergence\n convergence_loop: do while (tol_max >= tol .and. iter < num_iter); iter = iter + 1\n\n tol_max"}
+{"text": "op: do while (tol_max >= tol .and. iter < num_iter); iter = iter + 1\n\n tol_max = -1. ! Reset the tolerance value\n\n! Compute solution for the k-th iteration\n iteration_loop: do i = 1, n\n\n! Compute the current x-value\n xk = (b(i) - dot_product(A(i,1:i-1),x(1:i-1)) - dot_product(A(i,i+1:n),x(i+1:n))) / A(i, i)\n\n! Compute the error of the solution\n! dot_product(a,v)=a'b\n tol_max = max((abs(x(i) - xk)/(1. + abs(xk))) ** 2, abs(A(i, i) * (x(i) - xk)), tol_max)\n x(i) = xk\n end do iteration_loop\n end do convergence_loop\n\n if (present(actual_iter)) actual_iter = iter\n gauss_sparse = tol_max\n\nend function gauss_sparse\n\n*/\n\n(\nvar dot_product = { |a, b| (a * b).sum };\nvar gauss_sparse = { | num_iter, tol, b, a, x |\n var gauss_sparse;\n // Locals\n var i, n, iter;\n var tol_max, xk;\n // Initialize values\n tol_max = 2.0 * tol;\n iter = 0;\n // Compute solution until convergence\n while { (tol_max >= tol) and: (iter < num_iter) }\n {\n iter = iter + 1;\n\n tol_max = -1.0; // Reset the tolerance value\n // Compute solution for the k-th iter"}
+{"text": "l_max = -1.0; // Reset the tolerance value\n // Compute solution for the k-th iteration\n i = 1;\n n.do {\n // Compute the current x-value\n xk = (b[i] - dot_product(a[i][i-1], x[i-1]) - dot_product(a[i][i+1], x[i+1])) / a[i][i];\n // Compute the error of the solution\n // dot_product(a,v)=a'b\n tol_max = max((abs(x[i] - xk)/(1.0 + abs(xk))) ** 2, abs(a[i][i] * (x[i] - xk)), tol_max);\n x[i] = xk;\n }\n\n };\n tol_max\n};\ngauss_sparse.(8, 2, [0, 1, 2, 3, 4], [[0, 1, 2], [1, 2, 3]], [0, 1, 2, 3, 4]);\n)\n```"}
+{"text": "SuperCollider classlib — testsuite/classlibrary/TestSerialPort.sc\n\nTests for SerialPort These tests perform integration testing on SerialPort by creating an input/output pair of virtual serial ports prior to each test. To run these tests on macOS/Linux, you need the `socat` utility. To run on Windows, you need to install `com0com` and configure it for use with the CNCA0 and CNCB0 ports.\n\n```supercollider\nTestSerialPort : UnitTest {\n\n var skipSerialTests;\n var input;\n var output;\n var socatPath;\n var com0comPath;\n\n const kBufferSize = 8192;\n\n setUp {\n if(this.skipSerialTests) { ^this };\n #input, output = this.createPorts();\n }\n\n tearDown {\n if(this.skipSerialTests) { ^this };\n this.destroyPorts();\n }\n\n // Return if socat (macOS/Linux) or com0com (Windows) is not installed.\n // This method memorizes its results.\n // FIXME find better way to annotate/skip tests\n skipSerialTests {\n if(skipSerialTests.notNil) {\n ^skipSerialTests;\n };\n skipSerialTests = false;\n if(thisProcess.platform.name == \\windows) {\n com0comPath ?? { this.findCom0com };\n com0comPath ?? {\n \"Skipping most SerialPort tests because com0com could not be found.\".warn;"}
+{"text": " ?? {\n \"Skipping most SerialPort tests because com0com could not be found.\".warn;\n skipSerialTests = true;\n }\n } {\n socatPath ?? { this.findSocat };\n socatPath ?? {\n \"Skipping most SerialPort tests because socat could not be found.\".warn;\n skipSerialTests = true;\n }\n };\n ^skipSerialTests;\n }\n\n findCom0com {\n block {|break|\n [\n \"C:\\\\Program Files\\\\com0com\\\\setupc.exe\",\n \"C:\\\\Program Files (x86)\\\\com0com\\\\setupc.exe\",\n \"C:\\\\Program Files (Arm)\\\\com0com\\\\setupc.exe\"\n ].do({|thisPath|\n if(File.exists(thisPath), {\n com0comPath = thisPath;\n break.();\n })\n })\n };\n com0comPath !? {com0comPath = thisProcess.platform.formatPathForCmdLine(com0comPath)}\n }\n\n findSocat {\n socatPath = \"which socat\".unixCmdGetStdOut.replace($\\n);\n if(socatPath.size == 0, {socatPath = nil}); //reset to nil if it's an empty string\n socatPath ?? {\n block {|break|\n [\n \"/usr/bin/socat\",\n \"/usr/local/bin/socat\",\n \"/opt/homebrew/bin/socat\"\n ].do({|"}
+{"text": "cat\",\n \"/opt/homebrew/bin/socat\"\n ].do({|thisPath|\n if(File.exists(thisPath), {\n socatPath = thisPath;\n break.();\n })\n })\n }\n };\n socatPath !? {socatPath = thisProcess.platform.formatPathForCmdLine(socatPath)}\n }\n\n // Create a pair of virtual serial ports and return their names\n createPorts {\n if(thisProcess.platform.name == \\windows) {\n ^this.getCom0ComPorts;\n } {\n ^this.createSocatPorts;\n }\n }\n\n destroyPorts {\n if(thisProcess.platform.name != \\windows) {\n \"killall socat\".unixCmdGetStdOut();\n };\n }\n\n getCom0ComPorts {\n var cmd = \"% list\".format(socatPath);\n var allPorts = cmd.unixCmdGetStdOut;\n var first, second;\n var getNameFromLine;\n\n if(allPorts.size == 0) {\n Error(\"No virtual ports available, create ports first\").throw;\n };\n\n allPorts = allPorts.split($\\n);\n\n getNameFromLine = {|line|\n var thisPort = line.findRegexp(\"PortName=([^,\\r\\n]+)\")[1][1];\n if((thisPort == \"-\") || (thisPort == \"COM#\")) {thisPort = \"\\\\\\\\.\\\\\" ++ line.split($ ).first}; //"}
+{"text": ")) {thisPort = \"\\\\\\\\.\\\\\" ++ line.split($ ).first}; // use internal name if there's no alias;\n thisPort\n };\n\n first = allPorts[0].stripWhiteSpace;\n first = getNameFromLine.(first);\n if(first.isEmpty) {\n Error(\"Could not get the port name\").throw;\n };\n\n second = allPorts[1].stripWhiteSpace;\n second = getNameFromLine.(second);\n if(second.isEmpty) {\n Error(\"Could not get the port name\").throw;\n };\n\n \"Using ports % and %\\n\".postf(first, second);\n\n ^[first, second]\n }\n\n createSocatPorts {\n var cmd = \"% -d -d pty,raw,echo=0 pty,raw,echo=0 2>&1\".format(socatPath);\n var pipe = Pipe.new(cmd, \"r\");\n var first, second;\n\n first = pipe.getLine;\n first = first.findRegexp(\"/dev/(ttys|pts).*\");\n if(first.isEmpty) {\n Error(\"socat is not installed\").throw;\n };\n\n first = first[0][1];\n\n second = pipe.getLine;\n second = second.findRegexp(\"/dev/(ttys|pts).*\");\n if(second.isEmpty) {\n Error(\"couldn't read second tty from socat\").throw;\n };\n\n second = second[0][1];\n\n ^[first, second]\n }\n\n // Sanitizes done action to avoid extra"}
+{"text": "][1];\n\n ^[first, second]\n }\n\n // Sanitizes done action to avoid extra post\n // args should be an event with keyword-arg pairs for SerialPort.new, or nil\n mkPort { |dev, args = (Event())|\n ^SerialPort.performWithEnvir(\\new, args ++ (port: dev)).doneAction_({});\n }\n\n // ----------- tests -----------------------------------------------------------------------------------------\n\n test_devices {\n // used to hang forever on macOS (#4131)\n SerialPort.devices;\n }\n\n test_open_onExistingDevice_defaultArgs {\n var port;\n if(this.skipSerialTests) { ^this };\n\n port = this.mkPort(input);\n this.assert(port.isOpen);\n port.close();\n }\n\n // check that reasonable combinations of arguments are supported for opening ports\n test_open_onExistingDevice_variousSupportedArgs {\n var port;\n var argLists = [\n (crtscts: true),\n (xonxoff: true),\n (stopbit: false),\n (baudrate: 19200),\n (exclusive: true),\n ];\n if(this.skipSerialTests) { ^this };\n\n argLists.do { |argList|\n var details = \"Arguments: %\".format(argList);\n this.assertNoException({ port = this.mkPort(input, argList) },\n \"Opening serial port with reasonable argum"}
+{"text": "ort = this.mkPort(input, argList) },\n \"Opening serial port with reasonable arguments should not throw\",\n details: details);\n this.assert(port.isOpen,\n \"Opening serial port with reasonable arguments should succeed\",\n details: details);\n port.close();\n };\n }\n\n test_open_errorOnExistingDevice_crtsctsAndXonxoffBothTrue {\n var port;\n if(this.skipSerialTests) { ^this };\n this.assertException({ port = SerialPort(input, crtscts: true, xonxoff: true) },\n PrimitiveFailedError,\n \"Trying to open a serial port with both xonxoff and crtscts should throw\");\n port !? { port.close() };\n }\n\n test_open_errorOnMissingDevice {\n if(this.skipSerialTests) { ^this };\n this.assertException( { SerialPort(\"/dev/doesnt_exist\") }, PrimitiveFailedError, \"Trying to open a missing serial port should throw\");\n }\n\n test_close {\n var port;\n if(this.skipSerialTests) { ^this };\n\n port = this.mkPort(input);\n port.close();\n this.assert(port.isOpen.not);\n }\n\n test_connectionLost {\n var in, cond;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n cond = Condition();\n this.destroyPorts();\n\n "}
+{"text": "\n\n in = this.mkPort(input);\n cond = Condition();\n this.destroyPorts();\n\n fork { 3.wait; cond.test_(true) };\n while { in.isOpen or: cond.test.not } { 0.001.wait };\n\n this.assert(in.isOpen.not);\n }\n\n test_next_noData_producesNil {\n var port;\n if(this.skipSerialTests) { ^this };\n\n port = this.mkPort(input);\n this.assertEquals(port.next, nil);\n port.close();\n }\n\n test_putAndNext_oneByte {\n var in, out, result, rout, cond;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n out = this.mkPort(output);\n result = nil;\n cond = Condition();\n\n out.put($a);\n\n rout = fork {\n while { result.isNil } {\n result = in.next;\n 0.01.wait\n };\n cond.test_(true).signal;\n };\n fork { 3.wait; cond.test_(true).signal };\n\n cond.wait();\n this.assertEquals(result, $a.ascii);\n rout.stop();\n\n in.close();\n out.close();\n }\n\n test_putAndNext_twoBytes {\n var in, out, result, rout, cond;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n out = this.mkPort(output);\n result = nil;\n cond = Condition();\n\n out.put("}
+{"text": ");\n out = this.mkPort(output);\n result = nil;\n cond = Condition();\n\n out.put($a);\n out.put($b);\n\n rout = fork {\n while { result.isNil } {\n result = in.next;\n 0.01.wait\n };\n cond.test_(true).signal;\n };\n fork { 3.wait; cond.test_(true).signal };\n\n cond.wait();\n this.assertEquals(result, $a.ascii);\n this.assertEquals(in.next, $b.ascii);\n rout.stop();\n\n in.close();\n out.close();\n }\n\n test_putAndRead_oneByte {\n var in, out, rout, cond, result;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n out = this.mkPort(output);\n\n rout;\n cond = Condition();\n result = nil;\n\n out.put($a);\n rout = fork { result = in.read; cond.test_(true).signal };\n fork { 3.wait; cond.test_(true).signal };\n\n cond.wait();\n this.assertEquals(result, $a.ascii);\n rout.stop();\n\n in.close();\n out.close();\n }\n\n test_rxErrors_noDataSent_isZero {\n var in;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n this.assertEquals(in.rxErrors, 0);\n in.close();\n }\n\n test_rxErrors_bufferOverf"}
+{"text": "ors, 0);\n in.close();\n }\n\n test_rxErrors_bufferOverflow {\n var in, out, rxErrs;\n var written = 0, res, now, timeoutTime = 5;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n out = this.mkPort(output);\n rxErrs = 0;\n\n // Overflow the buffer by exactly 1\n for(0, kBufferSize) { |i|\n while { res = out.put($a); res == false } { // retry if writing failed\n \"retrying send...\".postln;\n 0.001.wait;\n };\n if(res) {written = written + 1};\n 0.0001.wait;\n };\n\n now = thisProcess.mainThread.seconds;\n\n // spin until all data has been read\n while { (rxErrs == 0) and: ((thisProcess.mainThread.seconds - now) < timeoutTime) } { rxErrs = in.rxErrors; 0.01.wait; };\n\n if((thisProcess.mainThread.seconds - now) > timeoutTime) { \"TIMEOUT!\".warn };\n // \"Written bytes: %\\nrxErrs: %\\n\".postf(written,rxErrs);\n\n this.assert(rxErrs > 0);\n\n in.close();\n out.close();\n }\n\n test_putAll {\n var in, out, result, rout, cond;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n out = this."}
+{"text": "ipSerialTests) { ^this };\n\n in = this.mkPort(input);\n out = this.mkPort(output);\n result = nil;\n rout;\n cond = Condition();\n\n out.putAll(\"Hello\");\n\n rout = fork {\n while { result.isNil } {\n result = in.next;\n 0.01.wait\n };\n cond.test_(true).signal;\n };\n fork { 3.wait; cond.test_(true).signal };\n\n cond.wait();\n this.assertEquals(result, $H.ascii);\n this.assertEquals(in.next, $e.ascii);\n this.assertEquals(in.next, $l.ascii);\n this.assertEquals(in.next, $l.ascii);\n this.assertEquals(in.next, $o.ascii);\n this.assertEquals(in.next, nil);\n rout.stop();\n\n in.close();\n out.close();\n }\n\n test_doneAction_onNormalClose {\n var in, ranAction, cond;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n ranAction = false;\n cond = Condition();\n\n in.doneAction_ {\n ranAction = true;\n cond.test_(true).signal;\n };\n fork { 3.wait; cond.test_(true).signal };\n\n in.close();\n cond.wait();\n\n this.assert(ranAction);\n }\n\n test_doneAction_onConnectionLost {\n var in, ranAction, cond;\n if(this.skipSerial"}
+{"text": "onConnectionLost {\n var in, ranAction, cond;\n if(this.skipSerialTests) { ^this };\n\n in = this.mkPort(input);\n ranAction = false;\n cond = Condition();\n\n in.doneAction_ {\n ranAction = true;\n cond.test_(true).signal;\n };\n fork { 3.wait; cond.test_(true).signal };\n\n this.destroyPorts();\n cond.wait();\n\n this.assert(ranAction);\n }\n}\n```"}
+{"text": "SuperCollider classlib — testsuite/classlibrary/TestServer_ServerGUI.sc\n\nTestServer_ServerGUI.sc Author: Brian Heim (brianlheim@gmail.com) Tests for the GUI created by s.makeGui TODO: recording state tests?\n\n```supercollider\n // Note: If you are changing these, you probably mean to change `getButtons`!\n const bootButtonIdx = 0;\n const killButtonIdx = 1;\n const defaultButtonIdx = 2;\n const recordButtonIdx = 3;\n const volumeButtonIdx = 4;\n\n var server;\n var window;\n var buttons;\n var buttonNames;\n\n setUp {\n if(buttonNames.isNil) {\n buttonNames = Array.fill(5, \"\");\n buttonNames[bootButtonIdx] = \"boot\";\n buttonNames[killButtonIdx] = \"kill\";\n buttonNames[defaultButtonIdx] = \"default\";\n buttonNames[recordButtonIdx] = \"record\";\n buttonNames[volumeButtonIdx] = \"volume\";\n };\n\n server = Server(this.class.name);\n server.makeGui;\n window = server.window;\n buttons = this.getButtons(window);\n }\n\n tearDown {\n server.stopAliveThread; // XXX: needed to avoid alive threads started by server.makeGui\n server.remove;\n window.close;\n 0.5.wa"}
+{"text": " by server.makeGui\n server.remove;\n window.close;\n 0.5.wait; // XXX: wait for window to execute its onClose\n window = buttons = server = nil;\n }\n\n // Puts the buttons from the window in the same order as the indices expected\n // by this class. If the order ever changes, it would be much easier to adjust\n // here than to edit the values in each test method.\n getButtons { |w|\n ^w.view.children.select(_.isKindOf(QButton));\n }\n\n // Asserts states (values & enabled/disabled) of buttons. `testName` is the\n // name of the condition being tested (e.g. \"Before booting\")\n assertButtonStates { |expValues, expEnabled, testName|\n var actValues = buttons.collect(_.value);\n var actEnabled = buttons.collect(_.enabled);\n\n expValues.do { |val, i|\n this.assertEquals(actValues[i], expValues[i],\n \"%: '%' button should have correct value\".format(testName, buttonNames[i]));\n this.assert(actEnabled[i] == expEnabled[i],\n \"%: '%' button should be %\".format(\n testName, buttonNames[i], expEnabled[i].if(\"enabled\", \"disabled\")));\n }\n }\n\n // test the GUI state without any action taken\n test_noBoot {\n var expValues = [0, 0, 0, 0, 0];\n var expEnabled = [true, true, true, false, true"}
+{"text": "0, 0, 0, 0, 0];\n var expEnabled = [true, true, true, false, true];\n this.assertButtonStates(expValues, expEnabled, \"Before booting\");\n }\n\n // GUI state after booting\n test_boot {\n var expValues = [1, 0, 0, 0, 0];\n var expEnabled = [true, true, true, true, true];\n this.bootServer(server);\n this.assertButtonStates(expValues, expEnabled, \"After booting\");\n server.quitSync;\n }\n\n // GUI state after booting and muting the server\n test_mute {\n var expValues = [1, 0, 0, 0, 1];\n var expEnabled = [true, true, true, true, true];\n this.bootServer(server);\n server.volume.mute;\n this.assertButtonStates(expValues, expEnabled, \"After muting\");\n server.volume.unmute;\n server.quitSync;\n }\n\n // GUI state after booting, muting, then unmuting the server\n test_unmute {\n var expValues = [1, 0, 0, 0, 0];\n var expEnabled = [true, true, true, true, true];\n this.bootServer(server);\n server.volume.mute;\n server.volume.unmute;\n this.assertButtonStates(expValues, expEnabled, \"After muting and unmuting\");\n server.quitSync;\n }\n\n // GUI state after booting then quitting\n test_quit {\n var expValues"}
+{"text": "c;\n }\n\n // GUI state after booting then quitting\n test_quit {\n var expValues = [0, 0, 0, 0, 0];\n var expEnabled = [true, true, true, false, true];\n this.bootServer(server);\n server.quitSync;\n this.assertButtonStates(expValues, expEnabled, \"After quitting\");\n }\n\n // GUI state after setting default\n test_default {\n var expValues = [0, 0, 1, 0, 0];\n var expEnabled = [true, true, true, false, true];\n var oldDefault;\n\n oldDefault = Server.default;\n Server.default = server;\n\n this.assertButtonStates(expValues, expEnabled, \"After defaulting this server\");\n\n Server.default = oldDefault;\n }\n\n // GUI state after setting not default\n test_undefault {\n var expValues = [0, 0, 0, 0, 0];\n var expEnabled = [true, true, true, false, true];\n var oldDefault;\n\n oldDefault = Server.default;\n Server.default = server;\n Server.default = oldDefault;\n\n this.assertButtonStates(expValues, expEnabled, \"After un-defaulting this server\");\n }\n\n}\n```"}
+{"text": "SuperCollider classlib — testsuite/classlibrary/TestSourceCode.sc\n\nFormatting is on purpose here to catch edge cases. Don't change it.\n\n```supercollider\n f = { 1 + 1 };\n this.assertEquals(f.def.sourceCode.quote, \"{ 1 + 1 }\".quote);\n\n f = {1+1};\n this.assertEquals(f.def.sourceCode.quote, \"{1+1}\".quote);\n\n f = {1+1}\n /* dont remove this comment */\n ;\n this.assertEquals(f.def.sourceCode.quote, \"{1+1}\".quote);\n\n f = { var a, b = 10;\n\n };\n this.assertEquals(f.def.sourceCode.quote, \"{ var a, b = 10;\n\n }\".quote);\n }\n\n test_partial {\n var f;\n\n f = _ + 1;\n this.assertEquals(f.def.sourceCode.quote, \"_ + 1\".quote);\n\n f = (_ + 1)\n // dont' remove this comment or new line\n ;\n this.assertEquals(f.def.sourceCode.quote, \"(_ + 1)\".quote);\n\n f = (_ + 1);\n this.assertEquals(f.def.sourceCode.quote, \"(_ + 1)\".quote);\n\n f = _ + _ + _ + _;\n this.assertEquals(f.def.sourceCode.quote, \"_ + _ + _ + _\".quote);\n\n f = (_ + (_ + (_)) + _);\n this.assertEquals(f.def.sourceCode.quote, \"(_ + (_ + (_)) + _)\".quote);\n }"}
+{"text": "f.def.sourceCode.quote, \"(_ + (_ + (_)) + _)\".quote);\n }\n\n test_compileString {\n var func = { 1 + 1 };\n this.assertEquals(func.asCompileString, \"{ 1 + 1 }\");\n }\n}\n```"}
+{"text": "SuperCollider classlib — testsuite/classlibrary/TestSynthDefVersions.sc\n\n```supercollider\n readAndWriteSynthDefs { |version|\n var defArray, stream, descArray;\n var libName = thisMethod.name.asSymbol;\n var lib = SynthDescLib(libName);\n var defClass = if (version > 1) { SynthDef } { SynthDefOld };\n var graphFunc = { |in, out, freq=440, amp=1.0| Out.ar(out, (SinOsc.ar(freq) * In.ar(in)) * amp) };\n var variants = (a: [ freq: 220 ], b: [ freq: 100 ], c: [ freq: 600 ]);\n\n // test with multiple SynthDefs per message. Also include variants.\n defArray = [\n defClass.new((\"test_v\"++version++\"_1\").asSymbol, graphFunc, variants: variants),\n defClass.new((\"test_v\"++version++\"_2\").asSymbol, graphFunc, variants: variants)\n ];\n\n descArray = defArray.collect { |def| def.asSynthDesc(libName) };\n\n this.assertNoException({\n stream = CollStream.on(Int8Array.new(256));\n if (version > 1) {\n defArray.writeDef(stream, version);\n } {\n defArray.writeDefOld(stream);\n };\n stream.pos = 0; // rewind\n\n this.assertNoException({\n var set = lib.readStream("}
+{"text": " = 0; // rewind\n\n this.assertNoException({\n var set = lib.readStream(stream);\n var array = set.asArray.sort { |a, b| a.name < b.name };\n var isEqual = array.every { |desc, i|\n this.compareSynthDescs(desc, descArray[i])\n };\n\n this.assert(isEqual, \"reconstructed SynthDesc (version %) should be equal to original SynthDesc\".format(version));\n\n ^array;\n }, \"SynthDef version % can be read from stream\".format(version));\n\n }, \"SynthDef version % can be written to stream\".format(version));\n\n ^nil;\n }\n\n test_readAndWriteSynthDefs {\n var arrays = (1..3).collect { |version|\n this.readAndWriteSynthDefs(version)\n };\n var isEqual = arrays.flop.every { |descs|\n descs.do(_.name = \"dummy\"); // bash names\n this.compareSynthDescs(descs[0], descs[1]) and: {\n this.compareSynthDescs(descs[1], descs[2])\n }\n };\n this.assert(isEqual, \"(reconstructed) SynthDescs of all versions should compare equal\");\n }\n\n readCorruptedSynthDefs { |version|\n var defArray, data, stream, libName = thisMethod.name.asSymbol;\n var lib = SynthDescLib(libName);\n var defClass = if (version > 1) { SynthD"}
+{"text": "ynthDescLib(libName);\n var defClass = if (version > 1) { SynthDef } { SynthDefOld };\n var graphFunc = { |in, out, freq=440, amp=1.0| Out.ar(out, (SinOsc.ar(freq) * In.ar(in)) * amp) };\n var variants = (a: [ freq: 220 ], b: [ freq: 100 ], c: [ freq: 600 ]);\n var didReadStream;\n // test with multiple SynthDefs per message. Also include variants.\n defArray = [\n defClass.new((\"test_v\"++version++\"_1\").asSymbol, graphFunc, variants: variants),\n defClass.new((\"test_v\"++version++\"_2\").asSymbol, graphFunc, variants: variants)\n ];\n\n stream = CollStream.on(Int8Array(256));\n if (version > 1) {\n defArray.writeDef(stream, version);\n } {\n defArray.writeDefOld(stream);\n };\n data = stream.collection.copy;\n // remove the last 4 bytes\n data = data.extend(data.size - 4);\n // now try to read the corrupted SynthDef.\n // on every iteration, slice off half of the data.\n didReadStream = false;\n while { data.size > 1 } {\n stream = CollStream(data);\n try {\n SynthDescLib.global.readStream(stream);\n didReadStream = true;\n };\n data = data.extend(data.size div: 2);\n };\n this.assert(didRead"}
+{"text": " };\n data = data.extend(data.size div: 2);\n };\n this.assert(didReadStream.not, \"passing corrupted SynthDef v% data to SynthDescLib-readStream must throw an Error\".format(version));\n \"done\".postln;\n }\n\n test_readCorruptedSynthDefs {\n (1..3).do { |version|\n this.readCorruptedSynthDefs(version)\n };\n }\n}\n```"}
+{"text": "SuperCollider classlib — testsuite/classlibrary/TestTaskProxy.sc\n\n```supercollider\n test_TaskProxy_playOnInstanceClock {\n var actualClock;\n var clock = TempoClock(2);\n var cond = Condition();\n var proxy = TaskProxy{ actualClock = thisThread.clock; cond.unhang };\n proxy.play; // needs to play once before setting clock_, otherwise playOnce sets the player's clock for us\n cond.hang;\n proxy.clock_(clock).play;\n cond.hang;\n this.assertEquals(actualClock, clock, \"TaskProxy.play() should use instance's clock if no argClock is given\");\n }\n\n}\n```"}