Thursday, July 27, 2006


boa constritor and csound

I crashed boa contrictor by doing some sort of new library thing and then the undo button. It sorta looks like borland until you use it and then you realise there is a learning curve. Does cool things though. I realized that I cunfused python with tlk. It is a two part series one in tlk where they show notes being played by the each and the second in python. there are other examples on the web but I have to keep my phone open in the daytime but I know they are there because I have seen them befour. How much is there from cabel and the example in the magazine that is reusable??? Not much realy they depend on the rest of the package. Learning python without the manual is a bit of a chalenge to say the least. Is the def files usable??? maybe not but just for the sake of seeing what other people are doing here it is.. this is by no means even a beta of a csound library...

import csnd
except ImportError:
import CsoundVST
import os
import sys

def play(self):
Starts CSD generation and csound in a seperate process. If
csound's already playing stops it first.

@rtype: boolean
@return: True if the csound process started successfully.
if self._playing:
return self._startCsound()

def stop(self):
Stops running Csound process.

@rtype: boolean
@return: True if there was a running csound process to be stopped, else False.
if self._playing == True:
self._playing = False
return True
return False
def _kill(self):
Wrapper for os.kill to emulate kill if not on unix.
if sys.platform in ("win32"):
import win32process
if self._handle.handle > 0 and win32process.GetExitCodeProcess(self._handle) > 1:
import win32api
win32api.TerminateProcess(self._handle, 0)
self._pid = None
import signal
os.kill(self._pid, signal.SIGTERM)
self._pid = None
def _startCsoundOnMSW(self, cmd):
Wrapper for _startCsound on Windows plattforms

@type cmd: string
@param cmd: Commando for the csound process.
import win32process

si = win32process.GetStartupInfo()
si.dwFlags = 0
si.hStdInput = None
si.hStdOutput = None
si.hStdError = None

procArgs = (None, # appName
cmd, # commandLine
None, # processAttributes
None, # threadAttributes
1, # bInheritHandles
0, # dwCreationFlags
None, # newEnvironment
None, # currentDirectory
si) # startupinfo
processHandle, threadHandle, pid, tid = win32process.CreateProcess(*procArgs)

self._handle = processHandle
self._pid = pid

# Timeout for feedback on the succes of the csound process
timeOut = float(self.config.getVal(tools.config.Csound.FEEDBACK_TIMEOUT)) / 1000.0
import time

return win32process.GetExitCodeProcess(self._handle) == 259

class CsoundThread(threading.Thread):
def __init__(self, csound, commandline):
self.isRunning = True
self.csound = csound
self.commandline = commandline
print "csound loaded"
# self.locked = 0
def run(self):
# Embed an orchestra in this script.
self.csound.setOrchestra('''#include 'ruleChorale.orc'
# And a score.
self.csound.setScore('''#include 'ruleChorale.sco'
# Command line
self.csound.setCommand('''%s''' %self.commandline)
# Export the orc and sco.
# Start the performance.
# Absolutely MUST yield to wxWindows or the app will freeze!
# print 'running'

def stop(self):
stop the csound thread loop
print 'stopping csound'
self.isRunning = False

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?