musescore / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
12.39k stars 2.68k forks source link

Playback high pitched and/or sped up/faster when using multi-channel or surround WASAPI Audio Output (Buffering issue) #17648

Closed heisluft closed 2 months ago

heisluft commented 1 year ago

Issue type

General playback bug

Bug description

MuseScore 4 does not handle Surround WASAPI output correctly, the samples intended only for two channels gets split up into all channels (can be seen in my mixer software, see atached video), so when the remaining samples (in my case only 1/4 of all samples (7.1 configuration)) get played pack, it sounds hig pitched and sped up. I discovered this while testing builds for #15235 (Although the issue should persist scince MultiChannel Output was first introduced in #15698.

Steps to reproduce

  1. start a mu4 instance built with code from #15698.
  2. select a multi channel WASAPI output in settings
  3. Playback any note or song
  4. Sounds high-pitched and sped up. In mixing software of the audio device it can be seen that all channels of it receive input, not just the first two.

Screenshots/Screen recordings

https://user-images.githubusercontent.com/30872344/223803798-83b0316b-dd1f-4826-b072-44ac51783762.mp4

MuseScore Version

= 4.0.1

Regression

No.

Operating system

Windows 10

Additional context

No response

cbjeukendrup commented 1 year ago

I had a proof-of-concept fix in https://github.com/musescore/MuseScore/commit/47928a8ae072316b3df2634a2b598d5636a66db4, but it was deemed "not nice" (which I actually agree with. I don't quite see a better solution though.)

bkunda commented 1 year ago

@RomanPudashkin @cbjeukendrup perhaps we need to have a chat about this to discuss for which project we should prioritise it.

Jojo-1000 commented 1 year ago

@cbjeukendrup I already have a prettier fix for this, where I put the channel change in the mixer (so the sound generation still runs on two channels, then the mixer uses that to fill two of the surround channels). I think this is better than trying to make all of the instruments and effects surround-capable. There are still some device change glitches I wanted to fix and didn't get around to, but otherwise it runs fine. If that sounds good to you, I will create a pull request.

cbjeukendrup commented 1 year ago

@Jojo-1000 That certainly sounds good! Would be great if you could open a PR with what you have so far, and then we can look into the device change glitches later.

DmitryArefiev commented 1 year ago

@heisluft Can you check #17669 please if it fixes your issue? Thanks!

heisluft commented 1 year ago

Hey @DmitryArefiev I would like to, however the actions of the PR don't seem to have produced a downloadable artifact and I don't have the ability rn to get a QT installation up & runnning, so I am unable to compile MU myself. Would it be possible to link me an artifact generated by CI?

cbjeukendrup commented 1 year ago

@heisluft Here is the link to download the builds: https://github.com/musescore/MuseScore/actions/runs/5039329182 (To find it, on the pull request page, go to the "Checks" tab and click the Windows check, which should bring you to this download page.)

heisluft commented 1 year ago

Thanks alot! The PR indeed fixes the issue. Looking forward to the release ^^

Also, I find the theoretical Possibility of surround mixes very intriguing, combined with musesounds it'd make for an even better cinematic scoring experience!

jods4 commented 3 months ago

What's up with this issue? The last comments, dated May 2023, suggests there was a working fix available in a PR but it was never merged.

I have a 4 speakers setup and I just tried the current MuseScore 4.4.0 release: its playback is high-pitched (doubled frequency). Changing my Windows 10 configuration to use only 2 speakers fixes the MuseScore issue (to the detriment of my speakers, of course).

cbjeukendrup commented 3 months ago

The implementation suggested in the linked PR is not ideal because it involves locking, which we quite strongly want to avoid in the audio engine because it may negatively affect performance.

At some point earlier, I created a less involving workaround for this problem; this was also not merged for the reason that it was a workaround and added yet another layer of processing, albeit a simple one. But since it looks like it's going to take some time to find a real solution, Roman recently proposed to revive that workaround. So we'll probably do that in the not-too-far future.

DmitryArefiev commented 2 months ago

@heisluft Can you check latest nightly please? https://github.com/musescore/MuseScore/actions/runs/11049808270

Jojo-1000 commented 2 months ago

@DmitryArefiev I can confirm that the playback is normal on my device with this version.

heisluft commented 2 months ago

@DmitryArefiev Works as expected. Thank you!

DmitryArefiev commented 2 months ago

Thanks for checking! Kudos to @mathesoncalum !

mathesoncalum commented 2 months ago

All credit to @cbjeukendrup & @RomanPudashkin!

rienheuver commented 2 months ago

This works for me too, wonderful!