3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Analog Sound Synthesis on Your Computer

Step 4Now some sound!

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).

« Previous StepDownload PDFView All StepsNext Step »
2 comments
Feb 3, 2012. 9:11 AMWineSoaked says:
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 :)

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
17
Followers
6
Author:Mark Rehorst(Mark Rehorst's Projects Page)
I was electrical engineer for 22+ years, then went back to school and became a dentist.