SPSound Class Reference
Inherits from | NSObject |
Declared in | SPSound.h |
Overview
The SPSound class contains audio data that is ready for playback.
Just as SPTexture contains image data, SPSound contains audio data. It loads audio files in different formats and keeps them in memory (or streams them if the format supports it).
You can use SPSound to play a sound directly, but this won’t give you much control.
If you want to control the playback and volume of the sound, you you have to create an
SPSoundChannel first (via createChannel
).
If you need to play a sound repeatedly, create the SPSound object only once and keep it in memory. Then call play or create a channel when you want to play the sound.
Your sounds will automatically be paused when the application is disrupted (e.g. by a phone call), and will continue playback where they stopped.
Behind the scenes, the SPSound class will choose the appropriate technology for playback: uncompressed files will use OpenAL, compressed sound will be handled by Apple’s AVAudioPlayer. You don’t have to care.
Tasks
Initializers
-
– initWithContentsOfFile:
Initializes a sound
-
+ soundWithContentsOfFile:
Factory method.
Methods
-
– play
Starts playback of the sound.
-
– createChannel
Creates an audio channel that gives you more control over playback. Don’t forget to retain it!
Properties
-
duration
The duration of the sound in seconds.
property
Instance Methods
createChannel
Creates an audio channel that gives you more control over playback. Don’t forget to retain it!
- (SPSoundChannel *)createChannel
Discussion
Creates an audio channel that gives you more control over playback. Don’t forget to retain it!
Declared In
SPSound.h