2
$\begingroup$

I am in the early stages of learning DSP and am writing a simple synthesizer. I want to dabble in oversampling and am following this guide: https://www.nickwritesablog.com/introduction-to-oversampling-for-alias-reduction/

Adding 0’s and then doing an LPF is fine, but why would I then want to down-sample, as it states to do? When I play a sample back in response to a MIDI note, shouldn’t I just use the up-sampled buffer directly? Does playing a note count as the down-sampling part? If I were to up-sample, filter, down-sample, and then use that buffer to play MIDI notes, I would absolutely get the aliasing issue again, right? So I need to know that I am understanding this correctly and if not then I need a correction.

L. Spiro

$\endgroup$
2
  • $\begingroup$ PCM sample playback is not exactly the same as "synthesis". But they are both triggered from MIDI Note On messages. If you want to upsample your PCM sample buffers, that's fine, but do it in advance, not in real time. In real time, your interpolation should be simple. I would recommend linear interpolation, but then make sure you upsample your instrument sound files by at least a factor of 4x. Maybe 8x. Then linear interpolation will be fine. $\endgroup$ Jan 13, 2022 at 4:49
  • $\begingroup$ This is an offline renderer, meaning it does not respond to real-time events. You give it the MIDI data and a sound bank and it renders the result. As such, I can spend as much time as needed to get the best result. Oversampling will be done in advance, but I will be interested in more complex interpolators later. I am looking at these: yehar.com/blog/wp-content/uploads/2009/08/deip-original.pdf Any input on that? $\endgroup$
    – L. Spiro
    Jan 13, 2022 at 7:08

2 Answers 2

1
$\begingroup$

If your motivation was to increase the sampling rate, then yes you are correct, once you filter you will have completed interpolation and have a higher rate copy of your signal.

The zero insert create replicas (images) in the spectrum. When you filter out these images properly, you will then have a higher sampled (interpolated) waveform.

The comment in the linked article to then down-sample was to probably just to explain down-sampling and decimation. Once you filter the regions in a higher sampled waveform where energy would otherwise alias in (which happens to be the same regions where images were created in the zero insert process if the ratio is the same), you can then down-sample (take every N'th sample) safely as since the filtering was completed, there is no energy that will alias in. We would only do this if we wanted to return to the original sampling rate (the reason we may actually do this is when we require a fractional sampling rate change where we interpolate by $M$ and decimate by $N$).

This post details resampling concepts further will additional links to other posts on the topic.

$\endgroup$
2
  • $\begingroup$ Okay, so basically I am correct in my general understanding. Inserting 0’s and filtering is part of the process, the rest is just useful to their needs, whereas my version of that would be to simply play the sounds back on MIDI notes. I couldn’t accept that down-sampling was useful for my needs because that would mean that you could store data in a buffer that would not alias at double the sampling rate, which isn’t possible. I think I got what I need to make good progress now. Thank you. $\endgroup$
    – L. Spiro
    Jan 13, 2022 at 7:14
  • $\begingroup$ That is correct. $\endgroup$ Jan 13, 2022 at 11:14
0
$\begingroup$

If you have a sample of a piano, say a 10000 samples of a 440 Hz A4 sampled at 48kHz and you want to play an octave above that, 880 Hz A5 using a 48kHz D/A converter you would have to «compress» the original waveform to 5000 samples. A means to do that is downsampling such that you keep and shift the low frequency content, but remove the high frequency content (to avoid aliasing).

If you want to do any processing on the waveform (say, an amplitude envelope), you might want to work at a higher intermediate resolution as any discontinuities (of derivative) of the envelope could itself cause aliasing. Then you would downsample correspondingly before playback (or file rendering in your case).

I am shure that practical rompler and wavetable synthesis designs have deviced more elaborate solution that trades sound quality, cpu and memory usage and processing delay in clever ways.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.