Snes APU Emulator "Crackle"

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Snes APU Emulator "Crackle"

Post by bazz »

I've been spending all week incorporating Blargg's Snes_Spc APU into Raph's vSPC as a debugger interface behind SNES Tracker. but I ran into following issue, I need help with it.

I've noticed crackling on various tracks - I will reference from Super Metroid "Arrival on Crateria" .. You can use Audio Overload, or BSNES (higan), or whatever I haven't tred. I also noticed the crackling when playing Super Metroid in RetroArch with a BSNES core.. (can't remember which core exactly..) most importantly with the APU emu I'm using for my SNES Tracker - Blargg's latest Snes_Spc, I find the crackling pretty lame sometimes. It's not always there, but I notice it and I'm growing aware to it. If you don't hear it try turning your volume up more than half-way. it sounds like static on the mid-high frequencies, and it doesn't happen on all songs. I'm not sure if it's an accurate reproduction of a true SNES.. and I won't know that answer myself for awhile (SNES is in Boston). But god-damn, I dislike it so much that I'm interested in just having a SNES Tracker with better-than-SNES sound if that's the outcome.. If I could only figure out how to produce the audio samples in a cleaner way..

Here are exact refereces:
here's how the one with crackle sounds: http://www.metroid-database.com/music/s ... ateria.mp3
the rain and thunder isn't the crackling im talking about, this is much more subtle and very light high frequency static-e. sometimes sounds like grainy distortion..
someone managed to render the track without crackle. i dont know how ()..: https://www.youtube.com/watch?v=kmmpZfRmBFk


Any leads on this guys? gals..

p.s. I debated learning to incorporate Byuu's APU/DSP but since I heard the crackles there too I'm not that interested.. Besides, isn't his APU/DSP different from Blargg's? Haven't bothered to check it out. I haven't tried ZSNES, but it's like that ZSNES APU is eh or likely written in IA-32 asm and I don't want that.


EDIT: I just tried out SPCPlay which has an APU written in .. u guessed it.. ia32 assembly.. .-. I dont want to uck with that shi/and it's old.. I wonder why it sounds better .. so smooth.. compared to what I'm hearing on Byuu's / Blargg's.. What's going on?
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Snes APU Emulator "Crackle"

Post by koitsu »

I don't really hear what it is you're referring to (and I have amazingly good hearing (tradeoff for having crappy eyesight), especially to high-frequency noises), at least in the mp3 you linked.

There are a couple spots at the end of lightning/thunder that have a brief/soft pop, but other than that I don't really hear what it is you're talking about.

Have you tried listening to the actual SPC/RSN rips in an SPC emulator like Alpha-II SPC Player or similar? I can provide what that sounds like if you want (I tend to use settings that use Sinc interpolation, not Gaussian like the actual SNES, because I think Gaussian sounds like muffled crap).

Can you snip out the portion(s) that depict the issue using, say, Audacity and then provide them here / links to them (preferably in .wav, since the source material you linked is MP3, so MP3 -> MP3 is going to just add more compression/sound worse)?
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Snes APU Emulator "Crackle"

Post by bazz »

sure thing.. The first thing you hear is the crackley one.. played on Audio Overload with a version of Blargg's APU emulator. His latest one has the same behavior, even with the Spc_Filter activated..

The second one is from SNES SPC700 Player 2.14.5 (an older version, just something random I grabbed today in hopes of better quality, and it succeeded) -- it uses a furthering of Alpha-II's SnesAPU x86 win32 DLL, and here's its homepage: http://dgrfactory.jp/spcplay/index.html. It's in japanese.. Google Translate that hoe if need be.

Anyways! That SPC700 Player one has no static-E clicks. I played it at 400% volume because this player has a much lower volume than the first take from Audio Overload.. and I used the "SNES" interpolation-setting on it.

link: https://www.dropbox.com/s/zsp43qn1zoggp ... e.wav?dl=0

I'm hoping to achieve similar clean results with Blargg's APU-Emu, but I have no idea how to do that.. I feel that I must do an EQ that lowers the high frequencies, but I have no idea how to do it programatically :[ :'(( But even that intuition is ill-fitted, because I have no experience in audio coding and DSP and filters X[
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Snes APU Emulator "Crackle"

Post by koitsu »

Okay, I see what you're talking about now (for those reading/trying: turn your volume up a bit, it becomes quite noticeable then, but is easily missed at lower volumes).

I hope lidnariq comments here, because I'm not sure how to exactly explain what I think the issue is. IMPORTANT: I am *not* an audio guy.

To me, it looks like either over-amplification that results in clipping (of the generated waveform), or something wrong with the waveform generation for specific samples. The thing that seems to be causing the noise is the "bass" noise being used, or possibly that *combined* with the background "rain", but I think it's the former. It looks to me like some of the "bass" samples are very aggressively shooting up and down in their waveforms in such a way that doesn't seem... smooth. I can try to upload a screenshot with areas circled if I'm not being clear.

Although this gets me wondering... SNES samples loop automatically on playback, right? I remember when doing music tracking on the PC, that looped samples tended to have "clicks" or "blips" if the end of the waveform didn't match the start; you'd get a "popping" noise that was very short and could sound "high-frequency" in some cases. Maybe that's what's happening here?

It would help if we could single out just a single sample (e.g. the "bass" noise by itself) and see if that's where the issue is, or if it's only present if there is something else being mixed with it (e.g. the "rain"). Looking at the results in Audacity is hard because of the intermixed "rain" -- hard to do reliable waveform analysis that way.

I'll see if I can find one of the SPC players I've used in the past which can let you mute tracks or play and extract individual samples/instruments.

P.S. -- Have you tried contacting blargg directly (not here on the forum), i.e. via Email? His Email address is in the upper right of his web pages under Contact.

Edit: JCOM-SPC let me toggle individual channels. The "bass" noise is on the 2nd channel, while the "rain" is on the 3rd channel. Mute out all the channels except for the 2nd and you'll get what I think is most relevant. I still can't find the SPC player thing I've used in the past which gave me a surprisingly large amount of control over all the samples. Grrr...
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Snes APU Emulator "Crackle"

Post by bazz »

Yes I contacted him an hour ago via email. :D

Linked him to this thread as well..
I am recording the problematic voice solo'd
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Snes APU Emulator "Crackle"

Post by bazz »

Solo'd problematic voice.. Run from Blargg's latest Snes_Spc APU emu going thru my SNES Tracker debugger built on top of vSPCPlay. https://www.dropbox.com/s/ijlw3p20epo2i ... o.wav?dl=0
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: Snes APU Emulator "Crackle"

Post by lidnariq »

(koitsu: :) )

To be honest, I have the hardest time hearing any difference at all. But I do see something interesting if I look at the FFT:
spc_issue.jpg
I think the clicks are still present in the last one bazz posted.
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Snes APU Emulator "Crackle"

Post by bazz »

The clicks are most definitely present in my last post lidnariq, that's precisely why I posted it, to point out the solo'd voice responsible, or at least apparently most responsible,, This happens on other tracks too.. like the "Brinstar Red Soil Swamp" (GREAT SONG). Note: There are tracks where it is unnoticed or nonexistent, but I have tasted the fruit of smoothness via SPCPlay / youtube renders and I want to obtain it in my tracker. Read more: Good news, Blargg is on the scene, I think. I just got a response from him. He's curious as to whether this is accurate emulation or not. But I told him, even if it IS accurately doing thing, that I would love to have an option to opt out of it! I want clean music, not that garble.. and when other SPC players are playing it nicely I know it can be done. and I know the APU emulation is causing it. I'm not an APU master, but I'm close. Tahahaha!! HAHAH! But, I told Blargg I'm willing to convert his good instructions into work if he knows how to solve it. We'll see what he says, he might end up solving it himself. I might be speaking too soon. Who knows..
Last edited by bazz on Wed Dec 31, 2014 7:01 pm, edited 1 time in total.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Snes APU Emulator "Crackle"

Post by koitsu »

Dammit, why didn't I think of an FFT analysis? That's why we <3 you lidnariq. :-) Yes, the latest file (spc_issue_solo.spc) contains the same problem. And I think what's shown on the left is what I'm hearing as well / what bazz is reporting.

Just for benefit: to see what lidnariq indicated in his screenshot, use Audacity to load up one of the wav files. Once its loaded, on the far left of the waveform, near the filename, click the down-arrow and choose Spectrogram. You can adjust some of the spectrogram behaviours under Edit / Preferences / Spectrograms. I'd suggest increasing the max freq to 20kHz as well -- the top of the click seems to cap off at about 13~15kHz.

And those definitely correlate with the clicks I hear. Although when zooming in to look at the actual waveform itself, I really don't see any reason for the cause.

One thing to note: the clicks seem to come in pairs if you look at the spectrograms. There's a large one, almost always immediately followed by a smaller one roughly half its size. I find that interesting.
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Snes APU Emulator "Crackle"

Post by bazz »

+1 for the Audacity mini-tut

Another interesting note is that I hear the crackles during sections where this is no "surge" in spectogram.. you can even hear crackling after the first "spectogram section" exits. for some brief moments I do. And if I haven't made this clear, I need headphones myself for this kind of "aural precison" .. but I'm a musican making a musician's tool - I won't sacrifice this goal I have to eliminate this phenomenon-- especially when I've heard other SPC players playback the same tune perfectly <3 ... but I'm not sure if this phenomenon is accurate emulation or not -- I definitely want to get rid of it, and I definitely want to know if that's accurate emulation.
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: Snes APU Emulator "Crackle"

Post by lidnariq »

I actually do see discontinuities in the waveform:
spc_issue_solo.jpg
(These three are at 4.296s, 4.328s, and 4.361s )
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Snes APU Emulator "Crackle"

Post by bazz »

That's promising dude. I wish I had more to say, but you're a total godsend. :)
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Snes APU Emulator "Crackle"

Post by bazz »

Blargg and I are taking care of it
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Snes APU Emulator "Crackle"

Post by koitsu »

Awesome. A write-up of the root cause would be appreciated by, well, probably a lot of people. Kudos to you and of course blargg :-)
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Snes APU Emulator "Crackle"

Post by bazz »

I know I ought to document this stuff more officially, as I've been schooled, but not yet.. Thus:


The issue was with songs that change the volume registers quickly -- this is what causes the discontinuity in the waveform and therefore the click.. Blargg compensated by developing an optional feature SMOOTH_DSP, which if defined in a preprocessor definition, would somehow smoothen out the volume transitions (don't ask me for details on how he actually does it, but I'd like to know as well :) -- it is a private change that he asked me to take my time using it to see how it sounds.. I love it!! <3 I must have listened to 500+ of SPC with it by now.. Albeit the same hundreds (Mariokart, Star Fox, Super Metroid, Seiken Densetsu, Super Mario RPG, Kirby's Dream Course, Super Scope, Yoshi's Island, Super Mario World, and some others).

The change is present in SNES Tracker github but I doubt anyone can find it :P
If you do more power to you.

K

An official update to his APU is contingent on my approval, which I gave him in a recent email. ---> Note, right now Blargg is kind of a mess when it comes to this APU <--- but I have the following hope that he might identify which of his many code bases is the latest and greatest APU emulator, and then upload that to a Github repo. We'll see what he does, or doesn't do :{
Post Reply