An Instrument is a function that has a unique name attached to it and Specs that describe the input and output datatypes.
It is stored in a library by its name and can be retrieved by that name. They can be used to create SynthDefs but also as a general use library of resuable functions.
Instr can be looked up by their name and will be loaded from disk. Every package or quark can have a folder called Instr which will be searched when loading an Instr. So Quarks can be used to share collections of Instr / SynthDefs.
Unlike SynthDef, Instr can take any kind of input for its arguments, not just (including an Integer quantity, symbols or even other functions) and so while a SynthDef has a fixed architecture for a Synth, an Instr can generate multiple SynthDefs of varying architectures. For instance you could specify an Env or a fixed time duration or a quantity (how many parallel voices to create, detuned against each other) or even the name of a UGen (LFSaw, Pulse) to use for the oscillator.
There are methods detailed below for creating SynthDefs from Instr. Instr also support partial application (supplying some of the arguments in advance) and function composition (chaining them together to make a new Instr)
SynthDefs can be created and Synths can be spawned in various convienient ways.
Instr can also be used in Patterns.
Instr can be chained together, used as subroutines and have inputs partially satisfied.
Instr can be chained together using a lisp dialect.
When used with Patch there are some glue functions to make language-server communication much easier and clearer.
------------------------------------------------------------
Whenever you create an Instr it is stored in the library:
and can be retrieved:
or redefined:
Make a SynthDef:
Make a Synth:
A simple reference gui:
Browse your Instr library:
name |
Valid formats: All quarks/Instr folders are searched |
func |
the ugenFunc Note: when using your Instrument with Patch THERE IS NO NEED TO USE Out.ar though you may explicitly use it if you wish. It will be appended to your ugen graph func if needed. |
specs |
Specify what kind of input is required, and the working range of values. somewhat optional - these can be guessed from the argnames. if no spec is supplied, Instr will use the function's argument name to lookup a spec in Spec.specs. eg arg freq -> looks for Spec.specs.at(\freq) If nothing is found there, it will default to a ControlSpec with a range of 0 .. 1 These specs are used by Patch to determine the suitable type of input. They may be used in many other situations, and you will find many uses where you will wish to query the specs. The default/initial value for the Spec is taken from the function defaults. different lazy ways to specify the spec... |
outSpec |
optional - InstrSynthDef can determine the outputSpec by evaluating the ugenGraph and finding what the spec of the result is. An Instr can be .ar, .kr or can even return an object, a player, or a pattern. |
private
The default directory to look for Instr. Each quark can also contain an Instr/ dir and those will be searched.
p |
path |
look up an Instr by name, searching and loading from disk if not already loaded.
name |
loads Instr by name from file
name |
loads all Instr in all Instr/ directories. This usually doesn't take very long and doesn't take up that much memory. I load all on compile.
private
dir |
Because Instr files are kept in quarks this can greatly increase the number of files that the language compiler will attempt to examine. It won't compile them, but it looks at all of those folders anyway. This adds the paths of all of your Instr folders to the LanguageConfig exclude paths.
clear the Library cache
As a class method, this looks up (or loads) the Instr and values it with supplied args. It can thus be used as a kind of subroutine or easily reusable function.
Equivalent usage when using an instance:
name | |
args |
array or dict |
see ar
name | |
args |
array or dict |
choose a random Instr from the library.
start |
if supplied, this is the address of the branch within the Instr library tree from which to choose |
an Instr
returns all Instr in the library tree in a flat list
startAt |
if supplied, address of a branch within the tree. eg. Instr.leaves("oscillators") |
an Array of Instr
filters the Instr library for those matching the output Spec.
outSpec |
an Array of Instr
chooses a random Instr among those matching the outputSpec
outSpec |
an Instr
instr |
remove an Instr from the library
instr |
returns the removed Instr or nil it wasn't defined
a method for creating many related instruments. short for orchestra, but funnier.
name | |
pairs | |
outSpec |
convert dotNotation to symbolized list form: [\one,\two,\three] private
name |
checks if an object by this name is already defined
name |
Boolean
name |
symbolized |
name as list of symbols |
private
symbolized |
name as list of symbols |
rootPath |
private
private converts dotNotation to symbolized list
singleName |
the symbolized version of the name: [\one,\two,\three] dotNotation is usually nicer to work with.
the canonical instr name with each path element joined by dots : "one.two.three"
string
get or set the Instr function
an array of specs, one for each input
the output Spec of the Instr. if your Instr is not 'audio' rate or is multi channel than it is best to specify an outSpec
those that were declared when creating the Instr, as opposed to those that were not supplied and were guessed by using the argName
Most methods accept args in the form of a list [ 440, 1.0, Env.adsr ] or as a argName:value dict (env:Env.adsr)
This utility function converts the supplied arguments to the list form.
args |
array or dict |
array
values the function using the supplied inputs. this is for using Instr as a subroutine or function library.
... inputs |
inputs as separate arguments |
inputs as a single array or dict same as .valueArray but should probably change to accept ... inputs
inputs |
array or dict |
values the function with the supplied inputs, filling in any missing ones by looking up by argName in the current Environment
inputs |
array or dict |
like value but takes a single array
inputs |
array or dict |
same as ar
... inputs |
array or dict |
creates a SynthDef
args |
array or dict |
outClass |
if no Out.ar is found in your Instr then it automatically adds one and an argument called \out The default class is Out, but you can specify ReplaceOut or OffsetOut |
creates SynthDef and writes it to file
dir |
directory to write to. the name is unique and is determined by the arguments |
args |
array or dict |
this
same as writeDefFile, older syntax
dir | |
args |
array or dict |
this
create a SynthDef and add it to the SynthDescLib for use in Patterns. see also Instr-Patterns
args |
array or dict |
libname | |
completionMsg | |
keepDef |
for Patterns. older system, .add is preferred now
args |
array or dict |
spawn a Synth into the same Group as a node, directly after that node in the call graph
anode | |
args |
array or dict |
bundle | |
atTime |
see atTime |
out |
out bus index |
a Synth
spawn a Synth into the same Group as a node, directly before that node in the call graph
anode | |
args |
array or dict |
bundle | |
atTime |
see atTime |
out |
out bus index |
a Synth
spawn a Synth into the Group, adding it as the first node in that group
anode | |
args |
array or dict |
bundle | |
atTime |
see atTime |
out |
out bus index |
a Synth
spawn a Synth into the Group, adding it as the last node in that group
anode | |
args |
array or dict |
bundle | |
atTime |
see atTime |
out |
out bus index |
a Synth
spawn a Synth that replace an already playing Synth and frees it
anode | |
args |
array or dict |
bundle | |
atTime |
see atTime |
out |
out bus index |
sets the Event 'type' = 'instr' and 'instr' = this and then .plays the Event.
event |
Event to play. Instr arguments will be looked up by name in the Event. |
same as valueArray, for use in Streams
... inputs |
array or dict |
function composition : construct a CompositeInstr by patching this Instr into another one.
that |
another Instr (or a CompositeInstr or Papplied Instr) |
partial application : fix certain args with the supplied object. returns a PappliedInstr
... args |
either a dict or a list. if a list then non nil arguments will |
\audio \control \scalar \stream If the Instr has an out spec then it will determine the rate. Otherwise its assumed to be the default 'audio'
a Symbol
If the Instr has an out spec then it will determine the numChannels. Otherwise its assumed to be the default 1
Integer
full path on disk if the Instr was loaded from a file
same as argsSize
number of arguments / inputs.
array of Symbols
the defaults for each argument that were specified in the function; eg. for { arg freq=440; } the defArg is 440
array of default args
i |
i |
either the default value supplied in the function or the spec's default value.
i |
the instr name as a string: "one.two.three"
deprec.
calculates the unique SynthDef name for the supplied arguments. this is fairly efficient and is even used when spawning Events in Patterns
args |
array or dict the objects that determine the unique SynthDef. they may determine the rate, whether a control input is added or not and they may insert unique objects into the SynthDef. |
string
group | |
bundle |
targetStyle | |
anode | |
args |
array or dict |
bundle | |
atTime |
see atTime |
out |
out bus index |
creates a Patch, guis it and plays it
... args |
a Patch
creates a Patch and plays it
... args |
a Patch
creates a Patch and plays it for {duration} seconds and plots it
args |
array or dict |
duration |
printable name
for storing Instr and objects that have Instr. if the Instr was loaded from disk then the dotNotation instr name is used. if it was created with something like Patch({ SinOsc.ar }) then the source code is used.
if the name is the same then its the same Instr. so copying just returns self. this might be changed.
this
private
specs | |
outsp |
outSpec |
private
argSpecs |
a filter is any instr that has an input the same spec as its output.
Boolean
... args |
bus |