square to sine wave converter

Started by 11-90-an, July 01, 2020, 12:41:21 PM

Previous topic - Next topic

R.G.

Quote from: mozz on July 23, 2020, 06:01:51 PM
You could probably make a square to sine convertor for guitar that would clean up 1 frequency yet leave the harmonics there. How wide a bandwidth for that 1 freq i don't know.
Mr. Fourier says that for a fundamental, the next nearest harmonic is two times that frequency. So if you're getting fundamental and harmonics from a string, having a reasonable rolloff at 2F is a good bandwidth. That's one octave wide.

We commonly play guitar with (musicology speaking) third interval, which is (um... IIRC) 4/3 the fundamental of the lowest string, so excluding a second string at 4/3 the fundamental means we need to exclude a frequency at 1.3333 times the fundamental.

The filters would need (pulling this out of the air, here) to be 20db down at 1.3 times the fundamental to exclude a second string played at the same time. Extrapolating from that, you'd need at least 1/3 octave filters for single-string stuff, and narrower than 1/3 octave for allowing lowest-frequency extraction from two or more strings.

Er - I think.   :) 
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.

StephenGiles

What about the front end of the EH rack guitar synthesiser, that will convert any input to sine wave, only problem is availability of CA3094!! However, it may be possible to use LM13700 in the adaptive filter with associated component changes, although much easier to track down 3094s.
"I want my meat burned, like St Joan. Bring me pickles and vicious mustards to pierce the tongue like Cardigan's Lancers.".

anotherjim

Quote from: ElectricDruid on July 23, 2020, 06:48:06 PM
Quote from: anotherjim on July 23, 2020, 04:46:39 PM
Following a link elsewhere led to this...
https://worldradiohistory.com/UK/Elektor/80s/Elektor-301Circuits-79-179.pdf
Circuit 101 on p19 of the pdf.

Yep, basic integrator. Same problem - amplitude goes down as frequency goes up.
I guess the title of circuit #101 (it is the 101st circuit, not using 101 as a beginner class metaphor!) is misleading - it is claiming constant amplitude output of a sawtooth from a square input of variable frequency.


ElectricDruid

Quote from: anotherjim on July 24, 2020, 03:47:31 AM
Quote from: ElectricDruid on July 23, 2020, 06:48:06 PM
Quote from: anotherjim on July 23, 2020, 04:46:39 PM
Following a link elsewhere led to this...
https://worldradiohistory.com/UK/Elektor/80s/Elektor-301Circuits-79-179.pdf
Circuit 101 on p19 of the pdf.

Yep, basic integrator. Same problem - amplitude goes down as frequency goes up.
I guess the title of circuit #101 (it is the 101st circuit, not using 101 as a beginner class metaphor!) is misleading - it is claiming constant amplitude output of a sawtooth from a square input of variable frequency.

Sorry, I was too hasty and didn't read all the way through. Yes, it has the same fundamental problem, but those circuits have compensated it. That's clever, and if it works as well as they say it does, it'd be pretty impressive.

We're still a good way from a sine wave though. Our poor guitar signal needs turning into a pure square wave (comparator fuzz style, and ideally with 50% duty cycle) then feeding into this circuit, then the output from this need rectifying to make a triangle wave, and then that triangle wave needs wave shaping using a OTA overdrive or similar to make an approximated sine wave. Phew!
Well, I guess it *might* work, but to me that seems like a lot of steps where something can go wrong.


Ben Lyman

Last spring semester, we studied this via zoom class. No access to the school lab, this worked in Multisim. It starts with a sq wave oscillator, converts to triangle, then to sine. I've been tempted to try it out in real life but haven't had the chance yet. The assignment was called "Triangle Wave" but the added 3rd opamp was for extra credit.

"I like distortion and I like delay. There... I said it!"
                                                                          -S. Vai

PRR

#25
Quote>> ..  it is claiming constant amplitude output of a sawtooth from a square input of variable frequency.
> .. those circuits have compensated it. That's clever, and if it works as well as they say it does...

There is a dynamic response waveform at the end which suggests it will always bobble.

Converting arbitrary waves to sines is trivial in un-real time. Listen, tune your MOOG or HP200AB knob. You can contrive a digital demon to do this, off-line. The problem is doing it "live" without sea-sick pitch.
  • SUPPORTER

StephenGiles

The other alternative is the front end of the EH Deluxe Octave Multiplexer, almost identical to that of the Guitar Synth.
"I want my meat burned, like St Joan. Bring me pickles and vicious mustards to pierce the tongue like Cardigan's Lancers.".

Rob Strand

QuoteLast spring semester, we studied this via zoom class. No access to the school lab, this worked in Multisim. It starts with a sq wave oscillator, converts to triangle, then to sine. I've been tempted to try it out in real life but haven't had the chance yet. The assignment was called "Triangle Wave" but the added 3rd opamp was for extra credit.
The idea is,

        triangle  --->  integrator ---> Parabolic (second-order)  which approximates sine.

The integrators are leaky so they end-up being low-pass filters.

The next line of thinking is square-wave --> high-order low-pass filter to remove the harmonics.

They end-up being frequency dependent, so that goes back to the tracking filters.

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

Digital Larry

Quote from: R.G. on July 02, 2020, 01:34:27 AM
Yeah, if you get to choose your starting point, picka sine and make the square follow it.
DDS makes this all academic.
Your dentist did it for you?  And people say they only collect expensive guitars!   ;)

Quote from: ElectricDruid on July 02, 2020, 05:42:25 AM
I do think it's funny that getting from a square to a sine should be so hard, when getting from a sine to a square is so easy.
It's actually reassuring to me, lest the universe collapse or something.   :icon_biggrin:

My useless suggestion was going to be to generate square from sine, add them, then subtract the square with another couple of op-amps and viola yes I said viola, you have sine!  Sorry you caught  me with insomnia, waiting for the melatonin to kick in.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

amptramp

Suppose you have a square wave input and you are trying to generate a sine wave.  The waveform goes up to a fixed value and stays there until it goes down again and one alternation of the sine wave (i.e. half of it) is complete.  One method would be to set a digital counter to determine the duration of its stay at the high fixed value.  Then it could fill in and read from a sine ROM so it could generate an output, using values from the ROM spaced at a sample frequency, so if the sample frequency is four times the sample period, you get four samples in the time the input stays at one level and you can calculate or read from another ROM the sine ROM angles from that.  But one thing you can't get rid of is the latency between the input and output because until the signal input drops down from the fixed value, you don't know the duration of the waveform and the output would have to be delayed until the frequency becomes unambiguous.

The problem is the latency would get longer at lower frequencies and no one has mentioned the real time aspects of this - it a sine wave coming out a half cycle later , the latency will vary with frequency, getting longer at lower frequencies.  It is not a fixed latency as you would get from a pure delay.

Analog methods have the same problem - bandwidth replaces sample frequency and signals coming out of filters are effectively delayed even if there is nothing comparable to the clock in a digital system.  Lower frequency filters generate an output with more delay than higher frequency filters.

StephenGiles

Having played extensively with the EH Rack Guitar Synth I build in early 1980s, I promise you that its front end - totally analog of course, gives a perfect sinewave from any input .
"I want my meat burned, like St Joan. Bring me pickles and vicious mustards to pierce the tongue like Cardigan's Lancers.".