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