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

[audio] Remove 'clac' noise when playing wave (javasound) #2670

Merged
merged 2 commits into from
Jan 10, 2022

Conversation

dalgwen
Copy link
Contributor

@dalgwen dalgwen commented Jan 6, 2022

A 'clac' can be heard at the beginning of a wav file when playing on the javasound sink.

This is because the code playing the sound targets PCM. But a WAV file has an additional header (fmt). When the code tries to play this header as if it was actual sound, it outputs a "pop" noise.
This bug was first encoutered when playing WAV from the Google TTS, and also in my tests with the Pico TTS, and with the play action from a wav file in the sound directory.

With the fix in this PR, the code consumes (at most) 400 + 2 bytes (if it is a wav file) by trying to get to a "magic" packet that marks the beginning of the real PCM data.

I put the removal code in an utility class because every audio sink playing PCM could potentially need to remove the fmt header.

Close #2669

A 'clac' can be heard at the beginning of a wav file when playing on the javasound sink.

Close openhab#2669
Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
@dalgwen dalgwen requested a review from a team as a code owner January 6, 2022 14:00
Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

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

Thanks again for your contribution. Looks good so for. I left some nit-picking comments on the code style.

@dalgwen
Copy link
Contributor Author

dalgwen commented Jan 9, 2022

Thank you. Done.
I will have to restrain myself from using 'this' in my future contributions (I like it for its emphasizing effect, but I understand it is unusual).

Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
@dalgwen dalgwen force-pushed the 2669-fix_clac_noise_beginning_wav branch from c9a1727 to 6c45275 Compare January 9, 2022 17:58
Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your patience.

@cweitkamp cweitkamp added the bug An unexpected problem or unintended behavior of the Core label Jan 10, 2022
@cweitkamp cweitkamp added this to the 3.3 milestone Jan 10, 2022
@cweitkamp cweitkamp merged commit fa029b2 into openhab:main Jan 10, 2022
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
* [audio] Remove 'clac' noise when playing wav (javasound)

A 'clac' can be heard at the beginning of a wav file when playing on the javasound sink.

Close openhab#2669
Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
GitOrigin-RevId: fa029b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When playing a WAV file on the javasound sink, there is a "clac" noise at the beginning
2 participants