Commits

Brendan Howell  committed b2a2da5

fake loader / switcher works

  • Participants
  • Parent commits 93d6202

Comments (0)

Files changed (3)

         self.algorithm = "straight"
         self.position = 0
         self.velocity = 1
+        self.name = "empty"
 
     def load(self, intext=None):
         if intext:
             self.words = text.split()
             self.markov = markov.Markov(text)
             self.burroughs = burroughs.Burroughs(text)
+            self.name = intext
         else:
             pass
             #mount the drive

File lexer.pyc

Binary file modified.
 import lexer
 import random
 import math
+import glob
 
 #axis 4 is fader
 #axis 5 is speed
 
+lexers = []
+lexer_idx = 2
 deck_A = lexer.Lexer("/dev/fd0")
 deck_B = lexer.Lexer("/dev/fd1")
 font = "fonts/pcsenior.ttf"
 out_text = [] # list of screen text rows
 cursor = ScreenText()
+next_lexer = 2
 ypos = 0
 framerate = 25
 wordrate = 3
 wordcounter = 0
-rows = 12
+rows = 10
 font_size = 14
 ROW_WIDTH = 45
 reverse = False
 bgcolor = ( 0, 0, 0 )
+monitor = "A"
 
-joy = pygame.joystick.Joystick(0)
+#joy = pygame.joystick.Joystick(0)
 
-#TODO: word clock and fixed frame rate
+#TODO: fake loader array
+#TODO: fake loader switch with Q
 #TODO: deck loading in separate thread
 #TODO: burroughs slicer
 #TODO: color knob
 #TODO: set to 72 Characters per Line
 
 def handle_keydown(event):
+    global monitor, reverse, bgcolor, lexer_idx
     print "got keydown: " + event.unicode
+    
+    #reverse / rewind?
     if event.unicode == "r":
-        global reverse
         reverse = True
-    if event.unicode == "t":
-        global bgcolor
+        
+    #trog mode
+    elif event.unicode == "t":
         bgcolor = (255,255,255)
         for row in out_text:
             row.setColor(0,0,0)
     
+    #cue next text
+    elif event.unicode == "q":
+    	if monitor == "A":
+    	    deck_A = lexers[lexer_idx]
+    	else:
+    	    deck_B = lexers[lexer_idx]
+    	
+    	lexer_idx += 1
+    	if lexer_idx >= len(lexers):
+    		lexer_idx = 0
+    		
+    #switch A/B monitor-loader
+    elif event.unicode == "a":
+        monitor = "A"
+    elif event.unicode == "s":
+        monitor = "B"
+    
+    
 def handle_keyup(event):
     print "got keyup: " + str(event.key)
     if event.key == pygame.K_r:
 
 
 def setup():
+    global deck_A, deck_B
+
     pycessing.size(640, 480)
     pycessing.framerate = framerate
     
     cursor.setFontFromFile(font, font_size)
     
+    #for now use fake lexers from disk
+    textfiles = glob.glob("test-data/*.txt")
+    for textfile in textfiles:
+        lex = lexer.Lexer("/dev/fd0")
+        lex.load(textfile)
+        lexers.append(lex)
+    
+    deck_A = lexers[0]
+    deck_B = lexers[1]
+    
     for i in range(rows):
         row = ScreenText()
         row.setFontFromFile(font, font_size)
         #row.text = str(i)*22
         row.setColor( 0 , 255, 0)
         out_text.append(row)
-    deck_A.load(fakedrive="test-data/freud-dreams.txt")
-    deck_B.load(fakedrive="test-data/poe-perloined-letter.txt")
+    #deck_A.load(fakedrive="test-data/freud-dreams.txt")
+    #deck_B.load(fakedrive="test-data/poe-perloined-letter.txt")
     deck_A.algorithm = "markov"
     deck_B.algorithm = "markov"
     print "done loading"
     pycessing.onKeyDown = handle_keydown
     pycessing.onKeyUp = handle_keyup
 
-    joy.init()
+    #joy.init()
 	
 def draw():
     
     #print "wordrate " + str(wordrate +0.25)
 
 
-    for axis in range(joy.get_numaxes()):
-		print "axis " + str(axis) + str(joy.get_axis(axis))
+#    for axis in range(joy.get_numaxes()):
+#		print "axis " + str(axis) + str(joy.get_axis(axis))
     
     # don't update if wordcount
     
         ypos = 446
         step = -38
     else:
-        ypos = 10
+        ypos = 82
         step = 38
     
     # update screen