AEAudioFileOutput.h
Go to the documentation of this file.
1 //
2 // AEAudioFileOutput.h
3 // TheAmazingAudioEngine
4 //
5 // Created by Michael Tyson on 7/04/2016.
6 // Copyright © 2016 A Tasty Pixel. All rights reserved.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source distribution.
25 //
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #import <Foundation/Foundation.h>
32 #import <AudioToolbox/AudioToolbox.h>
33 #import "AETime.h"
34 #import "AETypes.h"
35 
36 @class AERenderer;
37 
43 typedef void (^AEAudioFileOutputCompletionBlock)(NSError * _Nullable error);
44 
45 /*
46  * Condition block
47  *
48  * For use with @link AEAudioFileOutput::runUntilCondition:completionBlock: runUntilCondition:completionBlock: @endlink
49  *
50  * @returns Whether to stop (YES) or continue (NO)
51  */
53 
64 @interface AEAudioFileOutput : NSObject
65 
76 - (instancetype _Nullable)initWithRenderer:(AERenderer * _Nonnull)renderer
77  URL:(NSURL * _Nonnull)url
78  type:(AEAudioFileType)type
79  sampleRate:(double)sampleRate
80  channelCount:(int)channelCount
81  error:(NSError * _Nullable * _Nullable)error;
82 
92 - (void)runForDuration:(AESeconds)duration completionBlock:(AEAudioFileOutputCompletionBlock _Nonnull)completionBlock;
93 
105 - (void)runUntilCondition:(AEAudioFileOutputConditionBlock _Nonnull)conditionBlock
106  completionBlock:(AEAudioFileOutputCompletionBlock _Nonnull)completionBlock;
107 
111 - (void)finishWriting;
112 
114 @property (nonatomic, strong) AERenderer * _Nullable renderer;
115 
117 @property (nonatomic, readonly) double sampleRate;
118 
120 @property (nonatomic, readonly) int numberOfChannels;
121 
123 @property (nonatomic, strong, readonly) NSURL * _Nonnull fileURL;
124 
126 @property (nonatomic, readonly) UInt64 numberOfFramesRecorded;
127 
128 @end
129 
130 
131 #ifdef __cplusplus
132 }
133 #endif