Hi there, I am working on a synth emulator and have a question regarding proper sample playback when sample rate and pitch changes.
First issue is that the samples used for my emulator is recorded in 32kHz, while playback is in 44,1 kHz. Next issue is that the pitch changes depending on a number of factors. The most prominent factor is probably the difference in MIDI key number from where the original sample was recorded for and the key that you play in the emulator. What I do today, which gives a (surprisingly) accurate pitch is to calculate a float value with accumulated pitch adjustments needed and then read the closes sample value from the original instrument sample. The only problem with this solution, and the reason for my question here, is that the further away from the original pitch I get, the more I can hear artifacts in the sample playback (at low frequencies it almost sounds like it is using 8 bit samples). So clearly there needs to be some proper math / filters behind changing the sample rate / pitch during playback. I suspect this is what the libsamplerate & libsoxr libraries are used for.
I really enjoy watching the Bela youtube lectures and recently watched the episodes about the phase vocoder. It shows how to use FFT to make a pitch shifter, which is pretty similar, but not exactly, what I want. I want samples to play longer at lower frequencies, and to be shorter at higher frequencies (just like a natural string instrument).
Any pointers on how to properly adapt sample rate / pitch for sample based synth playback? I suspect people have asked about this before, but I really could not find any exact matches to my question in the forum archive.