Skip to content
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 for WDM KS WaveRT low-latency microphone capture quality #752

Merged
merged 5 commits into from
Mar 31, 2023

Conversation

feoff3
Copy link
Contributor

@feoff3 feoff3 commented Nov 16, 2022

In my tests with latency < 40 ms on Win10 with embeded Realtek sound card, WDM KS capture resulted in sound with lots of cracks.
I digged into the code and found out 1) there is a wrong assumption that host buffer position should be either 0 or 1/2 of buffer size when event is handled, 2) ensured that host ring buffer is read both from the end and the beginning if necessary (the exisiting code might resulted in reading non-initialized data beyond the end of the host buffer)

…e beginning and end of a host ring buffer)
@RossBencina
Copy link
Collaborator

Thank you for your contribution, please fix the trailing whitespace issue on line 6620 flagged by CI:

error: src/hostapi/wdmks/pa_win_wdmks.c(6620) trailing whitespace:
b' '

@RossBencina RossBencina requested review from dmitrykos and removed request for dmitrykos November 21, 2022 23:23
@RossBencina
Copy link
Collaborator

We notice that you've cut-and-pasted the same buffer copying code to two different places: PaPinRenderSubmitHandler_WaveCyclic, PaPinCaptureEventHandler_WaveRTPolled -- can you please confirm that both of these code paths have actually been tested on your machine? Copy-pasta is always a risk and I'd like to be sure that both codes are correct and tested.

@feoff3
Copy link
Contributor Author

feoff3 commented Nov 30, 2022 via email

@RossBencina RossBencina added the src-wdmks MS WDM/KS Host API /src/hostapi/wdmks label Dec 5, 2022
@feoff3
Copy link
Contributor Author

feoff3 commented Dec 14, 2022

@RossBencina I have tested the SubType_kPolled type of capture code, and it produces distorted sound with ~10ms latency both with my updated code and original code.
On the other hand, my code improves SubType_kNotification type of capture significantly. So for now, I return the original code for SubType_kPolled, and push my code for SubType_kNotification.

I leave the SubType_kPolled type as is until the further investigation.

@RossBencina
Copy link
Collaborator

@feoff3 thank you. please fix the whitespace issue as previously requested.

@RossBencina
Copy link
Collaborator

@feoff3 do you think this should be merged as-is or were you planning to do more work on it? If merge, we'll fix the whitespace.

@feoff3
Copy link
Contributor Author

feoff3 commented Jan 10, 2023 via email

@dechamps
Copy link
Contributor

Currently this PR only touches the PaPinCaptureEventHandler_WaveRTEvent() function. @feoff3 Is this because these issues don't apply to the render side, or because you didn't look at the render side at all? I'm wondering if similar issues on the render side could be causing #763.

@feoff3
Copy link
Contributor Author

feoff3 commented Jan 21, 2023 via email

@RossBencina
Copy link
Collaborator

@feoff3 could you review our comments and commits please? It would be great if you could test the changes on your system too.

Copy link
Collaborator

@RossBencina RossBencina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awaiting response to our requests for change, and review of our commits.

@feoff3
Copy link
Contributor Author

feoff3 commented Jan 24, 2023

@RossBencina @philburk @dechamps Guys, thanks for the feedback. Give me several days to check your comments and run a couple of tests on my side.

@feoff3
Copy link
Contributor Author

feoff3 commented Feb 6, 2023

sorry guys, still stuck with other tasks. gonna do it next week

Copy link
Contributor Author

@feoff3 feoff3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap, makes sense

Copy link
Contributor Author

@feoff3 feoff3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes looks good, thank you guys

@feoff3
Copy link
Contributor Author

feoff3 commented Mar 9, 2023

@RossBencina
For some reason "change requested" is still there and I am not able to approve your changes via Github UI (it allows me to comment only, no approval).
I have incorporated the suggested changes into a new commit.
I have tested the commit against a small test app on my side, see the app: https://gist.github.com/feoff3/c989e054d6a88369995ba7860c9eaabd

@RossBencina RossBencina added the final merge review Maintainers flag as ready to make a final merge decision label Mar 20, 2023
@RossBencina RossBencina merged commit 0e9b386 into PortAudio:master Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
final merge review Maintainers flag as ready to make a final merge decision src-wdmks MS WDM/KS Host API /src/hostapi/wdmks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants