/*

 *  Descriptions of the classes the the players

 *  will use or see, and an explanation of how they

 *  fit together.

 */


// graphics/


/*  MsgWindow

 *

 *  Each player has a MsgWindow to display private messages;

 *  it responds to the OSC command '/msgWindow'.

 *  Player 0 (the conductor) has, in addition to the private MsgWindow,

 *  a public MsgWindow that's projected to the audience; it responds

 *  to the OSC command '/publicMsgWindow'.

 *

 *  If player 0 is hooked up to a projector to display the public MsgWindow,

 *  set the `projection' argument to true.

 *  Set it to false for single-monitor display (this is the default).

 */

 

 

m = MsgWindow(playerNum: 0, public: false);                    // private MsgWindow

n = MsgWindow(playerNum: 0, public: true, projection: false);  // public MsgWindow


m.add_msg("Hello PlORKiverse"); // write a message

m.set_clock("12:34");

m.clear;

m.reset_timekeeper;

m.advance_timekeeper;


/*

 *  FreqTablesWindow.sc

 *

 *

 */

 

f = FreqTablesWindow(numPlayers: 8);

f.set_amp(0, 1);

f.set_freq(0, 4411.1);

f.set_amp(1, 1);

f.set_amp(7, 1);

(

var freqs;

freqs = [

4411,

4411.1,

4413.12,

4414.11,

4454.1,

4431,

4432.2,

4423.39

];

freqs.do {

arg freq, i;

f.set_amp(i, 1);

f.set_freq(i, freq)

}

)




/*

 *  KeyboardWindow.sc

 *

 *

 *

 */


k = KeyboardWindow(numPlayers: 1);

k.key_down(6, $q);

k.key_down(6, $w);

k.key_up(6, $q);


/*  SynthWindow.sc

 *

 *  Each player has a SynthWindow to display the frequency of their impulse wave;

 *  it responds to the OSC command '/synth'.

 *  The frequency value is colored red if the synth volume is turned down all the way,

 *  and colored green if it's turned up.

 *

 *  When the SynthWindow pops up, the SuperCollider sound server should turn on.

 *  Once the server boots, the window color should change from red to black.

 *  Occasionally it *doesn't* boot, in which case you should hit command-K

 *  to recompile SuperCollider.

 *

 */

 

s = SynthWindow(playerNum: 0);


s.set_amp(1);       // green text

s.set_freq(4410.4); // change frequency

s.set_amp(0);       // red text



// interface/



/*  ConductorWindow.sc

 *

 * 

 *  The ConductorWindow sets the clock,

 *  parses messages generated by each player's CodingWindow,

 *  and schedules events.

 *

 *  The ConductorWindow is run by player 0 ("0.local").

 *  It will try to establish contact with each

 *  player, and if it fails (either because the player's aren't named correctly,

 *  or because they're not on player 0's network), it will post a warning.

 *  

 */


// Load other windows to test ConductorWindow's OSC messaging.

f = FreqTablesWindow(numPlayers: 8);

m = MsgWindow(playerNum: 0, public: false);

p = MsgWindow(playerNum: 0, public: true, projection: false);

s = SynthWindow(playerNum: 0);


c = ConductorWindow(numPlayers: 1);


c.start_clock; // both MsgWindow clocks should start running

c.stop_clock;

c.start_clock(offset: 15); // start 15 seconds into the piece

c.stop_clock;

c.parse(0, "00:10 4411 +");

c.parse_msg_list(0, ["00:10 4411", "00:10.1 +", "00:10.2 -"]);

c.parse_msg_lists([["0:05 4411 +", "0:05.1 4411.1", "0:05.2 -"]]);

c.send_private_msg(0, "Hello player 0");

c.send_public_msg("How many laptop performers does it take...");

c.set_synth(0, \amp, 1);

c.set_synth(0, \impulseFreq, 4411);

c.update_freq_tables(0, \amp, 1);

c.update_freq_tables(0, \impulseFreq, 4411);


/*  CodingWindow.sc

 *

 *  The CodingWindow sends OSC messages to the ConductorWindow.

 *  Unfortunately, after you type a message and hit return,

 *  you need to click the window to reselect it.

 *

 */

 

w = CodingWindow(playerNum: 0);


// user/



// The CodingWindow sends OSC messages directly to the KeyboardWindow:


k = KeyboardWindow(numPlayers: 1);



// If `numPlayers' is wrong, the ConductorWindow and KeyboardWindow

// will hang for about a minute and then complain,

// but the program shouldn't die.


c = ConductorBundle(numPlayers: 8, projection: false);

m = PlayerBundle(playerNum: 0);


// All together now...

p = PLOrkBundle(playerNum: 0, numPlayers: 1, projection: false);