antonhornquist / Grrr-sc

Grid controller UI toolkit for SuperCollider
5 stars 1 forks source link

Grrr-sc

Grid controller UI toolkit for SuperCollider.

Description

Grrr-sc provides high level UI abstractions for grid based controllers such as monome 40h, 64, 128 and 256 devices. Widgets, ie. buttons and toggles, are placed on controllers. Widgets can be nested in containers which allows for modes and paging. Grrr reuses principles of the standard SuperCollider GUI class library.

Usage

Grrr can be used as a framework for building full featured apps or in live coding.

Examples

Hello World

a=GRScreenGrid.new; // creates a virtual grid which shows up in a separate window
b=GRButton(a, 0@0); // places a 1x1 button at top left key
b.action = { |view, value| (value.if("Hello", "Goodbye") + "World").postln }; // sets an action to be triggered when the button is pressed

// pressing the top left grid button of the grid will change led state and output to the Post Window

An Example With Sound

s.boot;
a=GRMonome.new; // creates a monome
b=GRButton(a, 0@0); // places a 1x1 button at top left key
b.action = { |view, value| if (value) { c = {SinOsc.ar}.play } { c.release } }; // sets an action to be triggered when the button is pressed
a.spawnGui; // spawns a virtual grid

// pressing the top left grid button of the grid will change led state and audition a sine oscillator

A Simple Step Sequencer

s.boot;
a=GRMonome.new; // creates a monome
b=GRStepView.new(a, 0@7, a.numCols, 1); // the step view defines when to play notes 
c=GRMultiToggleView.new(a, 0@0, a.numCols, 7); // toggles representing note pitch
c.valuesAreInverted=true;

(
    // sequence that plays a note for steps that are lit
    fork {
        b.playhead = 0;
        inf.do {
            if (b.stepValue(b.playhead)) { (degree: c.toggleValue(b.playhead)).play };
            0.15.wait;
            b.playhead = (b.playhead + 1) % b.numCols;
        }
    }
)

a.spawnGui; // spawns a virtual grid

(
// randomize pattern
b.numCols.do { |index|
    c.setToggleValue(index, (c.numRows).rand);
    b.setStepValue(index, [true, false].choose);
};
)

Requirements

Grrr-sc requires the SerialOSCClient-sc library. The library has been developed and tested in SuperCollider 3.8.0.

Installation

Install the SerialOSCClient-sc dependency.

Copy the Grrr-sc folder to the user-specific or system-wide extension directory. Recompile the SuperCollider class library.

The user-specific extension directory may be retrieved by evaluating Platform.userExtensionDir in SuperCollider, the system-wide by evaluating Platform.systemExtensionDir.

Documentation

Reference documentation in SCDoc help format is available in the SuperCollider IDE once the Grrr library is installed.

Tests

An automated test suite for Grrr-sc is available separately: GrrrTests-sc

Implementation

Code readability has been favored over optimizations.

The grrr-rb library is a Ruby port of this library. The SuperCollider and Ruby classes are generated using the rsclass-rb class generator based on meta data defined in the grrr-meta-rb repository.

Classes

Extending Grrr

It's possible to create custom widgets and add support for additional grid controllers by subclassing base classes in the Grrr library. Refer to section "Extending Grrr" in the bundled documentation for details on extending Grrr.

License

Copyright (c) Anton Hörnquist