Skip to content

Store sample rate of block#35

Open
Gusted wants to merge 1 commit intoruuda:masterfrom
Gusted:sample-rate-block
Open

Store sample rate of block#35
Gusted wants to merge 1 commit intoruuda:masterfrom
Gusted:sample-rate-block

Conversation

@Gusted
Copy link

@Gusted Gusted commented Jun 10, 2024

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

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
Copy link
Owner

@ruuda ruuda left a 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.

return self.buffer;
}

/// Returns the sample rate of this block.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
/// Returns the sample rate of this block.
/// Returns the sample rate of this block in Hz.

};

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);
Copy link
Owner

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:

0b0000 => sample_rate = None, // 0000 means 'get from streaminfo block'.

Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants