Csound Csound-dev Csound-tekno Search About

batch processing / rendering CSDs using Python

Date2007-10-23 09:42
FromTim Mortimer
Subjectbatch processing / rendering CSDs using Python
Hi folks,

I want to "batch render" csd files in a nominated directory.

i'm starting a new Module in my parse||eval program/motherscript therefore
to do exactly that - that's why the code below is plonked within a
"mainline" function

but, err, yp, it doesnt run. in fact it crashes python

the CSD's themselves all run fine in Csound alone however....

So, how do i call & render a batch of CSD to their respective -o files, one
after the other (doesn't have to be synchronous) 

all the header information / flags etc are allready pre defined in the CSD
file.

but for anyone who understands any python, i think the code below should
make my intentions pretty clear.

Thanks any/everyone!

###############


import csnd
import os

csound = csnd.CppSound()

def mainline():

    dirlist = os.listdir('aaa CSDs 2 render')
    csound.setPythonMessageCallback()
    
    for filename in dirlist:
	
	# render each csd file in the directory to its associated -o file
	# (which is already defined in its CSoptions in the file)
	
        csdfile = open('aaa CSDs 2 render/'+filename,'r')
        
        csd = csdfile.read()
        csdfile.close()
        
        csound.setCSD(csd)

        csound.exportForPerformance()

        csound.perform()

    return

-- 
View this message in context: http://www.nabble.com/batch-processing---rendering-CSDs-using-Python-tf4675931.html#a13359617
Sent from the Csound - General mailing list archive at Nabble.com.