From the original SynthMaker forum (2004–2014), with its members’ names and dates.
JIftw ·
Hi,
Because of this problem: Lowpass filter before waveread,
I have modified the waveplayer so that it is 2x oversampled.
You will notice the difference in quality if you change the pitch/speed/rate.
Because there is an interaction effect between my oversampling and the interpolation used, I have assembled a utility to graph 5 interpolators with and without oversampling (10 combinations). The various levels of aliasing with each combination are more obvious this way. By default, a saw wave is used to illustrate.
Usage: You can change "Octave detune" so that aliasing can be seen easily (you will see the spectrum 'fold' back unto itself).
Change the selector to compare interpolators and oversampling on/off. From 0 to 9 I have ordered the combinations from what I think is worst to best. See the index reference to know which number corresponds to which combination. I have best results combining Exonerate's Bspline or Optimal2nd interpolation and my oversampling. The worst is using BSpline without oversampling.
Some modules were made by others:
Cubic interpolation: C.Hack1
BSpline & Optimal2nd Interpolation, original waveplayer: Exonerate
(I removed some functions of the waveplayer for this demo).
FFT display: sambean
Special thanks to them
Please try to do assembly optimizations to the oversampling code and share them in this thread ! Thanks !
mHz ·
I think you are chasing wild goose 🙂
JIftw ·
Not chasing anymore, I caught it. It tastes good, so I offer you some.
mHz ·
lol.
JIftw ·
As there isn't much interest in this, I do not continously update this thread.
If anyone wants the latest version, please PM me.
JIftw ·
exonerate ·
Thanks for sharing JIftw 🙂
I see lots of obvious optimization that can be done (combining code segments in one then ASM ect..).
I don't currently have time to spare on doing such optimizing, but if I come to use your oversampled player in future I'll be sure to optimize it and repost!
Cheers 😉
Exo
MegaHurtz ·
Guide me through this a bit (im actually hoping I dont understand)..
Im currently thinking, what if any step was represented in the ramp, there cant be a step misrepresented.
So this would actually be doing damage? (standing still and reversing).
Or am i horribly wrong??
Edit: Maybe a tip from an ole nuthed like me, 24 bit internal and samplerate proof.
Becouseits by default more efficient do do it like this.
Doing "oversampling" Is for the free pseudo high q skeit you get for free without asking 😕
Running your song into oblivion at the point its nearly done. (you know what I mean 😉 )
Sow to recap on it, this is for me also. Never hurts to do this..
You have a square at n point, amplitude 1. This we both agree on wouldnt want it to be there.
Becouse maybe it shouldhave been a sine.. If we are going to be very blunt about
what could be a very minimal sine, its even not 0-0,5-1-0,5-0-n0,5-n1-n0,5 (becouse this is a triangle).
This takes you 8 samples, and has its harmonics. (tbh we cant tell there but the distortion pattern can)
So to estimate a sine @ 44k we need 16 samples to spare this means 8x oversampling. (minimum)
Look at this like so.. we have a resolution to our ear of 22khz.
96k has an N point of 48 khz, where the half of this 24k makes its first 0-1-0-n1 triangle.
wich we have a hard time interpreting as a triangle becouse its over our hearing threshold.
This does leve distortion that makes your sound sound "harsh/digital"
But if you cascade or yust cut these frequencys out, the distortion should be minimised.
And the results should be truely accurate with very minimal pahase distortion.
JIftw ·
I have a lot of difficulty to understand you, but will try my best to reply 🙂
Don't hesitate to rephrase your question if I missed it completely.
Guide me through this a bit (im actually hoping I dont understand)..
Im currently thinking, what if any step was represented in the ramp, there cant be a step misrepresented.
So this would actually be doing damage? (standing still and reversing).
Or am i horribly wrong??
The code takes the input sample number to be read (PostInt + PosFrac) and calculates intermediary positions for reading in parallel. It relies on the interpolation code to do the rest 😉 After, my basic resampling is a simple average.
If you play a 44100 Hz file at 44100 Hz exactly, this code will modify the sound (i.e. it will not be bit-per-bit identical to the original). But it should be transparent (no bad audible artifacts). Because in this case, my module requires interpolation even tough it is unnecessary, finding the most artifact-free interpolation is crucial. Hence the comparator module at the top of the thread.
The ideal application is truly when doing pitchbending, or when playing files of various sample rates that differ from the host's if static filtering+resampling is not done.
Edit: Maybe a tip from an ole nuthed like me, 24 bit internal and samplerate proof.
Becouseits by default more efficient do do it like this.
Doing "oversampling" Is for the free pseudo high q skeit you get for free without asking
Running your song into oblivion at the point its nearly done. (you know what I mean )
I don't. I'm sorry, I don't understand what you mean.
So to estimate a sine @ 44k we need 16 samples to spare this means 8x oversampling. (minimum)
I believe that near 20 kHz, triangle vs sine doesn't matter. Why worry about not being able to adequately represent 20kHz sines ? No point going above 96 kHz sample rate anyway. At this rate, transient response is excellent, and frequency response is good enough even in the absence of oversampling. We don't hear anything above 24 kHz, and many of us don't hear above 20 or even as "low" as 16 kHz. If we don't hear above, why worry about distortion in the form of additional harmonics in such high frequencies ? Other forms of distorsion become more relevant.
wich we have a hard time interpreting as a triangle becouse its over our hearing threshold.
Precisely.
This does leve distortion that makes your sound sound "harsh/digital"
Not exactly. If you're talking outside the subject of resampling, then all harmonics that we don't hear cannot by definition be the cause of the "harsh" quality, unless there is non-linear interaction of some kind, like intermodulation.
If you were speaking within the context of resampling, your sentence seems to imply that the "distorsion" that is heard after aliasing occured is due to audible high energy content at high frequencies. It is not so. Aliasing distorsion in the specfic case of pitch-bending brings the high-frequency harmonics that should have gone beyond audibility back into audible range, spectrally inverts them, and loses their harmonic relation to the fundamental. Doesn't make it necessarily harsh-sounding, rather, as I am pitch-bending a note up, I hear a faint other one going down. This note doesn't care about harmony, so I don't like her.
Off-topic: Besides I don't like the term "harsh/digital" as used within the field of synths. I've build my own reference-grade pair of loundspeakers and done a little audio restoration & mastering for consumers, lots for myself. This is my only audio background; it's a hobby. When I come into the synth world, the newbie that I am does not understand people that qualify sounds as "fat analog-sounding" or "thin harsh digital". Speak in Hz ! Give me the waterfall plot ! Virtual analog is a ridiculous term to me. Do they actually modelize electro-physical reactions occuring in the real analog synth ? No.
Anything higher than half the destination sampling rate will fold-back unto the audible range during resampling. Hence the need to filter before resampling. The waveplayer does a crude resampling when playing at rates different than the original, and we can't dynamically filter before, as we discussed in this thread Lowpass filter before waveread .
This is why I made this module.
With 2x oversampling, assuming both sample file and host have the same sampling frequency, and that the sample file uses all available signal bandwith (frequency response extends to half-sample rate), this module allows to play the file up to 1 octave higher without aliasing. What I find particularily interesting is that my oversampling module seems to positively affect the performance of the interpolators also when playing at lower rates. I don't know why. Exonerate, could you enlighten me on this ?
MegaHurtz ·
After reading your post I think it`s better to state upfront, you do not have to tell me what im
educated to do. I do not mean this in an offensive way.
First of all the average of two liniar equals is the liniar equal shifted.
say 1+1,5 / 2 = 1,25.. so no increase in resolution whatsoever, yust a shift in samples.
Utilising this interpolation technique results in a slight loss of quality by bending the image a bit.
Secondly your definition of aliassing, is as with many who learn it by reading it here on the forum a false one.
Like any newb likes to yell aliassing sometimes. So heres again what it really is.
aliassing occurs because you do not have enough samples to represent a waveform thats of a very high frequency.
wich results in a lower one. You may be able to imagine A 22.1K sinewave at 441K.
would be something like 0- 0.1- 0.2- 0.3- 0.4- 0.5- 0.6. Where it shouldhave been a 1 sample square.
This too happens to harmonics of a triangle. (if you can catch my drift).
Still its nice to have a dit of code correcting for the loss of momentum in ramps, but I dont ever have these couse i build a decent ramp 🙂
JIftw ·
(Previous post)
MegaHurtz wrote: Sow to recap on it, this is for me also. Never hurts to do this..
(Now)
MegaHurtz wrote: After reading your post I think it`s better to state upfront, you do not have to tell me what im
educated to do. I do not mean this in an offensive way.
No offense taken, as it was not my intent. I tought I could participate in the recap, and that writing down my tought process would make it simpler to state the purpose of this module and improve on it. I am just a beginner in this.
MegaHurtz wrote: so no increase in resolution whatsoever
Of course. That is not what I'm seeking.
MegaHurtz wrote: Secondly your definition of aliassing, is as with many who learn it by reading it here on the forum a false one.
Like any newb likes to yell aliassing sometimes. So heres again what it really is.
aliassing occurs because you do not have enough samples to represent a waveform thats of a very high frequency.
Nothing new. Your stated definition of aliasing is the same as mine. I am aware that aliasing occurs during sampling (including resampling) when the sample rate is insufficient to represent the signal. I pointed out what happens during the specific case of the waveplayer which skips samples to play at a faster rate, which, because it is not preceded by low-pass filtering, results in aliasing. Playing a 48 kHz file at +1 octave is equivalent to reading the file at a 96 kHz rate (there will be signals up to 48 kHz). But if the host is at 48 kHz, resampling is required. The waveplayer does this by skipping samples. This is a crude resampling without prior anti-alias filtering. My definition is correct. The specifics of spectral inversion, loss of harmonic relation to the fundamental I stated do not contradict in any way the definition of aliasing. It is just my description of the audible artifacts.
Say we have a wave at 24 kHz for a sample rate of 48 kHz. The normalized samples go -1, 1, -1, 1, -1, etc.
If this is played at twice the rate (+1 octave) by skipping samples, the result is DC. Either -1, -1, -1, or 1, 1, 1
With my basic code, it will merge -1 with 1 to cancel out, 0. (This is at the limit, nyquist. At less extreme frequencies, cancellation is less severe. It's basically a low-pass filter prior to decimation.)
JIftw ·
exonerate wrote: I don't currently have time to spare on doing such optimizing, but if I come to use your oversampled player in future I'll be sure to optimize it and repost!
Much appreciated ! 🙂
MegaHurtz ·
Aah, now i get ya, You have actually spotted a very rare potential problem. 🙂
Not being able to predict when and where its going to happen actually implies it is
going to happen at a liniar average as well. (also a 12 dB one).
Only using an average on positional values creates distortion on the transition point from end to 0.
There is a fix to a slight phasing effect caused by the precise ramp.
Removing this by subtracting the ramp itself instead of the length, does cause another evil
namely clicks. but it does enshure a 0 start anytime.
Wrote something here? To have a post removed or your name hidden, write to [email protected].