3 ms·
> Since the number of pixels on the x-axis of the canvas is typically much smaller than the number of samples That's not the cause. The cause is simply that to
by chrisjj 3y ago
> Since the number of pixels on the x-axis of the canvas is typically much smaller than the number of samples
That's not the cause. The cause is simply that too few of the samples are plotted.
Your min/max solution succeeds by ensuring all significant samples are plotted.
- MadDemon 3y agoIf you're canvas has say 2000 pixels on the x-axis and you're trying to plot one second of 44.1kHz audio, you'll end up with more than 20 samples per pixel. You can then either reduce the number of samples or draw multiple lines within that pixel. Both approaches can result in aliasing. OP's approach seems to just draw lines between every sample, so using the second option. If you change the "Scale" in the example, you can clearly see how peaks appear/disappear due to aliasing (especially between 200 - 400 frames / px).
- chrisjj 3y ago> You can then either reduce the number of samples or draw multiple lines within that pixel. Both approaches can result in aliasing. I would disagree that the latter can result in the "super aliased" in question. Drawing one line per sample leaves very little aliasing.
- xipix 3y agoThe min/max solution doesn't prevent aliasing. Consider that if you do manage to avoid aliasing, you'll be rendering something visually akin to a downscaled version of a fully-detailed, high-resolution plot of the waveform.
- chrisjj 3y agoMin/max does prevent the "super aliased" result in question. I'd agree it leaves a little aliasing.
- MadDemon 3y agoIt renders a waveform that looks very similar to what it would look like if you drew a line between all points. If you have 100 samples per pixel and you draw lines between all of them, you'll essentially end up with a filled area that goes from the lowest sample to the highest. So practically the same thing as just taking the min and max and then filling everything in between. The advantage is that you're avoiding all those lines in between. If you zoom it, the signal changes very smoothly without those aliasing effects where peaks appear and disappear. The web demo currently doesn't allow zooming in, so you can't test it there, but if you download the whole Samplab app (https://samplab.com/download https://samplab.com/download), you can try out what it looks like when zooming in.
- chrisjj 3y agoA great explanation.