Seamless sound loop?

Is it possible to seamlessly loop audio? I'm getting a relatively significant gap between loops. It is a wavy tone with no gaps in it, so it's easy to hear where the loop ends/begins. Wondering if this has anything to do with me or it's just not going to be possible.

I can confirm that the audio file (.wav) doesn't have any gap in it and loops seamlessly in Audacity. And it's only about 1.5 seconds long, so it's not very large.

I am using a sampleplayer for this:

sndIntro = playdate.sound.sampleplayer.new('audio/intro')
sndIntro:play(0)

I may consider trying to recreate this sound with the synth object (or similar), but this method is so much easier and is the exact sound I need in my game.

1 Like

At some point in the past, I had a similar issue. I ended up using the :setLoops() function, and then just setting it to loop at an explicit value.

Note that this function uses a Sequence (so you'll need that set up too), and that it takes "steps" as its value, and I'm not 100% sure what that value is in relation to seconds. Looking back at some old code, I had a 48s long .mid file (doesn't have to be a MIDI file though), and had it looping at the 46,100 steps point, for some reason that I can't recall. Vaguely it was something like:

menuMidi = playdate.sound.sequence.new('assets/audio/menu-music.mid')
menuMidi:setTempo(950)
menuMidi:setLoops(0,46100)
1 Like

@fosterdouglas Hey, thanks a ton for the suggestion. I'll play around with this method and see if I can get this to work. I'll report back here with any success.

1 Like

In Audition I use fileplayer for perfect loops, not sampleplayer.

1 Like

Would you mind posting the file here (or DM it to me if you don't want to share it publicly for whatever reason) so I can see if I can reproduce that? It should be looping seamlessly but this is an area where new bugs keep popping up as I fix others, so I wouldn't be surprised if something creeped in. :confused: