Oolite 1.91.0.7659-250410-0031890
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 90 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 init, setUp, and sIsSetUp.

Referenced by init, OOMusic::initWithContentsOfFile:, OOALBufferedSound::initWithDecoder:, and OOALStreamedSound::initWithDecoder:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initWithContentsOfFile:

- (id) initWithContentsOfFile: (NSString *) path

Reimplemented in OOMusic.

Definition at line 97 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

References kMaxBufferedSoundSize, kOOLogSoundLoadingError, kOOLogSoundLoadingSuccess, nil, OOLog, setUp, sIsSetUp, and sIsSoundOK.

+ Here is the call graph for this function:

◆ initWithCustomSoundKey:

- (id) initWithCustomSoundKey: (NSString *) key

Provided by category OOSound(OOCustomSounds).

Definition at line 11063 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 135 of file OOALSound.m.

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

References nil.

◆ isSoundOK

+ (BOOL) isSoundOK

Definition at line 156 of file OOALSound.m.

157{
158 return sIsSoundOK;
159}

References isSoundOK, and sIsSoundOK.

Referenced by OOALBufferedSound::initWithDecoder:, OOALStreamedSound::initWithDecoder:, and isSoundOK.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ masterVolume

+ (float) masterVolume

Definition at line 80 of file OOALSound.m.

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

References masterVolume, OOOpenALController::masterVolume, setUp, OOOpenALController::sharedController, and sIsSetUp.

Referenced by PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, Universe::initWithGameView:, masterVolume, PlayerEntity::setGuiToGameOptionsScreen, setMasterVolume:, and Universe::startSpeakingString:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ name

- (NSString *) name

Reimplemented in OOALBufferedSound, OOALStreamedSound, and OOMusic.

Definition at line 142 of file OOALSound.m.

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

References name, and OOLogGenericSubclassResponsibility.

Referenced by OOMusic::name, name, and OOSound(OOJavaScriptExtentions)::oo_jsDescription.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oo_jsClassName

- (NSString *) oo_jsClassName
implementation

Provided by category OOSound(OOJavaScriptExtentions).

Definition at line 311 of file OOJSSound.m.

312{
313 return @"Sound";
314}

◆ oo_jsDescription

- (NSString *) oo_jsDescription
implementation

Provided by category OOSound(OOJavaScriptExtentions).

Definition at line 305 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 289 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 175 of file OOALSound.m.

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

References rewind.

Referenced by OOSoundChannel::playSound:looped:, rewind, and OOSoundChannel::update.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMasterVolume:

+ (void) setMasterVolume: (float) fraction

Definition at line 64 of file OOALSound.m.

64 :(float) fraction
65{
66 if (!sIsSetUp && ![self setUp])
67 return;
68
69 fraction = OOClamp_0_1_f(fraction);
70
71 OOOpenALController *controller = [OOOpenALController sharedController];
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

References masterVolume, OOOpenALController::masterVolume, OOOpenALController::setMasterVolume:, setUp, OOOpenALController::sharedController, and sIsSetUp.

Referenced by PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, and setUp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp

+ (BOOL) setUp

Definition at line 46 of file OOALSound.m.

47{
48 if (!sIsSetUp)
49 {
50 sIsSetUp = YES;
51 OOOpenALController* controller = [OOOpenALController sharedController];
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}

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

Referenced by MyOpenGLView::init, init, initWithContentsOfFile:, OOALBufferedSound::initWithDecoder:, OOALStreamedSound::initWithDecoder:, masterVolume, setMasterVolume:, and setUp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ soundBuffer

- (ALuint) soundBuffer

Reimplemented in OOALBufferedSound, and OOALStreamedSound.

Definition at line 162 of file OOALSound.m.

163{
165 return 0;
166}

References OOLogGenericSubclassResponsibility, and soundBuffer.

Referenced by OOSoundChannel(Private)::enqueueBuffer:, and soundBuffer.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ soundIncomplete

- (BOOL) soundIncomplete

Reimplemented in OOALStreamedSound.

Definition at line 169 of file OOALSound.m.

170{
171 return NO;
172}

References soundIncomplete.

Referenced by soundIncomplete.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ soundWithCustomSoundKey:

+ (id) soundWithCustomSoundKey: (NSString *) key

Provided by category OOSound(OOCustomSounds).

Definition at line 11055 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(), OOSound(OOCustomSounds)::initWithCustomSoundKey:, OOSoundSource(OOCustomSounds)::initWithCustomSoundKey:, OOSoundSource(OOCustomSounds)::playCustomSoundWithKey:, PlayerEntity(Sound)::playInterfaceBeep:, and OOSoundSourcePool::playSoundWithKey:priority:expiryTime:overlap:position:.

+ Here is the caller graph for this function:

◆ update

+ (void) update

Definition at line 149 of file OOALSound.m.

150{
151 OOSoundMixer * mixer = [OOSoundMixer sharedMixer];
152 if( sIsSoundOK && mixer)
153 [mixer update];
154}

References OOSoundMixer::sharedMixer, sIsSoundOK, update, and OOSoundMixer::update.

Referenced by GameController(OOPrivate)::doPerformGameTick, and update.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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