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 speaker.PlayAndWait #140

Merged
merged 2 commits into from
Jan 24, 2024
Merged

Add speaker.PlayAndWait #140

merged 2 commits into from
Jan 24, 2024

Conversation

MarkKremer
Copy link
Contributor

@MarkKremer MarkKremer commented Jan 7, 2024

Adds a quality of life function to play a sound and wait until it is finished. This function waits until the samples have reached the driver. Actual applications should probably not use this but it's useful for testing and example code.

// before
done := make(chan struct{})
speaker.Play(beep.Seq(streamer, beep.Callback(func() {
	done <- struct{}{}
})))
<-done

// after
speaker.PlayAndWait(streamer)

Downside: not having this function is a good reason to explain beep.Seq and beep.Callback. Now part of the tutorial needs to be rewritten.

@MarkKremer MarkKremer marked this pull request as ready for review January 7, 2024 15:55
@MarkKremer MarkKremer requested a review from a team January 7, 2024 15:55
@MarkKremer MarkKremer merged commit 28ff2ed into main Jan 24, 2024
1 check passed
@MarkKremer MarkKremer deleted the speaker-play-and-wait branch January 24, 2024 16:02
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