-
Notifications
You must be signed in to change notification settings - Fork 247
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
Generate samples at a multiple of channels #249
Conversation
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.
Overall ok, except for two nits. Sorry for the late review.
src/source/pausable.rs
Outdated
/// Sets whether the filter applies. | ||
/// | ||
/// If set to true, the inner sound stops playing and no samples are processed from it. | ||
#[inline] | ||
pub fn set_paused(&mut self, paused: bool) { | ||
self.paused = paused; | ||
// Minimize calls to channels by only calling on state change |
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.
This comment is wrong. You always call the function when paused is true, even if it was true before. In general, set_paused
shouldn't be called often so minimizing calls shouldn't be needed. I'd say you should just remove the comment.
src/source/pausable.rs
Outdated
Pausable { | ||
input: source, | ||
paused: paused, | ||
paused_channels: paused_channels, |
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.
Please use init shorthand here.
I think I fixed those issues. Long term using something like the sample crates Frame trait would avoid these issues at the type level, but that's a big change to the API. |
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.
Thanks!
I ran into an issue where pausing and unpausing would swap the channels of a stereo source. It was because the number of samples the pause source generated while paused wasn't a multiple of 2. This has two fixes for that issue.
One Pausable now always generates Zero's in a multiple of the number of channels.
Two Periodic only changes things at a multiple of the number of channels. This might help other similar issues.
I also fixed Delay since it has the same potential issue.
I suspect channel ordering issues can also occur if current_frame_len isn't a multiple of the channels, when called before iterating. Also if the iterator returns a None that's not aligned with current_frame_len. Those could cause the issue with Repeat, Stop and various ways of chaining Sources.