Moved from here.
Care to share? I've casually looked into this in the past and am interesting in learning how to do it properly/the DSP way.
Thanks,
James
Ok. Here's some fundamental DSP knowledge (Part I):
Well, as far as the NES's APU is concerned, realistic emulation is quite simple but performance hungry.
All the old sound chips nearly worked the same. As the budget for chip design was't that high during the good old days and the things you could do on an IC were really limited most sound chips are really simple in its inner workings.
One of the major problems when doing digital audio (and this is what NES APU, YM, SID, Paula do) is aliasing. There's this Nyquist theorem which basically says: Don't use a harmonic higher or equal to half your sample rate. So for e.g. 44.1kHz sample rate, you can go up to 20.05kHz.
All classic waveforms (like sawtooth, pulse/square and triangle) have lots of overtones/harmonics. These are sine waves at (normally) an integer multiple of the fundamental frequency. These harmonics is the stuff which makes digital audio really hard^^ Every 'hard edge' (i.e. like sawtooth's restart or the 'sides' of a pulse wave) contains lots of harmonics.
So what happens if you use a frequency/harmonic which is greater than half your sample rate? The frequency gets mirrored back. E.g. if you try to play a sine wave at 30kHz using 44.1kHz sample rate it will be mirrored back to ~10kHz (22.05kHz is the mirroring point).
As said earlier the pulse wave contains lots of harmonics at multiples of the fundamental frequency. These harmonics are also mirrored and the audible effect you get from this mirroring is what you would call aliasing.
There's a technique called bandlimited synthesis which generates the waveforms with just enough harmonics to prevent any mirroring, but this was science fiction back in the 80s. So the chip designers made their lives simple and just clocked their sound chips at e.g. the CPU clock's rate.
The SID runs at about 1MHz, the APU at 1.8MHz. Using souch high sample rates suppresses the aliasing noise and renders it nearly inaudible. (Nyquist frequencies of 500kHz (SID) and 900kHz (APU)).
Thats why those sound chips sounded great even if they were 'cheap' and did all sound generation the naive way.
Another thing was: Digital to analogue changers.
Nearly all of the chips use the cheap variant of only positive voltage DACs, but an audio wave 'swings' between positive and negative voltage. The cheapest way to get a signal from 'positive-only' to 'swing-between-negative-and-positive' is a so called DC blocker filter.
A DC blocker is nothing but a simple high-pass filter. Such a filter attenuates lower frequencies and lets higher frequency content pass through. DC is just a constant value/voltage ... and a constant value/voltage has a frequency of 0. So any high-pass filter with a cutoff frequency higher than zero will remove the DC.
The cutoff frequency of a filter is the splitting point for it's pass- and stop-band. The pass-band is the range where frequencies may pass nearly unaltered, the stop-band is the range where frequencies are attenuated.
In case of a high-pass filter the stop-band is below its cutoff, the pass-band above.
Filters have a slope or transition width from stop-band to pass-band, i.e. you don't have a sharp edge which attenuates all frequencies below cutoff by -96dB, but you have an increasing attenuation from the cutoff point downwards (in case of a high pass filter).
More later, I have to leave the train ... work time^^
James wrote:
neet wrote:
For the sound: as I'm very familiar with DSP it's of course generated at the original sample rate and resampled correctly.
Care to share? I've casually looked into this in the past and am interesting in learning how to do it properly/the DSP way.
Thanks,
James
Ok. Here's some fundamental DSP knowledge (Part I):
Well, as far as the NES's APU is concerned, realistic emulation is quite simple but performance hungry.
All the old sound chips nearly worked the same. As the budget for chip design was't that high during the good old days and the things you could do on an IC were really limited most sound chips are really simple in its inner workings.
One of the major problems when doing digital audio (and this is what NES APU, YM, SID, Paula do) is aliasing. There's this Nyquist theorem which basically says: Don't use a harmonic higher or equal to half your sample rate. So for e.g. 44.1kHz sample rate, you can go up to 20.05kHz.
All classic waveforms (like sawtooth, pulse/square and triangle) have lots of overtones/harmonics. These are sine waves at (normally) an integer multiple of the fundamental frequency. These harmonics is the stuff which makes digital audio really hard^^ Every 'hard edge' (i.e. like sawtooth's restart or the 'sides' of a pulse wave) contains lots of harmonics.
So what happens if you use a frequency/harmonic which is greater than half your sample rate? The frequency gets mirrored back. E.g. if you try to play a sine wave at 30kHz using 44.1kHz sample rate it will be mirrored back to ~10kHz (22.05kHz is the mirroring point).
As said earlier the pulse wave contains lots of harmonics at multiples of the fundamental frequency. These harmonics are also mirrored and the audible effect you get from this mirroring is what you would call aliasing.
There's a technique called bandlimited synthesis which generates the waveforms with just enough harmonics to prevent any mirroring, but this was science fiction back in the 80s. So the chip designers made their lives simple and just clocked their sound chips at e.g. the CPU clock's rate.
The SID runs at about 1MHz, the APU at 1.8MHz. Using souch high sample rates suppresses the aliasing noise and renders it nearly inaudible. (Nyquist frequencies of 500kHz (SID) and 900kHz (APU)).
Thats why those sound chips sounded great even if they were 'cheap' and did all sound generation the naive way.
Another thing was: Digital to analogue changers.
Nearly all of the chips use the cheap variant of only positive voltage DACs, but an audio wave 'swings' between positive and negative voltage. The cheapest way to get a signal from 'positive-only' to 'swing-between-negative-and-positive' is a so called DC blocker filter.
A DC blocker is nothing but a simple high-pass filter. Such a filter attenuates lower frequencies and lets higher frequency content pass through. DC is just a constant value/voltage ... and a constant value/voltage has a frequency of 0. So any high-pass filter with a cutoff frequency higher than zero will remove the DC.
The cutoff frequency of a filter is the splitting point for it's pass- and stop-band. The pass-band is the range where frequencies may pass nearly unaltered, the stop-band is the range where frequencies are attenuated.
In case of a high-pass filter the stop-band is below its cutoff, the pass-band above.
Filters have a slope or transition width from stop-band to pass-band, i.e. you don't have a sharp edge which attenuates all frequencies below cutoff by -96dB, but you have an increasing attenuation from the cutoff point downwards (in case of a high pass filter).
More later, I have to leave the train ... work time^^