digimezzo / dopamine-windows

Audio player which tries to make organizing and listening to music as simple and pretty as possible.
https://digimezzo.github.io/site/
GNU General Public License v3.0
1.85k stars 263 forks source link

Spectrum analyzer performance is bad when using DirectSoundOut #694

Open digimezzo opened 6 years ago

digimezzo commented 6 years ago

By default, Dopamine uses WasapiOut as ISoundOut implementation. In combination with WasapiOut, FFMpegDecoder is used to decode audio files. This works well on "normal" editions of Windows. Unfortunately, there exist "N" editions of Windows which don't have the "Windows Media Feature Pack" installed by default (it can be installed by the user manually). This means that Windows Media Foundation is not installed on those systems.

FFMpegDecoder relies on DMO, which is part of Media Foundation. Because of this dependency, Dopamine is unable to play audio on N editions of Windows. Because a lot of users don't know there exist N editions of Windows, and because other players play audio fine, even without Media Foundation, I get a lot of reports that Dopamine doesn't work. See this CSCore issue for reference: https://github.com/filoe/cscore/issues/330

To work around that, for systems which don't have Media Foundation, Dopamine now uses DirectSoundOut in combination with FFMegDecoder. Of course, users loose automatic device switching when using DIrectSoundOut, but it is still an acceptable workaround, as audio will, at least, play. As soon as the user installs Media Feature Pack, Dopamine switches to WasapiOut.

There is however, an additional issue with DirectSoundOut: the spectrum analyzer is impossibly slow. Due to this, and because I couldn't figure out why it is so slow with DirectSoundOut, I disable the spectrum analyzer as soon as Dopamine detects that it needs to use DirectSoundOut. So, users without Media Foundation, won't see the spectrum analyzer.

Conclusion: it would be great to find out why the spectrum analyzer is slow in combination with DirectSoundOut.

filoe commented 6 years ago

It is "bad" because DirectSound is working with a far lower latency. You can try to decrease the latency even further but it is hard to tell how low you can go.

digimezzo commented 6 years ago

@filoe Thanks for confirming that. My first impression was indeed that with lower latencies it works a bit better. I'm just worries there might be interruptions in audio when going too low.

filoe commented 6 years ago

That's the problem. When going too low, there will be interruptions.