Monday, October 16, 2006

Transient Analysis and Using .wav Files for I/O

OK, this is cool. If you want to see what something would sound like through your circuit, you can create a voltage source that will use a .wav file to determine its value as a function of time, hook it up to the input, and then write a .wav file as output. This post should take you all the way through. I also recently switched from a Linux/Windows dual boot to a Windowless system, so I may touch from time to time on running LTspice in Linux under WINE.

Setting up a wav-controlled voltage source is as simple as right-clicking on the value of the source ('V' by default), and changing it to
wavefile="path\to\inputfile.wav" chan=N
where path\to\inputfile.wav is the path to the file and N is the channel that you want to use, starting from 0. So N would be 0 if you want to use the left channel of a stereo file. In Windows, you can just put the filename or a relative path and LTspice will look in the directory of the top-level schematic. In WINE this doesn't seem to work so well, and you need to put an absolute path.

To create an output .wav file, you'll need the .WAVE SPICE directive. To create a 16-bit file sampled at 44100 samples per second, you would place this:
.wave "path\to\outputfile.wav" 16 44100 NODE
Again, path\to\outputfile.wav is where you want to write the file, overwriting any other file with the same name. NODE is the name of the node that you want to use as the output.

For this simulation you'll want to use the Transient simulation type. This is the mode that simulates and plots your circuit over time. To use it, open the "Simulate" menu and choose "Edit Simulation Command." Select the leftmost tab, called "Transient," and fill in the start and end times. As far as I know, you should be able to leave the step time blank, and LTspice will figure it out.

After running the simulation, you should have an output .wav file that you can listen to in your favorite media player. Enjoy.

8 comments:

David said...

Excellent. Note that the path to the .wav file need not be quoted (unless it contains folder names with spaces), but backslashes (\) are essential; a "could not open wav file" error will result if forward slashes (/) are used.
Thanks Spencer!

Anonymous said...

I will not approve on it. I regard as nice post. Particularly the designation attracted me to review the sound story.

Anonymous said...

Genial fill someone in on and this fill someone in on helped me alot in my college assignement. Thanks you as your information.

Anonymous said...

Well I to but I think the brief should secure more info then it has.

Anonymous said...

Opulently I agree but I about the list inform should prepare more info then it has.

Anonymous said...

[B]NZBsRus.com[/B]
Skip Slow Downloads With NZB Downloads You Can Easily Search Movies, Games, MP3 Singles, Software & Download Them @ Blazing Speeds

[URL=http://www.nzbsrus.com][B]Newsgroup[/B][/URL]

Anonymous said...

Nice brief and this post helped me alot in my college assignement. Thanks you as your information.

Anonymous said...

Keep up the good work. general health Read a useful article about tramadol tramadol