-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 the sleep logic for streaming as per sample rate #279
Merged
+121
−8
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
80eb6da
sleep 100ms instead of sleeping as function of rate
puneithk 7d8f4b5
added sleep as inverse of sampling rate
puneithk d87d691
added LINEAR16 bytes per sample constant
puneithk ff7ffbc
added few variables
puneithk a23abdc
added truth and log4j
puneithk 0cee557
added 32khz audio
puneithk df11062
added Streaming Test
puneithk a253ebf
added unit tests for 16 and 32 khz audio
puneithk d1fdc61
checkstyle fixes
puneithk a44e692
renamed to KHz
puneithk 4ac456e
added comment
puneithk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Approximating realtime is dependent on the
samplingRate
, so you can't hard-code 100ms unless you're also hard-coding thesamplingRate
.The calculation here should instead be dependent on
samplingRate
, buffer size, and encoding. Since encoding is hard-coded to 2 bytes per sample, you should sleep for:which for 16000 Hz is
1600 / 16 = 100
(as expected), and for 32000 Hz is1600 / 32 = 50
(which is faster than the original32000 / 160 = 200
). I suspect there was just an error in the original calculation. (feel free to check my math as well - but at least it gives a shorter sleep duration, which is what you'd expect if you increase the sample rate while keeping the buffer size the same)