AEMixerBuffer.h
Go to the documentation of this file.
1 //
2 // AEMixerBuffer.h
3 // The Amazing Audio Engine
4 //
5 // Created by Michael Tyson on 12/04/2012.
6 //
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
14 //
15 // 1. The origin of this software must not be misrepresented; you must not
16 // claim that you wrote the original software. If you use this software
17 // in a product, an acknowledgment in the product documentation would be
18 // appreciated but is not required.
19 //
20 // 2. Altered source versions must be plainly marked as such, and must not be
21 // misrepresented as being the original software.
22 //
23 // 3. This notice may not be removed or altered from any source distribution.
24 //
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #import <Foundation/Foundation.h>
31 #import <AudioToolbox/AudioToolbox.h>
32 
38 typedef void* AEMixerBufferSource;
39 
43 #define AEMixerBufferSourceInactive (UINT32_MAX-1)
44 
57 typedef void (*AEMixerBufferSourceRenderCallback) (AEMixerBufferSource source,
58  UInt32 frames,
59  AudioBufferList *audio,
60  const AudioTimeStamp *inTimeStamp,
61  void *userInfo);
62 
75 typedef UInt32 (*AEMixerBufferSourcePeekCallback) (AEMixerBufferSource source,
76  AudioTimeStamp *outTimestamp,
77  void *userInfo);
78 
79 
95 @interface AEMixerBuffer : NSObject
96 
102 - (id)initWithClientFormat:(AudioStreamBasicDescription)clientFormat;
103 
126 void AEMixerBufferEnqueue(AEMixerBuffer *mixerBuffer, AEMixerBufferSource source, AudioBufferList *audio, UInt32 lengthInFrames, const AudioTimeStamp *timestamp);
127 
140 - (void)setRenderCallback:(AEMixerBufferSourceRenderCallback)renderCallback peekCallback:(AEMixerBufferSourcePeekCallback)peekCallback userInfo:(void *)userInfo forSource:(AEMixerBufferSource)source;
141 
158 void AEMixerBufferDequeue(AEMixerBuffer *mixerBuffer, AudioBufferList *bufferList, UInt32 *ioLengthInFrames, AudioTimeStamp *outTimestamp);
159 
177 void AEMixerBufferDequeueSingleSource(AEMixerBuffer *mixerBuffer, AEMixerBufferSource source, AudioBufferList *bufferList, UInt32 *ioLengthInFrames, AudioTimeStamp *outTimestamp);
178 
188 UInt32 AEMixerBufferPeek(AEMixerBuffer *mixerBuffer, AudioTimeStamp *outNextTimestamp);
189 
201 
215 void AEMixerBufferMarkSourceIdle(AEMixerBuffer *mixerBuffer, AEMixerBufferSource source);
216 
223 - (void)setAudioDescription:(AudioStreamBasicDescription)audioDescription forSource:(AEMixerBufferSource)source;
224 
228 - (void)setVolume:(float)volume forSource:(AEMixerBufferSource)source;
229 
233 - (float)volumeForSource:(AEMixerBufferSource)source;
234 
238 - (void)setPan:(float)pan forSource:(AEMixerBufferSource)source;
239 
243 - (float)panForSource:(AEMixerBufferSource)source;
244 
258 - (void)unregisterSource:(AEMixerBufferSource)source;
259 
266 @property (nonatomic, assign) AudioStreamBasicDescription clientFormat;
267 
276 @property (nonatomic, assign) NSTimeInterval sourceIdleThreshold;
277 
293 @property (nonatomic, assign) BOOL assumeInfiniteSources;
294 
298 @property (nonatomic, assign) int debugLevel;
299 
300 @end
301 
302 #ifdef __cplusplus
303 }
304 #endif