Skip to content
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

Add Loop2 that supports start and end positions #176

Merged
merged 5 commits into from
Sep 5, 2024

Conversation

MarkKremer
Copy link
Contributor

@MarkKremer MarkKremer commented Aug 8, 2024

This PR introduces Loop2 and deprecates Loop. Loop2 has options to configure a portion of the source streamer that must be looped. The new LoopTimes() is similar to the count argument of Loop but is given the number of repeats instead of the total number of plays.

The change from total play count to number of repeats is made partially to avoid the edge case of when a loop must be played 0 times. Because then it's unclear if the parts before and after the loop section must still be played. Number of repeats of 0 simply means play everything once.

The people over at the IKEMEN-Go project have their own implementation of this & I can see that it could be useful for other people as well.

Usage:

// Play streamer and repeat the section between the 5th and 20th second 2 times (played 3 times in total).
beep.Loop2(streamer, beep.LoopTimes(2), beep.LoopBetween(sampleRate.N(time.Second * 5), sampleRate.N(time.Second * 20)))

@MarkKremer MarkKremer changed the title Add loop start and stop positions Add loop start and end positions Aug 8, 2024
@MarkKremer MarkKremer marked this pull request as ready for review September 5, 2024 13:53
@MarkKremer MarkKremer changed the title Add loop start and end positions Add Loop2 that supports start and end positions Sep 5, 2024
@MarkKremer MarkKremer merged commit 01d1fa4 into main Sep 5, 2024
1 check passed
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