Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Bandlimited Waveforms and Aliasing

  1. #1

    Bandlimited Waveforms and Aliasing

    I've seen a lot of posts about band-limited waveforms reducing aliasing and generally sounding a lot better than the standard waveforms in the audio library. I must say using the standard audio library oscillators can sound a bit sterile, so I'm wondering if I should explore this approach. However I'm still confused about what exactly band-limited waveforms are and what the best way to implement them is in a teensy polysynth.

    Can anyone give a technical description of what this technique is and what the options are for implementing it?

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,219
    Yes, consider a square wave. It's spectrum technically goes on forever, all the odd harmonics (in practice
    the first few 1000 are easily powerful enough to be audible if in the range of hearing). However our ears
    can't pick up anything beyond about 20kHz, so for instance a 3kHz square wave has harmonics audible to
    the 5th or 7th at most (15kHz, 21kHz).

    If you sample a square wave in a simplistic manner at 44.1kSPS you alias down all the harmonics above
    22.05kHz back over the audio band - the 11th harmonic (33kHz) for instance will appear at 11.1kHz, and
    the 13th harmonic at 5.1kHz, both at audible levels.

    So to generate a square wave without these artifacts you have to use a non-naive method, either by over-sampling
    and filtering, or by constructing the waveform from band-limited samples in the first place. (For instance a
    sinc pulse or integrated sync pulse can be used as a strictly band-limited version of a spike or an edge waveform).

    The basic issue is that sampling at 44.1kSPS (or whatever rate) copies and reflects the spectrum every 44.1kHz.

    Square/rectangular and sawtooth waves are the worst for this (fast edges have lots of harmonics), triangle waves
    also give audible artifacts, but sinewaves don't have harmonics up above 20kHz to reflect back down, so aren't an
    issue.

  3. #3
    Thanks so much, Mark!

    So in practice, sampling a square wave (or any waveform with high harmonic content) at 44.1 kSPS will reflect harmonics that should be above our hearing range back into the audible range? And that doesn't sound very musical to our ears apparently.

    I'm realizing you did some work on this in another thread.

    I just tried out those bandlimited waves in the waveform object of the audio library. (Didn't realize it would be that easy.) Wow! MASSIVE difference in musicality. Thank you for your work on that.

    I will say I am getting some popping with those waveforms though. I'm going to try to troubleshoot in that thread to keep things organized.

  4. #4
    Edit: There was no popping on those waveforms. Just my own bug in the multiplexer code. I spoke too soon.

    Again, thank you for your explanation and for your work on the audio library! It makes a huge difference.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •