SH-101 pwm

DSP, Plug-in and Host development discussion.
andy_FX
KVRist
120 posts since 10 Aug, 2005

Post Tue Feb 26, 2008 10:19 am

In another thread about circuit modeling there was talk as to the texture of analog pwm and oscillators in general. Well I've put a little bit of noise and hum into the phase increment and pwm control signal of my pure digital osc and have come up with some examples. I've also sampled the pulse output of an sh-101 with a hammerfall soundcard as well as captured it's output with an oscilloscope. The pulse was set up a little bit, full level, open filter with no res and max volume.

http://www.vellocet.com/dsp/sh101

The examples with digi vs analog have alternating samples of me manually playing notes. So, how do you think the test went? Can you pick the digital from the analog?

andy_FX
KVRist
120 posts since 10 Aug, 2005

Post Tue Feb 26, 2008 10:23 am

Sorry, the static .wav of the pulse from the sh-101 failed to record properly, but there is a .csv of the waveform you can load into mathematica etc to check out.

andy_FX
KVRist
120 posts since 10 Aug, 2005

Post Tue Feb 26, 2008 12:09 pm

If you zoom into the waveforms you can see one has a non-linear phase bandlimiting filter, and one has a linear phase one, but I'll let you work out which is the analog and which is the digital.

mystran
KVRAF
5246 posts since 12 Feb, 2006 from Helsinki, Finland

Post Tue Feb 26, 2008 12:26 pm

Half the samples seem have 100Hz hum on them. Ignoring the hum for the purpose of comparison, I guess I still like the examples without that hum have more pleasing drift characteristics (the humming one is a bit clean to my taste), though the samples are short enough that it's hard to say how they would possibly behave once run through effects (which I guess is more important than just how a short sample sounds alone). I don't care to guess which one is which.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

boimb
KVRist
176 posts since 5 Sep, 2006

Post Tue Feb 26, 2008 1:03 pm

mystran wrote:Half the samples seem have 100Hz hum on them. Ignoring the hum for the purpose of comparison, I guess I still like the examples without that hum have more pleasing drift characteristics (the humming one is a bit clean to my taste), though the samples are short enough that it's hard to say how they would possibly behave once run through effects (which I guess is more important than just how a short sample sounds alone). I don't care to guess which one is which.
i also hear hum. especially noticeable in the first sample :shrug:

but besides that it sounds identical to me.

don't get the importance though...

nollock
KVRian
1153 posts since 10 Dec, 2003

Post Tue Feb 26, 2008 1:55 pm

On the "pulse" wave file I noticed these things.

Whats sounds like background hum on the first note.

The slight variations in the notes sounded different. On the first notes it sounds smoother, on the 2nd notes it sounded more steppy. Say if the variation was comming from a random lfo with a smoothed output on the first and a random lfo with a stair step output on the second.

On the other sample its imposible to hear any such minute differences imo.

Id assume the former to be the analog versions, but im not that sure.

***edit***

Just stuck em through a spectrum anylizer and i think you can see the difference. If you watch the range 18khz..22khz, you'll see the second notes dance up and and down more eraticly, the first notes more softly. You'll need to use a smaller window size so the effect doesnt get averaged out, i was using 8192. Plus its very obvious on the last note.

***edit*
Last edited by nollock on Tue Feb 26, 2008 2:36 pm, edited 2 times in total.

andy_FX
KVRist
120 posts since 10 Aug, 2005

Post Tue Feb 26, 2008 2:21 pm

mystran wrote:Half the samples seem have 100Hz hum on them. Ignoring the hum for the purpose of comparison, I guess I still like the examples without that hum have more pleasing drift characteristics (the humming one is a bit clean to my taste), though the samples are short enough that it's hard to say how they would possibly behave once run through effects (which I guess is more important than just how a short sample sounds alone). I don't care to guess which one is which.
I'll try to make the hum less noticeable in the recordings and make the notes longer, so you can compare them. I'm just installing a wave editor at home, so I can't actually tell you which is which just yet, but I would hope that your fine ears have picked the analog version as the more pleasing to listen to.

otristan
KVRAF
1938 posts since 28 Mar, 2005

Post Tue Feb 26, 2008 2:35 pm

In the PWM examples, it may sound stupid but I hear some modulation of the tone of the second during the sound. (maybe the crappy HP I use at my place underline this)

So I would say the second one is the analog one.

my 2 cents.

User avatar
aciddose
KVRAF
12165 posts since 7 Dec, 2004

Post Tue Feb 26, 2008 3:09 pm

it will be very difficult for most individuals to guess which is analog or digital since they haven't ever used both systems.

to my ears this seems quite good though. although differences seem to exist between the tones, i cant say that either of any pair of tones definitely belongs to group.a or group.b, forget about identifying either group as 'analog' or 'digital'.

the sh-101 has fairly nasty oscillators compared to other synthesizers. the best sounding oscillators have to be oscillators such as the tb-303, ms-20 which use a SCR for reset. the minimoog is also nice as it uses a reset-to-reference, however it uses the more typical schmitt-trigger to trigger the resets. other oscillators such as the early sh- series use a schmitt-trigger to trigger reset and active-feedback reset, an opamp integrator with a fet connecting output and negative input during reset. finally, the worst sounding analog oscillators in my opinion are the function generators with rounded and very steady tones, such as the CEM3340 used in the sh-101 and mc-202. the then have the oscillators used in the juno and jupiter series which are variations on a hybrid design, these sound even more static. the minblep/blit software oscillator is of course the most static possible.

i'm applying a definition of "most analog = best" here, though. so this order only makes sense if you're trying to do 'analog modeling' or get 'real analog' timbres. generally when people think of 'analog' they're actually thinking of the middle-ground as in the sh-101/mc-202 and other synths based upon CEM or other integrated chips.

all of the oscillators can be roughly modeled however with the simple reset point modulation... it's all just a matter of correctly integrating your modulation sources before applying them. i think you may have a little too much modulation going on here. i'll explain exactly how the reset point is influenced in the analog circuits so you can understand what type of filters must be applied;

the source of our modulation is a combination of brown to pink noise from all components connected to the reference rail and 60/120hz and harmonic sources from our psu rectifier / capacitor compbination. typically even if we use a specifically generated reference voltage for reset, we'll have a significant influence from the supply rails, typically the time-differentiation of v+ and v-.

most regulators have a minimum ripple rejection of -40db, so we should start from this level after generating our brown/pink noise + mains hum. there are typically bypass capacitors across the rails near our oscillator input pins, and typically the trace reactance will be limited in significance to an average resistance of 5ohm. our bypass capacitors are typically 10u and 100n, and ignoring ESR and reactive calculations we can just assume we'll have a r/c filter of 5ohm into 10u.

the value by which we actually modulate our reset point can be taken by differentiation of this signal, or we can use this signal directly as a reset point. typically mains hum will be below the level of brown/pink noise, typically -3db below. these numbers should come out naturally if you accurately calculate coefficients from the power supply components you're attempting to model, however unless you're trying to be dead accurate a fair-guess should be fine.

the only important factors in my opinion are that you correctly scale and filter these signals, this should reduce the hum people are noting in your example clips.

i'm unable though, as i've already pointed out, to successfully assign either tone out of the two tones presented in each pulse/frequency to either a A or B group, so the differences will probably be minor from what you've already implemented.

what you have implemented is being compared to the sh-101 or CEM3340 oscillator in this case however, and that one isnt a good one to model after if you're looking for the best analog timbres. you might want to model a ms-10 or tb-303 oscillator instead - these two are basically the same.

nollock
KVRian
1153 posts since 10 Dec, 2003

Post Tue Feb 26, 2008 3:18 pm

aciddose wrote: the sh-101 has fairly nasty oscillators compared to other synthesizers. the best sounding oscillators have to be oscillators such as the tb-303, ms-20 which use a SCR for reset. the minimoog is also nice as it uses a reset-to-reference, however it uses the more typical schmitt-trigger to trigger the resets. other oscillators such as the early sh- series use a schmitt-trigger to trigger reset and active-feedback reset, an opamp integrator with a fet connecting output and negative input during reset. finally, the worst sounding analog oscillators in my opinion are the function generators with rounded and very steady tones, such as the CEM3340 used in the sh-101 and mc-202. the then have the oscillators used in the juno and jupiter series which are variations on a hybrid design, these sound even more static. the minblep/blit software oscillator is of course the most static possible.
I noted when looking at Andys wavefiles that the waveform peak to peak is offset with PW. This indicates to me that they are both generated by adding two saws, one flipped and out of phase.

I'd always assumed analog PWM was done by feeding a sawtooth into a comparator, < PW = -1, > pw =1. So you get a fixed -1..1 peak to peak whatever the pulsewidth.

How is Square and PWM usualy implemented in analog? Surely adding two saws together would be non cost effective?

User avatar
aciddose
KVRAF
12165 posts since 7 Dec, 2004

Post Tue Feb 26, 2008 3:20 pm

"how is pwm done in analog"

it is generated via ramp -> compare to pw voltage. however, it then generally is eventually passed through a dc blocking filter which might create the illusion of peak amplitude modulation.

i want to add that the effect becomes most pronounced with a very moderate amount of pwm, perhaps from 50% to 55%. the clean software oscillator will sound very dull, while the analog oscillator will sound far more rich in this range. since modulating the reset point only applies very fine frequency and pw modulation per reset, rather than constantly over a whole cycle the output ramp waveform should not be modified at all.

here is a great example:

http://xhip.cjb.net/temp/public/analog_ ... _again.mp3

you can definitely tell which is which here.

SCR reset analog oscillator vs. naive clean xhip oscillator, both square.

edit: in the analog version the comparator has a small input offset, maybe 200mv max (it is discrete, unbalanced) and so the tone isnt perfectly tweaked into a "square" state. i should produce another example where xhip is set to 52% so we can match more closely. even with the analog oscillator tweaked by a multi-turn trimmer, you can still never get only odd harmonics due to the reset point modulation:

http://xhip.cjb.net/temp/public/analog_ ... in_two.mp3

first we have the not-exactly-square, then we have lfo->pwm. it is easy for me to tell in both cases that the analog oscillator is far more rich - although this is a subtle difference it can have a major influence on filtered sounds which accent the "dirty" vs. "not dirty" properties of each even further.

another good example, the artifacts from modulation become fairly apparent in the high registers:

http://xhip.cjb.net/temp/public/high_freq_ramp.wav

mystran
KVRAF
5246 posts since 12 Feb, 2006 from Helsinki, Finland

Post Tue Feb 26, 2008 5:07 pm

andy_FX wrote:[...] but I would hope that your fine ears have picked the analog version as the more pleasing to listen to.
I honestly don't see why it'd matter, as I find both of those quite acceptable, as I can tell from those samples. The thing that mostly annoys me in average digital synth is oscillators being too stable; when you put it through a delay line, the comb-filter picks up couple of frequencies and it sounds awful. Either adding some drift to the oscillators or slightly modulating the delay line will fix that. Both of these seem fine on that front, though no idea if longer samples would pick up some other regularities which would make one of them sound annoying.

I also don't think it's all that hard to come up with acceptably drifting pulse waves. Whatever frequency content one prefers for the drift, since a pulse wave is essentially two states with transitions between 'em controlled by the phase (in the most simple form anyway, no idea how SH-101 happens to do it but guessing offset-saw + comparator), one can just add noise to frequency and/or pulse-width control signals, and it'll translate into a nicely drifting pulse-wave.

I find saws and especially triangles kinda more evil, since the obvious noise-modulation will result in noise in the waveform which especially for triangles makes alternative possibilities more interesting. I honestly can't see why modulated pulses were claimed to have some sort of defining character of analogueness, because ignoring LFO shapes, the comparator that is responsible for shaping a pulse from a saw will also eliminate most of the interesting variations that could be present in the saw. Not to mention all the interesting stuff that could happen in a triangle-shaper.

Yes (and this is not for you andy), if you wanna compare an analog PWM with a naive digital PWM then obviously the analog will sound much better, but then again naive digital sounds naive digital in whatever thing you do. Stack a couple of stable saws in detune, and it tends to sound like a couple of stable saws in detune; do the same with drifty saws (analog or digital), and you need much less of them for that well-known effect. There's a million of other examples. Comparing analog with naive digital in order to prove that non-naive digital stuff can't sound equal or better is damn pointless.

As for other specific characteristics of something like a pulse wave, the type of transitions remains, but I don't see why that can't be easily sampled for a BLEP, and I think it's mostly a matter of taste what kind of spectral content one happens to like. I don't even mind a pure lowpass-BLEP personally, since at the end of the day whatever filter one has will shape it anyway.

For PWM then I guess the LFO (and whatever stuff between the LFO and the VCO) could make a difference. I have to admit I'm still not quite sure which one of the PWM examples I prefer; both seems to have some nice characteristics that the other lacks. But like I said, I can pick whichever I like more, I don't care whichever happens to be analog. :)

As for offsets in peak-to-peak, that's obviously something one gets by applying a magic component called DC-blocker. :P

nollock
KVRian
1153 posts since 10 Dec, 2003

Post Tue Feb 26, 2008 5:15 pm

aciddose wrote:"how is pwm done in analog"

it is generated via ramp -> compare to pw voltage. however, it then generally is eventually passed through a dc blocking filter which might create the illusion of peak amplitude modulation.
Ah that explains it thanks!

Now I'm wondering if I need DC blocking filters for my Blep Square, it's phase ucumulator + comparitor, rather than 2 saws.
i want to add that the effect becomes most pronounced with a very moderate amount of pwm, perhaps from 50% to 55%. the clean software oscillator will sound very dull, while the analog oscillator will sound far more rich in this range. since modulating the reset point only applies very fine frequency and pw modulation per reset, rather than constantly over a whole cycle the output ramp waveform should not be modified at all.
If i have understood everything you've written, i should be able to emulate this effect by adding some noise to the phase acumulator of my Blep square. It is implemented as a acumulator + comparitor, so the niose would only affect the points at which the bleps are dropped in.

I'll have a go and come back with some samples.

User avatar
aciddose
KVRAF
12165 posts since 7 Dec, 2004

Post Tue Feb 26, 2008 5:22 pm

you cant emulate the effect via modulation of frequency, pw, or by adding modulation to an integrator in the oscillator. you must adjust the reset point of the waveform _once_ per cycle based upon the modulation signal which is processed _every sample_. the result is that different frequencies beat against the modulation differently, and the over-all frequency is modulated, yet the ramp shape remains unmodified.

another very important property of analog comparators i have not mentioned here is that they have limited gain, and limited slew. with open-loop gain at full v- to v+, you should be getting both effects.

so, the "attack" will be smooth, as the output is actually just a very high amplitude version of the ramp which is clipped. there will be over-shoot because of limited slewing at the positive clipping point where the ramp transitions to the flat peak. on the "release" or down-slope you'll have an immediate reset from the input, meaning the only effect will be the limited slew of the opamp. you'll then have a non-linear curve heading negative with once again some over-shoot at the most negative point.

the up and down ramps will be shaped very differently, which is in combination with the reset point modulation the cause of a perfectly tweaked "square" having additional even harmonics in an analog oscillator / waveshaper.

a good rule of thumb to remember is that 50uS = 20khz. if the effect you're looking at is less than 50uS, other than potential conversion to an audible frequency signal at a non-linear element further down the chain the effect in question is unlikely to be important.

User avatar
aciddose
KVRAF
12165 posts since 7 Dec, 2004

Post Tue Feb 26, 2008 6:01 pm

discrete emitter output comparator with 2N3904/2N3906, tweaked for high speed:
- 1mhz slew at full scale. (15v/uS)

RC4558 opamp, typical bjt opamp used in analog synthesizers:
- 50khz slew at full scale. (1.2v/uS)

TL072 opamp, typical fet opamp used in analog synthesizers:
- 250khz slew at full scale. (5.5v/uS)

my frequencies here are only guesses, do the math if you want to be exact. actually, you'll need bench testing as these properties change with age of the components and between batches. these slew rates are not open-loop, my experience is that open loop bandwidth of a RC4558 is 25khz, TL072 is 15khz. the RC4558 is fairly linear slew while the TL078 is very non-linear.

over-all, these slewing effects have a minimal audible effect and so emulation should concentrate on the reset of the oscillator, not on the pulse waveshaper / comparator.

Return to “DSP and Plug-in Development”