@Mere: This revision is better, but try starting up the Wii system menu (if you don't have that, there's a guide
here and the method of extracting from a game is really easy and works just as well). I'm still getting a bit of clicking, but much less severe. I would post a screenshot but it appears to be the same thing as before. In fact, deleting the sample following the glitch makes a smooth, seamless wave. Your filter slope, however, appears to me to very good! Zooming in on the spectogram shows it's pretty similar to the real hardware. I wonder if there's anybody out there who did the Gamecube S/PDIF mod and could make a digital recording to compare to. Both of the recording devices I've tried have had too high a noise floor to answer this question unambiguously.
@moosehunter: Hey, that sounds a lot better! I could tell right away once the menu music started, and then I went and recorded it in the regular Dolphin to check and it did indeed have a lot less treble. It seems the 32 kHz one has more treble than the 48 kHz, and sounds practically the same as the original stream ripped from the game (though the wave doesn't come out exactly the same). But, weirdly enough, it has its stereo channels reversed compared to the original file, but then the 48 kHz version has them swapped back the right way again. Could you give me a compile with your mod to play around with? I want to see if a piece of music I'm consistently getting clicking with in Dolphin, in both 4.0-330 and 3.5-322, will still do so.
And thanks to both of you for your work.
The LR is likely to be reversed inside the emulator somewhere, I noticed that the upsampling swaps the channels as it goes.
The clicking hints at a rounding error, the upsampler code takes a generic factor as the rate between the samples, however, as I already know that it's a 3/2 conversion I can probably try tweaking the timing factor manually. Currently there's a rounding error being that it's trying to increment time as:
0.0
0.666666
1.333333
1.999999
I suspect that the loss of .000001 every 3 samples eventually causes a sample to be taken from the previous one. Although I'd have thought it'd take a heck of a lot of samples before that would occur. So it might not be that...
Any particular System Menu that you're using? Otherwise I'll probably grab the PAL one (as all my games are PAL) I just have to download or extract one.
Mine is NTSC, from 2008, and Dolphin shows it as RVL-WiiSystemmenu-v449, although that doesn't correlate obviously to any versions listed on the Wiki. Oh well, if a version from one of your games works for you, great, if not, you can still see spikes in the spectogram when recording during gameplay as well so it shouldn't be a problem. Zoom in on the spikes and then switch to waveform view and you should be able to find a glitch in that area.
nusd pulled down the 449 version, I've just tried it out, and the spectro graphs look ok on LLE recompiler and HLE with Xaudio2 output.
See attached image (or is there something on there that I'm not thinking is a glitch but is?
That looks good. The attached picture is what I'm getting when I do it with your fix. I'm using LLE recompiler and XAudio2 as well. I've checked with the system menu, Shiren the Wanderer, Kirby Air Ride, and Mario Kart: Double Dash and I get spikes in the spectogram with all of them. How do recordings during gameplay look for you?
hmm, I wonder if I mixed up zip files. On the google drive there's a glitch_fix.zip, that's the one I tested out, and gave the output I graphed...
I am pleased to report that that version works perfectly! Thanks for implementing this. I'm happy my suggestion of SoX turned out to be a useful for you. I hope your work can be added to the master branch.
Now, as far as I can see there are three more sound issues with Dolphin and I'd like to know if you might have an idea as to the causes of them. First is the treble loss that is happening mostly in the mixer per moosehunter's results. Did you see anything in the code that might explain this?
Second is something I would have thought related to the resampling, but now I'm not really sure. As you could see in your spectogram of the Wii system menu music, there are two lines, one each at 15 kHz and 17 kHz. That seems a conspicuous place to have them seeing as those are either side of the 16 kHz Nyquist frequency of the Wii. You can even hear them (assuming you can still hear up that high) as a kind of noisiness not present on the real Wii. You can see that here.
I sample-aligned the recordings and inverted the phase of one of them, then mixed them together so they cancel out and boosted the volume by nearly 20 dB to properly hear the differences between the two. And this does make the noise easily audible. As I've said before, my recording device has a relatively high noise floor and increasing the volume here made that pretty apparent too, so I took a noiseprint of the buzz from the beginning before the music starts and canceled it out in the rest. I've put the pre-and-post noise reduction versions in
this zip so you can hear this artifact easily. This happens in other music as well, it's not just the system menu. Do you have any idea what causes this? I wonder if it's present in the audio before it gets to the mixer. This is one of the things I'd like to test with moosehunter's modification to narrow down where it's being introduced.
The last problem is the clicks and crackles that happen sometimes.
Here is a zip with volume-matched recordings of a piece of music from my Wii and from Dolphin (using your most recent fix, but it doesn't matter which revision is used, I get clicks in all I've tried). Many are subtle but it shouldn't be too hard to hear them if you're looking for them; some are larger than others, but a really obvious one is at 25.977 seconds in the left channel. If you look at the waveform, it's a short, sharp peak instead of an issue like a repeated sample. There's another at 16.275 seconds. Clicks don't normally look like this. It's always there, every time, any Dolphin version. The Wii recording verifies these clicks are incorrect behavior. What could be causing consistent clicking glitches? Here again, being able to get at the audio pre-mixer would tell us generally at which point this is going wrong.
Does the click vary with HLE or LLE? IE is it always there?
It does look quite odd, and as you say it's not a repeat, it looks like something doing the wrong math on something. Given it's there in all versions with upsampling, I'd say it's unlikely to be the upsampling code (as the one I put in is different from what was there)
I'll admit to struggling to hear them all clearly, (but then I'm in my thirties so lost a bit of khz range)
FYI, I tried to get the soxr library working, I just couldn't get it to pass audio through properly (I suspect it doesn't like being asked for really small buffers....)
The effect around 16khz is probably tunable, it's part of how that LPF works, and depending on the beta set it can be more or less aggressive.
Looking at the 32khz data, the glitches are also in there.
Grab the 32khz_dump.zip from the drive, it's a new build which also dumps out the 32khz data (you'll find two .wav files saved. Note it doesn't have the resampler I did in it, it's just the standard one.
It appears that the emulator is running faster than the audio stream, and so the audio buffer fills up. In doing so, the audio starts to drop. This is why it takes a minute or so before the clicking comes in...
Oh and if you set the framelimit to be "audio" I suspect that the problem goes away as the buffer being full stalls the cpu a little till there's space.
Ah, didn't realize SoX didn't work for you at all. Congratulations on your work then.
The clicks do appear with HLE and LLE in the same places every time I play the game, even when starting the game from the beginning instead of skipping to the part using a save state, and I always have Dolphin set to framelimit by audio.
With the 32khz_dump build I'm still getting the clicks in the preSampler WAV with both HLE and LLE.

I was hoping this wouldn't be the case since I expect it'll be harder to determine the cause if it's introduced before this point. (By the way, your build is missing XAudio2 for some reason and has a blank in the box for audio backend when it's selected in another build of Dolphin that shares the configuration files. It will record sound normally when you start the game with the blank in the box but it doesn't output sound while the game is playing.) Thanks very much for giving me a mod that does this though!
The noise I demonstrated in the Wii system menu is present in the regular and old builds of Dolphin, so it couldn't be caused by the lowpass filter, right? It must be related to the resampling though since the noise is not made in the preSampler output. Is that what you were referring to when you said, "Looking at the 32khz data, the glitches are also in there,"? Because I am definitely not getting the noise in the 32 kHz dump.
In what game are you getting clicking?