Residency Alexander Baervoets



Plateau/nadine, Herderstraat 30 rue du Berger, 1050 Brussels

#!/usr/bin/pyhton

“”” connecting remote machines, one running puthon, the other supercollider, via internet with the OSC protocol-each time a new letter-movement is displayed on the screen an osc message is sent to supercollider triggering the correspondant sound samplesending.””

import pygame
from pygame.locals import *
import glob, sys, osc, random, time, os
##############################
#DATABASE OF THE MOVEMENTS
##############################
LEFT = -1
RIGHT=1
Sec=[0,1,2,3,3,4,5,6,7,8,8,9,10,11,11]
Keys=[“k”,  “f1”, “y”, “y”, “f6”, “b”, “m”, “s”, “d”, “d”, “u”, “f7”, “j”, “j” ,”;”]
keyProps = {

“f1”:    (‘b’,’left hand up’, LEFT, -7),

“b”:    (‘e’, ‘two steps backwards’, RIGHT, 0),

“d”:    (‘h’,’change of weight’, LEFT, -1),

“f6”:    (‘d’, ‘folded’, RIGHT, 2),

“f7”:    (‘j’, ‘turn’, RIGHT, 2),

“k”:    (‘a’, ‘turn right’, RIGHT, 0),

“j”:    (‘k’, ‘squeeze’, RIGHT, 0),

“m”:    (‘f’, ‘unfold and small arch’, RIGHT, 0),

“s”:    (‘g’, ‘knee up’, LEFT, -1),

“u”:    (‘i’, ‘elbows’, RIGHT, 0),

“y”:    (‘c’,’head down’, RIGHT, 7),

“;”:    (‘l’, ‘bend legs’, RIGHT, 0)

}
#######################################################
#CLASSES FOR DRAWING TEXT AND ITS POSITION ON THE PAGE#
#######################################################
class Text:
“””represents a text based score of a movement”””
def __init__(self, name):
self.name=name

def loadName(self):
surf=font.render(str(self.name).strip(“[]_\'”), True, (230, 230, 230))
return surf

class Stamp:
“””represents a specific mark on the page/combination of text with the position, and page”””
def __init__(self, text):
self.text=text.loadName() #pygame surface

def set_pos(self, col, row):
#list of valid positions
self.pagex=width/2 + col*IMG_WIDTH
self.pagey=height-((row+2)*GRIDHEIGHT)

def draw(self, screen):
screen.blit(self.text, (self.pagex, self.pagey))

class Page:
“””list of stamps”””
def __init__(self, stampsByPos={}):
self.stampsByPos=stampsByPos
self.cur_row = 0

def draw(self, screen):
for s in self.stampsByPos.values():
s.draw(screen)

########################################
#FUNCTIONS FOR PYGAME DISPLAY ANIMATION
########################################
numberList=[]
keylist=[]
(cursor_col, cursor_row) = (0, -1)
symbolsByPos={}
pages=[]
page=Page(symbolsByPos)
count=0
filename = “dump.txt”
keydump = open(filename,”a”)
keydump.write(“—-\n”)

def onKey(key, page):
“””find the position on the page”””
global cursor_row, cursor_col, symbolsByPos, keylist, pages, count
for k in keyProps.keys():
if k!=key:
pass
else:
cursor_col= keyProps[key][3]
cursor_row+= 1
t=Text(keyProps[key][0])
st=Stamp(t)
print cursor_col, cursor_row
symbolsByPos[(cursor_col, cursor_row)]=st
st.set_pos(cursor_col, cursor_row)

def notate(name):
“””making the notation on the screen”””
global cursor_row, cursor_col, symbolsByPos, keylist, pages, count, page, numbers4uffers
i=0
while 1:
for k in Keys:
keylist.append(k)
while i < len(keylist)+1: #look up how many movements in the list and do the code for all them
for event in pygame.event.get():
if event.type == pygame.QUIT or \
(event.type == KEYDOWN and event.key == K_ESCAPE):
sys.exit()
if i==15: #15 is the mumber of the seconds of the dance phrase
i=0
if keylist[i]== ‘k’:    #check if the position of i is in the first movement
msg= sendMsg(add, msg, ip, port)
msg
print keylist[i], msg, ‘WOW’
onKey(keylist[i], page)
elif keylist[i]==keylist[i-1]:
print keylist[i], ‘the previous is: ‘, keylist[i-1], ‘do nothing’
pass
else:
msg= osc.sendMsg(add, msg, ip, port)
print msg, ‘WOW’
onKey(keylist[i], page)
if cursor_row >=VAR:
keylist=[]
symbolsByPos={}
pageFile=name.join(‘_’) + (‘%d.bmp’ % count)
pygame.image.save(screen, pageFile)
pages.append(pageFile)
page = Page(symbolsByPos)
count+=1
cursor_row=-1
i+=1
time.sleep(2)
#DRAW SCREEN
screen.fill((100, 100, 100))
#DRAW CURSOR
cursor_width = IMG_WIDTH
cx = width/2
pygame.draw.rect(screen, (30, 47, 47), (cx + (cursor_col*IMG_WIDTH), stafftop, IMG_WIDTH, staffheight))
pygame.draw.rect(screen, (30, 47, 47), (0, (staffbottom-((cursor_row+1)*GRIDHEIGHT)),  width, GRIDHEIGHT))
#DRAW STUFF
pygame.draw.rect(screen, (0, 0, 0), (cx-2*IMG_WIDTH, stafftop, 4*IMG_WIDTH, staffheight), 1)
pygame.draw.line(screen, (0, 0, 0), (cx, staffbottom), (cx, stafftop), 1)
#DRAW STUFF TIME FRAMES
for row in range(0, 16, 1):
pygame.draw.line(screen, (0, 0, 0), (cx+0.2*IMG_WIDTH, height-(row+1)*GRIDHEIGHT),( cx-0.2*IMG_WIDTH, height-(row+1)*GRIDHEIGHT), 1)
#WRITE BODY INDICATIONS
rside=fontSmall.render(‘right side’, True, (255, 150, 50))
screen.blit(rside, (cx+30, staffbottom+35))

lside=fontSmall.render(‘left side’, True, (255, 0, 0))
screen.blit(lside, (cx-2*IMG_WIDTH, staffbottom +35))

lleg=fontSmall.render(‘leg’, True, (255, 0, 10))
screen.blit(lleg, (cx-1.6*IMG_WIDTH, staffbottom +3))

lbody=fontSmall.render(‘body areas’, True, (255, 0, 20))
screen.blit(lbody, (cx-4*IMG_WIDTH, staffbottom +3))

larm=fontSmall.render(‘arm’, True, (255, 0, 30))
screen.blit(larm, (cx-6*IMG_WIDTH, staffbottom +3))

rleg=fontSmall.render(‘leg’, True, (255, 160, 60))
screen.blit(rleg, (cx+1.2*IMG_WIDTH, staffbottom +3))

rbody=fontSmall.render(‘body areas’, True, (255, 170, 70))
screen.blit(rbody, (cx+2.5*IMG_WIDTH, staffbottom+3))

rarm=fontSmall.render(‘arm’, True, (255, 180, 80))
screen.blit(rarm, (cx+5.5*IMG_WIDTH, staffbottom +3))
#WRITE COPYRIGHT HOLDER NAME
identity=fontSmall.render(‘Copyleft ‘+ name +’ 2009-06′, True, (30, 20, 30))
screen.blit(identity, (10, 22))
#DRAW CUR PAGE
page.draw(screen)
#refresh frames
pygame.display.flip()
clock.tick(FPS)

#########################################
#FUNCTIONS FOR OSC MESSAGES HUNDLERS
#########################################
def listLet(*msg):
“”” split the list of incoming message and retreive the necessary data “””
i=0
print ‘got’, msg
print len(msg[0][1])

while i < len(msg[0][1]):
#    print ‘i is ‘, i, ‘and typetag is ‘, msg[0][1][i]
if msg[0][1][i] == ‘f’:
print
print ‘so incoming data are ‘, int(msg[0][i+1]*10)
#puredata=int(msg[0][i+1]*10)
#numberList.append(puredata)
print
if msg[0][1][i] == ‘i’:
print
print ‘so incoming data are ‘, msg[0][i+1]
#puredata=msg[0][i+1]
print
#numberList.append(puredata)
i+=1
print numberList

def sendMsg(osc_add, msg, ip_add, port):
“”” listens to OSC messages sent by a set ip address and port and split them in single characters; numbers or letters”””
#osc.listen(ip_add, port)    #uncomment for use it when sending to localhost or when receiving data from remote computer
#osc.bind(listLet, osc_add)
print ‘ip address is ‘, ip_add, ‘, port is ‘, port
osc.sendMsg(osc_add, msg, ip_add, port)
for event in pygame.event.get():
if event.type == pygame.QUIT or \
(event.type == KEYDOWN and event.key == K_ESCAPE):
sys.exit()
osc.dontListen()

def clearscreen():
os.system(“clear”)

###################################
#GET PYGAME and OSC READY TO RUN
###################################
osc.init()
pygame.init()
pygame.font.init() # we need fonts
clearscreen()
###############################
#CONSTANTS-TWEAK ME-PYGAME
size = width, height = 1100, 765
FPS = 60
IMG_WIDTH=50
GRIDHEIGHT=50
VAR=int(height/GRIDHEIGHT)-1 #a whole number => devide the screen height with the grid size and substruct 2 => twice the grid size (once from bottom/once from top)
staffheight=VAR*GRIDHEIGHT
staffbottom=height-GRIDHEIGHT
stafftop= staffbottom-staffheight
pygame.display.set_caption(‘Labanotation’)
fontpath=’/Library/Fonts/liberation-fonts-0.2/LiberationSerif-Regular.ttf’
font=pygame.font.Font(fontpath, 25)
fontSmall=pygame.font.Font(fontpath, 18)
# open pygame window
screen = pygame.display.set_mode(size)# pygame.FULLSCREEN)
# make a pygame clock
clock = pygame.time.Clock()#########################################################
#SET THE VAR AND CALL THE FUNCTIONS OF OSC AND PYGAME
numbers4buffers=[1000, 1001, 1002, 1003, 1003, 1004, 1005, 1006, 1007, 1008,1008,  1009, 1010, 1011, 1011]
(add, msg, ip, port) = (“/s_new”, [“Player”, numbers4buffers, 0,1, “bufnum”, Sec], ‘10.0.1.5’, 57110)
notate(‘test’)

[NL] Van februari tot maart verblijft Alexander Baervoets in residentie ter voorbereiding van een nieuwe performance Hortus Conclusus. Hij werkt in Plateau samen met Christoph Ragg, Ariane Loze en Heike Langsdorf.

[FR] 1er février – 31 mars

Alexander Baervoets est en résidence à Plateau. Il y travaille avec Ariane Loze, Christoph Ragg et Heike Langsdorf au nouveau spectacle Hortus Conclusus.

[EN] 1 February – 31 March

Alexander Baervoets is in residence at Plateau. He is working with Ariane Loze, Christoph Ragg and Heike Langsdorf on the new performance Hortus Conclusus.