Oscillator Experiment Update: Piecewise Sine

After matrixsynth.com picked up “My Sine Oscillator Experiment,” doktor future started a discussion about different ways of emulating analog oscillators in digital. Adam S mentioned that he thought the Plan B sine looked like a piecewise quadratic to him and provided the following function:

y=
-(4/pi^2)[x - (pi/2)]^2+1, x from 0 to pi
(4/pi^2)[x-(3pi/2)]^2-1, x from pi to 2pi

After having checked it out in grapher.app myself, and confirmed it did look similar to the Plan B sine, I implemented this as a wave table in Csound. See piecewise.csd.

Piecewise + Plan B Model 15

In this image, I have superimposed Adam’s recommended piecewise function over the Plan B’s Model 15 sine wave. As you can see, their contours are not quite identical, though very, very similar.

After listening to both waves side-by-side, the harmonic distortion in the piecewise sine example is a tad louder, and the frequencies are just slightly off. At least to my ears. However, I consider it to be a wonderful approximation of the Model 15.

Oh, the Irony

Peter Grenader, the principle designer at Plan B, has this written in his bio:

“In 2001 , Peter returned to analog after a 22 year hiatus because he tired of trying to force digital instruments to behave in like manner.”

I’m finding this whole discussion a bit humorous as the three of us are doing exactly this, trying to force digital instruments to sound like analog. In this case, Mr. Grenader’s analog oscillator.

My Sine Oscillator Experiment

Over the weekend, I recorded/generated four sine waves of different synthesizer modules and compared the results. Each of the four oscillators are tuned to approximately to 440Hz, close enough to get a sense of each wave shape.

This is a very casual observation of contour and contour only, so please do not read too much into my findings. Here are the results:

Csound Digital Oscillator

This first graph shows a digital sine wave generated within the computer music language Csound. This is what I used as my test reference. Being that this is a purely mathematical construct, I figured this would be the perfect wave to compare against its analog counterparts.

Doepfer A-110 Standard VCO

Upon casual observation, you may notice that the sine isn’t the most accurate in the world. In fact, you might go as far to say this isn’t a sine wave at all. One noticable feature of this oscillator is that little glitch you see at 90ยบ. This is consistent among every cycle at the stated frequency. I have two of these modules, and there were no significant differences when compared to each other.

Now it might sound like I’m completely down on this module. The truth is, I’m actually quite happy with this dirtiness of this unit, as it adds character. It is sometimes the imperfections that make something great.

Plan B Model 15

This unit has the smoothest contour of the three analog examples. Though the shape doesn’t adhere completely to the perfectly generated Csound test reference, it certainly gets close. The peak and the dip seem to be a bit rounder, almost as if they are slightly compressed.

Cwejman D-LFO

Now, I must say that it probably isn’t fair that I’m comparing a device designed specifically for low frequencies. With that being said, the contour fared noticeably better than the Doepfer. You might notice that the peak and the dip are both a little on the sharp side. The D-LFO comes with two oscillators, both of which I tested. I found both to be consistent with one another.

All Examples Compared

For fun, I thought it would be nice to superimpose each example over one another so we can better observe how much variation can exist between sine wave oscillators.

Other Variables in the Equation

Since I recorded the three analog signals, there were at least two extra variables that may have introduced distortion to the resulting wave shapes. The first would be the recording device, an Apogee Ensemble with the soft limit feature set to off. The second is the cable. I used the same cable for all the recordings. I always patched directly from the sine wave outputs to the Ensemble input.

I did go the extra step and recorded the Csound sine wave with the Ensemble and cable. I found there were no significant differences, in terms of contour, between the original generated wave and the recorded version.

My Methods

Last, I want to share the methods I used to collect and present the data. I recorded the three analog signals with the Apogee Ensemble, and with the software Peak. I took screen captures of peak, and then processed them in Photoshop. In Photoshop, I removed the dotted zero line, and replaced it with a solid line. I also resized each image so the waves would have matching periods. Though I compressed the width of each waveform, the contours of the waves were not affected.

And like I said, this experiment is just the casual observations of one guy, and completely non-scientific.