Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOSound Class Reference

#include <OOALSound.h>

+ Inheritance diagram for OOSound:
+ Collaboration diagram for OOSound:

Instance Methods

(id) - initWithContentsOfFile:
 
(NSString *) - name
 
(ALuint) - soundBuffer
 
(BOOL) - soundIncomplete
 
(void) - rewind
 
(id) - init [implementation]
 
(id) - initWithDecoder: [implementation]
 
(id) - initWithCustomSoundKey:
 
(jsval) - oo_jsValueInContext: [implementation]
 
(NSString *) - oo_jsDescription [implementation]
 
(NSString *) - oo_jsClassName [implementation]
 

Class Methods

(BOOL) + setUp
 
(void) + update
 
(void) + setMasterVolume:
 
(float) + masterVolume
 
(BOOL) + isSoundOK
 
(id) + soundWithCustomSoundKey:
 

Detailed Description

Definition at line 30 of file OOALSound.h.

Method Documentation

◆ init

- (id) init
implementation

Definition at line 42 of file OOALSound.m.

91{
92 if (!sIsSetUp) [OOSound setUp];
93 return [super init];
94}
static BOOL sIsSetUp
Definition OOALSound.m:41
BOOL setUp()
Definition OOALSound.m:46

References nil, setMasterVolume:, OOOpenALController::sharedController, sIsSetUp, and sIsSoundOK.

+ Here is the call graph for this function:

◆ initWithContentsOfFile:

- (id) initWithContentsOfFile: (NSString *) path

Reimplemented in OOMusic.

Definition at line 42 of file OOALSound.m.

97 :(NSString *)path
98{
99 if (!sIsSoundOK) return nil;
100
101 [self release];
102 if (!sIsSetUp && ![OOSound setUp]) return nil;
103
104 OOALSoundDecoder *decoder;
105
106 decoder = [[OOALSoundDecoder alloc] initWithPath:path];
107 if (nil == decoder) return nil;
108
109 if ([decoder sizeAsBuffer] <= kMaxBufferedSoundSize)
110 {
111 self = [[OOALBufferedSound alloc] initWithDecoder:decoder];
112 }
113 else
114 {
115 self = [[OOALStreamedSound alloc] initWithDecoder:decoder];
116 }
117 [decoder release];
118
119 if (nil != self)
120 {
121 #ifndef NDEBUG
122 OOLog(kOOLogSoundLoadingSuccess, @"Loaded sound %@", path);
123 #endif
124 }
125 else
126 {
127 OOLog(kOOLogSoundLoadingError, @"Failed to load sound \"%@\"", path);
128 }
129
130 return self;
131
132
133}
static const size_t kMaxBufferedSoundSize
Definition OOALSound.m:39
static BOOL sIsSoundOK
Definition OOALSound.m:42
#define OOLog(class, format,...)
Definition OOLogging.h:88
static NSString *const kOOLogSoundLoadingSuccess
static NSString *const kOOLogSoundLoadingError
return nil

◆ initWithCustomSoundKey:

- (id) initWithCustomSoundKey: (NSString *) key

Provided by category OOSound(OOCustomSounds).

Definition at line 10720 of file Universe.m.

11063 :(NSString *)key
11064{
11065 [self release];
11066 return [[OOSound soundWithCustomSoundKey:key] retain];
11067}
id soundWithCustomSoundKey:(NSString *key)
Definition Universe.m:11055

◆ initWithDecoder:

- (id) initWithDecoder: (OOALSoundDecoder *) inDecoder
implementation

Reimplemented in OOALBufferedSound, and OOALStreamedSound.

Definition at line 42 of file OOALSound.m.

135 :(OOALSoundDecoder *)inDecoder
136{
137 [self release];
138 return nil;
139}

◆ isSoundOK

+ (BOOL) isSoundOK

Definition at line 42 of file OOALSound.m.

157{
158 return sIsSoundOK;
159}

◆ masterVolume

+ (float) masterVolume

Definition at line 42 of file OOALSound.m.

81{
82 if (!sIsSetUp && ![self setUp] )
83 return 0.0;
84
86 return [controller masterVolume];
87}
OOOpenALController * sharedController()

◆ name

- (NSString *) name

Reimplemented in OOALBufferedSound, OOALStreamedSound, and OOMusic.

Definition at line 42 of file OOALSound.m.

143{
145 return @"";
146}
#define OOLogGenericSubclassResponsibility()
Definition OOLogging.h:129

◆ oo_jsClassName

- (NSString *) oo_jsClassName
implementation

Provided by category OOSound(OOJavaScriptExtentions).

Definition at line 257 of file OOJSSound.m.

312{
313 return @"Sound";
314}

◆ oo_jsDescription

- (NSString *) oo_jsDescription
implementation

Provided by category OOSound(OOJavaScriptExtentions).

Definition at line 257 of file OOJSSound.m.

306{
307 return [NSString stringWithFormat:@"[Sound \"%@\"]", [self name]];
308}

◆ oo_jsValueInContext:

- (jsval) oo_jsValueInContext: (JSContext *) context
implementation

Provided by category OOSound(OOJavaScriptExtentions).

Definition at line 257 of file OOJSSound.m.

289 :(JSContext *)context
290{
291 JSObject *jsSelf = NULL;
292 jsval result = JSVAL_NULL;
293
294 jsSelf = JS_NewObject(context, &sSoundClass, sSoundPrototype, NULL);
295 if (jsSelf != NULL)
296 {
297 if (!JS_SetPrivate(context, jsSelf, [self retain])) jsSelf = NULL;
298 }
299 if (jsSelf != NULL) result = OBJECT_TO_JSVAL(jsSelf);
300
301 return result;
302}
static JSObject * sSoundPrototype
Definition OOJSSound.m:33
static JSClass sSoundClass
Definition OOJSSound.m:48

◆ rewind

- (void) rewind

Reimplemented in OOALStreamedSound.

Definition at line 42 of file OOALSound.m.

176{
177 // doesn't need to do anything on seekable FDs
178}

◆ setMasterVolume:

+ (void) setMasterVolume: (float) fraction

Definition at line 42 of file OOALSound.m.

64 :(float) fraction
65{
66 if (!sIsSetUp && ![self setUp])
67 return;
68
69 fraction = OOClamp_0_1_f(fraction);
70
72 if (fraction != [controller masterVolume])
73 {
74 [controller setMasterVolume:fraction];
75 [[NSUserDefaults standardUserDefaults] setFloat:[controller masterVolume] forKey:KEY_VOLUME_CONTROL];
76 }
77}
void setMasterVolume:(ALfloat fraction)
float masterVolume()
Definition OOALSound.m:80

Referenced by init.

+ Here is the caller graph for this function:

◆ setUp

+ (BOOL) setUp

Definition at line 42 of file OOALSound.m.

47{
48 if (!sIsSetUp)
49 {
50 sIsSetUp = YES;
52 if (controller != nil)
53 {
54 sIsSoundOK = YES;
55 float volume = [[NSUserDefaults standardUserDefaults] oo_floatForKey:KEY_VOLUME_CONTROL defaultValue:0.5];
56 [self setMasterVolume:volume];
57 }
58 }
59
60 return sIsSoundOK;
61}

◆ soundBuffer

- (ALuint) soundBuffer

Reimplemented in OOALBufferedSound, and OOALStreamedSound.

Definition at line 42 of file OOALSound.m.

163{
165 return 0;
166}

◆ soundIncomplete

- (BOOL) soundIncomplete

Reimplemented in OOALStreamedSound.

Definition at line 42 of file OOALSound.m.

170{
171 return NO;
172}

◆ soundWithCustomSoundKey:

+ (id) soundWithCustomSoundKey: (NSString *) key

Provided by category OOSound(OOCustomSounds).

Definition at line 10720 of file Universe.m.

11055 :(NSString *)key
11056{
11057 NSString *fileName = [UNIVERSE soundNameForCustomSoundKey:key];
11058 if (fileName == nil) return nil;
11059 return [ResourceManager ooSoundNamed:fileName inFolder:@"Sounds"];
11060}
OOSound * ooSoundNamed:inFolder:(NSString *fileName,[inFolder] NSString *folderName)

Referenced by GetNamedSound().

+ Here is the caller graph for this function:

◆ update

+ (void) update

Definition at line 42 of file OOALSound.m.

150{
152 if( sIsSoundOK && mixer)
153 [mixer update];
154}

The documentation for this class was generated from the following files: