forked from zoul/Finch
/
Sound.h
45 lines (37 loc) · 1.11 KB
/
Sound.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#import <OpenAL/al.h>
#import <OpenAL/alc.h>
enum SoundError {
kSEInvalidNumberOfChannels = 1,
kSEInvalidEndianity,
kSEInvalidSampleResolution
};
@interface Sound : NSObject
{
BOOL loop;
ALuint source, buffer;
float gain, pitch, duration;
}
// Sound length in seconds.
@property(readonly) float duration;
// Is the sound currently playing?
@property(readonly) BOOL playing;
// Should the sound loop?
@property(assign, nonatomic) BOOL loop;
// Sound gain.
@property(assign, nonatomic) float gain;
// Sound pitch.
@property(assign, nonatomic) float pitch;
// Designated initializer. The format
// is AL_FORMAT_{MONO,STEREO}{8,16}.
- (id) initWithData: (const ALvoid*) data size: (ALsizei) size
format: (ALenum) format sampleRate: (ALsizei) frequency
duration: (float) seconds;
// Convenience initializer, will decode the
// sound for you using the Decoder class.
- (id) initWithFile: (NSURL*) fileURL error: (NSError**) error;
// Just as the one above, logs errors using NSLog
// instead of reporting through NSError.
- (id) initWithFile: (NSURL*) fileURL;
- (void) play;
- (void) stop;
@end