Oolite
Loading...
Searching...
No Matches
OOSoundSourcePool.h
Go to the documentation of this file.
1/*
2
3OOSoundSourcePool.h
4
5Manages a fixed number of sound sources and distributes sounds between them.
6Each sound has a priority and an expiry time. When a new sound is played, it
7replaces (if possible) a sound of lower priority that has expired, a sound of
8the same priority that has expired, or a sound of lower priority that has not
9expired.
10
11All sounds are specified by customsounds.plist key.
12
13
14Copyright (C) 2008-2013 Jens Ayton
15
16Permission is hereby granted, free of charge, to any person obtaining a copy
17of this software and associated documentation files (the "Software"), to deal
18in the Software without restriction, including without limitation the rights
19to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20copies of the Software, and to permit persons to whom the Software is
21furnished to do so, subject to the following conditions:
22
23The above copyright notice and this permission notice shall be included in all
24copies or substantial portions of the Software.
25
26THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32SOFTWARE.
33
34*/
35
36#import "OOMaths.h"
37#import "OOTypes.h"
38#import <Foundation/Foundation.h>
39
40@interface OOSoundSourcePool : NSObject {
41@private
43 uint8_t _count;
44 uint8_t _latest;
45 uint8_t _reserved;
48 NSString* _lastKey;
49}
50
51+ (instancetype)poolWithCount:(uint8_t)count minRepeatTime:(OOTimeDelta)minRepeat;
52- (id)initWithCount:(uint8_t)count minRepeatTime:(OOTimeDelta)minRepeat;
53
54- (void)playSoundWithKey:(NSString*)key
55 priority:(float)priority
56 expiryTime:(OOTimeDelta)expiryTime
57 overlap:(BOOL)overlap
58 position:(Vector)position;
59
60- (void)playSoundWithKey:(NSString*)key
61 priority:(float)priority
62 expiryTime:(OOTimeDelta)expiryTime;
63
64- (void)playSoundWithKey:(NSString*)key
65 priority:(float)priority; // expiryTime:0.1 +/- 0.5
66
67- (void)playSoundWithKey:(NSString*)key
68 priority:(float)priority
69 position:(Vector)position; // expiryTime:0.1 +/- 0.5
70
71- (void)playSoundWithKey:(NSString*)key
72 position:(Vector)position; // expiryTime:0.1 +/- 0.5
73
74- (void)playSoundWithKey:(NSString*)key; // priority: 1.0, expiryTime:0.1 +/- 0.5
75
76- (void)playSoundWithKey:(NSString*)key overlap:(BOOL)overlap; // if overlap == NO it waits for key to finish before playing key again
77- (void)playSoundWithKey:(NSString*)key overlap:(BOOL)overlap position:(Vector)position;
78
79@end
double OOTimeDelta
Definition OOTypes.h:193
double OOTimeAbsolute
Definition OOTypes.h:192
struct OOSoundSourcePoolElement * _sources
OOTimeAbsolute _nextRepeat