Dolphin, the GameCube and Wii emulator - Forums

Full Version: How/why does Dolphin generate sound frequencies above 17 KHz?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
I tracked down the revision with the fix for the 1.5 hour audio bug; it was 1591. The little pops and clicks are present there, but they're also present in the revision prior to that, so that's not the cause. EDIT: I said something different here before but investigated further. It appears that I'm not consistently getting more of the clicks in the later revisions than I am in 322. They seem more prone to it, but it doesn't always happen. I haven't heard these sounds in other games, but I don't play many. I believe Xenoblade Chronicles has been reported as suffering from this problem, but I don't have it or I'd see if I have the same experience.
I believe that's fairly normal with up-sampling, and often a low-pass filter is added to try and remove the unexpected data.

Looking at the code it's just doing a linear interpolation, without any kind of low pass filter on it, hence it going over 16khz (half the original sample rate).

I happened to be looking in that code just to see if there was anything in there causing audio break-ups, appears that it's not that area that's the problem, it's run out of samples in the mixer and so just repeats the last data (my old i7-920 isn't quite up to running things at full speed Sad)

Attached is a patch that might help a little bit, I add a special case for 32k to 48k conversions. By special casing the code it looks at the next 2 samples, and makes 3 samples from them (it's still a linear interpolation). It then applies a really basic low pass filter at 16khz.

To do the low pass filter properly would need a better algorithm for the conversion (at least it's in a different thread so could take the time to do something different)

Note that the patch isn't anywhere near as clean (or tidy) as I'd like, but I figured it might give you something to play with, and is against the git master from today.
Ah, how fortunate. Would you mind compiling that for Windows x64 for me? Searching for how to apply a patch I find the pauldacheez quote, "Applying patches is some complex shit. Unless you're willing to learn how to use Git and compile Dolphin yourself, you're out of luck."
(11-10-2013, 02:17 PM)nothingtosay Wrote: [ -> ]Ah, how fortunate. Would you mind compiling that for Windows x64 for me? Searching for how to apply a patch I find the pauldacheez quote, "Applying patches is some complex shit. Unless you're willing to learn how to use Git and compile Dolphin yourself, you're out of luck."
Ah, guess the developer in me think it's not that complex to use git and have visual studio compile it Wink

I'll have to find a file sharing thing to upload via (forum limit is 1MB, but the zip is 7MB).

but on my brief analysis of the intro to zelda TP the frequency analysis shows a change in the frequency response (adacity frequency analysis shows slightly lower response at the top), and I think slightly less popping, however, it's hard to know am I hearing a slight difference because I want to Smile



I'll do some more work to try and find a better low pass filter that can kill most of the noise over 16khz.
MediaFire is good, fast, and free. Don't know if there are any places that let you upload without an account anymore.


If the problem is introduced from a sub-optimal resampling algorithm, one of the best resamplers is open source: SoX. I don't know if incorporating it into Dolphin would be sensible, feasible, or efficient, but the idea is the only contribution this layperson can make. Maybe just a part of its code could be used or an idea gained by looking at it.
(11-11-2013, 05:49 AM)nothingtosay Wrote: [ -> ]MediaFire is good, fast, and free. Don't know if there are any places that let you upload without an account anymore.


If the problem is introduced from a sub-optimal resampling algorithm, one of the best resamplers is open source: SoX. I don't know if incorporating it into Dolphin would be sensible, feasible, or efficient, but the idea is the only contribution this layperson can make. Maybe just a part of its code could be used or an idea gained by looking at it.
I didn't see SoX when looking around, I did find a resampler and libresampler.

With a bit of messing around, I've managed to change the the conversion code to do a better resampling job.

SoX does look like it's got a better API (assuming the endianness of the DSP PCM data can be accounted for) Something to look at another day.

In the meantime, I've uploaded a build to:
https://drive.google.com/folderview?id=0Bw73DvmT5qKXSlBaSHo3SVJZSUE


You should be able to click the zip file, and then download it.

The diffs are a mess at the moment, however, I'm more interested in if it actually solves the problem, if it does I'll look at how to tidy up the code, and also at SoX.

As it might be better to use a library that provides all the necessary goodness, and copes with the various hardware configs out there.

Certainly in my testing this build pretty much drops anything over 16khz (it does have a slope though, so there is some up to about 17khz)
Tried it but i didn't find any audio issues fixed by it...
Mere Wrote:I didn't see SoX when looking around, I did find a resampler and libresampler.
Yeah, I linked directly to the resampler portion of the larger program. I think it's the most popular part so they separated it for the convenience of people who want to use only it.

Thank you very much for your efforts and for compiling for me. I'll test anything you try out.

Mere Wrote:Certainly in my testing this build pretty much drops anything over 16khz (it does have a slope though, so there is some up to about 17khz)
There is a slope to the real Wii as well, going up to about 18 kHz. Is the slope configurable in any way so that it could be made to more closely emulate the hardware? The Wii lowpass seems to cut hard at 18 kHz, whereas SoX lets some through. (This is a pretty minor thing since I doubt it will change sound quality at all, but I figure it's worth doing if it can be done easily.) Here is a comparison of a 10-second channel intro (Shiren the Wanderer again) on hardware and with your patch.


I'm sure you noticed those frequency spikes in the recording from the patched Dolphin. Well, I do indeed still get the occasional clicking sounds, so the lowpass filter doesn't seem to have fixed that. In fact, it seems to have made some new ones, I'm sorry to say. Sad With the regular 4.0-330 I don't get any clicks when starting up the Wii system menu, but the patched version always produces four (at least) very clear clicks during the initial crescendo of music that it begins with. This is what they look like in the waveform:


Those frequency spikes correlate with glitches like the one shown there. It's not as bad as it looks in the channel intro recording because they're not all audible, I suppose they're being masked by the rest of the loud music, but obviously each spike represents a glitch that shouldn't happen. It doesn't appear to be 100% deterministic in where and when they appear as I've gotten a wide variance in the number and placing of them just in recording that 10-second channel intro. But some do appear to be consistent, like in the system menu music and the majority of spikes in the channel intro happen in the same places but not always with the same strength. The clicks happen in all audio backends. Any idea what's up with this? Are you getting the same thing?
The slope can be tuned I think.

Hmm, the glitch looks more like it stepped back in time for one sample.

Having had you point it out, if I use the spectro view and zoom into one of the spikes I can clearly see it.

Certainly odd. It could be my logic to try and keep the offset into the timeline is going askew and rolls back one sample now and again...

Ok the glitch should be fixed, I'm not seeing them in the zelda TP intro. Turned out to be a wrapping issue which meant the code was throwing away the time offset into, and it was reset, which meant it was reading the same sample point again. The reason for the irregularity is that the buffer had to wrap, and the time offset be non zero (due to the 2/3 ration of 32/48 there was a 1/3 chance).

(I'd actually assumed the spectro graph spikes were when the emulator couldn't keep up Sad)

There's a new version on the drive share:
resampler_fix_x64-2013-11-11.zip

I've also changed turned the aggressiveness of the filter, not sure if it's better or worse, but it does run till around 18khz now.
(11-09-2013, 11:53 AM)delroth Wrote: [ -> ]Do you have some programming skills? If so, you should try to patch Dolphin to dump audio before the AudioCommon Mixer does stuff to it. If not, hope that a developer will do that so that we can have more info on why Dolphin generates these frequencies. My guess: resampling done in the AudioCommon mixer introduces these problems (and we already know it's very broken).
Here you go. There's the Dolphin resampled audio, the audio before resampling, and the audio before resampling resampled by Audacity.


32000 Hz: https://mega.co.nz/#!SNMiAZAT!IiHnqlRa76a0wkEGOc7mUFiC5Yh1keDO4boxCiVGqKY
48 KHz: https://mega.co.nz/#!rdVRCCya!C2zphkf1McCq8rCVqZ-3_g1D4K0yCVhzqQHLDqb-YBM
Pages: 1 2 3 4