Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
http://bisqwit.iki.fi/src/fceu-bisqwit-blargg-sound-improvement-patch.txt http://bisqwit.iki.fi/src/fceu-bisqwit-blargg-sound-improvement-patch2.txt This source code patch, applied to FCEU source code, adds support for Blargg's Game Music Emu. More precisely, it replaces the sound engine in FCEU with Blargg's sound engine, which in my opinion produces a lot better quality sound than the one in FCEU. It does it using the same principle as the "fake mute workaround" patch in snes9x, i.e. it pretends different things to the game than what is actually happening. This ensures maximum sync compatibility with existing movies, while best sound is produced. I am recommending this to all those who make AVIs of NES movies on this site. Note: This patch is not (yet) savestate robust. Using savestates in conjunction with this patch will produce wrong sounds. This has no effect to movie sync or the end product, but it may annoy those who make the movies, so it should only be used by AVI encoders. Comparisons: Zelda II: https://files.tasvideos.org/bisqwit/nes_sound_comp/f-zelda2.mp3 -- FCEU https://files.tasvideos.org/bisqwit/nes_sound_comp/b-zelda2.mp3 -- Blargg Gimmick!: https://files.tasvideos.org/bisqwit/nes_sound_comp/f-gimmick.mp3 -- FCEU https://files.tasvideos.org/bisqwit/nes_sound_comp/b-gimmick.mp3 -- Blargg Blaster Master: https://files.tasvideos.org/bisqwit/nes_sound_comp/f-blasmast.mp3 -- FCEU https://files.tasvideos.org/bisqwit/nes_sound_comp/b-blasmast.mp3 -- Blargg Super Mario Bros: https://files.tasvideos.org/bisqwit/nes_sound_comp/f-smb1a.mp3 -- FCEU https://files.tasvideos.org/bisqwit/nes_sound_comp/b-smb1a.mp3 -- Blargg Akumajou Densetsu (Castlevania III): https://files.tasvideos.org/bisqwit/nes_sound_comp/f-akuden.mp3 -- FCEU https://files.tasvideos.org/bisqwit/nes_sound_comp/b-akuden.mp3 -- Blargg Kirby's Adventure: https://files.tasvideos.org/bisqwit/nes_sound_comp/f-kirbyu.mp3 -- FCEU https://files.tasvideos.org/bisqwit/nes_sound_comp/b-kirbyu.mp3 -- Blargg Besides the ~7 dB volume difference, one difference I can spot easily is that Blargg's patch efficiently removes coarse noise that comes from digital sampling of the input sound. Something to do with Nyquist frequencies. The vibratoes are also more accurate, and the relative volumes of different mixing units are more pleasant. The MP3 files are encoded using "mode=3:preset=50:aq=1" lameopts in mencoder, with 48000 Hz input. This is the setup used for most of the AVI encodings of NES movies on this site by me. EDIT: I updated the patch to use updated version of Blargg's lib. However, it is largely untested so far (whereas the previous version has been used in tens of publications already), so use at your own risk :)
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
Well, the differences are not so much noticeable. Which one is more accurate? Also, if it could be in Windows version as an option that can be enabled/disabled, it would be nice.
Senior Moderator
Joined: 8/4/2005
Posts: 5777
Location: Away
It indeed softens the noise, which sounds like interpolation to me. And since I strongly dislike interpolation (while it makes the sound softer, it effectively muffles it, which is evident in these samples if you equalize the sound level), I would most likely be against such an idea. Although I generally am a proponent of the better quality at the expense of compatibility, this is not the case of better quality to me.
Warp wrote:
Edit: I think I understand now: It's my avatar, isn't it? It makes me look angry.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
moozooh wrote:
Sounds like interpolation to me.
Yes, the difference between the two strongly resembles the difference between interpolated and non-interpolated sound.* However, the theory behind the change is much more complex -- it is explained here: http://slack.net/~ant/bl-synth/ -- and there are other changes as well, like better emulation and more balanced volume ratios in mixing of different channels (for example, in Blaster Master, you may notice that the noise "drum" channel is much softer in the Blargg version than in the FCEU version.) *) There are always to ways to look at interpolated sound sampling. -- One: Non-interpolated is good, interpolated is muffled. -- Two: Interpolated is good, non-interpolated introduces high-pitched noise. Which opinion you take, usually depends on what you've used to listening to. But I repeat, this is not about interpolation, even though it sounds similar. It is about noise reduction :) It's not about lowpass filtering either; it does not remove/reduce highpitched tones: highpitched tones come out just fine; it's the aliasing artifacts that get removed.
Senior Moderator
Joined: 8/4/2005
Posts: 5777
Location: Away
Yeah, I do understand it's not about interpolation alone, but the thing is that I'm ok with noise. It doesn't sound "harsh" to me, I call it "crisp". Antialiasing that takes place in this case doesn't extract the original information subjected to downsampling (since it's largely impossible), it just tries "guessing" it based on the given input. These guesses may be right in one case and wrong in another (the "error" on the page you linked to: there's no way to predict the initial form of the wave if its samples eventually alias themselves to the same level), but what they're doing is changing the sound in a way I don't appreciate. For me, the aliasing artifacts is a part of the music — a whole genre of music. Trying to enhance it in such a way, especially given that it doesn't really uncover the details lost due to downsampling (much unlike hi-res textures for N64 games, even though the concept is similar), sounds a bit pointless to me.
Warp wrote:
Edit: I think I understand now: It's my avatar, isn't it? It makes me look angry.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
It does not "guess". It has all the access to the original intention of the game; it receives all the I/O access which programs the specific waveforms and amplitudes and periods, and it gets run at the same rate as the CPU, so there is no guesswork involved. In other words, it is not a postprocessor that tampers with PCM data already generated by some source. It is a full-featured NES synthesizer that generates the audio with the limitations of the target sampling rate in mind.
Senior Moderator
Joined: 8/4/2005
Posts: 5777
Location: Away
It's still limited by the system's technical specifications, though, so the margin of improvement is too small to be easily noticeable, let alone dramatic, and all that only to get butchered by low bitrate MP3? I don't see much point, especially (as I said before), it doesn't even sound better to me. Only different, and different not in a way I like. Lifting off the limitations of the NES to produce a higher level of sound quality would have probably been better, but there's no way to extract that kind of information from the data stored in the game to be processed by the synth, is there?
Warp wrote:
Edit: I think I understand now: It's my avatar, isn't it? It makes me look angry.
Emulator Coder, Skilled player (1311)
Joined: 12/21/2004
Posts: 2687
It sounds clearly better to me... less irritating to listen to and more like it sounds on a real NES. But I wonder if the same argument would also point to using an NTSC filter for the video encoding.
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
I think Bisqwit uses blargg's ntsc filter if I remember correctly. So, nitsuja, willing to add that feature?
Post subject: Re: Blargg's NES sound patch
adelikat
He/Him
Emulator Coder, Site Developer, Site Owner, Expert player (3576)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
Bisqwit wrote:
The MP3 files are encoded using "mode=3:preset=50:aq=1" lameopts in mencoder, with 48000 Hz input.
why aq=1? aq=0 is a higher quality setting that produces slightly smaller filesizes. It is slightly slower, but audio encoding is very fast anyway (especially mono audio as in the case of NES encodes).
It's hard to look this good. My TAS projects
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Phil wrote:
I think Bisqwit uses blargg's ntsc filter if I remember correctly.
I don't use that. It requires using a significantly higher resolution. (Something like ~576x448 instead of 256x224) Would like to, though :) Re: aq=1, I use it because aq=0 is pathologically slow sometimes. But I use aq=0 when I have lots of time and I remember to change it. This time I didn't.
Emulator Coder
Joined: 6/8/2005
Posts: 14
Heh, just noticed this thread. Hope its revival isn't a problem. - If volume level was the main issue, it shouldn't be hard to increase FCEU's volume. - Back when I was doing more APU research, Xodnizel was implementing my findings too, and implemented the non-linear mixing, which I still don't do in any code I've released. It's minor, but in this respect, it's more accurate. Not sure about its accuracy in other areas. - FCEU uses band-limited synthesis too, as far as I know (if it's anything like Festalon, which was my first inspiration for getting into emulation coding), so there shouldn't be any noticeable difference. I didn't hear much difference in the sound samples (besides volume). Of course the compression artifacts of a ~50 kbps mp3 stream mask anything subtle anyway. On the other hand, FCEU used a quite slow synthesis algorithm, so maybe the speed increase is worth it. - NES sound does NOT have any aliasing. It's generated at effectively a 1.79 MHz clock rate. Yes, while your sound card only runs at 48000 Hz or so, the NES runs at 1789773 Hz. Any aliasing is due to poor emulation, and not accurate. This includes the noise being too loud. If you prefer aliasing, then you have not had enough exposure to the real thing, and obviously didn't record and listen to the game music on tape as a kid all the time :). My code and FCEU both convert this 1.79 MHz signal down to 48000 Hz (or whatever rate you set) the same way it would be converted if you hooked a NES up to the line input of a PC sound card and digitized it. NES noise does get softer at at higher rates, because more of the signal goes above audible (and above the Nyquist limit around 20 kHz) and is thus filtered out. No guessing is involved. The error diagram on my band-limited synthesis page is showing the error that linear interpolation introduces, as compared to proper band-limited interpolation. Linear interpolation simply doesn't filter out the frequencies above Nyquist, so they fold over (alias) and become audible scratchyness or worse.