Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If 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).


> 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.


> Drawing one line per sample leaves very little aliasing.

It's definitely gonna look better than just skipping samples, but you're also gonna draw a lot of unnecessary lines.


Unnecessary lines are trivially avoided by the proposed min/max optimisation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: