Sound'n'ngSpice Examples

Various examples - work in progress. see spicesound for syntax and overview.

RC - filter

A simple bandpass filter.

the file rcfilter.cir reads

capacitive bandpass filter

v1 1 0 file /tmp/test.wav snd(0 0 1.0 0 0 1)
r1 1 2 200
c1 2 0 5u
c2 2 3 1u
rload 3 0 1k

.sndparam /tmp/test-filter.wav 48000 wav24 1.0 0.0 1
.sndprint tran v(1) v(3)
.tran 2.08333e-05 5.0 0 2.08333e-05

This processes the first 5 seconds (the 5.0 in the .tran line) of the input file /tmp/test.wav (using the first channel - the last 0 in v1..snd..0 line) writing /tmp/test-filter.wav which is a stereo file. first channel: unprocessed signal v(1) and 2nd channel: processed signal v(3)

decreasing the time-step yields much better results: 1/96000 or 1/48000/4 ..

.tran 1.04166e-05 5.0 0 1.04166e-05
.tran 5.20833e-06 5.0 0 5.20833e-06
.tran 2.08333e-06 5.0 0 2.08333e-06

I've used aliki to generate a frequency sweep from 20Hz to 20kHz: sweep_sin20_20k_5s48k.wav.gz - screenshots were made with rezound: the plotted result files show the original sound in the top and the processed audio in the bottom waveform. the spectrum plot was done with ngSpice iplot.

bandpass filter waveform screenshot bandpass spectrum

removing capacitor c1 yields a high-pass filter which I found useful for testing the frequency response and ngSpice's timing accuracy.

highpass filter waveform screenshot highpass filter waveform zoom-in

Jimi Hendrix Fuzz Face

fuzz face example waveform zoom-in

Audio example

Produced with jimi_fuzz-snd.cir and gits.wav.gz (unzip to /tmp/gits.wav and run ngspince -b jimi_fuzz-snd.cir). processed at 1s/(64*48k).

The output contains the original sound in the left and the fuzz-processed audio in the right channel. Original here is a test-clamp audio output, which includes ngspice resampling: it's not a copy from the source-file data.

Be aware that this example simulates an old fuzz distortion; recorded direct-in without any further processing. Therefore the weird sound is somewhat expected ;) - the circuit still needs fine-tuning: eg. tweak the input voltage range of the guitar and fuzz/volume potentiometers.


foxx.oregano.gz is modeled after:


  • The simulated Diodes and NPNs are not the original, but the default models available with oregano.
  • the gain/sustain pot is modeled in R50/R51 - sum 50k
  • the tone pot is modeled in R60/R61 - sum 50k
  • flip the octave switch, by removing diode D1. w/o Diode = off

Beware: it's not yet debugged…

oss/spicesound/examples.txt · Last modified: 06.06.2007 18:44 by rgareus