loading
Like the sound of those old analog synthesizers? Want to play with one on your own time, at your own place, for as long as you want, for FREE? Here is where your wildest Moog dreams come true. You can become an electronic recording artist or just make some cool, trippy sounds to listen to on your mp3 player. All you need is a computer!

It's all done through the magic of a free circuit simulator called LTSpice. Now I know you're probably saying "Gee willikers, Tyler, I don't know anything about running a circuit simulator- that sounds HARD!". Don't worry, Bunky! It's easy and I'll give you a few templates to start with and modify to make whatever weird noises you want.

Not sure it's worth the effort? Here's a link to a ready to play sound file (it is made from "composition_1.asc" in step 7 of this 'ible) that you can try out. I converted it from .wav to mp3 to reduce the download time. http://www.rehorst.com/mrehorst/instructables/composition_1.mp3
There's some low bass in it the sound so listen with headphones or good speakers.

If you like what you see, vote for me!

Note: I have attached schematic files for LTSpice that you can run on your computer, but for some reason when you try to download them the names and extensions get changed. The contents of the files look OK, so after downloading the files just change the names and extensions and they should work. The correct names and extensions are shown on the icons you click to download.

Step 1: First Things First

LTSpice is a windows program, but don't let that get you down. It runs fine under Wine in linux. I suspect there are no problems running it in VMWare client, VirtualBox, or other virtualization tools under linux, and probabaly on Macs too.

Download a copy of LTSpice for Windows (ugh!) here:
http://www.linear.com/designtools/software/ltspice.jsp

Install it.

What is LTSpice? It is a time-domain circuit simulator that every electronics hobbyist ought to know how to use. I'm not going to provide a detailed tutorial on how it works here, but I will explain a few things you'll need to know as we go along.

One word of warning- it is easily possible to produce frequencies that are too low or too high to hear. If you do that and drive your expensive speakers with a high powered amp you may just blow your speakers/amp to bits. ALWAYS look at the waveforms before you play them back and be careful to limit the volume when you play back a file for the first time just to be safe. It is always a good idea to play the files via cheap headphones at low volume before trying speakers.

Step 2: Input

Input to the simulator is in the form of a schematic diagram. You select components, place them on the schematic, then wire them together. Once your circuit is complete, you tell the simulator how you want it to simulate the circuit and what sort of output you want.

Take a look at the schematic called resistors.asc. You'll see there is a circuit that includes a voltage source, a pair of resistors, a labeled output node, a ground, and a text command line. Let's look at each one. Now is a good time to open the circuit file linked below.

Ground:
This is the MOST CRITICAL component on your schematic. You MUST have a ground connected to at least one point on your circuit or you will get very strange results from your simulations.

The voltage source:
If you are putting a voltage in a circuit, you need to tell it whether it is AC or DC (or something more complex), what the voltage is, the "internal resistance" of the source, etc. You can enter those parameters by right clicking with the pointer on the source. All you really need is the resistance for simple simulations.

Resistors:
The resistors are pretty easy to understand. Just right-click to set value of resistance. Ignore any other parameters that might be hiding there.

Labeled input and output nodes:
Just names for nodes in the circuit that are user friendly.- use names like "output", "input", etc.

The simulation directive:
the .tran statement tells the simulator how you want the circuit to be simulated. This is a time-domain simulator which means it analyzes the circuit at different points in time. You need to tell it what the maximum time step should be and how long the simulation should run in "circuit-time", not real time. If you tell the simulator to run for 10 seconds of circuit-time and you set the maximum time step to 0.001 seconds, it will analyze the circuit at least 10,000 times (10 sec/0.001 sec) then stop.

When the simulation runs, the voltage at every node in the circuit and the currents into and out of every node will be calculated and saved at each time step. All that info will be available to plot on a display like an oscilloscope screen (time of the horizontal axis, voltage or current on the vertical axis. Alternatively, you can also send the output to a .wav audio file that you can play on a computer, burn to a CD, or convert to mp3 to play on your mp3 player. More on that later...

Step 3: Output

Output can be a graphical plot of voltage vs time, voltage vs voltage, etc., or a text file consisting of a bunch of voltages or currents at each time step, or a .wav audio file that we are going to use a lot in this instructable.

Download and open the file "resistors.asc". Click the little running man symbol (upper left part of the screen) and the circuit should run. Now click on the "OUT" label in the circuit. You'll see the voltage labeled "output" displayed on the graphical output along a horizontal axis that represents time. That is the voltage measured relative to ground (that's why you need at least one ground in every circuit!).

Those are the basics. Try changing one of the resistor values or the voltage then rerun the simulation and see what happens to the output voltage. Now you know how to run a circuit simulator. Easy wasn't it?

Step 4: Now Some Sound!

Open the circuit called "dizzy.asc". This one is a weird noise maker that uses a modulator and a couple voltage sources to produce a CD quality (16 bits, 44.1 ksps, 2 channels) audio file that you can play with.

The modulator component is an actually an oscillator. Frequency and amplitude are both adjustable like a VCO and VCA in a real analog synthesizer. The wave form is always sinusoidal, but there are ways to alter it- more on that later.

The frequency limits are set by the mark and space parameters. Mark is the frequency when the FM input voltage is 1V and space is the frequency when the FM input voltage is 0V. The output frequency is a linear function of the FM input voltage, so the frequency will be half way between the mark and space frequencies when the FM input voltage is 0.5V and will be 2x the mark frequency when the FM input voltage is 2V.

The modulator can also be amplitude modulated via the AM input pin. The modulator (oscillator) output amplitude will match the voltage applied to the AM voltage input. If you use a DC source with a voltage of 1, the output amplitude will be 1V (that means it will swing between -1 and +1 V).

The modulator has two outputs- sine and cosine. The waveforms are exactly the same except they are 90 degrees out of phase. This can be fun for stereo audio applications.

There is a .tran statement that tells the simulator the maximum time step and the duration of the simulation. In this case, circuit-time (total simulation time) = audio file time. That means if you run the simulation for 10 seconds you'll get an audio file that is 10 seconds long.

The .save statement is used to minimize the amount of data the simulator will save as it runs the simulation. Normally it saves the voltages at every node and the currents into and out of every component. That can add up to a LOT of data if your circuit gets complicated or you run a long simulation. When you run the simulation, just select one voltage or current from the list in the dialog box and the data file (.raw) will be small, and the simulation will run at maximum speed.

Finally, the .wave statement tells the simulator to create a CD quality stereo audio file (16 bits per sample, 44.1 ksps, two channels) putting the voltage at "OUTL" in the left channel and the voltage at "OUTR" in the right channel. The .wav file consists of 16 bit samples. Full scale output in the .wav file (all 16 bits in a sample turned on) occurs when the voltage being output is exactly +1 Volt or -1 Volt. Your synthesizer circuit should be set up to generate voltages no more than +/- 1V out to each channel, otherwise the output in the .wav file will be "clipped" whenever the voltage exceeds +1 or -1 V.

Since we are making an audio file that is sampled at 44.1 ksps, we need the simulator to simulate the circuit at least 44,100 times per second, so we set the maximum time step to 1/44,100 sec or about 20 microseconds (us).

Step 5: Other Types of Voltage Sources, Other Types of Sounds.

An analog synthesizer needs a source of random noise. You can generate noise using a "behavioral voltage source" (bv) and you can switch it on and off using a "voltage controlled switch" (sw).

Using the bv component to generate noise involves defining the voltage based on a formula. The formula for generating noise looks like this: V=white(time*X)*Y The white function creates a random voltage between -0.5 and +0.5 V using the current time value as a seed. Setting Y to 2 gives a +/- 1V swing. Setting X between 1,000 (1e3) and 100,000 (1e5) affects the spectrum of the noise and changes the sound.

The voltage controlled switch also needs some parameters to be set in a .model statement. You can use multiple voltage controlled switches and multiple model statements to make each one behave differently if you want. You have to tell the simulator the "on" and "off" resistances and the threshold voltage at which it switches. Vh is "hysteresis voltage". Set it to some positive value like 0.4V and there won't be any clicking sounds when the switch opens and closes.

>>>Update: here's an even easier way to make a gated noise source- just multiply the noise voltage by a pulsed source- see easy_gated_noise.asc, below.

Step 6: Bells, Drums, Cymbals, Plucked Strings

Bells, drums, cymbals, and plucked strings are all percussive. They have a relatively fast rise time and an exponential decay time. Those are easy to create using sine and behavioral voltage sources combined with some simple circuits.

Look at the schematic "bell_drum_cymbal_string.asc". The pulsed voltage sources with the resistor, capacitor and diode create the fast rise and slow exponential decay waveforms needed. Those output voltages modulate the outputs of behavioral sources set up as random noise or sine wave sources. When the pulsed source voltage rises it quickly charges the capacitor. The capacitor then discharges through the resistor. The diode keeps the voltage source from discharging the capacitor when the source voltage is at zero. Bigger resistor values increase the discharge time. You can specify the rise time of the pulsed source - the cymbal is a nise source with a very fast rise time. The drum is also a noise source that operates at lower frequency and has a slower rise time. The bell and string use sine wave sources that are modulated by pulsed sources too. The bell operates at higher frequency and has a faster rise time than the string.

Run the simulation and listen to the result. Note that the drum appears in both channels while all the other sounds are either right or left channel. The two resistors at the drum output are responsible for putting the sound into both channels.

Step 7: Putting It All Together

OK, now you've seen how to make some sounds and how to shape the envelopes and frequency modulate them. Now it's time to put a few different sources together in a single schematic and generate something interesting to listen to.

How do you get that noise source to come into the composition at 33 seconds? How do you turn on that chiming bell at 16 seconds, then turn it off, then turn it on again at 42 seconds? One way is to use a behavioral voltage source to make the desired sound then turn it on and off by multiplying the sound generating voltage by another voltage that turns the sound on and off, as was done in bell_drum_cymbal_string.asc. You can do the same sort of thing to fade sounds in and out.

The idea here is to set up repeating sounds then use additional source(s) to add those sounds to your composition at desired times by multiplying their voltages by the sound voltages. You can include as many voltages in the final sound output as you want, just keep multiplying them (same as logical "and") together. By starting the sounds up all at once they will remain in perfect sync throughout the composition so they will never be early or late in the time of the music.

Look at composition_1.asc. There are two bells, one in each channel. The pulse_bell voltages operate throughout the simulation but the sounds only show up in the output when V(bell_r) and V(bell_l) are not equal to 0.

Step 8: Exponential Ramp

Update 7/10- scroll to bottom

Here's a circuit that generates an exponential ramp applied to a pair of noise sources. V1 and V2 generate linear ramps that start at 0 and rise to X volts (left channel) and Y volts (right channel) in periods prd_l and prd_r. B1 and B3 use a formula to convert the linear ramps to exponential ramps with maximum amplitudes of 1V. B2 and B4 generate random noise that is amplitude modulated by the exponential ramps and by parameters amp_l and amp_r (simple level controls).

I have attached an mp3 file generated by this circuit so you can hear what it sounds like. You'll probably have to rename the file to get it to play.

X and Y set the voltage limits of the linear ramps. Eventually both channel's ramps get scaled to 1V, but by setting X and Y you can control the steepness of the exponential ramp. A small number like 1 gives a nearly linear ramp, and a large number like 10 gives a very steep exponential ramp.

The ramp periods are set using parameters prd_l and prd_r. The linear ramp rise time is set to the prd_l or prd_r value minus 5 ms, and the fall time is set to 5 ms. The longish fall-time prevents clicking at the end of each ramp as the amplitude drops back to zero.

out_l and out_r are the products of the time-based random noise voltages, the exponential ramp voltages, and the parameters amp_l and amp_r. Note the right channel random noise value uses a different "seed" than the left channel. That keeps the noise in each channel random and different from the opposite channel. If you use the same seed, at the same time value you'll get the same random value and the sound will end up in the center instead of being perceived as two different sources, one in each channel. This could be an interesting effect to play with...

Update: notice that the waveform goes from 0V to some positive value. It is better for the voltage to swing between equal positive and negative values. I reworked the schematic to do just that but it increased the complexity of the equation that defines the waveform a little. Download the exponential_ramp_noise.asc (remember that the Instructables server will change the name and extension when you save it).







Step 9: Exponential Ramp Applied to a Sine Wave

This page shows how to use the exponential ramp from the previous step to modulate a sine source (actually, sine and cosine). The behavioral voltage source is used to turn a linear ramp into an exponential ramp that drives the FM input on a modulate2 component.

The amplitude is modulated by both a fast exponential ramp and a slow sine wave.

Listen to the sample file- it sounds pretty weird.

Step 10: Suggestions

1) You can vary the total simulation time - keep it short while you're playing with components and when you get the sound you like, then set the simulator to run for 30 minutes (1800 sec) or however long you like. You can copy circuits from one page to another and you can make subcircuits so you can just connect little circuit modules together like using a patch board on a real synthesizer.
2) A CD sample rate is 44.1 ksps. If you keep the maximum time-step down to 20 us you'll get a "clean" output because the simulator will have data available for each new sample. If you use a smaller time-step the simulation will be slow and probably won't have any effect on the sound. If you use a longer time-step you may hear some aliasing that you may or may not like.
3) use the .save dialogbox statement on your schematic and when you run the simulation and select just one of the voltages or currents to keep the size of the.raw file small. If you don't make a selection, ALL the voltages and currents will be saved and the .raw file will get VERY large.
4) try using very low frequencies to modulate higher frequencies
5) try using higher frequencies to modulate lower frequencies.
6) combine outputs from some low frequency sources with some high frequency sources to make things interesting.
7) use a pulsed voltage source to modulate a sine or other source to provide rhythm.
8) use analog circuits to shape voltage pulses into something you want.
9) use mathematical expressions to define the output of a behavioral voltage source

Have fun!
This looks like something I could have fun with. Only trouble is when I run te circuits I get a spice run error "trouble creating output .wave file" any suggestions ?
<p>I have the same issue on a Mac computer. I have tried to remove all spaces in pathname, but it doesn't solve the issue. Any advice?</p>
change it to c:\windows\test.wav
I got the same message when I tried to use a nonexistant directory to store the output file. If you don't have a c:\temp directory, make one and LTSpice won't have a problem creating the file. I wouldn't recommend junking up your windows folder with what may grow to be a very large file. Use a temp directory so you don't have to worry about deleting its contents at a later date when you're cleaning up your computer and can't remember what or why about the file.
if you clog up your computer, you clog up your computer. it doesn't matter where you do it
If you want to put the files in your Windows directory you're welcome to do it, however, the Windows folder is already clogged up with malware called "Windows". Most people don't clean up their machines by deleting files in the Windows folder, but a "temp" folder is a good place to put temporary files because 6 months from now you can just delete them without a thought about what the files are and how they were generated.
Please don't bash Windows, there is malware like Fruit and Animal software already. Rather have something that makes me feel at home.
If you are using my .wave statement unedited, make sure that the c:\temp directory exists before you try to run the simulation. If you have edited the .wave statement to put the output file in your "My Documents" folder you may have a problem because of the blank space between "My" and "Documents". Are you running the program as an administrator on the computer? If not you may need to make sure you are an administrator.
I would think that, for a musician's purposes, exporting the waveform in 24 bit, 96kHz would be more suitable format. Of course, whether real musicians would go to these lengths to generate music is another question :)
You can specify 24/96 if you want, or even higher resolution than that. You'll also have to make the time step in the simulation shorter to ensure that your simulation generates a data point for each 96 kHz sample.<br><br>Musicians probably wouldn't bother, but it can be used to make a high resolution test CD or can be used as a signal source for electronic testing. It can also be used to test the response of a circuit you want to simulate, say a crossover for an audio system, etc.
Hmm, this looks like an interesting approach for very experimental music, but it seems to have a quite high &quot;effort-per-result factor&quot; compared to conventional &quot;synthesizer construction kits&quot; like SynthEdit, SynthMaker etc. So if someone is looking for an easier way to create your own software synthesizers, check those out.
could you post a video of its sounds?<br>ive a old casio im going to build something with im still in the research of the what all to atempt with it , i did manage to get all its components out 150 screws latter i put it back up on the thinking of what to do with it shelf lol
Something that would be awesome is running it in realtime with a MIDI input<br />
Really awesome instructable!&nbsp;I had no idea a program like this existed, very useful.<br />
This is great. thanks! For more advance sound design theory check out point blank <a href="http://www.pointblankus.com/sound-design-course.php" rel="nofollow">online music production school</a> <br />
can you play these through a midi keyboard?
Hey!<br/>My first post for 1 year that i read this fantastic website,<br/>but i must say that your project is just<br/><strong>awesome</strong> ! and for both educational and experimental purpose !<br/><br/>Thank's a lot and BRAVO !<br/>Alexis (from Paris, France)<br/><br/>
Merci beaucoup mon ami!
Way to go Mr Phoenix-DIY. I especially like the idea of synthesing analog circuits to make "digital" music. Its like SteamPunk but for software. Does anyone know of any libraries of analog circuits that could be used.
Figuring out how to get the behavior you want is half the fun. There are a lot of on-line circuit libraries that you can tap for circuits, but most of what you need for synthesis is right there in the special function modules. Horowitz and Hill's "The Art of Electronics" is a very good, educational reference. Those of you on a tight budget can check the usual on-line sources for that one... One thing I haven't figured out how to do (yet) is make a swept frequency filter. I'm working on that and when I figure it out I'll modify this 'ible with the how-to. I think a VCVS type circuit should work, with f0 controlled by a swept voltage source. A swept peaking filter operating on a pulsed source should sound real interesting. Unfortunately there is no way to have anything like a variable resistor that you can turn while the simulation runs. I'll add some more sources and envelopes as I generate them.
Hi Tyler You could use the SW(itch) component. Its resistance can be made variable with voltage. A pair of these can then be applied to any 2 pole active filter ckt. Better yet, you could use the BV or BI sources to create resistances. They can be self referenced. Ie. the BI current can be a function of the voltage across itself. An external control voltage can be multiplied in as well, to make them variable. The imagination is the limit. The problem is digging deep enough!
I think that would work. I'll try to come up with a circuit and add it to this 'ible. You're right- the only limit is the imagination. All these voltage and current sources get hard to keep track of so when I figure out how to make subcircuits I'll make some standard synthesizer modules as subcircuits that can just be dropped into the schematic and wired together. Then just add a few parameters to control them and you're off to the races. I want to figure out a way to make a wide-band width phase shifter that is controlled by a voltage so I can play with some stereo effects. The sin/cos output from the mod2 component is cool but it would be more fun to shift the phase to any value. Keep checking back to this 'ible every few days as I add more sounds/components. TD
Nice ible on doing sound with it. Great job! I hope this inspires more people to learn to use spice. Ive been using LTS for 8 yrz now, and am Totally addicted to it. It is Thee Most verstatile tool Ever! Ive simmed mechanical and acoustic as well as electronic systems with it. You can even use it to lay out perf board projects. But, i havent tried its sound capabilities. Now off to try doing some sound synth! Thanx for your inspiration.
Nice! I just started learning LTSpice before the end of last semester. This is a great I'ble.
Thanks! I have merely scratched at the surface of the sort of fun you can have with LTSpice. Not only can you generate a .wav for output, but you can use a .wav file for input. That means you can "build" audio filter circuits and hear what the filter will do to the sound. You can test crossovers, notches, etc. without having to actually build them.
Can you fix the files? WhenI go to DL they are bad files or something
For some reason the Instructables server changes the names and sometimes extensions of the files. The .mp3 file comes down with an .mp3 extension and it plays, but the schematic files, which are actually text files and can be opened, read and editied (though I don't recommend it) with any text editor, have both file name and extension changed. Just change the extensions to .asc when you save the schematic files to your computer and they should work OK. All the schematics should have a .asc extension. When you installed LTSpice it registered the .asc extension so once you change the extension from .tmp to .asc the file icon should change and if you click on it LTSpice should open and display the schematic.
Wow very very cool

About This Instructable

37,313views

118favorites

License:

Bio: I was electrical engineer for 22+ years, then went back to school for 6 years and became a dentist.
More by Mark Rehorst:Space Laser Manual Go-To For Your Telescope 3D Printer Bed Upgrade/Replacement Use DesignSpark Mechanical to Duplicate and 3D Print a Decorative Finial 
Add instructable to: