Creating infinite loop #202
Answered
by
sbooth
angstsmurf
asked this question in
Q&A
-
Sorry if I'm missing something obvious, but what is the preferred way to loop a sound indefinitely? |
Beta Was this translation helpful? Give feedback.
Answered by
sbooth
Sep 7, 2021
Replies: 1 comment 1 reply
-
There is no way to schedule a truly infinite repeat but you can get close using SFBLoopableRegionDecoder. It wraps an underlying decoder (which must be seekable) and has various convenience constructors for setting up the region based on starting frame position, frame length, and repeat count. The simplest case for looping an entire decoder is something like: let decoder = try AudioDecoder(url: url)
let loopedDecoder = try LoopableRegionDecoder(decoder: decoder, framePosition: 0, frameLength: decoder.length, repeatCount: Int.max)
// Use `loopedDecoder` |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
angstsmurf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is no way to schedule a truly infinite repeat but you can get close using SFBLoopableRegionDecoder. It wraps an underlying decoder (which must be seekable) and has various convenience constructors for setting up the region based on starting frame position, frame length, and repeat count. The simplest case for looping an entire decoder is something like: