JucK Doc

From CSWiki
Jump to: navigation, search

JucK

JucK

JucK_Dev

Introduction

  • JucK is a swing-based GUI creator for ChucK.
  • Currently supported GUI elements:
    • Slider
    • Checkbox
    • Radiobutton
    • Dropdown menu
    • Textfield
    • Two-Dimensional Checkbox
    • Two-Dimensional Grid
    • Button
    • ToggleButton
  • Planned Features
    • ChucK libraries to parse JucK messages

System Requirements

  • ChucK System Requirements
  • Java 1.4 or higher
    • Compilation: javac Juck.java
    • Execution: java Juck <file.jk>

Tutorial

Writing a JucK File

  • A .jk file has several required entries. In order:
    • [Name of the GUI to be created]
    • [Target of OSC message] [Port to send OSC messages out of]
    • [Layout]
      • panels: [number of rows] [number of columns]
      • manual: [width] [height]
    • elements (see IV. GUI Elements for specific parameters)


  • Example 1: testpanel.jk
    • This is a very simple GUI with only one element, a slider. The overall window is labelled "MidiSlider", as indicated by the first line. It sends OSC messages to localhost through port 6449. The layout is panels, and the next line defines the number of rows and columns to be created (in this case there is only one element, so only one row and one column is necessary). The next line contains the only element of the GUI - a slider with labele "Frequency" that ranges from 0 - 127; initialized to 0, ticks marked every 5 units; does NOT have to snap to ticks (false) ; oriented vertically.
MidiSlider
localhost 6449
panels
1 1
slider Frequency 0 127 0 5 false vertical
  • Example 2: testmanual.jk
    • Everything here is identical, except for the layout. Because manual layout is specified, the following line does not contain the number of rows and columns; rather, it defines the width and height of the overall window (can be resized). In this case, the line for the slider (and any element) must contain an additional two parameters at the end for JucK to decide where to place the slider in the window. In this case, the parameters (5, 5) dictate that the LEFTmost border of the slider be placed 5 units away from the LEFT border of the overall window, and that the TOPmost border of the slider be placed 5 units away from the TOP border of the overall window. A few other parameters have been changed as well: the ticks are marked every 3 units; the slider DOES have to snap to ticks (true); and the orientation is horizontal. In addition, I have specified a preferred size for the slider (width: 290, height: 40). These two final parameters are optional, and also work in the panels layout.
MidiSlider
localhost 6449
manual
400 100
slider Frequency 0 127 0 3 true horizontal 5 5  290 40

Writing a ChucK File

  • Code that must appear in a .ck file in order to receive messages from a .jk file (this will become much clearer with an example):
    • create OSC receiver
    • set port for receiver to receive from
    • have the receiver start listening
    • create an address for the receiver; store in a new variable
    • loop: pass time until an event occurs; process the event
  • Example 1: test.ck
    • for each GUIelement to listen for, a new function must be created and sporked
// create sin oscillator; set gain and reverb
sinosc s => JCRev r => dac;
.5 => s.gain;
.1 => r.mix;

// declare global variables (in this case, only int i to take midi values)
int i;

// spork functions (must be done in order to receive multiple events)
spork~ listenSlider();
 
// infinite event loop to pass time
while( true )
{
    0.05::second => now;
    i => std.mtof => s.freq;
}

// function to listen to test.jk
fun void listenSlider()
{
    // create our OSC receiver
    OscRecv recv;
    // use port 6449 to listen
    6449 => recv.port;
    // start listening (launch thread)
    recv.listen();
    // create an address in the receiver; store in new variable
    // the input is "/GUIname/element type/ element name, expected type"
    // expected types: i(int), s(string), f(float), b(boolean)
    recv.event( "/MidiSlider/Slider/Frequency, i" ) @=> OscEvent e;
	
    // listener loop
    while( true )
    {
    // wait for event to arrive
        e => now;

        // grab the next message from the queue. 
        while( e.nextMsg() )
        {         

            // getInt fetches the expected int (as indicated by "i")
            e.getInt() => i;
	
            // print
            <<< "got (via OSC):", i >>>;
        }
    }
}

GUI Elements

Element Parameters

  • SLIDER [title] [min] [max] [initial] [interval] [snap] [orientation] [width] [height]
    • title: (string) label to put on the element; unique to this .jk file
    • min: (int) minimum value of slider
    • max: (int) maximum value of slider
    • initial: (int) initial value to set slider
    • interval: (int) interval to set ticks
    • snap: (boolean) whether or not
    • orientation: (string) vertical or horizontal
    • width(optional): width of slider
    • height(optional): height of slider
  • CHECKBOX [title] [number of items] [list of items...] [orientation]
    • title: (string) label to put on the element; unique to this .jk file
    • number of items: (int) number of checkboxes to create
    • list of items...: (string)s names of the checkboxes
    • orientation: (string) vertical or horizontal
  • RADIOBUTTON [title] [number of items] [list of items...] [orientation]
    • title: (string) label to put on the element; unique to this .jk file
    • number of items: (int) number of radiobuttons to create
    • list of items...: (string)s names of the radiobuttons
    • orientation: (string) vertical or horizontal
  • DROPDOWN [title] [number of items] [list of items...]
    • title: (string) label to put on the element; unique to this .jk file
    • number of items: (int) number of checkboxes to create
    • list of items...: (string)s names of the checkboxes
  • TEXTFIELD [title] [width]
    • title: (string) label to put on the element; unique to this .jk file
    • width: (int) width of the textfield in characters
  • TWODCHECKBOX [title] [number of items] [number of rows] [number of columns] [list of items...] [orientation]
    • title: (string) label to put on the element; unique to this .jk file
    • number of items: (int) number of checkboxes to create
    • number of rows: (int) number of rows of checkboxes to create
    • number of columns: (int) number of columns of checkboxes to create
    • list of items...: (string)s names of the checkboxes
    • orientation: (string) vertical or horizontal; determines whether the checkboxes are arranged across by rows, or down by columns
  • TWODGRID [title] [number of rows] [number of columns] [row names] [column names] [orientation]
    • title: (string) label to put on the element; unique to this .jk file
    • number of rows: (int) number of rows of checkboxes to create
    • number of columns: (int) number of columns of checkboxes to create
    • row names: (string)s labels to place on rows
    • column names: (string)s labels to place on columns
    • orientation: (string) vertical or horizontal; determines only label placement (left or top)
  • BUTTON [title] [name]
    • title: (string) label to put on the element; unique to this .jk file
    • name: (string) text to place on the button
  • TOGGLEBUTTON [title] [name]
    • title: (string) label to put on the element; unique to this .jk file
    • name: (string) text to place on the togglebutton

OSC Values

  • Slider: (int) value of the slider
  • Checkbox: (string, int) name of the checkbox; 0/ 1 for on/ off
  • RadioButton: (string) name of the radiobutton
  • DropDown: (string) name of selected item
  • TextField: (string) current text in the textfield
  • TwoDCheckBox: (string, int) name of the checkbox; 0/ 1 for on/ off
  • TwoDGrid: (int, int, int) row and column index; 0/ 1 for on/ off
  • Button: (int) 1 every time the button is pressed
  • ToggleButton: (int) 0/ 1 for on/ off