-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix a lot of issues related to no sound on mac #3492
Conversation
Let's open a discussion. I've fixed the bug, sound appeared on MacBook 12".
|
If only Mac is affected by that problem, why making that change for all OSs? |
In general, I agree. We know about Mac issues, also we know about Bluetooth issues, which may be related. But, if we don't know, it doesn't mean that no issues exist. Since we have specific limit in our code, we cannot expect any value here. So, we have to control it somehow. I would prefer to set minimal value, but there is no option. |
AFAIK the bluetooth issues are Mac only too? |
mscore/pa.cpp
Outdated
@@ -125,11 +125,15 @@ bool Portaudio::init(bool) | |||
#endif | |||
out.hostApiSpecificStreamInfo = 0; | |||
|
|||
err = Pa_OpenStream(&stream, 0, &out, double(_sampleRate), 0, 0, paCallback, (void*)this); | |||
int defaultFramesToProcessFromCallback = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned long
rather than int
This is old but maybe it helps? |
Awesome. Very glad we have a solid explanation for the problem. I don't think it's a good idea to hard code the I'm also pretty sure that it's related with "Bluetooth not working" I believe bluetooth will typically use smaller |
Is there something to learn from what Audacity does? It is working reliably for me on MacBook 12", for built-in and BT and USB.
|
I'm wondering... if this is actually consistent with the symptoms I am seeing on my MacBook 12":
|
Don't afraid huge changes in voice.cpp - it is just extracting huge write logic to separate methods. What I've done actually is generating envelope for minimum 100 frames. If framesBuf from pa is less, we generate envelope for 100 anyway but send only framesBuf number of frames. It results in weak attack and ending sound of notes. I'm trying to use cache data, but still no success. To emulate no sound case as on MacBook 12 or bluetooth, set fifth argument of Pa_OpenStream in pa.cpp to desired small buff size (39 - for MacBook, 14 - for bluetooth from experiments). |
Hi Anatoly, nice job there!
1. Just to let you know that on MacBook 12” I have no problem with MuseScore Bluetooth audio.
Also, HDMI and USB audio outputs are OK.
Only built-in audio is a problem. (And also AirPlay, but I haven’t rigorously confirmed that one).
Is this consistent with your findings?
2. I have found that if built-in audio is in a working state (rarely!), I can cause it to fail by selecting and deselecting the Bluetooth. However, BT itself does not have an issue - at least I have not observed one yet despite extensive testing.
3. A related issue is that MS includes input devices in the output device dropdown, and they are often not identified as inputs. Therefore users may select an input device by accident, resulting in silence - I think that may be responsible for some of the no-audio reports.
Sorry to bug you, hope it’s useful!
Howard
… On Feb 27, 2018, at 08:15, Anatoly ***@***.***> wrote:
Don't afraid huge changes in voice.cpp - it is just extracting huge write logic to separate methods. What I've done actually is generating envelope for minimum 100 frames. If framesBuf from pa is less, we generate envelope for 100 anyway but send only framesBuf number of frames. It results in weak attack and ending sound of notes. I'm trying to use cache data, but still no success.
To emulate no sound case as on MacBook 12 or bluetooth, set fifth argument of Pa_OpenStream in pa.cpp to desired small buff size (39 - for MacBook, 14 - for bluetooth from experiments).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#3492 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AZMeiv49__Ra1tQhJ4IxoZ8VdxB5PLfTks5tZAACgaJpZM4SR61U>.
|
Finished implementation of the cache. Reverted all changes in pa.cpp to keep optimal buffer size. So, for now, I cannot imagine a case when there is no sound because of buffer size. This PR is supposed to fix MacBook 12" no sound issues, bluetooth issues. According to my investigation, slow computers also could be affected. I tried to describe all the changes in commit log, but logic in Voice and dip generation is too complex. BTW, I enriched my knowledge :) This PR should be thoroughly tested in terms of sound quality. There should be no glitches, no rattling, no noise. Everything we find, I will fix... I'm happy now. Long weekends are waiting for me :) |
Would be great to also fix the display of input devices in the output list, as selecting those would cause no sound also. Furthermore fix the truncation of the entries in that list. |
fix the display of input devices in the output list, as selecting those would cause no sound also This is a totally different bug. So please, not in this PR. |
@lasconic for sure. I was not even going to :) |
Hi Anatoly, sounds great! I’m ready to test thoroughly. How will I know which build has the fix?
Thanks, Howard
… On Mar 1, 2018, at 12:36, Anatoly ***@***.***> wrote:
Finished implementation of the cache. Reverted all changes in pa.cpp to keep optimal buffer size. So, for now, I cannot imagine a case when there is no sound because of buffer size. This PR is supposed to fix MacBook 12" no sound issues, bluetooth issues. According to my investigation, slow computers also could be affected.
I tried to describe all the changes in commit log, but logic in Voice and dip generation is too complex. BTW, I enriched my knowledge :)
This PR should be thoroughly tested in terms of sound quality. There should be no glitches, no rattling, no noise. Everything we find, I will fix...
I'm happy now. Long weekends are waiting for me :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#3492 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AZMeisH9mi8NYoe2YpI12xttSvdfJ1dFks5taDFfgaJpZM4SR61U>.
|
Well, there is no build with fix I suppose until this PR will be merged to master... Are you a developer? Are you building MuseScore sources? |
Hi Anatoly - I’m a software engineer but I’m not a developer on this project.
For this one I’m just an anxious user and tester!
I’m hoping to get the sound fixed on v 2.1 (or 2.2 I guess).
I’m not familiar with how up-revs happen here…
Howard
… On Mar 1, 2018, at 13:18, Anatoly ***@***.***> wrote:
Well, there is no build with fix I suppose until this PR will be merged to master... Are you a developer? Are you building MuseScore sources?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#3492 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AZMeimxTwAx6wxVTug0nPWITO4wTHI57ks5taDuGgaJpZM4SR61U>.
|
But since Travis and AppVeyor work on this build, I believe they should create build with this PR. @lasconic, am I right? |
Only Appveyor creates downloadable builds from PR. So only for windows. |
The good news, it sounds ok with internal speakers and I have sound via bluetooth (after a MuseScore restart but that's expected) The not so good news, Bluetooth playback is not as good than the internal speakers, I hear some glitches. |
@lasconic did you use MacOS debug build for testing using code from this PR or downloaded AppVeyor's package and ran MuseScore on virtual machine? I've checked sound on both Windows debug build and downloaded AppVeyor's build with my JBL Charger 3 Bluetooth speaker. Sound is good, without noise or glitches with the default (1024 even with Bluetooth) number of frames and the hardcoded 14 frames as you mentioned you had for bluetooth headphones, Sound is still great even after switching devices on the fly. Maybe, it is about computers with less memory or CPU resources... |
I tested on MacOS debug. Tried now with release. Same problem : glitches with bluetooth headphones. |
With my QC35 headphones, n = 14 in |
Significant clue someone mentioned and I’ve confirmed to be dependable after multiple tests (with released version 2.1) - no counterexample so far:
1. Start with MuseScore in its “no-audio” situation.
2. Close MS
3. Plug in the earbuds
4. Start MS
Result: earbud audio works
5. Unplug the earbuds (with MS still running)
Result: built-in audio works
… On Mar 5, 2018, at 14:49, Anatoly ***@***.***> wrote:
@lasconic <https://github.com/lasconic> did you use MacOS debug build for testing using code from this PR or downloaded AppVeyor's package and ran MuseScore on virtual machine?
I've checked sound on both Windows debug build and downloaded AppVeyor's build with my JBL Charger 3 Bluetooth speaker. Sound is good, without noise or glitches with the default (1024 even with Bluetooth) number of frames and the hardcoded 14 frames as you mentioned you had for bluetooth headphones, Sound is still great even after switching devices on the fly.
Maybe, it is about computers with less memory or CPU resources...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#3492 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AZMeilptp8zxkOra8dRAbMFqL-UezOEPks5tbZZXgaJpZM4SR61U>.
|
@lasconic, I've reproduced the case on MacOS. My CPU utilisation directly correlates with number of glitches. While playing tremolos for Viola, it glitches hardly and CPU usage is about 100%... |
@polarbreeze, we are discussing not merged changes to master and 2.2. After I finish with it, you can test it using nightly build. Speaking about switching devices, the issue exists, indeed. But it is another issue, so I'll switch there later. |
OK, thanks Anatoly
… On Mar 6, 2018, at 04:00, Anatoly ***@***.***> wrote:
@polarbreeze <https://github.com/polarbreeze>, we are discussing not merged changes to master and 2.2. After I finish with it, you can test it using nightly build.
Speaking about switching devices, the issue exists, indeed. But it is another issue, so I'll switch there later.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#3492 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AZMeinIIjSZ1EAuZfKyu-Q_Q80q6ByJuks5tblA9gaJpZM4SR61U>.
|
@lasconic I've added comments and fixed bluetooth devices issue. There is last issue with small noise on stopping playback, but it is not critical. I'll find way to fix it. |
Awesome. Let me test. |
Hardcoded frames buffer size is seemed to solve the issues, but it may lead to performance issues. Correct soultion is in progress on master (see musescore#3492).
… framesBuff from PortAudio is too small If we don't specify framesPerBuffer parameter in Pa_OpenStream, PortAudio will choose optimal value for particular callback call. It can vary from run to run even on the same hardware depending on available system resources. While generating signal, interpolating and applying effects, we assume that framesBuffer contains more than minimal number of frames to generate envelope. BTW, it is not true. If framesBuffer is smaller, algos cannot generate correct sound and just keep silence. I've implemented cache which keeps generated values from dsp algorithms and applies it step-by-step to buffer values from pa_callback. Cache is filled each time algos generate dsp values. If buffer frames are not enough to generate envelope, algos generate values for further calls and keep it in cache. Required number of frames has been selected as a number of frames for one phase multiplying by number of phases. Actually, smaller numbers of this value generates good results, but it is better to keep it as max as possible to provide perfect sound. Code changes: - Replaced C-like variables with std containers for comfortable debugging and better usage - Extracted similar code calls to separate methods - Implemented cache as std constainers, so also implemented convertion from std::vector to C-like float* to fill the pa buffer - Changed the logic of applying effects and interpolation, it is now possible to use them separately. This is required to fill effects several times after calculating the interpolation is finished. Removed std::vector<float> to keep cache - process buff values on the fly. Performance is better, but still glitches on https://musescore.com/user/166080/scores/175421. BuffSize = 64 with my wired headphones.
met's align master with 2.2 by merging this one on master too. See #3518 |
If we don't specify framesPerBuffer parameter in Pa_OpenStream, PortAudio will choose (randomly?) the value. In Voice::write, we assume that RestN which initially keeps the value of frames from pa_callback will be bigger than env_data->count. The last is 43 on my Mac (47 on my Ubuntu machine), but default frames count from pa callback on failed MacBook 12" is 39. So, we cannot correctly process all frames and envelop and produce sound, specifically amplitude calculation fails and Voice::write returns under this if statement 'if (volenv_section == FLUID_VOICE_ENVDELAY)'.
So, I hardcoded 630 since it is the value from my Mac. Also I've got 1027 for Ubuntu.