Oolite
1.91.0.7658-250404-b1488af
Toggle main menu visibility
Main Page
Topics
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
z
Enumerations
g
k
m
o
r
s
t
w
Enumerator
a
b
c
d
e
g
j
k
m
n
o
p
r
s
t
u
w
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Modules
Pages
Loading...
Searching...
No Matches
src
Core
OOALMusic.m
Go to the documentation of this file.
1
/*
2
3
OOALMusic.m
4
5
6
OOALSound - OpenAL sound implementation for Oolite.
7
Copyright (C) 2005-2013 Jens Ayton
8
9
Permission is hereby granted, free of charge, to any person obtaining a copy
10
of this software and associated documentation files (the "Software"), to deal
11
in the Software without restriction, including without limitation the rights
12
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
copies of the Software, and to permit persons to whom the Software is
14
furnished to do so, subject to the following conditions:
15
16
The above copyright notice and this permission notice shall be included in all
17
copies or substantial portions of the Software.
18
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
SOFTWARE.
26
27
*/
28
29
#import "
OOALMusic.h
"
30
31
static
OOMusic
*
sPlayingMusic
=
nil
;
32
static
OOSoundSource
*
sMusicSource
=
nil
;
33
34
35
@implementation
OOMusic
36
37
+ (id)allocWithZone:(NSZone *)inZone
38
{
39
return
NSAllocateObject([
OOMusic
class
], 0, inZone);
40
}
37
+ (id)allocWithZone:(NSZone *)inZone {
…
}
41
42
43
- (void)
dealloc
44
{
45
if
(
sPlayingMusic
==
self
) [
self
stop
];
46
[
sound
release];
47
48
[
super
dealloc];
49
}
43
- (void)
dealloc
{
…
}
50
51
- (id)initWithContentsOfFile:(NSString *)inPath
52
{
53
self
= [
super
init
];
54
if
(
nil
!=
self
)
55
{
56
sound
= [[
OOSound
alloc] initWithContentsOfFile:inPath];
57
if
(
nil
==
sound
)
58
{
59
[
self
release];
60
self
=
nil
;
61
}
62
}
63
64
return
self
;
65
}
51
- (id)initWithContentsOfFile:(NSString *)inPath {
…
}
66
67
68
- (NSString *)
name
69
{
70
return
[
sound
name
];
71
}
68
- (NSString *)
name
{
…
}
72
73
74
- (void)setMusicGain:(
float
)newValue
75
{
76
if
(
nil
!=
sMusicSource
)
77
{
78
[
sMusicSource
setGain
:newValue];
79
}
80
}
74
- (void)setMusicGain:(
float
)newValue {
…
}
81
82
83
- (float)
musicGain
84
{
85
if
(
nil
==
sMusicSource
)
return
0.0f;
86
return
[
sMusicSource
gain
];
87
}
83
- (float)
musicGain
{
…
}
88
89
90
- (void)playLooped:(BOOL)inLoop
91
{
92
if
(
sPlayingMusic
!=
self
)
93
{
94
if
(
nil
==
sMusicSource
)
95
{
96
sMusicSource
= [[
OOSoundSource
alloc] init];
97
}
98
[
sMusicSource
stop
];
99
[
sMusicSource
setLoop
:inLoop];
100
[
sMusicSource
setSound
:sound];
101
[
sMusicSource
play
];
102
103
sPlayingMusic
=
self
;
104
}
105
}
90
- (void)playLooped:(BOOL)inLoop {
…
}
106
107
108
- (
OOSoundSource
*)
musicSoundSource
109
{
110
return
sMusicSource
;
111
}
108
- (
OOSoundSource
*)
musicSoundSource
{
…
}
112
113
114
- (BOOL)
isPlaying
115
{
116
return
sPlayingMusic
==
self
&& [
sMusicSource
isPlaying
];
117
}
114
- (BOOL)
isPlaying
{
…
}
118
119
120
- (void)
stop
121
{
122
if
(
sPlayingMusic
==
self
)
123
{
124
sPlayingMusic
=
nil
;
125
[
sMusicSource
stop
];
126
[
sMusicSource
setSound
:nil];
127
}
128
}
120
- (void)
stop
{
…
}
129
130
@end
OOALMusic.h
sPlayingMusic
static OOMusic * sPlayingMusic
Definition
OOALMusic.m:31
sMusicSource
static OOSoundSource * sMusicSource
Definition
OOALMusic.m:32
nil
return nil
Definition
OOProbabilitySet.m:449
OOMusic
Definition
OOALMusic.h:38
-[OOMusic isPlaying]
BOOL isPlaying()
Definition
OOALMusic.m:114
-[OOMusic musicSoundSource]
OOSoundSource * musicSoundSource()
Definition
OOALMusic.m:108
OOMusic::sound
OOSound * sound
Definition
OOALMusic.h:40
-[OOMusic name]
NSString * name()
Definition
OOALMusic.m:68
-[OOMusic stop]
void stop()
Definition
OOALMusic.m:120
-[OOMusic dealloc]
void dealloc()
Definition
OOALMusic.m:43
-[OOMusic musicGain]
float musicGain()
Definition
OOALMusic.m:83
OOSoundSource
Definition
OOSoundSource.h:44
-[OOSoundSource isPlaying]
BOOL isPlaying()
Definition
OOSoundSource.m:129
-[OOSoundSource gain]
float gain()
Definition
OOSoundSource.m:279
-[OOSoundSource setLoop:]
void setLoop:(BOOL inLoop)
Definition
OOSoundSource.m:111
-[OOSoundSource setGain:]
void setGain:(float gain)
Definition
OOSoundSource.m:269
-[OOSoundSource play]
void play()
Definition
OOSoundSource.m:135
-[OOSoundSource setSound:]
void setSound:(OOSound *inSound)
Definition
OOSoundSource.m:94
-[OOSoundSource stop]
void stop()
Definition
OOSoundSource.m:171
OOSound
Definition
OOALSound.h:31
-[OOSound init]
id init()
Definition
OOALSound.m:90
-[OOSound name]
NSString * name()
Definition
OOALSound.m:142
Generated by
1.13.2