Debian Codegraph @

iOS/Csound iOS Swift Examples/Csound iOS SwiftExamples/csound-iOS/classes/CsoundObj.h

raw symbols SCIP
1 /*
2
3 CsoundObj.h:
4
5 Copyright (C) 2014 Steven Yi, Victor Lazzarini, Aurelius Prochazka
6
7 This file is part of Csound for iOS.
8
9 The Csound for iOS Library is free software; you can redistribute it
10 and/or modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 Csound is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with Csound; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 02111-1307 USA
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 // get input or output that maps to a channel name and type, where type is
128 // CSOUND_AUDIO_CHANNEL, CSOUND_CONTROL_CHANNEL, etc.
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