by [Theo Verelst] Using the parallel port setup examplified in [applying the parallel port to drive a LED and read a switch from tcl], and a Texas Instruments high quality Volume Control chip [http://focus.ti.com/docs/prod/folders/print/pga2310.html], I made an audio control application where Tcl/Tk can change the volume of a stereo sound source in real time, and with high quality. [http://82.168.209.239/Wiki/HPIM0355b1m.jpg] This electronics project not a beginners project, though for electronicists not very hard, and the interesting part is of course the use of tcl to control the electronics, which makes it possible to in a portable and very flexible and easy to use way make interfaces. The PGA2310 (or 2311) is connected up using the more or less the standard application diagram, where it has two audio inputs and two outputs, a +5V and -5V power supply, with a seperate 5V specified for the digital circuitry, and the 4 control pins Chip Select, Serial Data In, Serial Data clock, and Serial Data Out are connected to a standard parallel port on a PC. The idea is now that tcl Is used to write the right bit string using the serial protocol and the tcl [parallel port] library and driver, to set the audio chip to a certian volume. This script makes a scale appear from Tk, which realtime interactively controls the volume of a stereo sound source using the chip and the parallel port: proc bitno {v i} {return [expr ((1<<$i) & $v) >> $i ] } proc setparvol {{v1 192} {v2 192}} { global pv1 pv2 set pv1 0 ; set pv2 0 lpt_wrdata 0 for {set i 7} {$i >= 0} {incr i -1} {lpt_wrdata [expr ([bitno $v1 $i] << 2) + 0 + 0] ; lpt_wrdata [expr ([bitno $v1 $i] << 2) + 2 + 0] ; set pv1 [expr $pv1+(([lpt_rdstat]>>6)<<$i) ]} for {set i 7} {$i >= 0} {incr i -1} {lpt_wrdata [expr ([bitno $v2 $i] << 2) + 0 + 0] ; lpt_wrdata [expr ([bitno $v2 $i] << 2) + 2 + 0] ; set pv2 [expr $pv2+(([lpt_rdstat]>>6)<<$i) ]} lpt_wrdata 1 return [list $pv1 $pv2] } load E:/Theo/Tcl/LptTcl.dll lpt_wrdata 0 toplevel .vsl scale .vsl.sl pack .vsl.sl -expand y -fill y proc slcom {v} {setparvol $v $v} .vsl.sl conf -from 255 -to 0 -tickinterval 20 -command {slcom} Does it work? Yes, it works nice and smooth, and more than fast enough. The circuit and program could be a but simplified, but this version reads back the previous value from the chip via it's serial out pin, which is reported back from the setparvol procedure as a 2 element list with values from 0 to 255. Zero dB for the chip is 192. [http://82.168.209.239/Wiki/volslid1.jpg] Also, I used [Pcom] with a adapted version of the above, to remotely control volume, over a network. Related subjects: * [LED display driven by the parallel port under tcl control] * The BF533 EZ-LITE DSP board from Analog has high quality audio interfaces, and the IDE uses tcl [http://www.analog.com/UploadedFiles/Product_Highlights/583395620553772119225156ADSPBF533.pdf] * [remote execution using tcl and Pcom] * Because I happened to need it, and maybe to not put off people who arrived at this page for other reasons (googling for volume control...) see also this page: [Windows WAVE volume control using Snack]