Csound Csound-dev Csound-tekno Search About

Re: batch processing / rendering CSDs using Python

Date2007-10-24 13:44
From"Michael Gogins"
SubjectRe: batch processing / rendering CSDs using Python
Yes, if you have multiple threads in your script this may not work, in which 
case you should use the Csound threading object. This is used in some of the 
example scripts.

Regards,
Mike

----- Original Message ----- 
From: "Oeyvind Brandtsegg" 
To: 
Sent: Wednesday, October 24, 2007 6:01 AM
Subject: Re: [Csnd] batch processing / rendering CSDs using Python


> Could you test if your setup works * without the loop* ?
> e.g.
>
> import csnd
> import os
> csound = csnd.CppSound()
> def mainline():
>   csound.setPythonMessageCallback()
>   csdfile = open('filename,'r')
>   csd = csdfile.read()
>   csdfile.close()
>   csound.setCSD(csd)
>   csound.exportForPerformance()
>   csound.perform()
>   return
>
> I haven't tested the code above. Is it complete, or do you have other
> things happening at the same time. Maybe you could supply a simple
> test.csd, and I could try to test it here.
> You set up and run csound a little differently than I do,
> and I can't determine if there's anything wrong just by looking.
> Is the csound.perform() call equvalent to:
> performanceThread = csnd.CsoundPerformanceThread(csound)
> performanceThread.Play()
> ?
>
> I'm not sure, but when you want to batch process several csd files,
> you should maybe do :
> csound.Reset()
> csound.Cleanup()
> in between each csd.
>
> best,
> Oeyvind
>
>
> 2007/10/24, Tim Mortimer :
>>
>> thanks Jonathon - but that didn't work
>>
>> I think somehow i need to defer the loop iteration until the conclusion 
>> of
>> the csdfile rendering / playback so some sort of scheduling or something
>> might be in order
>>
>> so, err yeah.
>>
>> Oeyvind, if you read this & finish your debugging exercise anytime soon 
>> i'd
>> love 5 minutes of your time.
>>
>> Michael G - well, never responds to any of these types of python / csnd
>> queries of mine it seems.
>>
>> That's fine. I'll keep asking anyway. If these abortive threads of mine
>> prove to be nothing other than a catalog of things i couldn't do with 
>> csnd,
>> it will still hopefully be of some value to someone in the future on that
>> basis alone.....
>>
>> Im afraid when i open csnd.py looking for greater insight i don't see 
>> much
>> that resembles my "python for idiots / dummies / pygmies / giants /
>> antelopes ...." book(s).....
>>
>>
>> Jonathan Murphy-2 wrote:
>> >
>> > I'm not a python person, but on the perhaps spurious assumption that a
>> > for loop is a for loop, it looks to me like csd will no longer be
>> > valid when you pass it to csound. If the rest of your code is ok,
>> > maybe something like this, closing the file when you're done with it:
>> >
>> >     for filename in dirlist:
>> >         csdfile = open('aaa CSDs 2 render/'+filename,'r')
>> >         csd = csdfile.read()
>> >         csound.setCSD(csd)
>> >         csound.exportForPerformance()
>> >         csound.perform()
>> >         csdfile.close()
>> >
>> > Hope this helps,
>> > Jonathan.
>> >
>> > Tim Mortimer  writes:
>> >
>> >
>> >
>> >
>>
>> --
>> View this message in context: 
>> http://www.nabble.com/batch-processing---rendering-CSDs-using-Python-tf4675931.html#a13382201
>> Sent from the Csound - General mailing list archive at Nabble.com.
>>
>> --
>> Send bugs reports to this list.
>> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk
>>
> -- 
> Send bugs reports to this list.
> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk 

Date2007-10-26 08:01
FromTim Mortimer
SubjectRe: batch processing / rendering CSDs using anything
Oeyvind, Michael, everyone.

There is no need for threads or anything fancy i shouldnt think / hope

all i want to do is call a bunch of csd's in a folder (that as it happens
have been generated & assembled using python), & render them to their -o
"xyz.wav" as already hard coded / flagged / defined in each 
within each CSD.

one after the other is fine. if i have a piece based on 16 separate phase
vocoder instruments, each pushing up around the 100% cpu mark, it's gonna
make a lot more sense for me to just render all my "material" & then have a
very simple arrangement csd to tie it all together & play it back with. That
way if i change 1 instrument part, i don't have to worry about rendering a
whole performance. & it will save me typing "csound joebloggs.csd" a million
& one times....

i'll even settle for a .bat file if it comes down to it!

but all i've managed to suss out about that is 

for %f in (*.csd) do csound .... ???

can anybody complete that statement? (windows)


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

Date2007-10-27 19:48
From"Oeyvind Brandtsegg"
SubjectRe: batch processing / rendering CSDs using anything
AttachmentsNone  

Date2007-10-28 02:38
FromTim Mortimer
SubjectRe: batch processing / rendering CSDs using anything
Thanks for your advice Oeyvind.

i've tried various twists & slight variations on the code as i have seen in
the various examples. none of them run sucessfully (if they do, they crash
before exiting) & none produce any audio (either to .wav or realtime out) 

i have sucessfully run csound in python with separate orc & sco files
however. (as per the koch example)

i could redesign my program slightly & work from separate orc & sco files.
in some ways that makes sense in terms of archiving work (just save
generated sco's with one generic set of orc's per composition)

but the idea of having a bunch of csd's that can be run individually, &
batch processed at will is still i think a desirable outcome

simply getting any embedded csd to run however is the first challenge.

apologies for being a bit scatty with this. it's not getting a major amount
of attention from me, as usual, i'm tackling several different issues at
once (depending on what i feel like tackling on any given day)

but if I have your attention oeyvind, then you have mine also.

see if you can make this work below then (preferably outputting to .wav
file)

import csnd

csound = csnd.CppSound()
csound.setPythonMessageCallback()

csound.setCSD('''




 ./temp.orc ./temp.sco 




sr	=  48000
ksmps	=  64
nchnls  =  2

0dbfs   = 1

gisine 		ftgen 100, 0, 16384, 10, 1

instr 01

	asig	oscili .5, p4, 100, 1

        outs asig asig
        
endin








i 1 0 4 440
i 1 5 4 880

e





''')


csound.exportForPerformance()
csound.compile()
while True:
    csound.performKsmps(True)
csound.cleanup()


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