Interesting Waveform Relationship

Started by JKowalski, April 16, 2009, 12:04:56 AM

Previous topic - Next topic

JKowalski

Just an interesting find while messing with waveform interactions: Mathematically, if you multiply a perfect triangle wave with it's 90 degree phase shifted twin, you get a perfect sine wave, at a diminished amplitude and twice the frequency. There are analog multipliers out there... Maybe this has uses?

Stable sine wave LFO? Sine wave octaver?

Just throwing it out there.

Here's a visual, on an online graphing program. The triangle wave was approximated with the function     abs(sin(x))-abs(cos(x))    , which is a decent approximation. I believe that non ideal replacement for a true triangle wave causes the slight difference between the triangle created sine wave (blue) and the standard (yellow)


MoltenVoltage

That's cool, good work.

It looks like the sine wave amplitude is 1/3 of the triangle wave, is that always (or ever) the case?

Any chance of getting a link to the graphing program?   :icon_biggrin:
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

Projectile

That is very interesting. I might be able to use that to do some interesting DSP effects. Thanks.

alanlan

Interesting although you don't get a perfect sine by multiplying triangle waves - just something which looks similar - would be OK for modulation effects and so on but not if you required a perfect sine.

frequencycentral

This looks fascinating, though the math is totally over my head! I'm sure someone will put it to good use. Good work!
http://www.frequencycentral.co.uk/

Questo è il fiore del partigiano morto per la libertà!

JKowalski

#5
Quote from: alanlan on April 16, 2009, 08:14:35 AM
Interesting although you don't get a perfect sine by multiplying triangle waves - just something which looks similar - would be OK for modulation effects and so on but not if you required a perfect sine.

Well, as I said, you might be able to get a perfect sine wave if you used perfect triangle waves - I did not know how to create a perfect triangle wave function mathematically, so I had to use an approximation. If you look at the graph, you can see the triangle waves are slightly curved at the ends.


Quote from: MoltenVoltage on April 16, 2009, 01:38:48 AM
That's cool, good work.

It looks like the sine wave amplitude is 1/3 of the triangle wave, is that always (or ever) the case?

Any chance of getting a link to the graphing program?   :icon_biggrin:

http://www.walterzorn.com/grapher/grapher_e.htm

Used a TI-83 for the original finding, and then graphed it here so I could give you guys a visual.

Yes - it seems to be closer to 3/10 then to a true 1/3, however.

MohiZ

#6
2((-1)^(round(x)))*x-2((-1)^(round(x)))*(round(x));
2((-1)^(round(x+0.5)))*(x+0.5)-2((-1)^(round(x+0.5)))*(round(x+0.5));
(2((-1)^(round(x+0.5)))*(x+0.5)-2((-1)^(round(x+0.5)))*(round(x+0.5)))*(2((-1)^(round(x)))*x-2((-1)^(round(x)))*(round(x)));
0.25(sin(2*PI*x));

(for use with the online plotter above)

This creates perfect triangle wave for sure, but takes a million hours to compute. It still doesn't look like a _perfect_ sine wave, though, but a pretty good approximation. The amplitude of the sine wave seems to be exactly a quarter of the triangle wave's amplitude.

MoltenVoltage

I think this is it:



In this example, the sine wave is approximately 39.25% of the triangle wave amplitude

(Pi/4)^2 = .61685 (sine wave height)
Pi/2 = 1.5708 (triangle wave height)

.61685/1.5708 = .3927 (ratio)

Not sure if this ratio holds constant, but I don't see why it wouldn't.
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

JKowalski

#8
Thanks for the triangle wave functions, guys.

I just wanted to upload a visual of the perfect triangle wave created sine wave versus the real thing. I used molten voltage's triangle wave, being the easier to enter in.

It looks like our synthesized wave (red) is a little flatter, we have a more curved and lengthy peak then the real sine. All in all, a pretty damn good approximation, but definitely not perfect.


MoltenVoltage

Quote from: JKowalski on April 16, 2009, 06:13:44 PM
Thanks for the triangle wave functions, guys.

I just wanted to upload a visual of the perfect triangle wave created sine wave versus the real thing. I used molten voltage's triangle wave, being the easier to enter in.

It looks like our synthesized wave (red) is a little flatter, we have a more curved and lengthy peak then the real sine. All in all, a pretty damn good approximation, but definitely not perfect.



We're all assuming the tables in the function generator are accurate.

Anyway, I defy anybody to hear the difference in their phaser.

Thanks again for the link and the thread!
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

cpm

well, the product of two linear (x) function is a quadratic (x^2) thus a parabolic curve

it is a rough approximation. Look at the taylor series for a sine which is composed of x, x^3, x^5... components

MikeH

Quote from: MoltenVoltage on April 16, 2009, 08:15:54 PM

Anyway, I defy anybody to hear the difference in their phaser.


Totally- The faux-sine is a little flatter and would have a less 'sharp' turn around in the phase, but that actually might sound better.  If you can even tell the difference, that is.
"Sounds like a Fab Metal to me." -DougH

earthtonesaudio

So all you'd need is a triangle oscillator with quadrature outputs.  Anyone have a link to one?

cpm

what about the sum of both triagle waves?
would that be far more simple, and still useful for a not-triangle-not-square waveform?

Ripthorn

That's right, parabolic.  I was thinking convolution (which I think is gaussian, been a while), not multiplication.  The sum of two triangle waves could be interesting, though I can't visualize it right now.
Exact science is not an exact science - Nikola Tesla in The Prestige
https://scientificguitarist.wixsite.com/home

nelson

My project site
Winner of Mar 2009 FX-X

MoltenVoltage

Summing won't make sine waves.

I found this info:





Looks like with a quad op amp and a few parts you can build a voltage multiplier, which might do the trick.

I haven't tried it though.
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

JKowalski

#17
Quote from: cpm on April 17, 2009, 11:50:36 AM
what about the sum of both triagle waves?
would that be far more simple, and still useful for a not-triangle-not-square waveform?

You can do it in your head, if you think about it. It would be a square wave, with a really long transition time. Like \_/  \_/. Trapezoidal waveform, I guess.

If you divide the two functions, you get a tangent waveform. If you subtract, you get the same trapezoidal waveform as addition, except with a 90* change in phase.

Go ahead and try this stuff out if you want to, here is Molten Voltage's traingle waves in a copy-and-paste form:

(acos(sin(x))-(PI/2));
(acos(sin(x+(PI/2)))-(PI/2));
(acos(sin(x))-(PI/2))*(acos(sin(x+(PI/2)))-(PI/2));

Just change the bold multiplication sign to whatever operation you want to try.

And use this program to do it:

http://www.walterzorn.com/grapher/grapher_e.htm





Quote from: MoltenVoltage on April 17, 2009, 02:02:14 PM
Summing won't make sine waves.

I found this info:

Looks like with a quad op amp and a few parts you can build a voltage multiplier, which might do the trick.

I haven't tried it though.

Thanks for the info. There are some single chip analog voltage multipliers out there, am I correct? I'll have to scrounge around to find a cheap supply of some. But this is a good "fallback" idea.

Whats the last unnamed block in the last diagram supposed to represent? The antilog converter?




Quote from: nelson on April 17, 2009, 12:23:20 PM
Quote from: earthtonesaudio on April 17, 2009, 11:41:39 AM
So all you'd need is a triangle oscillator with quadrature outputs.  Anyone have a link to one?
http://mypeoplepc.com/members/scottnoanh/birthofasynth/id29.html

Thanks for the link - it's a little complicated, though. Perhaps we an find a minimal parts two phase only generator? Or design one.

R O Tiree

OT, perhaps, but I had a bit of an epiphany today... It's another interesting waveform relationship, to do with how a typical distortion gain stage clips:

That log amp that MV posted ^^^^ ... I decided to simulate it, because all the other references I found on logarithmic amps had the diode the other way around:



Which gave me this plot:



Just for completeness' sake I turned the diode round, as in MV's post, and started fiddling with input voltages and realised that, if I put a negative voltage in, I got the same logarithmic behaviour:



You can't plot negative log axes in Excel (duh... of course not) but, if it were possible, you'd see a straight line going through the origin (imagine copying that graph and rotating the copy 180 about the origin). So far so good.

Then I thought, "Hang on... what happens if I put both those diodes in there and ramp the voltage up from -2V to +2V?" and, lo and behold, I got the same values as before, giving a line straight line through the origin. So, opamps are, it seems, capable of some whacky "minus" logarithmic behaviour...

Then I though, "Hang on... I've seen that kind of thing thousands of times in schematics of distortion pedals. I wonder what would happen if I put a feedback resistor in there, like in a TS-808 gain stage?" I fed it DC voltages and this is the result:



OK, the dark blue line is the pure log amp line. The light blue is gain (A) of A=100, yellow is A=10 and purple is A=1.  What go we get from this? Well, the purple line (A=1) is pretty much linear (see bottom graph) up to about a Vin of 200mV, then it accelerates towards the log line (see top graph). I think that this is where the diode is getting enough voltage to start to switch on? Remember, although we typically say that a forward-biased silicon diode has a voltage drop of about 0.7V, it actually starts to pass a miniscule current at a much lower voltage, only fully switching on when the voltage gets above 0.7 or so. Looking now at the yellow line (A=10), it is linear over quite a small range (up to about 10mV, perhaps?) and then rapidly deviates towards the log line. The light blue line (A=100) pretty much tracks the pure log line.

So, I fed it an AC voltage and this is what I found:



The first 2 cycles are at a gain of 1, the next 2 are at a gain of 10 and the last 2 are at a gain of 100. The source is 140mV RMS, giving +/- 200mV P-P, roughly what you might expect from a single-coil pickup, just after hitting the strings.

OK, so I fed it a humbucker-strength signal, roughly +/- 1V P-P, cycles as before, 2 cycles @ A=1, 2 @ A=10, 2 @ A=100:



Here's what happens when you turn your volume knob down "to clean it up", as they say...



This was with a +/- 20mV P-P input signal.

So, this is why we get this smooth clipping in things like TS-808s... the gain stage is actually a tweaked logarithmic amplifier.

Compare and contrast, if you will, with a much-simplified gain stage from a ProCo RAT, where the diodes are clipping to ground:



...which is why this circuit gives much harsher distortion - all those sharp edges and odd-order harmonics. Note also, the hard limit at around +/- 0.7V.

Apologies to everyone who already knew this stuff, and apologies to everyone who didn't, but got bored half-way through. :icon_lol:
...you fritter and waste the hours in an off-hand way...

R O Tiree

Finally, what's the betting some boutique-copycat reads this and starts saying things like "ultra-accurate logarithmic amplifier stages give a smooth tone like you never heard before" on the blurb for his TS-808 clone?
...you fritter and waste the hours in an off-hand way...