Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Framework/CSound/CSoundServer.py
diff options
context:
space:
mode:
Diffstat (limited to 'Framework/CSound/CSoundServer.py')
-rwxr-xr-xFramework/CSound/CSoundServer.py89
1 files changed, 0 insertions, 89 deletions
diff --git a/Framework/CSound/CSoundServer.py b/Framework/CSound/CSoundServer.py
deleted file mode 100755
index 843fc0e..0000000
--- a/Framework/CSound/CSoundServer.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import select
-import sys
-import socket
-import csnd
-import threading
-import time
-
-from Framework.CSound.CSoundConstants import CSoundConstants
-
-#----------------------------------------------------------------------
-# This class was borrowed from Simon Schampijer. Thanks Simon!
-#----------------------------------------------------------------------
-
-# this is a multiple-client csound server
-# the listener is put in a separate thread
-
-class CsoundServerMult:
- # server start-up
- def __init__(self, addr):
- self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.server.bind(addr)
- self.size = 8196
- print "*** CsServer: Csound Python server listening at: @%s:%d" % (addr[0], addr[1])
- self.server.listen(32)
- self.input = [self.server,sys.stdin]
- self.running = 1
-
- # this is the interpreter function
- # if something is seen on the socket
- # it executes it as Python code
- def interpret(self):
- # run the universal orchestra
- csound = csnd.Csound()
-
- perf = csnd.CsoundPerformanceThread(csound)
-
- csound.Compile( CSoundConstants.FILES_DIR + '/univorc.csd' )
- perf.Play()
-
- while self.running:
- inputready,outputready,exceptready = select.select(self.input,[],[])
-
- for s in inputready:
- if s == self.server:
- # handle the server socket
- client, address = self.server.accept()
- print'*** CsServer: Client has been accepted on: ',address
- self.input.append(client)
-
- elif s == sys.stdin:
- # handle standard input
- junk = sys.stdin.readline()
- csound.SetChannel('udprecv.0.on', 0)
- perf.Stop()
- perf.Join()
- csound.Reset()
- csound = None
- print '*** CsServer: The csound instance has been reset successfully.'
- self.running = 0
-
- else:
- # handle all other sockets
- data = s.recv( self.size )
- if data.strip('\n') == 'off()':
- csound.SetChannel('udprecv.0.on', 0)
- perf.Stop()
- perf.Join()
- csound.Reset()
- csound = None
- print '*** CsServer: The csound instance has been reset successfully.'
- self.running = 0
- break
-
- print 'data = ', data
- if data:
- try:
- exec data
- except:
- pass #print "exception in code: " + data
- else:
- print '*** CsServer: remove socket: ', s.fileno()
- s.close()
- self.input.remove(s)
-
- for i in self.input:
- i.close()
- self.input.remove(i)
- self.server.close()
- print '*** CsServer: The server has been closed.'