• ### Emulating an antialiased Osc ( \[Phasor~\] )

We might have different definitions of aliasing, so we maybe mean the same.. I think of aliasing as being everything that doesn't belong to the original, intended spectrum. I hope I got you right, you mean everything that is related to folding over and distinguish it from waveshaping-effects?! Since you said:

Pushing a sine wave toward Nyquist doesn't make it less of a sine wave. It doesn't alias.

So just compare analog vs. digital and name the errors that occur:
quantized, steppy time: foldover at f_sr
steppy values (raw voltage at the output): kind of square-waveshaper..

It's not aliasing around the artificial sampling rate set by [samphold~]. The distortion extends up to the global sampling rate's Nyquist frequency and aliases there.

...NOnono.
I doupt that's the reason. This works at any samplerate, sothat the real one is negligible (if you don't want to make things more complicated). And the sin does what it would do in "realtime" as well.
E.g. Set the "new" sr to 5512.5 Hz (sr/8) and set the tablesize of your spectrum to 64.
Now watch the spectrum as the sine-freq goes beyond f_ny (=2756.25Hz): It comes back folded over!! Just like in realtime.. (beyond f_sr the whole procedure restarts...)

...the only thing that's different now is that "WE ARE DOGS" now (idk how frogs tend hear...), so we can hear past f_ny (..and see if you put the spectrums tablesize back to 512...)!
And what we see and hear is that the normal waveform get shaped more and more to a square when reaching f_ny! Or: the sqr-shape depends on f_ny -> the higher f_ny (rel. to f_osc), the less sqr-shape.
-So we have a sqare at f_ny. Itself has odd harmonics. So in the end we have sines at 1, 3, 5,... times f_ny!
Now as we sweep a sine up: from 0Hz to f_ny -> just sine;; from f_ny to f_sr (=2*f_ny! -> even!!) -> folded over (inverse) sine;; from f_sr to 3*f_ny (=odd ->"from sqr") -> "normal" sine again, and so on..
(Seen from time-domain: there is nothing past f_sr. Every oscillation past f_sr is just an osc "past 0Hz", thats due to the nature of a periodic signal..)

...Anyways, all those bandlimit- and "sinc"-approaches have one disadvantage, and that is the "ripple" of the last partial.
If I waveshape those these ripples can produce more undesired sounds than an aliasing-saw...
..So better no bandlimiting but the "upsample-filter"-method-> still aliasing but rather inaudible...

It seems in discrete time (and spectrum) in general one has to decide whether to keep harmonics OR the waveform as natural as possible.
Since I want both, I'll have to live with approximations...

• @Flipp said:

We might have different definitions of aliasing, so we maybe mean the same.. I think of aliasing as being everything that doesn't belong to the original, intended spectrum. I hope I got you right, you mean everything that is related to folding over and distinguish it from waveshaping-effects?!

Perhaps we are talking about two different things. However, it useful to use the correct definitions, as you can avoid long, perhaps unnecessary, discussion.

Aliasing is when frequencies outside of the bandwidth of a digital signal (i.e. 0Hz to Nyquist) foldover. After reading this post, it looks like what you're referring to would fall under the general umbrella of "distortion" or non-linear processing. I'm not sure if waveshaping is the right term, though.

...NOnono.
I doupt that's the reason. This works at any samplerate, sothat the real one is negligible (if you don't want to make things more complicated). And the sin does what it would do in "realtime" as well.

Yesyesyes.
The new frequencies that spring up due to the sine wave becoming "squarer" extend up to the global samplerate in Pd and alias there, so it's not really negligible (it never is). I don't know what you mean be "realtime" in this instance. This is all realtime.

As far as your example, that illustrates exactly what I'm talking about (though I don't know why you use a spectrum size of 64). Yes, the sinewave ITSELF aliases at 2756.25 Hz, but those new frequencies caused by the distortion don't. They alias at the global sample rate. So in a dac when the signal is converted to analog (which is only when this would happen), the new frequencies generated are above the sample rate and are then filtered out. No aliasing.

Take a look at the attached patch. The notes should hopefully clarify what I mean about the distortion.

from f_ny to f_sr (=2*f_ny! -> even!!)

This is really just an illusion. Those even "harmonics" are odd harmonics aliasing above the global sample rate (so, it isn't so negligible).

(Seen from time-domain: there is nothing past f_sr.

This is not something you can see from the time domain.

Every oscillation past f_sr is just an osc "past 0Hz", thats due to the nature of a periodic signal..)

If you really want to get technical, in discrete time everything between 0 Hz and SR is the SAME THING as everything between SR and SR*2, and SR*2 and SR*3, and so on. A discrete-time signal can't determine the distance, so the spectrum becomes infinitely periodic. But since it is periodic, it is easier to think of it as being finite between 0 Hz and SR, as everything you change in that range will change the rest of it (in some applications, like upsampling, you can't ignore it). It is not the nature of a periodic signal time-domain signal, however. It's the nature of discrete time.

...Anyways, all those bandlimit- and "sinc"-approaches have one disadvantage, and that is the "ripple" of the last partial.

What do you mean by this? Are you talking about the last partially suddenly dropping out when it hits Nyquist? I solved this by simply cross-fading between two oscillators--one with one more partial than the other--as the frequency approached Nyquist. It seems to work fine.

It seems in discrete time (and spectrum) in general one has to decide whether to keep harmonics OR the waveform as natural as possible.
Since I want both, I'll have to live with approximations...

It just depends on the application. If you are trying to make a bandlimited oscillator, then who cares if the saw looks like a perfect saw in an oscilliscope? Hell, even if all the harmonics weren't phase-aligned so that it doesn't look like a saw at all, it will still sound the same. If you're trying to make an LFO, then you would probably want something that looks like a perfect saw, and you wouldn't care about bandlimiting.

http://www.pdpatchrepo.info/hurleur/slow_sr_aliasing.mmb.pd

• ...After reading this post, it looks like what you're referring to would fall under the general umbrella of "distortion" or non-linear processing. I'm not sure if waveshaping is the right term, though.

Waveshaping always implies non-linearities. Linear (..no offs!) shaping would just be an amplification..

Yesyesyes.
The new frequencies that spring up due to the sine wave becoming "squarer" extend up to the global samplerate in Pd and alias there, so it's not really negligible (it never is). I don't know what you mean be "realtime" in this instance. This is all realtime

Hmhmhm...
But that "becoming squarer" is closely related to the "new" samplerate (of that s&h~), or rather its f_ny (=f_ny_new) (..cause it "becomes" a squarewave with f_sqr=f_ny_new)!!!
And how do you explain that the "harmonics" always meet at the f_ny_new (or at f_sr_new), if there was no relation to it... (choosing 5512.5 (=sr/8) was a little bit of an unfortunate accident, since new foldover fits right into the original (sr=44100..) foldover!)
It's obvious: Just change the new samplerate and watch the loundest partials fold at the new sr (and its multiples)...

The more quiet a sound the more negligible! And by using a low-freq. wave, the overtones that fold over are more quiet. That easy..
And the aliasing I hear is far from being quiet!!! ...beside being related to the new f_ny.
By "realtime" I still mean the contrast to the "slowed down time" of that patch.

As far as your example, that illustrates exactly what I'm talking about (though I don't know why you use a spectrum size of 64)

You shouldn't take a spectrum size of 64, just change the tablesize to "zoom in" so that it looks the same as in "realtime"..
...and beside that negligible "crap" from the original sr-aliasing, it just behaves nicely 'relative' to the f_sr_new.

(Seen from time-domain: there is nothing past f_sr.

This is not something you can see from the time domain.

You don't like the timedomain, do you?
...since shure it is: Sampling each "0.2 period" is the same as sampling each "1.2 period" since an offset of 1 period doesn't change anything..

What do you mean by this? Are you talking about the last partially suddenly dropping out when it hits Nyquist?

More or less. I mean that "sine on top of the waveform" (...that makes all values not being the same as before...)

It just depends on the application. If you are trying to make a bandlimited oscillator, then who cares if the saw looks like a perfect saw in an oscilliscope? Hell, even if all the harmonics weren't phase-aligned so that it doesn't look like a saw at all, it will still sound the same. If you're trying to make an LFO, then you would probably want something that looks like a perfect saw, and you wouldn't care about bandlimiting.

...I wonder why the saw is called SAW... (and not like "shark-tooth" or sth.)
A synth with just one osc (and filters) is a little lame, don't you think?!
So when there is another osc to mix with, phase becomes important, too. And with waveshaping the shape of the wave (...what else... ) is important! So a saw is a saw and not just "overtones decaying with 1/n"...

• @Flipp said:

Waveshaping always implies non-linearities.

Non-linearity, however, does not imply waveshaping. AM and FM, for example, are non-linear processes. But they aren't waveshapers.

Also, if you use a straight line as the transfer function, it's still a waveshaper, but it can be linear.

Hmhmhm...
But that "becoming squarer" is closely related to the "new" samplerate
<snip>
And how do you explain that the "harmonics" always meet at the f_ny_new (or at f_sr_new), if there was no relation to it...

The harmonics begin at the new SR, an extend beyond it. The only frequency that aliases at the new Nyquist is that of the sine wave (the fundamental of the distorted wave).

Take a look at my patch again. Starting at 0 Hz, as you increase frequency you will immediately see the first harmonic pop up at the "new SR". As you increase, some partials will increase in frequency while others decrease. Those decreasing once are folding over from the global sample rate, not the [samphold~] one. Once the [osc~] frequency goes above 2756.25, it aliases, and you see that frequency moving back toward zero. Everything above 2756.25 is distortion, and the only reason there are partials that fall below 5512.5 is because they were aliased at 22050. You can see this because the partials between 2756.25 and 5512.5 always go in the opposite direction of the lowest frequency, whether it has been aliased or not.

Take a look at the modified attached patch. I added a high-order Chebychev filter to act like an anti-aliasing filter would at the dac. It's not perfect because 1) no anti-aliasing filter is, and 2) there's still a global sampling rate, which would not be the case in a good dac. But it does illustrate some important points. First, the anti-aliasing filter fixes those steps so that the sinewave is reconstructed. Second, it shows that only the [osc~] frequency aliases at the new SR. If the other frequencies were aliasing, the level of that one remaining unfiltered partial would start to decrease as you increased the frequency. But it doesn't. It stays at the same level (plus or minus the filter ripple and slope). You can push it well beyond the SR and it will be a sine wave at the same level (except if you push WAY too high, but that's because of floating-point madness).

It's obvious: Just change the new samplerate and watch the loundest partials fold at the new sr (and its multiples)...

The loudest partial is the fundamental, i.e. the [osc~] frequency. It's the only one that folds over at that new Nyquist.

The more quiet a sound the more negligible!

That's because they're quiet. The amplitude range is limited by the bit depth. Also, they're just quiet.

And the aliasing I hear is far from being quiet!!!

That's not the aliasing you hear at the new SR you hear. It's the distortion. That artificial SR created by [samphold~] does not mean everything between that Nyquist and the global Nyquist don't exist.

...and beside that negligible "crap" from the original sr-aliasing, it just behaves nicely 'relative' to the f_sr_new.

In that it never aliases at that SR.

You don't like the timedomain, do you?

Sure I do. Most of what I do ends up being in the time domain. I just think it's important to know which domain is useful for what purpose.

...since shure it is: Sampling each "0.2 period" is the same as sampling each "1.2 period" since an offset of 1 period doesn't change anything..

But in a signal with more than one harmonic, you can't tell which of those harmonics were aliasing in the time domain. Also, as I mention before, .2 and 1.2 are technically the same thing in discrete time. You don't really even know which one it is.

...I wonder why the saw is called SAW... (and not like "shark-tooth" or sth.)

Hmm...maybe that's a hard-synced saw?

A synth with just one osc (and filters) is a little lame, don't you think?!
So when there is another osc to mix with, phase becomes important, too.

Yeah, in that case it might matter. But it doesn't have to be a perfect saw shape. Just a collection of harmonics with 1/n amplitude up until Nyquist that are phase-aligned.

By the way, if you see an oversampled-and-filtered sawtooth that just has a smooth transition where the discontinuity would be and no ripple, that means it used a filter that doesn't have a linear phase, and so the phase alignment gets fucked up anyway. A linear phase FIR filter will have some ripple, similar to a limited sum of sine waves, and it won't look like a perfect saw, either.

http://www.pdpatchrepo.info/hurleur/anti-alias_with_filter.pd

• @Flipp said:

...and beside that negligible "crap" from the original sr-aliasing, it just behaves nicely 'relative' to the f_sr_new.

Ah, sorry, I just realized what (I think) you meant by this. The aliased frequencies (from the global SR!) sit on top of each other, so they don't become a huge mess. If you change the new SR to, say, 5500, they don't overlap, you have nasty distortion all over the place, and so the anti-alias filter doesn't work in this case. You need a much higher global sampling rate for it to be worth it.

Posts 26 | Views 8916
Internal error.

Oops! Looks like something went wrong!