-1

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?

  • "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 Jul 21 at 0:39
  • 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 Jul 21 at 12:27
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.