[LAU] Need help debugging tcl in Cecilia-2.5

Robert Persson ireneshusband at gmail.com
Thu Oct 18 17:57:32 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I am trying to get Cecilia 2.5 working in Linux, or failing that, at
least to clear some of the bugs out of the way. The first big bug I am
trying to deal with is to get the output of sndinfo parsed correctly
using tcl. This is difficult because the only tcl I know is what I
have learned in the last few hours.

The problem is that the sndinfo that ships with csound5 produces very
untidy output compared to earlier versions. A whole lot of error
messages are jumbled up with various tabs and control characters. The
actual information the program is supposed to provide staggers out the
pub with the rest of this mess via stderr instead of stdin. tcl just
doesn't like this.

I have been trying to strip away some of the cruft using tr and a line
of perl I found on the web, but these instructions both use characters
that have special functions in tcl and I cannot work out how to pass
them to these other programs unprocessed. I have no idea how to escape
them.

The procedure I need to debug is the following:

proc getSoundFileInfo {path} {
    global prefs errno
    catch    {exec $prefs(help:CSND) -U sndinfo $path} stuff
    if {[lsearch $stuff "AIFF"] == -1 && [lsearch $stuff "WAVE"] == -1
} {return 0}

    set type [lindex $stuff [expr [lsearch $stuff "soundfile,"] - 1]]
    if {$type == ""} {
        set type [lindex $stuff [expr [lsearch $stuff "soundfile"] - 1]]
    }
    set dur  [lindex $stuff [expr [lsearch $stuff "seconds"] - 1]]
    set sr   [string trim [lindex $stuff [expr [lsearch $stuff
"srate"] + 1]] ", "]
    set tr   [string trim [lindex $stuff [expr [lsearch $stuff ${sr},]
+ 1]] ", "]
    set siz  [lindex $stuff [expr [lsearch $stuff ${tr},] + 1]]
    return   "$dur $sr [string tolower $type] $tr $siz"

Basically I need to take $stuff, strip away the escapes and tabs, and
replace the newlines with spaces. I have been trying to do this using
"exec sndinfo $path 2>&1" piped into the following commands:

{perl -ne 'chomp; s/(^\s+|\s+$)//g; print "$_ " if ( $_ ne "" );'
tr -d [:cntrl:]
tr -d /t

but I can only get tr -d /t to work as I want it to. I am hampered as
well by my slow and hamfisted debugging techniques. Obviously it would
be much more elegant if we could do do this job in tcl.

Also does anyone know what I should replace the "string tolower" in
the last line with? The current version of sndinfo now returns "WAV"
rather than "WAVE", but "wave", "wav", is what the functions that call
getSoundFileInfo need.

Before anyone asks the obvious question, the reason I am trying to use
cecilia 2.5 because version 2.0 doesn't work very well, with only
about 40% of its features usable. And the reason I am trying to get
csound5 working with it is because csound 4 segfaults when processing
most of the cecilia orchestras. In any case it is a real pity that
cecilia 2.5 has been available for the last 3 or 4 years, but has only
ever been packaged for the mac. All that I actually had to do to get
it up and running was to replace the contents of
/usr/local/lib/cecilia with its conterparts in Cecilia.app. Scores
that don't require you to load a sound file seem to work fine judging
by the little experience I have had so far.

Robert

- --
Robert Persson
ireneshusband at gmail.com


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHF9bByQ3sfGecJBIRAttzAJ9H7q4cFE8XU10C3LjykZTvvI6HtQCcDhAF
zaMzRH4c6Aw6WJxb2dZFz6M=
=rl0/
-----END PGP SIGNATURE-----




More information about the Linux-audio-user mailing list