« Return to Thread: Batch processing audio-files with csound(?)

Re: Batch processing audio-files with csound(?)

by peiman :: Rate this Message:

Reply to Author | View in Thread

Aha,

Hi,

That's very clever! I will give it a try, I am more familiar with csh command-line so I will spend some-time understanding your command. I get the general idea though :-)

Thanks
Peiman

I came up with this solution using a short bash command-line script and a specially prepared .csd file.

bash:

for i in `ls *.aif | sed 's/.aif//'` ; do cat batchfx.csd | sed "s/FILENAME/$i.aif/" > $i.batch.csd ; csound -d -A -o$i.batch.aif $i.batch.csd ; rm *.batch.csd ; done


batchfx.csd:

<CsoundSynthesizer>
<CsInstruments>
sr     = 44100
kr     = 4410
ksmps  = 10
nchnls = 2

# define theFile     #FILENAME#
# define ReverbTime  # 2 #
# define Amp         # 0.5 #

instr 1
        ilength filelen "$theFile"
        event_i "i", 2, 0, ilength + $ReverbTime
endin

instr 2
        asig1, asig2 diskin "$theFile", 1
        asig1 reverb asig1, $ReverbTime
        asig2 reverb asig2, $ReverbTime
        outs asig1 * $Amp, asig2 * $Amp
endin

</CsInstruments>
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>



Not the most elegant solution in the world.  However, it's possible to write a flexible shell script using this method.  I've only tested this in OS X, though it might work in linux and in windows using cygwin.

*** Warning: Use at your own risk ***

It's easy to accidently destroy important files with commands like "rm *.csd" if you aren't careful.


Best,
Jake

----
The Csound Blog
http://www.thumbuki.com/csound/blog 


peiman wrote:
Hello,

I was wondering if there is any way to batch process several audio-files with the same csound code? I have been studying the manual all day and cannot think of a way to do this. Would it for instance be possible to add an extra argument to the standard csound terminal command that will replace a particular variable defined in the score or orchestra (i.e. a file name)?

Many Thanks
Peiman  

 « Return to Thread: Batch processing audio-files with csound(?)