txt2snd

txt2snd is a small tool that allows to convert ngspice (wikipedia: SPICE) output into audio files - it's yet rather simple but has a built-in help. it's the predecessor and branch of the code now included in spicesound. As an external tool it's more flexible but much slower.

get the source: txt2snd-0.1.1.tar.gz

txt2snd reads 4 tabulator separated values per line in the format:

<idx/int> <time|ms/float> <ignored/float> <value/float>

example:

11      8.916652e-05    1.846313e-02    -7.477363e-01

this format can easily be generated by SPICE. in the following example 20 seconds of net 5 are printed at 48kSPS:

.print tran  v(4) v(5)
.tran 2.08333e-05 20.0 0 2.08333e-05
.op

Note: Rounding (spice-milliseconds to audio-sample) is buggy and txt2snd includes an only sometimes working workaround (use –verbose to investigate skipped/missing frames).

the following script might come in handy..

#!/bin/sh
INFILE=example.netlist
OUTFILE=/tmp/spice.txt
WAVFILE=/tmp/spice.wav
echo "# writing data to $OUTFILE"
ngspice -b $INFILE | awk 'BEGIN{go=0;} /^-------------------------------------/{go=1;} /^[0-9]/{if (go==1) print $0;}' > $OUTFILE
echo "# txt to snd"
cat $OUTFILE | txt2snd $WAVFILE
echo "# done."
 
oss/spicesound/txt2snd.txt · Last modified: 31.05.2007 19:29 by rgareus