"micrOSC" - simple guitar-to-square/triangle/sine wave shaper

Started by Taylor, March 04, 2011, 09:35:50 PM

Previous topic - Next topic

Taylor

Here's another quick and dirty idea. Often people want to make their guitar sound like a sine wave. That's really difficult to do really well. But it's not too difficult to do a decent approximation. This circuit is nothing revolutionary or especially original, just a series of building blocks.

We start by turning the guitar signal into a square wave using the first opamp in open loop mode. The transistor front end is there to gate the input when you stop playing, so you don't amplify noise. This whole section comes from Tim Escobedo's square wave shaper. The trimpot on the emitter (forgot to label it - 22k) needs to be set to gate on and off when you play.

Now that we have a square wave, we send that into an integrator, which turns the square wave into a triangle. The major caveat with this technique is that higher notes will inherently be lower in volume than lower notes.

The triangle is then sent into something pretty common in stompboxes: an opamp with diodes in the negative feedback loop. We tend to think of this arrangement as creating more harmonics, but with a triangle input it actually rounds of the pointy peaks of the wave and creates a pretty decent sine wave approximation within a certain frequency range. What we normally call the drive pot in a tube screamer is the sine wave shape trimmer. Might be a good idea to make it external to tune to different ranges.

Keep in mind that this is a very simple circuit compared to real pitch-tracking sine wave generators, so you can't expect too much out of it. The frequency content and volume will be different in different note ranges. You can tune it to work pretty well within a certain range, but then playing outside that range will result in lower volume or more harmonics. Still, with some tuning, it's in the ballpark with not too many parts.




Earthscum

I was thinking about trying  filtering starting at 33hZ (bass low end) and using a F-V circuit to vary the gain to help keep levels the same across the entire range in a triangle wave converter circuit. I wonder if you could apply that to this? Should be able to do it with a transistor, an few resistors, and a fet. Shouldn't be a significant increase in parts count for the possibility of it's function.
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

Taylor

Sounds interesting; I'm not aware of such a simple f-to-v circuit, do you have a link?

Earthscum

I was looking at something like what the Shocktave uses.

Basically, just use the square wave output to make a pulse. Smooth that out for a DC voltage. The closer the pulses (i.e. higher the pitch), the higher the voltage. When the pitch is lower, the voltage goes lower because you are sending the same pulse widths out farther apart.

llllllll = higher freq., higher voltage.
l   l   l   l   = lower freq., lower voltage

(just to illustrate for others how F-V conversion works)

Then you could use that voltage to control a fet to ground in the feedback.
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

R.G.

I think the first time I tried the square-tri-sine thing to make sine waves from a guitar must have been in the mid 70s. This square-tri-sine cascade is the textbook way to make analog waveform generators with opamps. Well, in a waveform generator, the square drives the triangle integrator, and that's fed back to drive the square wave, with the integration time being the speed control The sine is always done as a shaper on the triangle, which has the advantage of being constant amplitude where the square generator is a comparator with hysteresis. The constant triangle amplitude is a big deal in keeping the sine looking like a sine.

You've summed up the issues for applying this to guitar pretty well. The persistent problems are:
- getting a clean enough signal to make squares isn't always that easy; guitar nearly always gives you oddities that are not square, in that they have sometimes more than one zero crossing per cycle, and then sometimes not
- non-50% duty cycles mean the triangle is not really triangular, but integrates around with peaks on it depending on the squareness or not of the input
- sine shaping is not below a few percent distortion unless the amplitude of the triangle input to it is not only stable, but within very tight limits of amplitude all the time
- using a comparator at the front means that any noise on the input gets transformed into full-output noise pulses on the comparator input. So you need to be very careful about noise, and try to figure out how to keep the comparator and any preamps from letting the output do odd things when the comparator flips state at random on noise. Some kind of input thresholding and comparator hysteresis helps a lot. Or did for me.

I also tried compressing the $#@&^*#( out of the input to make it constant-ish level for clean squaring, then compressing the triangle to a constant-ish level to improve sine shaping. It got complicated and added noise issues.

That's not to imply that it can't sound good. Some of them I tried sounded OK, but I was chasing sines at the time, and never could get it to be usable for those purposes. You're dead right - it works with a well defined input signal, within a certain frequency range. I did all my work on this one on paper and in protos. The personal computer didn't happen until about a decade later, and even then circuit simulators that were useful for this kind of thing were another decade. (Yeah, yeah, R.G.; I bet you had to walk barefoot in the snow to school, up hill both ways... moan, whine. :icon_lol: )

The failure of this approach after lots of attempts is what led me down the path of filtering, flip-flop division for true squareness, then PLL multiplication and sine synthesis. That works, is wide band, and is only dependent on the input being square-able over the band and most of the time, as the PLL wipes out the little variations. After that, you only need to re-impose the envelope onto the output sine, which comes out at a constant level. The imposed envelope also serves the useful purpose of gating the thing off when there is no input and you don't want ugly grak coming out between notes. But this approach gets complicated too.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

MoltenVoltage

Maybe this isn't quite what you are looking for, but why not take a Blue Box type circuit and use the square wave output from that?  There's a one-octave down mod that's achieved by connecting the pins of the flip flop. 

http://www.tonepad.com/project.asp?id=33#

Good luck, it sounds like a fun project!
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

R.G.

Yep, something like that is what I was referring to for filtering, clipping, and then octave dividing before the PLL up-verter.

There has to be at least one divider to get to 50-50 duty cycle before the up-verting can do you much good. Otherwise jitter gets huge.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Earthscum

Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum