Cheap Highpass Filter? (just add/subtract and bitshifts)

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Cheap Highpass Filter? (just add/subtract and bitshifts)

Post by Dwedit »

I remember reading about a really cheap Highpass/DC cancellation filter that used only addition/subtraction and bit shifts. But I can't remember what the formula was, or where I heard about it from. I think emulators used this formula. Does anyone know it?
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Cheap Highpass Filter? (just add/subtract and bitshifts)

Post by lidnariq »

All digital filter design is relative to the sample rate, so I'd need more details before I could construct something similar to whatever you're thinking of...
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Cheap Highpass Filter? (just add/subtract and bitshifts)

Post by Dwedit »

Audio, like 44 or 48KHz.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Cheap Highpass Filter? (just add/subtract and bitshifts)

Post by lidnariq »

You could do a really lazy first-order IIR highpass with something like
out[n] = out[n-1]*(1024-1) + in[n]/1024
that's a lowpass, one second while I do more math


Oh, man, it's been waaaay too long since I last remembered this.

Simple IIR highpass:
out[n] = out[n-1]*(1024-1)/1024 + in[n] - in[n-1]

End up with a corner frequency of [sample rate ÷ 1024]
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Cheap Highpass Filter? (just add/subtract and bitshifts)

Post by Dwedit »

Can the constant 1024 be doubled to cut the corner frequency in half?
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Cheap Highpass Filter? (just add/subtract and bitshifts)

Post by lidnariq »

Sure.
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Cheap Highpass Filter? (just add/subtract and bitshifts)

Post by Ben Boldt »

Do you see how the example's constant translates to a shift Dwedit?

out[n-1]*(1024-1)/1024

Is the same as:
out[n-1]-(out[n-1] >> 10)


Doubling the constant to 2048 would turn into:

out[n-1]*(2048-1)/2048
out[n-1]-(out[n-1] >> 11)
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Cheap Highpass Filter? (just add/subtract and bitshifts)

Post by Zepper »

Dwedit wrote: Sat May 29, 2021 7:18 pm I remember reading about a really cheap Highpass/DC cancellation filter that used only addition/subtraction and bit shifts. But I can't remember what the formula was, or where I heard about it from. I think emulators used this formula. Does anyone know it?
You're welcome.
http://forums.nesdev.com/viewtopic.php?f=3&t=4946
Post Reply