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
11.86k stars 2.57k forks source link

Playback has different pitch when switching between audio devices with different sample rate during one session #17877

Open DmitryArefiev opened 1 year ago

DmitryArefiev commented 1 year ago

Issue type

General playback bug

Bug description

No response

Steps to reproduce

  1. Make sure your two audio devices connected have different sample rate (e.g. 44 and 48 kHz)
  2. Run MU
  3. Check playback
  4. Go to Preferences>I/O>Audio device
  5. Switch to another audio device
  6. Check playback - playback has different pitch

Screenshots/Screen recordings

I have external Audient iD14 with 44kHz iD44

and internal Realtek with 48kHz

Realtek48

MuseScore Version

4.1

Regression

No. In MS3 changing between audio devices during one session doesn't work

Operating system

Windows10

Additional context

After MU restart all good

DmitryArefiev commented 1 year ago

There are two kind of fixes could be here:

  1. Correct switching of playback sample rate in real time
  2. Show a message to user to restart MU (if sample rate of new device is different)
bkunda commented 1 year ago

I've just been able to confirm that I too can reproduce this issue. My scores play back one tone lower when routed through my external amplifier (Cambridge Audio CXA61). Problem resolves when switching to this output device, then restarting MuseScore.

(Testing in 4.1 RC).

DmitryArefiev commented 10 months ago

Also might happen when switching between internal audio and bluetooth headphones (see #19223)

optimizasean commented 6 months ago

Adding to this - it appears to fail on any resolution other than 44.1khz 24bit. Playback speed and pitch are approximate to the sample rate (higher than MU it plays shorter and higher pitch, lower than MU it plays slower and lower pitch).

Requires control of soundcard (cannot function with external soundcards unless Windows can override playback settings for them .Note: careful may cause issues with other usage of your device including crashing apps, playback failure or issues, general device issues, ... and same goes for other soundcards and playback devices

Very difficult to identify this was as a specific known bug and that no fix is available as of yet in any version. Happens 100% of the time with MU4 (latest main as of now) in Windows 10/11. Tested across multiple external soundcards and headsets (many do not have the ability to run in other sample rates or are not configurable). In general, having to run your soundcard manually at other sample rates is not desired behavior for any user as it interferes with many other software and their audio playback including browsers/YouTube/... commonly used with MuseScore (like when transcribing or exporting play-along tracks or using other plugins/sound fonts/....).

optimizasean commented 6 months ago

I am not too familiar with audio at the playback level in MuseScore - is a potential stopgap measure (or solution) to have a way to scale the playback of the output? If you could either set default as is or detect the soundcard settings and match, then allow further scaling based on a dropdown menu, could this be achieved through existing audio libraries or internal to MuseScore?

I have found some existing forum posts using Jack to manage audio routing to get around this but it would be ideal to have this ability built in (either as scaling or routing - not sure which is better implementation or difficulty wise).

DmitryArefiev commented 1 month ago

There are two kind of fixes could be here:

1. Correct switching of playback sample rate in real time

2. Show a message to user to restart MU (if sample rate of new device is different)

@bkunda What about to try implement №2 in 4.4 release? (it's easier than №1)