To make those higher-pitched noises sound correct, you'll have to generate the audio differently for them.
The DMG's noise channel itself generates audio at 524288 Hz; you could also do that, and then lowpass and downsample it to for your soundcard.
If you were more comfortable with audio, you could do some math and precalculate the audio for these higher pitches, or you could just convert them to an attenuation factor and a corner frequency and use a generic white noise source. But as is ... the laziest option, by far, is to just replace "problematic" s and r with a different value that sounds more similar to the original despite the aliasing.
Sound 4 (Noise): Highest frequencies?
-
- Posts: 6
- Joined: Mon Sep 07, 2020 5:08 am
Re: Sound 4 (Noise): Highest frequencies?
How to downsample that. Like I don't know the maths to do that wiki does't help that much
Re: Sound 4 (Noise): Highest frequencies?
That depends on the quality you want to get.
You can have good downsampling with quadratic interpolation.
It is easiest to do the interpolation / low pass filter / downsampling at the same time.
Some pseude code...
where target_buffer has the downsampled frequency (eg. 44100 Hz), and source_buffer has the frequency you render the signal at (e. g. 524288 * 2 Hz).
scale_sample_position would be
The sampling rate of the source buffer needs to be at least double the frequency of the source signal because of aliasing.
You would need to make sure that the interpolation (if you use any) happens when the filter samples from the source signal (meaning you need sub sample accuracy for the source position).
Also, the filter needs to be lowpass to a low enough frequency (in this case 22050 Hz) so that aliasing does not occur (or at least reduce amplitude above that range very much).
The math for building the filters is more complicated, and you would need to choose a filter that is good for this purpose.
http://www.iowahills.com/Example%20Code ... ebCode.txt
This contains code for making a few different FIR lowpass filters. Maybe one of those helps.
You can have good downsampling with quadratic interpolation.
It is easiest to do the interpolation / low pass filter / downsampling at the same time.
Some pseude code...
Code: Select all
for each position, sample in target buffer
sample = fir_lowpass_filter(source_buffer, scale_sample_position)
scale_sample_position would be
Code: Select all
source_position = target_position * source_frequency / target_frequency
You would need to make sure that the interpolation (if you use any) happens when the filter samples from the source signal (meaning you need sub sample accuracy for the source position).
Also, the filter needs to be lowpass to a low enough frequency (in this case 22050 Hz) so that aliasing does not occur (or at least reduce amplitude above that range very much).
The math for building the filters is more complicated, and you would need to choose a filter that is good for this purpose.
http://www.iowahills.com/Example%20Code ... ebCode.txt
This contains code for making a few different FIR lowpass filters. Maybe one of those helps.