0
$\begingroup$

Thanks in advance for any help with my newbie question. I've been consulting quite a large number of resources in order to understand how I can create and playback a nice sawtooth without aliasing, but I feel something is really not clicking, since explanations I've been reading have only been confusing me further.

It's my understanding that aliasing should not occur if my signal does not contain any sinusoidal components above the Nyquist frequency. So, to be safe, I create a sawtooth using the following code:

            fs = 48000;
            a = linspace(0,(fs/20),fs);
            SinAudio = sin(2*pi*a+0.5*pi);

            for i = 1:(length(amaxi)-1)
                SawElement{i} = linspace(-1, 1, (amaxi(i+1)-amaxi(i)));
            end

            % Make first sawtooth element
            Saw = linspace(0,1,amaxi(1));

            % Concatenate rest of elements
            for i = 1:length(SawElement)
                Saw = [Saw, 0, SawElement{i}];
            end

In this case, what I perceived as aliasing is apparent as a lot of clearly audible low frequencies, that sort of sound bubbly, especially when I sweep the signal.

So, the base frequency is way below my sampling frequency, and the way I concatenate the elements of the sawtooth, I take two samples to go from 1 to -1. Intuitively, I feel like this is where it goes wrong, because if you were to create a signal like that from individual sinusoids, you would need A LOT of harmonics, which would be why I get aliasing..

HOWEVER, there should be no more harmonics there than when I create a sine wave like this:

fs = 48000;
a = linspace(0,(fs/4),fs);
x = sin(2*pi*a+0.5*pi);

Which is a sinewave with a frequency of half the nyquist frequency, and therefor I wouldn't expect aliasing... I think?

So, my questions are: 1) Why does a generated signal with maximum frequency at half the nyquist rate still alias? 2) How do I create a bandlimited sawtooth or squarewave? I tried using wavetable synthesis, and although I haven't tested the resulting signal yet, I don't see how bandlimited wavetable synthesis would give me any different results from the two pieces of code I described above; ultimately, there's going to be a point where my signal goes from 1 to -1 over the course of 2 or 3 samples, no matter how I generate my signal..

Thanks in advance, I've really been breaking my head over this....

Paul

$\endgroup$
  • 3
    $\begingroup$ A sawtooth isn't band-limited. $\endgroup$ – Batman Aug 10 '15 at 19:22
  • $\begingroup$ If you are sampling an analog sawtooth wave, then you might worry about aliasing... but if you're synthesizing a sawtooth wave, you shouldn't need to worry about aliasing. Why do you think there is aliasing? $\endgroup$ – CMDoolittle Aug 10 '15 at 20:00
  • $\begingroup$ Ah, I should have mentioned this (will edit it into the original post), but it's very clearly audible.. There's a lot of low frequencies audible above 5 or 6Khz. Especially when I produce a frequency sweep by concatenating SawElements of different steepness, I hear a very clear low frequency bubbling sound.. Also, I read this question + responses, which describes a problem very similar to my situation, where this suggestion was made: dsp.stackexchange.com/questions/15974/… $\endgroup$ – Dorstlesser Aug 11 '15 at 7:31
  • $\begingroup$ @Batman, I want to playback something that approximates a sawtooth, like synthesizers do. I believe that's called a band-limited sawtooth, but correct me if I'm wrong. My questions still remain the same. $\endgroup$ – Dorstlesser Aug 11 '15 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.