Skip to content
This repository has been archived by the owner on Dec 18, 2022. It is now read-only.

Pop when starting playback on WASAPI backend #288

Open
1 task done
nyanpasu64 opened this issue Jul 17, 2021 · 14 comments · May be fixed by #430
Open
1 task done

Pop when starting playback on WASAPI backend #288

nyanpasu64 opened this issue Jul 17, 2021 · 14 comments · May be fixed by #430
Assignees
Labels
bug Some kind of fixable problem was encountered high priority

Comments

@nyanpasu64
Copy link
Contributor

  • I have read the specified guidelines for issues

Describe the bug
When using the WASAPI backend on Windows, Tenacity usually pops when playback starts.

To Reproduce
Steps to reproduce the behavior:

  1. Open an audio file in Tenacity.
  2. In the toolbar, switch the audio backend (the leftmost dropdown box) from "MME" to "Windows WASAPI".
  3. Click on a non-silent part of the waveform and press Space to play.

Expected behavior
Playback occurs smoothly.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional information (please complete the following information):

  • OS: Windows 10 x64
  • Version: Git as of a few days ago

Additional context
Updating PortAudio to v19.7.0 fixes this bug. However it's tricky to make newer versions of PortAudio build and link properly, either through CMake proxies (I gave up on this approach but it might be workable) or by using PortAudio's native CMakeLists.txt (by disabling PortMixer through -Duse_portmixer=off and removing the usage of PaUtil_GetTime). I can push my hacky branch if anyone's interested, but I think stock PortAudio is missing loopback capture.

My guess is that this issue is fixed by PortAudio/portaudio@697fcdd, or less likely PortAudio/portaudio@9ebe293. However I don't know if cherry-picking is the right approach or we should upgrade PortAudio altogether.


After fixing this bug (which obscured the beginning of playback with loud pops), I noticed that WASAPI has a bit of "fade-in" unlike MME and DirectSound, but only if the first sample being played is significantly nonzero. This is present in Audacity 3.0.2, as well as Tenacity with both old and new PortAudio. I don't know if it's caused by WASAPI or PortAudio. I'd personally prefer if it could be disabled or removed, so you can hear the beginning of audio files properly (for example the attack of a sampled instrument), but I'm not sure how to remove it, and I don't know if it's worth the trouble.

@emabrey emabrey added bug Some kind of fixable problem was encountered high priority labels Jul 26, 2021
@Be-ing
Copy link
Contributor

Be-ing commented Aug 1, 2021

However I don't know if cherry-picking is the right approach or we should upgrade PortAudio altogether.

Neither, we should devendor all dependencies: #228

@nyanpasu64
Copy link
Contributor Author

Will devendoring dependencies make it less self-contained and more difficult to build on Windows without using external package managers like vcpkg?

@Be-ing
Copy link
Contributor

Be-ing commented Aug 1, 2021

Yes, that's the point. But it won't be difficult to build with vcpkg.

@emabrey
Copy link
Member

emabrey commented Aug 6, 2021

I may have incidentally addressed this issue with https://github.com/tenacityteam/tenacity/pull/430. If possible, can you build and test that PR locally and tell me if you can still repro the issue or if it is fixed? I was having popping issues and addressed them, and I have reason to believe it may also have fixed this issue.

@emabrey emabrey self-assigned this Aug 6, 2021
@emabrey emabrey linked a pull request Aug 6, 2021 that will close this issue
5 tasks
@nyanpasu64
Copy link
Contributor Author

I tried building that branch with the one-line fix to make it build. The audio playback bug is not fixed.

Apparently I failed to mention in this bug report, but even with AudioIO stubbed out to skip all function calls and instead fill the output buffer with nothing but a DC offset, the program still produces a crackle on old PortAudio, and only stops crackling on new PortAudio. So it's not Audacity or Tenacity's fault, but PortAudio's.

@emabrey
Copy link
Member

emabrey commented Aug 6, 2021

Ah, see I didn't know that you'd stubbed out the functions. In that case you are right, and it seems the only thing to do is to replace the PortAudio version used.

@Paul-Licameli
Copy link
Contributor

I tried building that branch with the one-line fix to make it build. The audio playback bug is not fixed.

I'm not surprised.

@Paul-Licameli
Copy link
Contributor

I tried building that branch with the one-line fix to make it build. The audio playback bug is not fixed.

I'm not surprised.

Why the confused face, @nyanpasu64 ?

@emabrey
Copy link
Member

emabrey commented Aug 8, 2021

I tried building that branch with the one-line fix to make it build. The audio playback bug is not fixed.

I'm not surprised.

Well considering that I wasn't trying to fix the issue, I just did something that may have fixed it as I had not diagnosed the source of the issue yet, not being surprised that it didn't work is entirely unremarkable. Please stop leaving passive-aggressive comments on everything I do on this repository.

@Paul-Licameli
Copy link
Contributor

Well considering that I wasn't trying to fix the issue, I just did something that may have fixed it as I had not diagnosed the source of the issue yet, not being surprised that it didn't work is entirely unremarkable. Please stop leaving passive-aggressive comments on everything I do on this repository.

Everything? No.

Only this one overthought and overconfident thing #412 you did, and pushed without anyone else reviewing it beforehand, which was a "fix" for a non-problem, and put in memory leaks necessitating other fixes of the fix, and is still in search of its bug, but sadly failing to find it here.

@Be-ing
Copy link
Contributor

Be-ing commented Aug 19, 2021

Has this been fixed since #228 was merged building with an updated PortAudio library?

@nyanpasu64
Copy link
Contributor Author

Tried building 13914c5. Now with WASAPI (but not MME/DirectSound/WDM-KS), beginning playback instead hangs and never finishes playing. (I hear a pop, but the UI never disables as it should during playback.) And the program crashes when I close it.

Tenacity_6U3qUpZ8AP

Honestly I don't like using external/vcpkg PortAudio. Now I can't "jump to source" in the IDE to navigate the PortAudio source, making it harder to set breakpoints within PortAudio to find out what the problem is (not sure if it's possible at all, if the .pdb files are located correctly), and harder to edit PortAudio and rebuild to see the effects on Tenacity.

@Be-ing
Copy link
Contributor

Be-ing commented Aug 19, 2021

Oof, that's nasty. You should be able to debug with vcpkg dependencies as long as you haven't deleted the buildtrees directory that vcpkg keeps extracted source code in. But yeah I understand it would be cumbersome to test changes to a library together with the application using vcpkg. I suggest deleting portaudio from the dependency list in vcpkg.json and building & installing PortAudio manually. You can point CMake to find it by specifying -D CMAKE_INSTALL_PREFIX=C:\some\path for the PortAudio build then specifying -D CMAKE_PREFIX_PATH=C:\some\path for the Tenacity build. Note that the Tenacity vcpkg repo is not using upstream PortAudio currently. It is using my PortAudio branch which can build the JACK backend on Windows (if you want to work on that too, that would be awesome!). My rewrite of PortAudio's CMake build system was just merged to the PortAudio master branch a few days ago.

@nyanpasu64
Copy link
Contributor Author

I don't feel like investigating right now, I may do so later though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Some kind of fixable problem was encountered high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants