system for computer music by samuel.freeman: _alpha ui
This page describes the use of text in sdf.sys_alpha.

sdf.sys.txt

Within sdf.sys_alpha there is a basic text editor for script-based interaction; text is used both by the user to instruct the system and by the system to inform the user.   The text editor has been made with Max+JavaScript+Jitter and renders on the gl ui.

Of the eight spaces in the system, space zero is reserved for the text editor.   Space zero is represented as the top-left square in the grid of eight spaces.

Space zero is thus unlike the other seven spaces in the set of eight. The space zero preview-toggle-square thing will only toggle between two states of sdf.sys.txt when clicked (as opposed to the three states described on the previous page):

Another way in which the sdf.sys_alpha space zero differs from the other seven spaces in the set of eight spaces is that three char data type Jitter matrices are used by the txt system, rather than the one plane of float32 data type used by the other spaces.

The text editor responds to qwerty input through a JavaScript within the Max patch.   The sdf.sys.txt system keeps track of how many modifier keys are held when a qwerty key is pressed, but not which modifiers they are.   The number of modifiers held is determined by Max objects and the int value input to inlet 2 of the js object; js inlet 1 is used for the ASCII number of the qwerty key pressed.
An excerpt of sdf.sys_alpha/sdf.sys.txt.js is reproduced below.  


var jsG = new Global("jsGlobal");
jsG.modifiers = 0;

x = "x";
y = "y";
abs = "abs";
	
atoi = {	
	"backspace":8, "delete":127, "return":13, "enter":3, "esc":27,
	"left":28, "right":29, "up":30, "down":31, 
	"!":33, "\\":34, "#":35, "$":36, "%":37, "&":38, "'":39, "(":40,
	")":41, "*":42, "+":43, ",":44, "-":45, ".":46, "/":47, "0":48, 
	"1":49, "2":50, "3":51, "4":52, "5":53, "6":54, "7":55, "8":56, 
	"9":57, ":":58, "\;":59, "<":60, ":":61, ">":62, "?":63, "@":64, 
	"A":65, "B":66, "C":67, "D":68, "E":69, "F":70, "G":71, "H":72, 
	"I":73, "J":74, "K":75, "L":76, "M":77, "N":78, "O":79, "P":80, 
	"Q":81, "R":82, "S":83, "T":84, "U":85, "V":86, "W":87, "X":88, 
	"Y":89, "Z":90, "[":91, "\\":92, "]":93, "^":94, "_":95, "`":96, 
	"a":97, "b":98, "c":99, "d":100, "e":101, "f":102, "g":103, "h":104, 
	"i":105, "j":106, "k":107, "l":108, "m":109, "n":110, "o":111, "p":112, 
	"q":113, "r":114, "s":115, "t":116, "u":117, "v":118, "w":119, "x":120, 
	"y":121, "z":122, "{":123, "|":124, "}":125, "~":126
};

cursor = { "x":0, "y":0 };

// ... 

function msg_int()
{
	if (activeFlag)
	{
		if (inlet == 2) jsG.modifiers = arguments[0];
		if (inlet == 1)
		{	if( jsG.modifiers < 2 ) qwertyKeyDown(arguments[0]);
			else doubleMod(arguments[0]);
		}
	}//end  if (activeFlag)
}// end function msg_int()


function qwertyKeyDown(asciiNum)
{
	if (asciiNum == atoi["backspace"] ){
		if ( cursor.x > 0)
		{
			cursorMove(x, -1);
			deleteChar();
		}
	}//end if backspace
	else if (asciiNum == atoi["delete"] ){
		deleteChar();
	}//end if delete
	else if (asciiNum == atoi["left"]){ 
		cursorMove(x,-1); // move left
		if (cursor.x < 0) // if moved to sub start of line
		{
			if (cursor.y > 0) //if not top line
			{
				cursorMove(y,-1);
				// find end of text...
					i = m_size.x-1;			
					cursorMove(abs,i,cursor.y);
					while( m_txtBuffer.getcell(i,cursor.y) == 32)
					{ i--; } //end while
				cursorMove(abs,i+1,cursor.y);	
			}//end if not top line
			else{ //if top line
				cursorMove(abs,0,0); }
		}// end if moved to sub start of line
	}//end if left
	else if (asciiNum == atoi["right"]){ 
		if ( cursor.x < m_size.x-1 ) cursorMove(x,1); 
	}//end if right
	else if (asciiNum == atoi["up"]){ 
		if ( cursor.y > 0 ) cursorMove(y,-1); 
	}//end if up
	else if (asciiNum == atoi["down"]){ 
		if ( cursor.y < m_size.y-1 ) cursorMove(y,1);
	}//end if down
	else if (asciiNum == atoi["delete"]){}//end if delete
	else if (asciiNum == atoi["return"]){ 
		cursorMove(abs,0,cursor.y+1);	}//end if return
	else if (asciiNum == atoi["enter"]){}//end if enter
	else if (asciiNum == atoi["esc"]){}//end if esc
	else {
		insertChar(asciiNum);
	}//end if not filtered	
}// end function qwertyKeyDown(asciiNum)


thisis and system control

The scripting syntax in sdf.sys_alpha allows several types of command.   First, there are geometry-based commands for specifying, and drawing with, points on the plane; this syntax and drawing system is called thisis and it is one of the elements brought into sdf.sys from my earlier work.   For an introduction to thisis, please refer to this page on my PhD archive site.

In sdf.sys_alpha the thisis drawing plane needs to be connected to one of the space matrices by name using the command (for example to use the matrix of space two):
draw_to m2

To submit the text buffer for parsing, the user must hold two modifier keys and press the return key.   The system then processes the text buffer one line at time.   If the line is empty or begins with // or /! then it is ignored.   Text parsing is based first on the first symbol in the line, but, for thisis commands in particular, the syntax is there after slightly more complicated than a simple left to right hierarchy.

// this line is commented out by the user 
//    ( alhtought they could use the other type: )

/! but this type of comment is used 
/!    whenever the system has put text into the buffer

The next type of text command targets the system itself and the spaces of the system. For example the line:
txtfile read init.txt
can be used as a shortcut to populate the text buffer with predefined commands such as:
setup space 3 load polarpeek

In some cases, such as with the loading of 'polarpeek', the contents of text buffer will be set with a prompt for further input; in the case of loading 'polarpeek' the system is looking for a command to set which matrix to read from:
space 3 m_peekfrom m?
where the ? would be replaced by an integer in range one to seven.

In this section about _alpha build implementations, the next page is about space and structure:

→ spaces and structures →

sdfsys.info
sdfsys.info

thisis
thisis

cirseq
cirseq

sdf.sys_alpha
alpha

tildegraph
tildegraph

dac pond
dacpond

sdf.sys_beta
beta

adc spiroid
adcspiroid



valid html (?) by sdf 2011–2012