Best choice for bandpass frequency


I am taking sound samples (simple tones) and playing them back on a Gameboy.

This hardware has 32 4-bit samples played back in loop at a frequency chosen by the programmer.

Consequences to this is that I can't fit the entire sample into the buffer. By taking only a portion, I can have higher frequencies represented, due to the increased sample rate, at the cost of lower frequencies no longer fitting in the 32 sample buffer.

Normally, frequencies above the Nyquist frequency "fold over" and affect the sound quality of the played sample. This is fixed with a lowpass filter in software before any conversion/playback that would cause this.

Also, long frequencies that can't be represented in the 32 samples don't fit, so a highpass filter in software seems like a good idea, to eliminate these frequencies and any artifacts they might introduce.

Together, these would form a bandpass filter, done in software, on a given sound/tone sample, to make sure these interferences are eliminated. These two points are tied, from any bottom frequency N to top frequency N*32, due to the size of the buffer.

However, putting this band somewhere where the sample has no frequencies would filter out most of the sound, and highly distort the output.

Is there an algorithm for choosing N to minimize distortion?


Posted 2019-07-20T17:52:23.783

Reputation: 1

"To preserve audio quality, then, I would need to run the sample through a bandpass filter from some frequency N to N*32, among other processes."

Where do you get "N to N*32" from? – Mark – 2019-07-21T00:39:57.580

I'm sorry mate but this question is formed from so many incorrect assumptions it's just not possible to unpick this. Nyqist aliasing only occurs when you try to play out samples that contain frequencies greater than fs/2. There's no need for a highpass filter in software. In any case you would be using lowpass, brickwall filters as anti-aliasing filters. – Mark – 2019-07-21T12:27:50.493



The first half of your question states some clear facts. "Gameboy" and "32 4-bit samples played back in a loop".

The rest of the question goes off in an unclear direction.

Any bandpass filter you use will be determined by the frequency response of the speaker in the device and the sampling rate used by the DAC in the hardware device.

To be honest, 32 samples is not a massive number of samples - particularly when looped. even at 8kHz sampling rate, 32 samples is only 31ms.


Posted 2019-07-20T17:52:23.783

Reputation: 7 535