Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOSoundSource.h
Go to the documentation of this file.
1/*
2
3OOSoundSource.h
4
5A sound source.
6Each playing sound is associated with a sound source, either explicitly or by
7creating one on the fly. Each sound source can play one sound at a time, and
8has a number of attributes related to positional audio (which is currently
9unimplemented).
10
11
12Copyright (C) 2006-2013 Jens Ayton
13
14Permission is hereby granted, free of charge, to any person obtaining a copy
15of this software and associated documentation files (the "Software"), to deal
16in the Software without restriction, including without limitation the rights
17to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18copies of the Software, and to permit persons to whom the Software is
19furnished to do so, subject to the following conditions:
20
21The above copyright notice and this permission notice shall be included in all
22copies or substantial portions of the Software.
23
24THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29OUT OF OR
30
31*/
32
33#import "OOSoundSource.h"
34#import "OOMaths.h"
35
36#ifndef OO_DEFAULT_SOUNDSOURCE_GAIN
37#define OO_DEFAULT_SOUNDSOURCE_GAIN 1.0f
38#endif
39
41
42
43@interface OOSoundSource: NSObject
44{
45@private
48 BOOL _loop;
49 uint8_t _repeatCount,
51 Vector _position;
53 float _gain;
54}
55
56+ (instancetype) sourceWithSound:(OOSound *)inSound;
57- (id) initWithSound:(OOSound *)inSound;
58
59// These options should be set before playing. Effect of setting them while playing is undefined.
60- (OOSound *) sound;
61- (void )setSound:(OOSound *)inSound;
62- (BOOL) loop;
63- (void) setLoop:(BOOL)inLoop;
64- (uint8_t) repeatCount;
65- (void) setRepeatCount:(uint8_t)inCount;
66
67- (BOOL) isPlaying;
68- (void) play;
69- (void) playOrRepeat;
70- (void) stop;
71
72+ (void) stopAll;
73
74// Conveniences:
75- (void) playSound:(OOSound *)inSound;
76- (void) playSound:(OOSound *)inSound repeatCount:(uint8_t)inCount;
77- (void) playOrRepeatSound:(OOSound *)inSound;
78
79// Positional audio attributes are used in this implementation
80- (void) setPositional:(BOOL)inPositional;
81- (BOOL) positional;
82- (void) setPosition:(Vector)inPosition;
83- (Vector) position;
84- (void) setGain:(float)gain;
85- (float) gain;
86
87// *Advanced* positional audio attributes are ignored in this implementation
88- (void) setVelocity:(Vector)inVelocity;
89- (void) setOrientation:(Vector)inOrientation;
90- (void) setConeAngle:(float)inAngle;
91- (void) setGainInsideCone:(float)inInside outsideCone:(float)inOutside;
92- (void) positionRelativeTo:(OOSoundReferencePoint *)inPoint;
93
94@end
OOSound * _sound
OOSoundChannel * _channel
uint8_t _remainingCount
uint8_t _repeatCount