With TclCsound, it is possible to transform the popular text editor e-macs into a Csound scripting/performing environment. When in Tcl mode, the editor allows for Tcl expressions to be evaluated by selection and use of a simple escape sequence (Ctrl-C Ctrl-X). This facility allows the integrated editing and performance of Csound and Tcl/Tk code.
In Tcl it is possible to write score and orchestra files that can be saved, compiled and run by the same script, under the e-macs environment. The following example shows a Tcl script that builds a csound instrument and then proceeds to run a csound performance. It creates 10 slightly detuned parallel oscillators, generating sounds similar to those found in Risset's Inharmonique.
load tclcsound.so Tclcsound
# set up some intermediary files
set orcfile "tcl.orc" set scofile "tcl.sco" set orc [open $orcfile w] set sco [open $scofile w]
# This Tcl procedure builds an instrument proc MakeIns { no code } { global orc sco puts $orc "instr $no" puts $orc $code puts $orc "endin" }
# Here is the instrument code append ins "asum init 0 \n" append ins "ifreq = p5 \n" append ins "iamp = p4 \n"
for { set i 0 } { $i < 10 } { incr i } { append ins "a$i oscili iamp, ifreq+ifreq*[expr $i * 0.002], 1\n" }
for { set i 0 } {$i < 10 } { incr i } { if { $i } { append ins " + a$i" } else { append ins "asum = a$i " } }
append ins "\nk1 linen 1, 0.01, p3, 0.1 \n" append ins "out asum*k1"
# build the instrument and a dummy score
MakeIns 1 $ins puts $sco "f0 10" close $orc close $sco
# compile csCompile $orcfile $scofile -odac -d -m0
# set a wavetable csTable 1 0 16384 10 1 .5 .25 .2 .17 .15 .12 .1
# send in a sequence of events and perform it for {set i 0} { $i < 60 } { incr i } { csNote 1 [expr $i * 0.1] .5 \ [expr ($i * 10) + 500] [expr 100 + $i * 10] } csPerform
# it is possible to run it interactively as # well csNote 1 0 10 1000 200 csPlay
The use of such facilities as provided by e-macs can emulate an environment not unlike the one found under the so-called ‘modern synthesis systems', such as SuperCollider (SC). In fact, it is possible to run Csound in a client-server set-up, which is one of the features of SC3. A major advantage is that Csound provides about three or four times the number of unit generators found in that language (as well as providing a lower-level approach to signal processing, in fact these are but a few advantages of Csound).