| Tobiah wrote:
>
> I sometimes use csound in shell scripts
(snip)...
I would love to see some examples of this technique.
> I would love to use csound in this way as a normal
> command line filter, using standard in and out. The
> problem is that when using standard in, one can not
> determine the length of the input sound file, and so
> a score of the proper length can not be generated.
I am by no means a shell-script expert, so there may well be better
solutions, but: What about storing the length of input in an
environment variable?
let's use the hypothetical scripts "flanger" and "echo".
You might call them like this:
flanger -i input.wav | echo -o output.wav
Here's what happens:
1. "flanger" sees that it has the "-i input.wav" arguments and decides
that it must call sndinfo, parse the result to find lenght of input.wav.
2. Length in sec. is stored in environment as $WAVLENGTH
3. echo sees that it does not have a "-i" argument and thus assumes its
input is from stdin. So it looks to $WAVLENGTH for the duration to use.
It also modifies $WAVLENGTH if it will be changing the length. This is
so subsequent filters in the pipe get the new length correct.
To make these scripts general-purpose filters, all scripts should test
for the existence of $WAVLENGTH and only call sndinfo if it does not
exist. You would then want the last called script to destroy $WAVLENGTH,
or else it will still be floating around the next time you run these
scripts. But how would the last script know it's the last one? By
checking to see whether it has a -o argument. If yes, then its output is
being written to a file and we can safely remove $WAVLENGTH. If no, we
should assume output is to a pipe or stdout.
One disadvantage: I don't know how this could be made to work with
redirection symbols > and < . Or backquotes.
---------------- paul winkler ------------------
slinkP arts: music, sound, illustration, design, etc.
zarmzarm@hotmail.com --or-- slinkp AT ulster DOT net
http://www.ulster.net/~abigoo/ |