There's no need to multiply by 256 yet, you may as well skip that for now.This is an extremely high frequency FIR high-pass filter, with a corner frequency at one sixth of the sample rate. Since the sample rate here is 1.8MHz, any audio that comes out is going to be awfully quiet... probably why you added the <<8.

Quote:

unsigned short *wavebuffer = (output_L / num_of_updates) ^ 0x8000;

I think it's very likely that this varying num_of_updates is the source of the noise you had with the original resampler.

Someone (ages ago) told me to do that for DMC/RAW PCM samples. So, I'm using that method for the APU output.

lidnariq wrote:

There's so many different little things...

Quote:

output_L += (value - previous_sample) << 8;previous_sample = value;

There's no need to multiply by 256 yet, you may as well skip that for now.This is an extremely high frequency FIR high-pass filter, with a corner frequency at one sixth of the sample rate. Since the sample rate here is 1.8MHz, any audio that comes out is going to be awfully quiet... probably why you added the <<8.

If I take out the << 8, how's made the decay >> 7 ???

Well, any suggestion? I don't know how to resample & apply the highpass filtering. That's the problem.

I'm confused. What "versions" do you mean? The resample method is just summing all the generated samples and divide by the number of samples.Plus, the "<< 8" is for 16-bit samples. I can't simply take it out.

Last edited by Zepper on Thu Jul 14, 2016 6:55 pm, edited 1 time in total.

You elided enough of the code that it was hard to tell exactly what was going on.

It looked like the output -= output>>7 was happening on isolated samples after the sample rate change; in that case it's just a simple volume adjustment.

If that volume adjustment happens BEFORE the filtering is applied, then it will change the exact frequencies that are filtered.

If you used a simple first-order output-delay like this:y[n] = a·(y[n-1] + x[n] - x[n-1]) →algebra→y[n] = a·y[n-1] + k·(x[n]-x[n-1]) →Z transform→Y = a·Yz¯¹ + a(X-Xz¯¹) →algebra→Y(1-az¯¹) = a(1-z¯¹)X →algebra→"transfer function" = Y/X = a(1-z¯¹)/(1-az¯¹)fraction on the right is 0 when z is 1.fraction on the right is infinite when z is 1/k.If a is 127/128, this corresponds to a corner frequency of .000724597 times the sample rate, or 1300Hz at 1.8MHz, and 35Hz at 48kHz.

Who is online

Users browsing this forum: No registered users and 7 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum