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