| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#import <AudioToolbox/ExtendedAudioFile.h> |
| 27 |
#import <AudioUnit/AudioUnit.h> |
| 28 |
|
| 29 |
#import "csound.h" |
| 30 |
|
| 31 |
typedef struct csdata_ { |
| 32 |
CSOUND *cs; |
| 33 |
long bufframes; |
| 34 |
int ret; |
| 35 |
int nchnls; |
| 36 |
int nsmps; |
| 37 |
int nchnls_i; |
| 38 |
bool running; |
| 39 |
bool shouldRecord; |
| 40 |
bool shouldMute; |
| 41 |
bool useAudioInput; |
| 42 |
ExtAudioFileRef file; |
| 43 |
AudioUnit *aunit; |
| 44 |
__unsafe_unretained NSMutableArray *valuesCache; |
| 45 |
} csdata; |
| 46 |
|
| 47 |
typedef struct { |
| 48 |
CSOUND *cs; |
| 49 |
int attr; |
| 50 |
const char *format; |
| 51 |
va_list valist; |
| 52 |
} Message; |
| 53 |
|
| 54 |
|
| 55 |
# pragma mark - Protocols (Bindings and Listeners) |
| 56 |
|
| 57 |
|
| 58 |
@class CsoundObj; |
| 59 |
|
| 60 |
@protocol CsoundBinding <NSObject> |
| 61 |
- (void)setup:(CsoundObj *)csoundObj; |
| 62 |
@optional |
| 63 |
- (void)cleanup; |
| 64 |
- (void)updateValuesFromCsound; |
| 65 |
- (void)updateValuesToCsound; |
| 66 |
@end |
| 67 |
|
| 68 |
@protocol CsoundObjListener <NSObject> |
| 69 |
@optional |
| 70 |
- (void)csoundObjStarted:(CsoundObj *)csoundObj; |
| 71 |
- (void)csoundObjCompleted:(CsoundObj *)csoundObj; |
| 72 |
@end |
| 73 |
|
| 74 |
|
| 75 |
# pragma mark - CsoundObj Interface |
| 76 |
|
| 77 |
|
| 78 |
@interface CsoundObj : NSObject |
| 79 |
|
| 80 |
@property (nonatomic, strong) NSURL *outputURL; |
| 81 |
@property (assign) BOOL midiInEnabled; |
| 82 |
@property (assign) BOOL useAudioInput; |
| 83 |
|
| 84 |
- (void)sendScore:(NSString *)score; |
| 85 |
|
| 86 |
- (void)play:(NSString *)csdFilePath; |
| 87 |
- (void)updateOrchestra:(NSString *)orchestraString; |
| 88 |
- (void)stop; |
| 89 |
- (void)mute; |
| 90 |
- (void)unmute; |
| 91 |
|
| 92 |
|
| 93 |
# pragma mark - Recording |
| 94 |
|
| 95 |
|
| 96 |
- (void)record:(NSString *)csdFilePath toURL:(NSURL *)outputURL; |
| 97 |
- (void)record:(NSString *)csdFilePath toFile:(NSString *)outputFile; |
| 98 |
- (void)recordToURL:(NSURL *)outputURL; |
| 99 |
- (void)stopRecording; |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
# pragma mark - Binding |
| 104 |
|
| 105 |
|
| 106 |
@property (nonatomic, strong) NSMutableArray *bindings; |
| 107 |
- (void)addBinding:(id<CsoundBinding>)binding; |
| 108 |
- (void)removeBinding:(id<CsoundBinding>)binding; |
| 109 |
|
| 110 |
|
| 111 |
# pragma mark - Listeners and Messages |
| 112 |
|
| 113 |
|
| 114 |
@property (assign) SEL messageCallbackSelector; |
| 115 |
- (void)addListener:(id<CsoundObjListener>)listener; |
| 116 |
- (void)setMessageCallback:(SEL)method withListener:(id)listener; |
| 117 |
- (void)performMessageCallback:(NSValue *)infoObj; |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
# pragma mark - Csound Internals / Advanced Methods |
| 122 |
|
| 123 |
|
| 124 |
- (CSOUND *)getCsound; |
| 125 |
- (AudioUnit *)getAudioUnit; |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
- (MYFLT *)getInputChannelPtr:(NSString *)channelName |
| 130 |
channelType:(controlChannelType)channelType; |
| 131 |
- (MYFLT *)getOutputChannelPtr:(NSString *)channelName |
| 132 |
channelType:(controlChannelType)channelType; |
| 133 |
|
| 134 |
- (NSData *)getOutSamples; |
| 135 |
- (int)getNumChannels; |
| 136 |
- (int)getKsmps; |
| 137 |
|
| 138 |
- (void)handleInterruption:(NSNotification *)notification; |
| 139 |
|
| 140 |
@end |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|