Page 1 of 2
"Peace Audio Synthesizer" Scriptable NES sound emulation
Posted: Sat Feb 23, 2013 10:24 pm
by peacedev
Hello!!
I would like to introduce "Peace Synthesizer Framework"
It support NES/Famicom sound emulation with customizable Visualization and DSP
#Demo
Vampire Killer - Castlevania #NES Stereolization process in "Peace Audio Synthesizer"
http://www.youtube.com/watch?v=1YqyFx5VKf4
Thanks!!
-------------------------------------------------------------------
http://peacedeveloper.appspot.com/
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Sun Feb 24, 2013 2:40 pm
by blargg
Please use something like
blipbuf for audio synthesis if possible.
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Sun Feb 24, 2013 5:57 pm
by peacedev
May i ask why blipbuf ?
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Sun Feb 24, 2013 6:10 pm
by tepples
BLEP (band-limited step) resampling, the technique used by blip-buf, is a way to eliminate aliasing from a signal when downsampling from the 1.79 MHz CPU frequency to 44100 or 48000 or whatever target frequency. It works by decomposing a signal into a sum of
Heaviside steps, low-pass filtering a single representative step, sampling that filtered step at various fractions of an output sample, and adding up all the steps. For example, a square wave at 250 Hz has 500 steps per second: 250 rises and 250 falls.
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Sun Feb 24, 2013 8:10 pm
by blargg
Why use something like blipbuf? Because otherwise the sound has a scratchy quality (due to aliasing) which pollutes the crystal-clear sound of the NES. This was evident in the recording you posted. I just wanted to bring it to your attention.
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Sun Feb 24, 2013 8:21 pm
by peacedev
tepples wrote:BLEP (band-limited step) resampling, the technique used by blip-buf, is a way to eliminate aliasing from a signal when downsampling from the 1.79 MHz CPU frequency to 44100 or 48000 or whatever target frequency. It works by decomposing a signal into a sum of
Heaviside steps, low-pass filtering a single representative step, sampling that filtered step at various fractions of an output sample, and adding up all the steps. For example, a square wave at 250 Hz has 500 steps per second: 250 rises and 250 falls.
Thank you very much
This is something very useful
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Sun Feb 24, 2013 10:23 pm
by peacedev
blargg wrote:Why use something like blipbuf? Because otherwise the sound has a scratchy quality (due to aliasing) which pollutes the crystal-clear sound of the NES. This was evident in the recording you posted. I just wanted to bring it to your attention.
Are there any proof of audible alias which generate by sampling in 44100 hz?
I see when visualize or analyse them I can found it easily.
However by hearing as for me it not much different.
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Sun Feb 24, 2013 10:50 pm
by Dwedit
The NES is actually generating audio at ~1.79MHz (that's megahertz, not kilohertz). Any other sample rate will be a resampled version of that.
If you use nearest-neighbor resampling, it sounds awful. Using linear interpolation doesn't sound too bad, but is still somewhat distorted. Bandlimited interpolation (what Blargg is doing) works best.
Blip-buffer also uses a clever programming trick to make the sound synthesis run really fast, it stores the wave as volume differences instead of volume levels, then converts back to volume levels before you play it.
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Mon Feb 25, 2013 1:05 am
by thefox
peacedev wrote:blargg wrote:Why use something like blipbuf? Because otherwise the sound has a scratchy quality (due to aliasing) which pollutes the crystal-clear sound of the NES. This was evident in the recording you posted. I just wanted to bring it to your attention.
Are there any proof of audible alias which generate by sampling in 44100 hz?
I see when visualize or analyse them I can found it easily.
However by hearing as for me it not much different.
Try synthesizing (naively) a single square wave sweeping from 0 -> Nyquist (22050Hz) and you'll certainly hear it.
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Mon Feb 25, 2013 4:48 am
by Bregalad
Yeah, I think it sounds awful when an emu has aliasing in its sound !
Fortunately it seems most NES emus solved this issue, but most GB/GBC/GBA emus does not. Even VBA which is the most popular GB/GBC/GBA have aliasing in it's sound. Result : All games which uses the game boy channels sounds bad. Even GBS players does have aliasing.

Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Mon Feb 25, 2013 4:54 am
by peacedev
thefox wrote:peacedev wrote:blargg wrote:Why use something like blipbuf? Because otherwise the sound has a scratchy quality (due to aliasing) which pollutes the crystal-clear sound of the NES. This was evident in the recording you posted. I just wanted to bring it to your attention.
Are there any proof of audible alias which generate by sampling in 44100 hz?
I see when visualize or analyse them I can found it easily.
However by hearing as for me it not much different.
Try synthesizing (naively) a single square wave sweeping from 0 -> Nyquist (22050Hz) and you'll certainly hear it.
Now I notice it, This may cause my sound distortion as well. Thanks a lot.
Will post lowpass/band pass filter help ? instead of bandlimiting
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Mon Feb 25, 2013 7:58 am
by tepples
Bregalad wrote:Fortunately it seems most NES emus solved this issue, but most GB/GBC/GBA emus does not. Even VBA which is the most popular GB/GBC/GBA have aliasing in it's sound.
The NES output path has natural antialiasing, with a low-pass filter in the RF box. GBA and DS, on the other hand, use a PWM DAC at around 32.8 kHz that itself introduces aliasing. GBA emulators and GSF players just treat it as if it were a 44 or 48 kHz DAC. The GBA uses a higher sampling frequency (262 kHz) in GBC mode, and emulators and GBS players should in theory be sampling at that rate and using BLEP downsampling to hit 44/48 kHz.
peacedev: Band-pass (or low-pass) and band-limiting mean pretty much the same thing. BLEP is just an efficient technique to implement a combined low-pass filter and decimation for square-like waves such as the output of second- and third-generation consoles' APU.
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Mon Feb 25, 2013 8:08 am
by peacedev
tepples wrote:Bregalad wrote:Fortunately it seems most NES emus solved this issue, but most GB/GBC/GBA emus does not. Even VBA which is the most popular GB/GBC/GBA have aliasing in it's sound.
The NES output path has natural antialiasing, with a low-pass filter in the RF box. GBA and DS, on the other hand, use a PWM DAC at around 32.8 kHz that itself introduces aliasing. GBA emulators and GSF players just treat it as if it were a 44 or 48 kHz DAC. The GBA uses a higher sampling frequency (262 kHz) in GBC mode, and emulators and GBS players should in theory be sampling at that rate and using BLEP downsampling to hit 44/48 kHz.
peacedev: Band-pass (or low-pass) and band-limiting mean pretty much the same thing. BLEP is just an efficient technique to implement a combined low-pass filter and decimation for square-like waves such as the output of second- and third-generation consoles' APU.
Thank you very much.
You are very cool person

Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Mon Feb 25, 2013 9:31 am
by Bregalad
GBA and DS, on the other hand, use a PWM DAC at around 32.8 kHz that itself introduces aliasing.
Does this apply to GB sound too ? I tought only the Direct Sound channels were affected by this.
At least I once made a test using the multiple available frequencies for the GBA PWM, and it turned out that while this affected strongly the Direct Sound channels (in a way that remains completely unemulated by the way), I remember it did not affect the GB soud in an audible way.
This was with my DS though - it's hard to record sound directly from the GBA SP now that my adapter has broken down.
Basically those were the results :
32 kHz PWM - 9 bits = horrible sound with lot of aliasing
64 kHz PWM - 8 bits = okay sound
128 kHz PWM - 7 bits = mediocre when the sound is quiet because of quantization
256 kHz PWM - 6 bits = Horrible sound because of quantization.
Link :
http://dl.dropbox.com/u/23465629/GBA_ju ... samples.7z
Re: "Peace Audio Synthesizer" Scriptable NES sound emulatio
Posted: Mon Feb 25, 2013 9:49 am
by James
blargg wrote:Why use something like blipbuf? Because otherwise the sound has a scratchy quality (due to aliasing) which pollutes the crystal-clear sound of the NES. This was evident in the recording you posted. I just wanted to bring it to your attention.
Is there a simple test-case for this (i.e., some game music that highlights the scratchy quality)? The Solstice intro, for example, is a good test-case for filtering out too-high frequencies.
I'm emulating the sound channels at 1.79MHz, low-pass filtering with a 512-tap FIR filter, and downsampling by 37 to get ~48kHz output. I suppose I haven't compared with a critical ear, but I don't notice any particularly scratchy differences between this method and the blipbuf method that I
currently previously used.
(Note that I'm not trying to say that my method is better; it's certainly not from a CPU utilization perspective. I don't understand the blipbuf method well enough to re-implement it, and my goal was to build something sans copy-paste code/libraries).
edit: typo