Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/internal/src/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,11 @@ namespace mxl::lib
{
// Read the mandatory grain_rate field
auto const sampleRate = parser.getGrainRate();
// Compute the grain count based on our configured history duration
auto const bufferLength = _historyDuration * sampleRate.numerator / (1'000'000'000ULL * sampleRate.denominator);
// Compute the buffer length based on our configured history duration.
// The length is divided by 500M instead of 1B to effectively make it twice the
// history duration, which is necessary, because only half of the buffer is
// accessible for reading at any one point in time.
auto const bufferLength = _historyDuration * sampleRate.numerator / (500'000'000ULL * sampleRate.denominator);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would add a comment to make it clearer. Something like: "The denominator is multiplied by 500M, rather than 1B, so that the buffer length is twice as large as the history duration."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fair point, I added an explanatory comment.


auto const sampleWordSize = parser.getPayloadSize();
// FIXME: The page size is just an educated guess to round to for good measure
Expand Down
Loading