[PD-cvs] supercollider/python supercollider.py,1.2,1.3

ksvalast at users.sourceforge.net ksvalast at users.sourceforge.net
Thu Jan 22 09:59:38 CET 2004


Update of /cvsroot/pure-data/supercollider/python
In directory sc8-pr-cvs1:/tmp/cvs-serv1698

Modified Files:
	supercollider.py 
Log Message:
Various

Index: supercollider.py
===================================================================
RCS file: /cvsroot/pure-data/supercollider/python/supercollider.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** supercollider.py	21 Jan 2004 08:58:03 -0000	1.2
--- supercollider.py	22 Jan 2004 08:59:35 -0000	1.3
***************
*** 22,25 ****
--- 22,42 ----
  
  # This file is far from complete, but its a start.
+ #
+ # All variables, classes and methods that are implemented in this file are
+ # tested, and should work.
+ #
+ # It would be easy to read the Supercollider server command reference, and just
+ # implement the missing methods and classes blindly. But I don't want to. When the
+ # implementation is so straight forward as here, its better to it properly.
+ #
+ # So if you need more functionality, you can either just read the Supercollider
+ # server command reference manual and implement the functionality directly
+ # in this file (and send me the changes afterwards!), or send me some python
+ # code you want to make work with this module, and I'll try to
+ # implement it for you.
+ #
+ # Serious missing functionality: Have no way to get reply from server. Have to
+ # find a more advanced OSC implementation than OSC.py 1.2 by Stefan Kersten used now.
+ #
  # -Kjetil.
  
***************
*** 27,30 ****
--- 44,48 ----
  import OSC,tempfile,xreadlines,os,time,types
  
+ standardip="127.0.0.1"
  standardport=57110
  startnode=1001;
***************
*** 38,50 ****
  
  
- # For some crazy reason, the sclang command tells the server to quits when exiting.
- # To fix that strange and unpleasant behaviour, uncommnet the following lines in etc. etc. etc.
- 
- 
  class Server:
!     def __init__(self,magic,port=standardport):
          if magic!=1234:
              print "Server.__init__: Are you sure you know what you are doing?"
              print "Seems like you probably wanted to use the 'localServer' variable."
          self.port=port
          self.freenode=startnode;
--- 56,67 ----
  
  
  class Server:
!     def __init__(self,magic,ip=standardip,port=standardport):
          if magic!=1234:
              print "Server.__init__: Are you sure you know what you are doing?"
              print "Seems like you probably wanted to use the 'localServer' variable."
+         if ip!=standardip:
+             print "Warning. Ip only supprted for evalSynth (but not tested)."
+         self.ip=ip
          self.port=port
          self.freenode=startnode;
***************
*** 59,62 ****
--- 76,80 ----
      def sendgetMsg(self,command,*args):
          apply(self.sendMsg,[command]+list(args))
+         # Simulated (and most probably extremely unaccurate) time used to get a reply. Use with care.
          time.sleep(1)
      def dumpOSC(self,code):
***************
*** 78,91 ****
          for line in xreadlines.xreadlines(open(synthname+".sc","r")):
              outfile.write(line)
!         tmpname2=tempfile.mktemp("")
!         outfile.write('}).writeDefFile("'+tmpname2+'");\n')
          outfile.close()
          os.system("sclang "+tmpname)
!         tmpname2+=synthname+".scsyndef"
!         self.loadSynthDef(tmpname2)
!         os.system("rm "+tmpname+" "+tmpname2)
          
  localServer=Server(1234)
  
  class Node:
      def __del__(self):
--- 96,107 ----
          for line in xreadlines.xreadlines(open(synthname+".sc","r")):
              outfile.write(line)
!         outfile.write('}).send(Server.new(\localhost,NetAddr("'+self.ip+'",'+str(self.port)+')););\n')
          outfile.close()
          os.system("sclang "+tmpname)
!         os.system("rm "+tmpname)
          
  localServer=Server(1234)
  
+ 
  class Node:
      def __del__(self):
***************
*** 96,100 ****
  
  class Synth(Node):
!     def __init__(self,server,name,args=[],position=sc_tail):
          self.server=server
          self.id=server.nextNodeID()
--- 112,117 ----
  
  class Synth(Node):
!     global localServer
!     def __init__(self,name,args=[],position=sc_tail,server=localServer):
          self.server=server
          self.id=server.nextNodeID()
***************
*** 116,126 ****
  
  class Buffer(BufferSuper):
!     def __init__(self,server,numFrames,numChannels=1):
          BufferSuper.__init__(self,server,numFrames,numChannels)
  
  class BufferRead(BufferSuper):
!     def __init__(self,server,filename,startFrame=0,numFrames=0):
          BufferSuper.__init__(self,server,numFrames,-1,filename,startFrame)
  
  
- 
--- 133,142 ----
  
  class Buffer(BufferSuper):
!     def __init__(self,numFrames,numChannels=1,server=localServer):
          BufferSuper.__init__(self,server,numFrames,numChannels)
  
  class BufferRead(BufferSuper):
!     def __init__(self,filename,startFrame=0,numFrames=0,server=localServer):
          BufferSuper.__init__(self,server,numFrames,-1,filename,startFrame)
  
  






More information about the Pd-cvs mailing list