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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
/*
CsoundObj.h:
Copyright (C) 2014 Steven Yi, Victor Lazzarini, Aurelius Prochazka
This file is part of Csound for iOS.
The Csound for iOS Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Csound is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Csound; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
*/
#import <AudioToolbox/ExtendedAudioFile.h>
#import <AudioUnit/AudioUnit.h>
#import "csound.h"
typedef struct csdata_ {
CSOUND *cs;
long bufframes;
int ret;
int nchnls;
int nsmps;
int nchnls_i;
bool running;
bool shouldRecord;
bool shouldMute;
bool useAudioInput;
ExtAudioFileRef file;
AudioUnit *aunit;
__unsafe_unretained NSMutableArray *valuesCache;
} csdata;
typedef struct {
CSOUND *cs;
int attr;
const char *format;
va_list valist;
} Message;
// -----------------------------------------------------------------------------
# pragma mark - Protocols (Bindings and Listeners)
// -----------------------------------------------------------------------------
@class CsoundObj;
@protocol CsoundBinding <NSObject>
- (void)setup:(CsoundObj *)csoundObj;
@optional
- (void)cleanup;
- (void)updateValuesFromCsound;
- (void)updateValuesToCsound;
@end
@protocol CsoundObjListener <NSObject>
@optional
- (void)csoundObjStarted:(CsoundObj *)csoundObj;
- (void)csoundObjCompleted:(CsoundObj *)csoundObj;
@end
// -----------------------------------------------------------------------------
# pragma mark - CsoundObj Interface
// -----------------------------------------------------------------------------
@interface CsoundObj : NSObject
@property (nonatomic, strong) NSURL *outputURL;
@property (assign) BOOL midiInEnabled;
@property (assign) BOOL useAudioInput;
- (void)sendScore:(NSString *)score;
- (void)play:(NSString *)csdFilePath;
- (void)updateOrchestra:(NSString *)orchestraString;
- (void)stop;
- (void)mute;
- (void)unmute;
// -----------------------------------------------------------------------------
# pragma mark - Recording
// -----------------------------------------------------------------------------
- (void)record:(NSString *)csdFilePath toURL:(NSURL *)outputURL;
- (void)record:(NSString *)csdFilePath toFile:(NSString *)outputFile;
- (void)recordToURL:(NSURL *)outputURL;
- (void)stopRecording;
// -----------------------------------------------------------------------------
# pragma mark - Binding
// -----------------------------------------------------------------------------
@property (nonatomic, strong) NSMutableArray *bindings;
- (void)addBinding:(id<CsoundBinding>)binding;
- (void)removeBinding:(id<CsoundBinding>)binding;
// -----------------------------------------------------------------------------
# pragma mark - Listeners and Messages
// -----------------------------------------------------------------------------
@property (assign) SEL messageCallbackSelector;
- (void)addListener:(id<CsoundObjListener>)listener;
- (void)setMessageCallback:(SEL)method withListener:(id)listener;
- (void)performMessageCallback:(NSValue *)infoObj;
// -----------------------------------------------------------------------------
# pragma mark - Csound Internals / Advanced Methods
// -----------------------------------------------------------------------------
- (CSOUND *)getCsound;
- (AudioUnit *)getAudioUnit;
// get input or output that maps to a channel name and type, where type is
// CSOUND_AUDIO_CHANNEL, CSOUND_CONTROL_CHANNEL, etc.
- (MYFLT *)getInputChannelPtr:(NSString *)channelName
channelType:(controlChannelType)channelType;
- (MYFLT *)getOutputChannelPtr:(NSString *)channelName
channelType:(controlChannelType)channelType;
- (NSData *)getOutSamples;
- (int)getNumChannels;
- (int)getKsmps;
- (void)handleInterruption:(NSNotification *)notification;
@end
|