SC setups may contain discrete and continuous control, e.g. using combinations of Pbinds, Tasks and Synths. There are many possible ways of interaction between such elements, sometimes there is the alternative to control things by server or language (e.g. Pbinds versus Demand Ugens) but often one needs to have both. VarGui is a multi purpose slider and player GUI, originally intended for indentifying parameters to be reused in other setups. Pbinds and Tasks can easily refer to environmental variables - in case of Pbinds e.g. via Pfunc, Plazy, Pcollect, but more conveniently via the dynamic scope PLx_suite - so VarGui can control environmental variables and synth controllers. For using event patterns with functional code and the related scoping features see Event_patterns_and_Functions. VarGui was not intended for performance, however (since miSCellaneous v0.4) it includes a player section. Players can be used in different (reset) modes, states of synths and streams are reflected by colors, it also works with wslib slider classes (Ex.8). For quick GUI generation using SynthDef metadata for controlspecs and / or automatic Pbind builds see VarGui_shortcut_builds. As both VarGui help files are quite full of details, a more general overview, including some exercises, is given in Introduction_to_miSCellaneous.
VarGui allows to choose SynthDefs or Synths, Events patterns or EventStreamPlayers and Task functions or Tasks as input. It is recommended to take the more general objects (SynthDefs, Event patterns, Task functions) as then derived Synths, EventStreamPlayers and Tasks are newly generated and the latter are run in newly generated Environments. If you follow this it is very unlikely to accidentally break gui representation of data (though it's not strict MVC paradigm).
On the other hand there are special cases when you might want to pass Synth objects / synth nodes, Tasks or EventStreamPlayers directly (e.g. HS_with_VarGui). Then a bit more care has to be taken as, although a VarGui instance doesn't allow to poll more than one GUI window from it, nothing prevents you from refering to identical Synth objects / synth nodes, Tasks, EventsStreamPlayers or environmental variables with different VarGui instances. This is not recommended as, obviously, a possible source of confusion.
If you are passing a Synth directly and moreover its SynthDef is not known to SynthDescLib setting a single component of an arrayed control also causes setting of all components below (no other choice at the moment, however, a very special case).
With miSCellaneous v0.16 (March 2017) backwards compatibility with Cocoa and SwingOSC is no longer supported, now cross-platform Qt is standard. VarGui was originally written with Cocoa as reference, though restrcitions on Qt are minor.
You can list styles by GUI.availableStyles
and set with GUI.style = \myFavoriteStyle
Create a new VarGui object, which holds control specifications.
varCtr |
specPairs or a collection of specPairs, where specPairs is a collection of the form [ key, spec, ... ] where key is the symbol of the environmental variable to be set and spec must be one of those:
If specPairs or single components of a collection of specPairs are nil and the corresponding stream arg is a Symbol or String pointing to a SynthDef, it will be tried to derive controls from corresponding SynthDef metadata resp. global ControlSpecs (see VarGui_shortcut_builds). Variables are set in environments that are either given implicitely (1) or explicitely (2):
From explicit or implicit envir input an ordered collection of non-identical environments is derived, which, without one of the above infos, will consist of currentEnvironment only.
Note that the i-th environment means the i-th non-identical environment, not necessarily (in the case of environments implicitely given by eventstream players / tasks) the environment of the i-th stream. Defaults to nil. |
synthCtr |
specPairs or a collection of specPairs, where specPairs is a collection of the form [ key, spec, ... ] where key is the symbol of the control arg to be set and spec must be one of those:
If specPairs or single components of a collection of specPairs are nil, it will be tried to derive controls from SynthDef metadata resp. global ControlSpecs (see VarGui_shortcut_builds).
Defaults to nil. |
stream |
Expects Pattern, EventStreamPlayer, Function, Task or a collection thereof, determining the number of stream players. Patterns / Functions are used as templates for EventStreamPlayers / Tasks in environments generated at init time. If stream is unequal nil variables given by varCtr will be set in the environments derived from it. Size of stream must at least equal and may exceed the number of varCtr groups, which (see above) may be given by varCtr itself (if a grouped collection of specPairs) or varCtrGroups. Correspondence between environments of variables and eventstream / task players is optionally indicated in the GUI - however the user is responsible for defining patterns and task functions that really involve the variables to be set ! Defaults to nil. |
synth |
Input to which synth controls are mapped. Expects Symbol refering to a SynthDef, Synth, nodeID or collection thereof. Size of synth must at least equal and may exceed the number of synthCtr groups, which (see above) may be given by synthCtr itself (if a grouped collection of specPairs) or synthCtrGroups. It is recommended to refer to "known" SynthDefs (SynthDescLib), best by passing Symbols or also registered Synths, otherwise the correct synth state must be given explicitely by assumePlaying, assumeRunning resp. assumeEnded, which is a nearby source of error and confusion. Defaults to nil. |
clock |
TempoClock, nil or collection thereof for playing streams. Passed clocks have precedence over implicitely given clocks (running eventstream players or tasks as stream input) in case of resuming from pause state. Defaults to the default TempoClock. quant - Quant, Float, nil or collection thereof used as quant data for playing streams. Will be used in case of resuming from pause state for running eventstream players or tasks given as stream input. Defaults to Quant.default (none). |
quant |
Quant, Float, nil or collection thereof used as quant data for playing streams. Will be used in case of resuming from pause state for running eventstream players or tasks given as stream input. Defaults to Quant.default (none). |
varEnvirGroups |
SequenceableCollection of Collections of Integer. Expects ordered partition of the number N of specPairs given to varCtr as a flat collection, also counting multiple occurences, thus defining a mapping: variable keys -> environments. Must be a valid partition of N (taking all integers i < N, 0 included, each only once). Its size must not exceed the number of implicitely or explicitely given environments (see varCtr). E.g. for 3 environments and 6 variables [[2], [0,1,5], [4,3]] would be valid. Defaults to nil. |
envir |
SequenceableCollection of Environments. Environments to be used for variable setting in case of absent stream players, only admissible if stream is nil. Defaults to nil. |
synthCtrGroups |
SequenceableCollection of Collections of Integer. Expects ordered partition of the number N of specPairs given to synthCtr as a flat collection, also counting multiple occurences, thus defining a mapping: synth control keys -> environments. Must be a valid partition of N (taking all integers i < N, 0 included, each only once). Its size must not exceed the size of synth. Defaults to nil. |
assumePlaying |
Boolean, nil or collection thereof, then size must equal the number of synths given by synth or synthCtr. Player state information for (unregistered) synths or nodeIDs, booleans are not accepted if corresponding items in synth are instances of Symbol or String. Defaults to nil. |
assumeRunning |
Boolean, nil or collection thereof, then size must equal the number of synths given by synth or synthCtr. Player state information for (unregistered) synths or nodeIDs, booleans are not accepted if corresponding items in synth are instances of Symbol or String. Defaults to nil. |
assumeEnded |
Boolean, nil or collection thereof, then size must equal the number of synths given by synth or synthCtr. Player state information for (unregistered) synths or nodeIDs, booleans are not accepted if corresponding items in synth are instances of Symbol or String. Defaults to nil. |
server |
The server to send node messages to. Defaults to the local server. |
Pbind defined with variable to be controlled while playing. Pfunc's function is evaluated at playtime of each Event and gets the value of the variable ~midi in the environment in which the EventStreamPlayer will be playing.
VarGui to set this variable. As a pattern is given as stream arg the derived EventStreamPlayer will run in a new environment which is generated at VarGui init time.
Try out basic slider and player functionality.
Playing:
Background of player button lightening yellow. Functionality of the reset button depends on the active mode. The green background of the reset mode button indicates that the reset button will reset while playing and its background will flash yellow.
The text field on the right side indicates whether an eventstream player or a task is playing, that on the left side shows the index of the environment in which the stream is playing. This is mainly useful if more stream players and variables of same names in different environments are involved - below the players there is a toggle button to indicate the envir index in slider name fields.
Pausing:
Now pushing the play button will resume the stream where it has been paused, pushing the reset button (if the reset mode button has green background) will reset and play the stream.
Pausing and reset:
This state can be reached from playing, pausing or ended stream when pushing the reset button under reset mode pause (orange background). Now only the play button can play the (reset) stream.
Stream has ended:
E.g. if an eventstream player has encountered nil, reset button's background will become red. Now it needs the reset button to go on and its action - pause or play - depends on the active mode.
VarGui to play synth of above definition and set synth args, player functionality with different stop / renew modes. Notification must be on. Note that pause, stop and resume actions cause sending of run / free messages, thus possibly audible clicks. To avoid that work with amp = 0 or use a gated envelope and a gate control slider with only values 0 and 1 or use Synths of limited duration as in Ex. 2.
Latency options (buttons and boxes below the player section): bundle latency of synth player actions can be set to nil, a custom value (button abbrieviation c) or global server latency (abbr. s), these two values can be set in the boxes below. Settings can be used to sync synth and stream players, if both contained in a GUI.
Synth players work similar as stream players, but there are more options. There is an addtional stop mode button that determines how and if renewing (creating new synth nodes of same definition) is handled.
If, as above, a synth is given by a reference to a known SynthDef VarGui will start with a basicNew Synth object, indicated by white background of the synth's number field:
Rate type (audio) is indicated in the field on the right. From this state a node on the server will be created by pause (newPaused) or play (new):
Now playing and pausing work as usual. The red and blue background of the stop mode button indicates that the red stop button will become a blue renew button as soon as the Synth is stopped (node freed). In addition to the renew modes play (green) and pause (orange) there is also a renew mode basic new (white):
If stop mode is set to renew (blue) the renew button will never change its function. Under renew mode play (green) every renew will free a Synth and immediately start a new (background flashing yellow):
If stop mode is set to stop (red background), the stop / renew button will change to red:
The renew mode button loses its function (greyed out) and stopping just frees the Synth:
Now stop mode would have to be changed in order to play a new Synth.
General functionality buttons:
Update
Unless the VarGui window was generated with option updateNow set to false (which could be desired e.g. for a start with Synth defaults), variables and synth controls are set to slider values at gui init time, normally updating is not required. As for most uses VarGui would generate new separate environments for passed event patterns and task functions, there is no update mechanism implemented if these variables would be changed otherwise. Analagously controls of Synths played (and probably just yet generated) by a VarGui player could of course be set by means other than a VarGui slider action. Anyway both situations seem to be exceptional (you could hardly do so just by an oversight), though you can update to all slider values manually.
Save
Opens a dialog to save the current slider state as an array of four items: varCtr as flattened array of specPairs, synthCtr as flattened array of specPairs, varEnvirGroups, synthCtrGroups (which are only stored as groupings in case of multiple key occurences, nil optherwise). Player data and synth information is not stored. For loading from a file you would have to pass this (see the load method below).
Stop
Free all synths and stop all streams. You can also use modifier keys for stopping groups of players, e.g. Shift-click on a stream players's pause button to stop all streams. Freeing all synths in the same way only works if all synth players can be stopped by their stop buttons at this time.
Create a VarGui, that loads a stored slider state (varCtr and synthCtr data) from the specified file, which has probably been saved before via dialog. See also VarGui_shortcut_builds: 6.
pathname |
Pathname string. |
filename |
Filename string. |
stream |
see VarGui: *new. |
synth |
see VarGui: *new. |
clock |
see VarGui: *new. |
quant |
see VarGui: *new. |
varEnvirGroups |
see VarGui: *new. |
envir |
see VarGui: *new. |
synthCtrGroups |
see VarGui: *new. |
assumePlaying |
see VarGui: *new. |
assumeRunning |
see VarGui: *new. |
assumeEnded |
see VarGui: *new. |
server |
see VarGui: *new. |
Create a VarGui, that loads a stored slider state from the specified file. This is for loading slider states that have been saved with miSCellaneous v0.3 or earlier, thus ignoring the synth control slider label. Though old code examples will not necessarily work after just replacing load by load_old as other conventions have changed too. Maybe you'd also have to change synth and stream (former players) or add assumePlaying and assumeRunning args.
pathname |
Pathname string. |
filename |
Filename string. |
stream |
see VarGui: *new. |
synth |
see VarGui: *new. |
clock |
see VarGui: *new. |
quant |
see VarGui: *new. |
varEnvirGroups |
see VarGui: *new. |
envir |
see VarGui: *new. |
synthCtrGroups |
see VarGui: *new. |
assumePlaying |
see VarGui: *new. |
assumeRunning |
see VarGui: *new. |
assumeEnded |
see VarGui: *new. |
server |
see VarGui: *new. |
Create a gui window.
sliderHeight |
Gui slider height. Defaults to 18. |
sliderWidth |
Gui slider width. Depends on number of columns if not given explicitely. |
labelWidth |
Slider label width. Default depends on platform and gui scheme (70 or 75). |
numberWidth |
Slider numberbox width. Default depends on platform and gui scheme (40 or 45). |
sliderType |
One of the Symbols \standard, \smooth, \round. Both latter refer to EZSmoothSlider and EZRoundSlider from wslib (Quark), which needs to be installed for that choice. See Ex.8 . Defaults to \standard. |
sliderMode |
One of the Symbols \jump, \move. Only relevant in case of sliderType \smooth or \round. Determines behaviour if slider field is clicked apart from the knob. See Ex.8. Defaults to \jump. |
playerHeight |
Gui player height. Defaults to 18. |
precisionSpan |
Integer. Precision span to be regarded for representation of controlspec step. See Ex.9. Defaults to 10. |
stepEqualZeroDiv |
Integer. Division to be assumed if controlspec step equals 0. See Ex.9. Defaults to 100. |
tryColumnNum |
Integer. VarGui tries to arrange variable and control sliders in this number of columns if possible under the restrictions of maxWindowWidth, sliderWidth, minPartitionSize and the following allow options. Internally a list of possible break indices is derived and then a partition as equal in size as possible is searched for. See Ex.5a, Ex.5b. Defaults to 1. |
allowSynthsBreak |
Boolean. Determines if all synth control sliders should be grouped within one column. Defaults to true. |
allowVarsBreak |
Boolean. Determines if all variable control sliders should be grouped within one column. Defaults to true. |
allowSynthBreak |
Boolean. Determines if control sliders of one synth should be grouped within one column. Setting false only has an effect if synth controls are ordered in connected groups. Defaults to true. |
allowArrayBreak |
Boolean. Determines if control sliders of an arrayed control (variable or synth) should be grouped within one column. Defaults to true. |
allowEnvirBreak |
Boolean. Determines if control sliders of one environment should be grouped within one column. Setting false only has an effect if environmental variables are ordered in connected groups. Defaults to true. |
minPartitionSize |
Integer. Determines the minimum number of sliders of same type that may be grouped in a different column. Defaults to 0. |
sliderPriority |
Symbol \var or \synth. Determines if variable or synth control sliders should be listed first. Defaults to \var. |
playerPriority |
Symbol \stream or \synth. Determines if stream or synth players should be listed first. Defaults to \stream. |
streamPlayerGroups |
Grouping of number of stream players (E.g. [[0], [1,2]] is a valid grouping of 3 players). Defines control group for modifier option of stream playing. Defaults to the grouping of all streamPlayers. |
synthPlayerGroups |
Grouping of number of synth players. Defines control group for modifier option of synth playing. Defaults to the grouping of all synthPlayers. |
comboPlayerGroups |
*** currently not working *** Grouping of number of synth and stream players. Defines control group for modifier option of combined synth and stream playing. Defaults to the grouping of all synth- and streamPlayers. |
font |
GUI font as String. Defaults to "Helvetica". |
colorsLo |
Low RGB value for color space, in which distinct slider colors for logical groups (synth, environment) and background are chosen by random. Must be between 0 and 1. Defaults to 0.25 in color mode and 0.4 in grey mode. |
colorsHi |
Hi RGB value for color space, in which distinct slider colors for logical groups (synth, environment) and background are chosen by random. Must be between 0 and 1. Defaults to 0.7 in color mode and 0.6 in grey mode. |
colorDeviation |
Nonnegative SimpleNumber. Determines the maximum amount of color deviation within a logical slider group (synth, environment). Within the maximum deviation distinct colors are ramdomly chosen, but arrayed controls get the same color. Defaults to 0.12 in color mode and 0 in grey mode. ctrButtonGreyCenter - Float between 0 and 1. Determines the grey center from which button colors deviate by the amount of ctrButtonGreyDev. Defaults to 0.5. |
ctrButtonGreyCenter |
Float between 0 and 1. Determines the grey center from which button colors deviate by the amount of ctrButtonGreyDev. Defaults to 0.5. |
ctrButtonGreyDev |
Float between 0 and 1. Determines the intensity of button colors deviating from ctrButtonGreyCenter. Defaults to 0.8 in color mode and 0.65 in grey mode. |
greyMode |
Boolean. Determines if color or grey mode is chosen. Defaults to false. |
varColorGroups |
Grouping of colors of variable control sliders. Overrules automatic color grouping. All indices < n (number of sliders) must occur exactly once. E.g. [[0], [1,2]] would be valid for n = 3. See Ex.7. |
synthColorGroups |
Grouping of colors of synth control sliders. Overrules automatic color grouping. All indices < n (number of sliders) must occur exactly once. E.g. [[0], [1,2]] would be valid for n = 3. See Ex.7. |
name |
Symbol or String. Name to be displayed in the GUI window title bar. If not given explicitely types of controls and players are indicated. |
updateNow |
Boolean. Determines if controls and variables should be set to slider values at GUI build time. To keep sliders in sync with control this is done by default - however there may be cases when it is desirable to start with other values, e.g. the synth's defaults. If set to false slider values will not be set before the slider is moved or before all values are set by the update method or the corresponding button. |
sliderFontHeight |
Float. Adapts to sliderHeight if value nil is given (default). Normally this doesn't have to be set except with very small sliderHeight and/or certain fonts. |
playerFontHeight |
Float. Defaults to 12. |
maxWindowWidth |
Float. Defaults to 1500. |
maxWindowHeight |
Float. Defaults to 700. |
SynthDef synth_0 from above, number of synth players multiplied by expanding single control. For multiple slider and player button control see the modifier options explained in Ex.1c.
GUI appearance customization: close window (only one window per VarGui instance allowed) and try again with same or other color options.
Force slider arrangement in 2 columns, controls of each synth should only be in one column.
You can save a slider state snapshot by button / dialog to the file "XY", only slider states (flattened spacPair collections) and groupings are stored, you have to pass synth data with load.
Update variables and controllers to current slider values. Like update button action. Unless the VarGui window was generated with option updateNow set to false, variables and controllers are immediately set to slider values and normally updating is not required.
Update variable sliders.
key |
Variable name given as Symbol. |
varNum |
Integer. Index of variable occurence in given varCtr. Defaults to 0. |
val |
Float. May also be collection, then a sequence of variable sliders is set. |
indexOffset |
Integer. Updating will start at this index in case key refers to arrayed control. Defaults to 0. |
updateNow |
Boolean. Determines if variables should immediately be updated with sliders. Defaults to true. |
Update synth sliders.
key |
Synth control name given as Symbol. |
synthIndex |
Integer. Index of synth in given synthCtr. Defaults to 0. |
val |
Float. Maybe also be collection, then a sequence of synth sliders is set. |
indexOffset |
Integer. Updating will start at this index in case key refers to arrayed control. Defaults to 0. |
updateNow |
Boolean. Determines if synth controls should immediately be updated with sliders. Defaults to true. |
Set GUI font.
font |
String. Defaults to "Helvetica". |
sliderFontHeight |
Integer. Defaults to 12. |
playerFontHeight |
Integer. Defaults to 12. |
Add an action to be evaluated as sliderView's mouseUpAction.
function |
Function. |
type |
Slider type, expects \var or \synth. Defaults to \var. |
index |
Integer. Slider index of given type. |
envir |
Environment where function should be evaluated. If not specified and type equals \var the environment associated with the variable will be taken. |
Start learining mode for receiving MIDI cc messages for slider control, see Ex.10.
Stop learining mode for receiving MIDI cc messages for slider control, see Ex.10.
There are different ways to read a sequence of values from a settable array assigned to an envir variable. PLseq is convenient, for a comparison with Plazy, Pfunc etc. see PLx_suite. In all cases the EventStreamPlayer can be played in an arbitrary environment, from which ~seq will be taken. This holds true for Patterns with functional code like Pfunc and also for PLseq, the latter has an envir arg which defaults to \current. Note that all PLx Patterns default to repeats = inf, ListPatterns as Pseq default to repeats = 1.
~seq
will be set and read in the new Environment, which will be generated at VarGui init time.
SynthDef from Ex.1a , four players from a Pbind, four varCtr specifications with shifted range.
Modifiers allow to control groups of sliders, values in other sliders are clipped to the according range. The following rules apply to synth and var control sliders separately, combined synth and var controls of same name work with Caps on cocoa and Cmd elsewise (Ex.2).
Modifier keys also apply to synth and stream player actions, the following to synth OR stream player combinations either:
You can try to benefit from eventstream players having variables in common. SynthDef from Ex.1a , second Pbind derived from p without pitch offset as parallel pattern.
SynthDef from Ex.1a
Try multiple slider movements with modifier keys as described in Ex.1c. As synth args and variables are identically named they can be controlled with linked slider movements using Cmd. Accordingly stream and synth player buttons can also be pressed in parallel.
Pbind producing a sequence of short events, each pbind-driven synth reading frequency from a control bus
Audio synth controlled by LFO pitch synth and a Pbind setting synth args (like Pmono). PLx ListPatterns taken here as they default to repeats = inf.
One may want to have controls grouped per name, not per Environment (resp. Pbind, Task, Synth), this can be achieved by passing a flat (not grouped) array of specPairs and the appropriate grouping, there are methods implemented for that special case of reordering:
SynthDef from Ex.1a
Passing symbols or strings as synth args, refering to known (added) SynthDefs, is recommended. However also Synths or nodeIDs can be given, but the player would have to know their state, so Synths should be registered.
Connect your midi device, maybe you have to restart SC then. As gui example e.g. take SynthDefs and Pbind from Ex.4a, evaluate both code blocks. It must be possible to refer to the VarGui instance (e.g. v = VarGui(...))