Use WAV file sample rate unless user explicitly set samprate#448
Merged
Use WAV file sample rate unless user explicitly set samprate#448
Conversation
Fixes issue where WAV file sample rates were ignored because the check for 'samprate == 0' always failed (samprate defaults to 16000). Now checks if -samprate was actually passed on the command line. If not, uses the WAV file's sample rate. If user explicitly set it, respects their choice. This allows WAV files with any sample rate (8kHz, 24kHz, 32kHz, 48kHz, etc.) to be processed correctly without requiring users to manually specify -samprate.
Contributor
|
Oh! That is pretty silly, I'm not sure why I thought the default value for |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
WAV files with non-default sample rates (e.g., 8kHz, 24kHz, 32kHz, 48kHz) were being silently ignored. The code checked if
samprate == 0before applying the WAV file's sample rate, butsampratedefaults to 16000, causing the check to always fail.Solution
Added a helper function
arg_was_set()that checks if-sampratewas actually passed on the command line by inspecting the stored argv. The WAV file's sample rate is now used unless the user explicitly provided-samprate.Behavior
Before:
-samprate 48000for correct processingAfter:
-samprateif desiredChanges
src/util/soundfiles.c(1 file, +19/-2 lines)arg_was_set()helper function to check command line argumentsps_config_wavfile()to properly detect user intentTesting
Tested with WAV files at various sample rates. Confirmed that:
-samprateflag use WAV file rate-samprateflag respect user's choice