|
View:
New views
18 Messages
—
Rating Filter:
Alert me
|
|
|
Batch processing audio-files with csound(?)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 |
|
|
Re: Batch processing audio-files with csound(?)Hi,
You could use the csound api from python, and pass the filenames and other parameters as macros using --omacro:XXX=YYY Cheers, Andrés 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 > -- Send bugs reports to this list. To unsubscribe, send email to csound-unsubscribe@... |
|
|
Re: Batch processing audio-files with csound(?)Thanks Andres,
Do you know an online article or tutorial about using the api with python? Best Peiman
|
|
|
|
|
|
Re: Batch processing audio-files with csound(?)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
|
|
|
Re: Batch processing audio-files with csound(?)Hi,
I had in mind for example to make a CSD that time stretches every file in a given directory. The problems that arise are this: 1- the length of the out-file needs to be variable according to the file's length. 2- the files can be specified as *.aiff in a given folder (on unix) but how can csound understand this and repeat the process for every file? 3- the output file needs to be generically renamed. I was thinking of using csound~ to build a simple application with max/msp, but after thinking I realize it wouldn't be that simple as the only way to do it is for max to: access the CSD, recognize and change particular variables and save the CSD as a temporary file for each render (I might give it a try). It would be nice if csound opcodes could be integrated into a shell script (I guess they can, I just don't know how!). So far I cannot work out how to call csound api from within python (on os x). Thanks Peiman Peiman
|
|
|
Re: Batch processing audio-files with csound(?)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
|
|
|
Re: Batch processing audio-files with csound(?)I've optimized it a bit by following Andres Cabrera's suggestion using the --omacro flag. This new command removes a few very unnecessary steps, including generating multiple files then deleting them. It's also much easier to read.
for i in `ls *.aif | sed 's/.aif//'` ; do csound -d -A --omacro:theFile=$i.aif -o$i.batch.aif batchfx2.csd ; done I also removed the following line for the .csd file: # define theFile #FILENAME# BTW, thanks for asking such a great question. I've never even considered that Csound could be used as an fx batch processor. Turns out, it's pretty quick and easy to use it as one. I'll be playing around with this off and on over the next few days. Best, Jake ---- The Csound Blog http://www.thumbuki.com/csound/blog
|
|
|
Re: Batch processing audio-files with csound(?)Thats great Jacob,
Thanks very much Peiman
|
|
|
Re: Batch processing audio-files with csound(?)Wow,
I just tried it. It's amazingly quick! Thanks for sharing this... Best Peiman
|
|
|
Re: Batch processing audio-files with csound(?)You might also have a look at sox, the so called "Switch army knife"
sound utility. I know its not Csound but it's designed from the start for batch processing and a great tool to have around. On 7/7/07, peiman <peimankhosravi@...> 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 > -- > View this message in context: http://www.nabble.com/Batch-processing-audio-files-with-csound%28-%29-tf4040859.html#a11479592 > Sent from the Csound - General mailing list archive at Nabble.com. > > -- > Send bugs reports to this list. > To unsubscribe, send email to csound-unsubscribe@... > Send bugs reports to this list. To unsubscribe, send email to csound-unsubscribe@... |
|
|
Re: Batch processing audio-files with csound(?)On Sat, 2007-07-07 at 12:07 -0700, Jacob Joaquin wrote:
> I've optimized it a bit by following Andres Cabrera's suggestion using the > --omacro flag. This new command removes a few very unnecessary steps, > including generating multiple files then deleting them. It's also much > easier to read. > > > for i in `ls *.aif | sed 's/.aif//'` ; do csound -d -A > --omacro:theFile=$i.aif -o$i.batch.aif batchfx2.csd ; done > That's neat, but you don't need to use "ls" or "sed" to trim the file name... for i in *.aif; do csound -d -A --omacro:theFile=$i -o${i%.*}.batch.aif batchfx2.csd ; done -- Send bugs reports to this list. To unsubscribe, send email to csound-unsubscribe@... |
|
|
Re: Batch processing audio-files with csound(?)Hello,
I've change the csd and the command a little for splitting interleaved stereo files into two seperate mono files (there may be a more elegant way to do this?). With a little change the same could be done for even 5.1 files, now I'm convinced csound can do almost anything! for i in *.aif; do csound -d -A -n --omacro:theFile=$i --omacro:outFile=${i%.*}.L.aif --omacro:sig=asig1 batchfx2.csd ; done | for i in *.aif; do csound -d -A -n --omacro:theFile=$i --omacro:outFile=${i%.*}.R.aif --omacro:sig=asig2 batchfx2.csd ; done <CsoundSynthesizer> <CsInstruments> sr = 44100 kr = 4410 ksmps = 10 nchnls = 2 ;call this batchfx2.csd instr 1 ilength filelen "$theFile" event_i "i", 2, 0, ilength endin instr 2 asig1, asig2 diskin "$theFile", 1 fout "$outFile", 8, $sig endin </CsInstruments> <CsScore> i1 0 1 </CsScore> </CsoundSynthesizer> Peiman
|
|
|
Re: Batch processing audio-files with csound(?)I split files using the mixer utility
==John ffitch -- Send bugs reports to this list. To unsubscribe, send email to csound-unsubscribe@... |
|
|
Re: Batch processing audio-files with csound(?)I didn´t know that utility. Thanks for letting me know.
Peiman
|
|
|
Re: Batch processing audio-files with csound(?)I've spent some considerable time this past week using Csound as a batch processor. There are a few issues that popped up while I was playing around. I created a command-line instrument, ShellVerb, that demonstrate solutions for these issues.
ShellVerb v0.1 http://www.thumbuki.com/csound/files/mailinglist/ShellVerb_v0.1.csd The techniques implemented: 1) Default parameter values with #ifndef 2) Ability to process either mono or stereo files 3) Adjust pitch of diskin if samplerates differs. Overall, I'm very happy with Csound's ability to handle command-line processing. I've made about five different instruments that I've already put to use on a project I'm working on. I'm certainly going to continue exploring this, and I'll share anything I find. If anyone finds a better solution, or more efficient way of designing a shell processors, please share. For example, sand-6's suggestion of using ${i%.*} was a big help. Best, Jake ---- The Csound Blog http://www.thumbuki.com/csound/blog
|
|
|
Re: Batch processing audio-files with csound(?)For any one on MacOS X or 9, I created a set of Applescripts a long time ago
that are "drag and drop" applications using Csound for FX processing. You just drop a sound file on the script in the Finder and it launches (the OS 9 version) of Csound to process it. The input file is determined via the -i flag but that could very easily be changed to -omacro. Also, I imagine that it would be easy on OS X to run a commandline Csound instead. An example is below (inspired by the effects instruments that Matt Ingalls made for MacCsound) for processing one file at a time. But you could loop on "theList" to process any number of files. Anthony Kozar anthonykozar AT sbcglobal DOT net http://anthonykozar.net/ peiman wrote on 7/7/07 2:03 PM: > I had in mind for example to make a CSD that time stretches every file in a > given directory. The problems that arise are this: > > 1- the length of the out-file needs to be variable according to the file's > length. > 2- the files can be specified as *.aiff in a given folder (on unix) but how > can csound understand this and repeat the process for every file? > 3- the output file needs to be generically renamed. > > So far I cannot > work out how to call csound api from within python (on os x). -- SC Reverberate (stereo) -- Drop a stereo sound file on this script and it will call Csound to apply the -- reverbsc opcode to the sound file. -- The output sound file is placed in the same directory. -- Anthony Kozar -- October 8, 2003 -- Modified for reverbsc and Csound 5 on May 2, 2006 -- edit this string to be the path to the folder of your .csd file (including final colon) property reverbDir : "Projects:Csound:scores-projects:Csound FX Droplets:orchestras:" -- edit this string to be the name of your .csd file property reverbFile : "reverbsc.csd" -- edit this string if you want to use a different suffix for the output file property fileSuffix : ".rvbsc" -- these are the Csound command-line options for messages, format, and buffers property options : "-m7 -s -A -R -b32768 -B32768" on open theList --try -- this script can only process one file; it could be modified for more if (length of theList is greater than 1) then beep display dialog "This script can accept only one file at a time. Only the first file will be processed." if the button returned of the result is "Cancel" then quit end if end if set soundfile to item 1 of theList set curInfo to info for soundfile if (folder of curInfo is true) then -- at least make sure that it is a file; more error checking here would be good beep display dialog "This script can only process files, not folders." else ProcessSoundFile(soundfile) end if end open on ProcessSoundFile(soundfile) set fullpath to (soundfile as string) copy text 1 thru (((length of fullpath)) - ((offset of ":" in (reverse of characters of fullpath) as string))) of fullpath to folderpath copy text (((length of fullpath) + 2) - ((offset of ":" in (reverse of characters of fullpath) as string))) thru (length of fullpath) of fullpath to sfname -- display dialog sfname set inputparm to " \"-i" & sfname & "\"" if (length of (sfname & fileSuffix) is less than 32) then -- Mac file names must be 31 characters or less set outputparm to " \"-o" & sfname & fileSuffix & "\"" else -- truncate the soundfile's name copy text 1 thru (31 - (length of fileSuffix)) of sfname to truncatedName set outputparm to "\"-o" & truncatedName & fileSuffix & "\"" end if set sfdir to " \"--env:SFDIR=" & folderpath & "\"" set commandline to "Csound " & options & inputparm & sfdir & outputparm & " \"" & reverbDir & reverbFile & "\"" display dialog commandline tell application "CsoundFront" Csound commandline activate end tell end ProcessSoundFile ------------- END OF SCRIPT --------------- ; reverbsc.csd <CsoundSynthesizer> <CsOptions> </CsOptions> <CsInstruments> ; 2-channel reverb ; ; ma++ 02.14.02 ; (Matt Ingalls) ; ; simple example of an effect that changes the file length ; ; Modified to use freeverb. ; Anthony Kozar ; May 2, 2006 sr = 44100 ksmps = 441 nchnls = 2 gkrevtime init 4.0 instr 1 aleft, aright ins denorm aleft, aright alr, arr reverbsc aleft, aright, 0.9, 14000, sr, 0.5 outs .5*(aleft + alr), .5*(aright + arr) endin ; this instrument handles terminating the score ; we have to extend the length by the reverb time. instr 9 ilen filelen "-i" ; get the length of the file in seconds ktime init 0 ktime times if (ktime < ilen + gkrevtime) kgoto skip event "e", 0,0,1 ; terminate now! skip: endin </CsInstruments> <CsScore> i1 0 9999999 ; max length i9 0 9999999 ; max length </CsScore> </CsoundSynthesizer> -- Send bugs reports to this list. To unsubscribe, send email to csound-unsubscribe@... |
|
|
Re: Batch processing audio-files with csound(?)I went back and made some modifications to the ShellVerb demo. I didn't like how I had created two separate instruments for processing mono or stereo files. If I had to make a modification to one instrument, I'd have to make a similar modification to the the other. This would naturally increase the odds of introducing a bug to the Csound code. In the new version, every audio stream will be processed by the same Reverb instrument. The trade off is that the Setup instrument is more complex.
ShellVerb v0.2 http://www.thumbuki.com/csound/files/mailinglist/ShellVerb_v0.2.csd Best, Jake ---- The Csound Blog http://www.thumbuki.com/csound/blog
|
| Free embeddable forum powered by Nabble | Forum Help |