superm0
superm0

Reputation: 983

Swift: How to play short sounds longer

I'm working on a SpriteKit project using Swift and I wanted to play my 1 sec long sound longer. For instance, the sound file is "beep" - I want it to be extended to something like "beeeep" or "beeeeeeeeep". I'm tried several options to play a sound file, but I can't find a way to extend it.

Currently, I'm using SKAction to play sound:

var beep = SKAction.playSoundFileNamed("beep.caf", waitForCompletion: false)
runAction(beep)

Anyone knows how to do this?

Upvotes: 1

Views: 340

Answers (1)

user3821934
user3821934

Reputation:

AVAudioPlayer has a rate property which lets you play at half to double speed. If half works, you can use that.

If that does not work, you can use AVComposition to create a composite track from your sound file. You can select portions of the sound file and stitch them together anyway you like.

Upvotes: 0

Related Questions