-
Notifications
You must be signed in to change notification settings - Fork 28
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
Store sample rate of block #35
base: master
Are you sure you want to change the base?
Conversation
FLAC can have a different sample rate for every frame, therefore it should be stored in `Block` and have a function that exposes the value of it. Ref: https://github.com/ietf-wg-cellar/flac-test-files/blob/main/uncommon/01%20-%20changing%20samplerate.flac
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.
Thank you for taking the time to open a pull request. This makes sense to add, but let’s make sure that the sample rate is always set to the correct value then.
@@ -504,6 +508,12 @@ impl Block { | |||
return self.buffer; | |||
} | |||
|
|||
/// Returns the sample rate of this block. |
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.
/// Returns the sample rate of this block. | |
/// Returns the sample rate of this block in Hz. |
@@ -773,7 +783,7 @@ impl<R: ReadBytes> FrameReader<R> { | |||
BlockTime::SampleNumber(snr) => snr, | |||
}; | |||
|
|||
let block = Block::new(time, header.block_size as u32, buffer); | |||
let block = Block::new(time, header.block_size as u32, header.sample_rate.unwrap_or_default(), buffer); |
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.
unwrap_or_default
would default to 0 when the header does not specify a sample rate. Instead, we need to get the value from the streaminfo:
Line 193 in 20fd6a7
0b0000 => sample_rate = None, // 0000 means 'get from streaminfo block'. |
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.
It doesn't seem like streaminfo is available from this function's scope?
FLAC can have a different sample rate for every frame, therefore it should be stored in
Block
and have a function that exposes the value of it.Ref: https://github.com/ietf-wg-cellar/flac-test-files/blob/main/uncommon/01%20-%20changing%20samplerate.flac