Oolite
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 84 of file OOALSound.m.

85{
86 if (!sIsSetUp)
87 [OOSound setUp];
88 return [super init];
89}
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 91 of file OOALSound.m.

91 :(NSString*)path
92{
93 if (!sIsSoundOK)
94 return nil;
95
96 [self release];
97 if (!sIsSetUp && ![OOSound setUp])
98 return nil;
99
100 OOALSoundDecoder* decoder;
101
102 decoder = [[OOALSoundDecoder alloc] initWithPath:path];
103 if (nil == decoder)
104 return nil;
105
106 if ([decoder sizeAsBuffer] <= kMaxBufferedSoundSize) {
107 self = [[OOALBufferedSound alloc] initWithDecoder:decoder];
108 } else {
109 self = [[OOALStreamedSound alloc] initWithDecoder:decoder];
110 }
111 [decoder release];
112
113 if (nil != self) {
114#ifndef NDEBUG
115 OOLog(kOOLogSoundLoadingSuccess, @"Loaded sound %@", path);
116#endif
117 } else {
118 OOLog(kOOLogSoundLoadingError, @"Failed to load sound \"%@\"", path);
119 }
120
121 return self;
122}
static const size_t kMaxBufferedSoundSize
Definition OOALSound.m:39
static BOOL sIsSoundOK
Definition OOALSound.m:42
#define OOLog(class, format,...)
Definition OOLogging.h:84
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 9958 of file Universe.m.

9958 :(NSString*)key
9959{
9960 [self release];
9961 return [[OOSound soundWithCustomSoundKey:key] retain];
9962}
id soundWithCustomSoundKey:(NSString *key)
Definition Universe.m:9950

◆ initWithDecoder:

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

Reimplemented in OOALBufferedSound, and OOALStreamedSound.

Definition at line 124 of file OOALSound.m.

124 :(OOALSoundDecoder*)inDecoder
125{
126 [self release];
127 return nil;
128}

References nil.

◆ isSoundOK

+ (BOOL) isSoundOK

Definition at line 143 of file OOALSound.m.

144{
145 return sIsSoundOK;
146}

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 75 of file OOALSound.m.

76{
77 if (!sIsSetUp && ![self setUp])
78 return 0.0;
79
80 OOOpenALController* controller = [OOOpenALController sharedController];
81 return [controller masterVolume];
82}
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 130 of file OOALSound.m.

131{
133 return @"";
134}
#define OOLogGenericSubclassResponsibility()
Definition OOLogging.h:141

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 294 of file OOJSSound.m.

295{
296 return @"Sound";
297}

◆ oo_jsDescription

- (NSString *) oo_jsDescription
implementation

Provided by category OOSound(OOJavaScriptExtentions).

Definition at line 289 of file OOJSSound.m.

290{
291 return [NSString stringWithFormat:@"[Sound \"%@\"]", [self name]];
292}

◆ oo_jsValueInContext:

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

Provided by category OOSound(OOJavaScriptExtentions).

Definition at line 273 of file OOJSSound.m.

273 :(JSContext*)context
274{
275 JSObject* jsSelf = NULL;
276 jsval result = JSVAL_NULL;
277
278 jsSelf = JS_NewObject(context, &sSoundClass, sSoundPrototype, NULL);
279 if (jsSelf != NULL) {
280 if (!JS_SetPrivate(context, jsSelf, [self retain]))
281 jsSelf = NULL;
282 }
283 if (jsSelf != NULL)
284 result = OBJECT_TO_JSVAL(jsSelf);
285
286 return result;
287}
static JSObject * sSoundPrototype
Definition OOJSSound.m:31
static JSClass sSoundClass
Definition OOJSSound.m:43

◆ rewind

- (void) rewind

Reimplemented in OOALStreamedSound.

Definition at line 159 of file OOALSound.m.

160{
161 // doesn't need to do anything on seekable FDs
162}

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 61 of file OOALSound.m.

61 :(float)fraction
62{
63 if (!sIsSetUp && ![self setUp])
64 return;
65
66 fraction = OOClamp_0_1_f(fraction);
67
68 OOOpenALController* controller = [OOOpenALController sharedController];
69 if (fraction != [controller masterVolume]) {
70 [controller setMasterVolume:fraction];
71 [[NSUserDefaults standardUserDefaults] setFloat:[controller masterVolume] forKey:KEY_VOLUME_CONTROL];
72 }
73}
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
void setMasterVolume:(ALfloat fraction)
float masterVolume()
Definition OOALSound.m:75

References masterVolume, OOOpenALController::masterVolume, OOClamp_0_1_f(), 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 sIsSetUp = YES;
50 OOOpenALController* controller = [OOOpenALController sharedController];
51 if (controller != nil) {
52 sIsSoundOK = YES;
53 float volume = [[NSUserDefaults standardUserDefaults] oo_floatForKey:KEY_VOLUME_CONTROL defaultValue:0.5];
54 [self setMasterVolume:volume];
55 }
56 }
57
58 return sIsSoundOK;
59}

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 148 of file OOALSound.m.

149{
151 return 0;
152}

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 154 of file OOALSound.m.

155{
156 return NO;
157}

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 9950 of file Universe.m.

9950 :(NSString*)key
9951{
9952 NSString* fileName = [UNIVERSE soundNameForCustomSoundKey:key];
9953 if (fileName == nil)
9954 return nil;
9955 return [ResourceManager ooSoundNamed:fileName inFolder:@"Sounds"];
9956}
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 136 of file OOALSound.m.

137{
138 OOSoundMixer* mixer = [OOSoundMixer sharedMixer];
139 if (sIsSoundOK && mixer)
140 [mixer update];
141}

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: