~~~WTF is a Comparator?~~~
Simply put, a comparator compares two voltages, an input and a reference voltage. If the input is less than the reference, the comparator will output a voltage near one of its supply voltages. Usually this is performed by an operational amplifier, and the inputs can go in the negative or positive inputs. For our uses, you'll want the reference voltage going to the negative input, and you will want to power the opamp with +-5V.
Now, on to synth uses:
~~~Simple Square Oscillator~~~
You've seen me post about this before, but mate, it's useful. A basic Operational Amplifier oscillator is really a type of feedback-driven Schmitt Trigger. Here is the schematic and output (note that the cap is the general frequency range and the 100k resistor can be varied up or down, I usually use a 1M pot):
Now, using the above oscillator, we can derive a few other features using a comparator after an RC lowpass (or highpass, but I'll be using a lowpass) filter. First, filter the output with an RC filter, like this:
The exact resistor value will vary from 10k depending on your frequency range, but make sure you get a generally triangle-like waveform along your whole frequency range. Then, set up a comparator after the filter with a voltage high enough that it only switches near the top of the triangle wave:
And then put another RC filter after that:
As for sine, you can simply put a second, low-cutoff filter and amplifier after the triangle wave stage. It won't be perfect, but it will be similar enough for musical purposes... usually. Bear in mind that certain stages may require amplification, decoupling, or buffering, depending on exactly how you process the signals.
I suppose we should start with a couple definitions. Pulse width (also known as duty cycle) is the ratio of time between when a square wave is high or low. For example, a normal square wave is 50% pulse width because half of the time it is high, half of the time it is low. Pulse width modulation is the use of a modulation source to vary the pulse width dynamically.
Now, when I do PWM stuff, I use saw waves for easier control of the pulse width due to having a longer length of wave (from lowest to highest peaks) to work with. For the following pictorial examples I will be using the saw waveform generated using the above generator. All you do is put a comparator (opamp) after it and vary the reference voltage to the comparator.
~~~Unique square waveforms ~~~
If you decide it would be fun to put a comparator on a wavefolder, such as the Lockhart wavefolder, you're in luck. The following image is not mine, however the basic premise is easily replicated:
~~~Gate signal from Keyboard/Sequencer~~~
It is always useful to have a gate signal from a keyboard or a sequencer. And, I'm sure you've already figured out how to do it, but if you haven't, it's simple: on the keyboard voltage output, put a comparator referencing ground. If you play legato, you will have a constant gate signal, but if you separate your notes (always a useful thing to learn how to do), you will get a separate gate signal for each note. Cool, huh?
Sometimes, you need a noise gate or similar system. This is also pretty easy to do:
Of course, there are more uses than just these. Play around, see what you end up with!