Skip to content

Add speaker.PlayAndWait#140

Merged
MarkKremer merged 2 commits into
mainfrom
speaker-play-and-wait
Jan 24, 2024
Merged

Add speaker.PlayAndWait#140
MarkKremer merged 2 commits into
mainfrom
speaker-play-and-wait

Conversation

@MarkKremer

@MarkKremer MarkKremer commented Jan 7, 2024

Copy link
Copy Markdown
Contributor

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
@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