rt300@0
|
1 #include "testApp.h"
|
rt300@2
|
2
|
rt300@39
|
3
|
rt300@0
|
4 extern Grid theGridView;
|
rt300@0
|
5 extern PresetManager presetManager;
|
rt300@1
|
6 extern EventLogger eventLogger;
|
rt300@3
|
7 extern Frequencer frequencer;
|
rt300@35
|
8 extern Hilbert hilbert;
|
rt300@9
|
9
|
rt300@24
|
10 const vector<string> parameterNames;
|
rt300@24
|
11
|
rt300@24
|
12 const string sliderParamNames[10] = {"Transpose", "1/4 note","1/6 note","1/7 note","1/8 note","Waveform", "Filter Type","Filter Freq", "Envelope","FM amt"};
|
rt300@24
|
13 //const vector<const string> v(ra[0],ra[1]);
|
rt300@24
|
14
|
rt300@24
|
15
|
rt300@35
|
16
|
rt300@7
|
17 //DeviceID3523537000
|
rt300@42
|
18 void testApp::initialiseVariables(){
|
rt300@16
|
19 paused = true;
|
rt300@39
|
20 sendMIDIAndOSC = false;
|
rt300@37
|
21
|
rt300@16
|
22 ofBackground( 0, 0, 0 );
|
rt300@0
|
23 ofEnableAlphaBlending();
|
rt300@36
|
24 currentSequence = 0;
|
rt300@40
|
25 //ofEnableSmoothing();
|
rt300@37
|
26
|
rt300@29
|
27 // open an outgoing connection to HOST:PORT for OSC
|
rt300@29
|
28
|
rt300@29
|
29 sender.setup( OSC_HOST, OSC_PORT );
|
rt300@28
|
30 ofSetFrameRate(50);
|
rt300@0
|
31 // reciever
|
rt300@6
|
32 lastMoveTime = ofGetSystemTimeMicros();
|
rt300@0
|
33 prevTouchX = 0;
|
rt300@0
|
34 prevTouchY = 0;
|
rt300@0
|
35
|
rt300@0
|
36 xLocked = false;
|
rt300@0
|
37 yLocked = false;
|
rt300@0
|
38
|
rt300@0
|
39 numActiveTouches = 0;
|
rt300@3
|
40 touch0.setCoord(17./7., 2./3.);
|
rt300@0
|
41 touch1.setCoord(10,20);
|
rt300@3
|
42
|
rt300@0
|
43 prevTouch0.setCoord(1,2);
|
rt300@0
|
44 prevTouch1.setCoord(10,20);
|
rt300@0
|
45 prevDist = 10;
|
rt300@16
|
46 slowFactor = 0.98;
|
rt300@27
|
47 preventingMovePostScroll = false;
|
rt300@16
|
48
|
rt300@16
|
49 // the 5 harmonics for the frequencer
|
rt300@16
|
50 freqIndexes.push_back(0);
|
rt300@16
|
51 freqIndexes.push_back(4);
|
rt300@16
|
52 freqIndexes.push_back(6);
|
rt300@16
|
53 freqIndexes.push_back(7);
|
rt300@16
|
54 freqIndexes.push_back(8);
|
rt300@16
|
55
|
rt300@16
|
56
|
rt300@42
|
57 ofxiPhoneSetOrientation( OFXIPHONE_ORIENTATION_PORTRAIT );
|
rt300@42
|
58 ofxiPhoneExternalDisplay::mirrorOn();
|
rt300@42
|
59 }
|
rt300@42
|
60 void testApp::initialiseGUIs(){
|
rt300@0
|
61 theGridView.init();
|
rt300@0
|
62
|
rt300@24
|
63 setupSliderGui();
|
rt300@24
|
64 sliderGUI->setVisible(true);
|
rt300@0
|
65
|
rt300@0
|
66 // initial slider vals
|
rt300@0
|
67 for(int i=0; i<10;i++){
|
rt300@0
|
68 sliderVals.push_back(64);
|
rt300@0
|
69 }
|
rt300@37
|
70
|
rt300@37
|
71
|
rt300@24
|
72 // set up iOS gui stuff
|
rt300@24
|
73 bottomTabViewController = [[BottomTabViewController alloc] initWithNibName:@"BottomTabViewController" bundle:nil];
|
rt300@24
|
74 [ofxiPhoneGetGLParentView() addSubview:bottomTabViewController.view];
|
rt300@24
|
75
|
rt300@24
|
76 [bottomTabViewController setAppRef:(id)this];
|
rt300@24
|
77 bottomTabViewController.view.frame = CGRectMake(0,getHeight()-44,getWidth(),44);
|
rt300@29
|
78 bottomTabViewController.view.hidden = YES;
|
rt300@37
|
79
|
rt300@24
|
80 /////
|
rt300@24
|
81
|
rt300@24
|
82 topButtonViewController = [[TopButtonViewController alloc] initWithNibName:@"TopButtonViewController" bundle:nil];
|
rt300@24
|
83 [ofxiPhoneGetGLParentView() addSubview:topButtonViewController.view];
|
rt300@24
|
84 [topButtonViewController setAppRef:(id)this];
|
rt300@24
|
85 [topButtonViewController show:(id)this];
|
rt300@24
|
86 topButtonViewController.view.frame = CGRectMake(0,0,getWidth(),44);
|
rt300@24
|
87
|
rt300@25
|
88 usernameAlertViewController = [[UsernameAlertViewController alloc] init];
|
rt300@42
|
89 [usernameAlertViewController setAppRef:(id)this];
|
rt300@26
|
90
|
rt300@27
|
91 helpViewController = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil];
|
rt300@27
|
92 [ofxiPhoneGetGLParentView() addSubview:helpViewController.view];
|
rt300@27
|
93 [helpViewController setAppRef:(id)this];
|
rt300@27
|
94 helpViewController.view.hidden = YES;
|
rt300@27
|
95
|
rt300@42
|
96 /*
|
rt300@42
|
97 sliderViewController = [[SliderViewController alloc] initWithNibName:@"SliderViewController" bundle:nil];
|
rt300@42
|
98 [ofxiPhoneGetGLParentView() addSubview:sliderViewController.view];
|
rt300@42
|
99 [sliderViewController setAppRef:(id)this];
|
rt300@42
|
100 sliderViewController.view.frame = CGRectMake(0,getHeight()-43 - 363,getWidth(),363);
|
rt300@42
|
101 //[sliderViewController show:(id)this];
|
rt300@42
|
102 */
|
rt300@36
|
103
|
rt300@42
|
104 setAllGUISliders(theGridView.getParams());
|
rt300@25
|
105
|
rt300@42
|
106 }
|
rt300@42
|
107
|
rt300@42
|
108 void testApp::initialiseMIDI(){
|
rt300@36
|
109
|
rt300@39
|
110 /////////////////////////
|
rt300@39
|
111 // MIDI
|
rt300@39
|
112
|
rt300@39
|
113 midiChannel = 7;
|
rt300@39
|
114 midiOffset = 0;
|
rt300@39
|
115
|
rt300@39
|
116 // enables the network midi session between iOS and Mac OSX on a
|
rt300@39
|
117 // local wifi network
|
rt300@39
|
118 //
|
rt300@39
|
119 // in ofxMidi: open the input/outport network ports named "Session 1"
|
rt300@39
|
120 //
|
rt300@39
|
121 // on OSX: use the Audio MIDI Setup Utility to connect to the iOS device
|
rt300@39
|
122 //
|
rt300@39
|
123 ofxMidi::enableNetworking();
|
rt300@39
|
124
|
rt300@39
|
125 // list the number of available input & output ports
|
rt300@39
|
126 ofxMidiIn::listPorts();
|
rt300@39
|
127 ofxMidiOut::listPorts();
|
rt300@39
|
128
|
rt300@39
|
129 // create and open input ports
|
rt300@39
|
130 for(int i = 0; i < ofxMidiIn::getNumPorts(); ++i) {
|
rt300@39
|
131
|
rt300@39
|
132 // new object
|
rt300@39
|
133 inputs.push_back(new ofxMidiIn);
|
rt300@39
|
134
|
rt300@39
|
135 // set this class to receive incoming midi events
|
rt300@39
|
136 inputs[i]->addListener(this);
|
rt300@39
|
137
|
rt300@39
|
138 // open input port via port number
|
rt300@39
|
139 inputs[i]->openPort(i);
|
rt300@39
|
140 }
|
rt300@39
|
141
|
rt300@39
|
142 // create and open output ports
|
rt300@39
|
143 for(int i = 0; i < ofxMidiOut::getNumPorts(); ++i) {
|
rt300@39
|
144
|
rt300@39
|
145 // new object
|
rt300@39
|
146 outputs.push_back(new ofxMidiOut);
|
rt300@39
|
147
|
rt300@39
|
148 // open input port via port number
|
rt300@39
|
149 outputs[i]->openPort(i);
|
rt300@39
|
150 }
|
rt300@39
|
151
|
rt300@39
|
152 // set this class to receieve midi device (dis)connection events
|
rt300@39
|
153 ofxMidi::setConnectionListener(this);
|
rt300@39
|
154
|
rt300@39
|
155 // END MIDI
|
rt300@42
|
156
|
rt300@42
|
157 }
|
rt300@42
|
158 //--------------------------------------------------------------
|
rt300@42
|
159 void testApp::setup(){
|
rt300@39
|
160
|
rt300@42
|
161 // initilaise
|
rt300@42
|
162
|
rt300@42
|
163 initialiseVariables();
|
rt300@42
|
164 initialiseGUIs();
|
rt300@42
|
165
|
rt300@42
|
166 // initialise PD
|
rt300@42
|
167
|
rt300@42
|
168 int ticksPerBuffer = 8; // 8 * 64 = buffer len of 512
|
rt300@42
|
169 core.setup(2, 1, 44100, ticksPerBuffer);
|
rt300@42
|
170
|
rt300@42
|
171 // setup OF sound stream
|
rt300@42
|
172 ofSoundStreamSetup(2, 1, this, 44100, ofxPd::blockSize()*ticksPerBuffer, 3);
|
rt300@42
|
173
|
rt300@42
|
174 tsc = [[TimedSessionController alloc] init];
|
rt300@42
|
175 [tsc setAppRef:(id)this];
|
rt300@42
|
176
|
rt300@42
|
177 //--------------------------------------
|
rt300@42
|
178 // load stuff
|
rt300@42
|
179 loadSequences();
|
rt300@42
|
180
|
rt300@42
|
181 // load presets
|
rt300@42
|
182 presetManager.startLoadAll();
|
rt300@42
|
183
|
rt300@42
|
184 eventLogger.startLoadAll();
|
rt300@42
|
185 //--------------------------------------
|
rt300@42
|
186
|
rt300@42
|
187 // now do things that will affect the start up state of the app
|
rt300@42
|
188
|
rt300@42
|
189 if(eventLogger.questionnaireCompleted){ // then we go into do-what-you-like mode
|
rt300@42
|
190
|
rt300@42
|
191 freeUseMode();
|
rt300@42
|
192 }else{
|
rt300@42
|
193 // then we're in timed session mode
|
rt300@42
|
194 showIntro();
|
rt300@42
|
195 }
|
rt300@42
|
196
|
rt300@42
|
197 // GO
|
rt300@42
|
198 paused = false;
|
rt300@42
|
199 eventLogger.logEvent(APP_STARTED);
|
rt300@24
|
200 }
|
rt300@24
|
201
|
rt300@24
|
202
|
rt300@24
|
203 //--------------------------------------------------------------
|
rt300@24
|
204 void testApp::exit(){
|
rt300@37
|
205
|
rt300@25
|
206 presetManager.exitAndSaveAll();
|
rt300@25
|
207 eventLogger.exitAndSave();
|
rt300@37
|
208
|
rt300@24
|
209 core.exit();
|
rt300@24
|
210
|
rt300@25
|
211 // are these handled automatically?
|
rt300@25
|
212 //[introViewController release];
|
rt300@25
|
213 //[topButtonViewController release];
|
rt300@25
|
214 //[bottomTabViewController release];
|
rt300@24
|
215
|
rt300@39
|
216 // clean up MIDI
|
rt300@39
|
217 for(int i = 0; i < inputs.size(); ++i) {
|
rt300@39
|
218 inputs[i]->closePort();
|
rt300@39
|
219 inputs[i]->removeListener(this);
|
rt300@39
|
220 delete inputs[i];
|
rt300@39
|
221 }
|
rt300@39
|
222
|
rt300@39
|
223 for(int i = 0; i < outputs.size(); ++i) {
|
rt300@39
|
224 outputs[i]->closePort();
|
rt300@39
|
225 delete outputs[i];
|
rt300@39
|
226 }
|
rt300@39
|
227
|
rt300@24
|
228 delete sliderGUI;
|
rt300@37
|
229
|
rt300@24
|
230 cout << "exit done \n";
|
rt300@0
|
231 }
|
rt300@24
|
232
|
rt300@24
|
233 //--------------------------------------------------------------
|
rt300@3
|
234 #pragma mark GUI
|
rt300@16
|
235 //--
|
rt300@16
|
236 float testApp::getWidth(){
|
rt300@16
|
237 // depends on orientation
|
rt300@16
|
238 return ofGetWidth();
|
rt300@16
|
239
|
rt300@16
|
240 }
|
rt300@16
|
241 float testApp::getHeight(){
|
rt300@16
|
242 // depends on orientation
|
rt300@16
|
243 return ofGetHeight();
|
rt300@16
|
244
|
rt300@16
|
245 }
|
rt300@24
|
246 #pragma mark GUI
|
rt300@24
|
247 ////////////////////////////
|
rt300@24
|
248 // These functions called from iOS toolbars
|
rt300@24
|
249 //--------------------------------------------------------------
|
rt300@24
|
250 void testApp::lockSequencerPressed(bool locked){
|
rt300@24
|
251 theGridView.shiftCentreToSnapped();
|
rt300@24
|
252 xLocked = locked;
|
rt300@39
|
253 eventLogger.logEvent(SEQ_LOCKED); // TODO whatabout unlock?
|
rt300@25
|
254
|
rt300@24
|
255
|
rt300@24
|
256 }
|
rt300@24
|
257 //--------------------------------------------------------------
|
rt300@24
|
258 void testApp::lockSynthPressed(bool locked){
|
rt300@24
|
259 theGridView.shiftCentreToSnapped();
|
rt300@24
|
260 yLocked = locked;
|
rt300@25
|
261 eventLogger.logEvent(SYNTH_LOCKED);
|
rt300@24
|
262
|
rt300@24
|
263 }
|
rt300@24
|
264 //--------------------------------------------------------------
|
rt300@24
|
265 void testApp::seqStartStop(bool go){
|
rt300@24
|
266 if(!go){ //stop
|
rt300@24
|
267 core.pd.startMessage();
|
rt300@24
|
268 core.pd.addFloat(0);
|
rt300@24
|
269 core.pd.finishMessage("fromOF", "seqStartStop");
|
rt300@25
|
270 eventLogger.logEvent(PAUSE_PRESSED);
|
rt300@24
|
271 }else { // play
|
rt300@24
|
272 //stopSequencer();
|
rt300@24
|
273 core.pd.startMessage();
|
rt300@24
|
274 core.pd.addFloat(1);
|
rt300@24
|
275 core.pd.finishMessage("fromOF", "seqStartStop");
|
rt300@25
|
276 eventLogger.logEvent(PLAY_PRESSED);
|
rt300@24
|
277 }
|
rt300@24
|
278 }
|
rt300@24
|
279 //--------------------------------------------------------------
|
rt300@24
|
280 void testApp::showQuestionnaire(){
|
rt300@24
|
281 // stop updating / drawing
|
rt300@37
|
282
|
rt300@24
|
283 // if(eventLogger.questionnaireCompleted) return;
|
rt300@37
|
284
|
rt300@27
|
285 [topButtonViewController pausePressed:(id)this];
|
rt300@24
|
286
|
rt300@24
|
287 //stopSequencer
|
rt300@27
|
288 seqStartStop(false);
|
rt300@24
|
289
|
rt300@24
|
290 questionnaireViewController = [[QuestionnaireViewController alloc] initWithNibName:@"QuestionnaireViewController" bundle:nil];
|
rt300@24
|
291 [ofxiPhoneGetGLParentView() addSubview:questionnaireViewController.view];
|
rt300@24
|
292
|
rt300@24
|
293 [questionnaireViewController setAppRef:(id)this];
|
rt300@24
|
294 [questionnaireViewController show:(id)this];
|
rt300@24
|
295
|
rt300@24
|
296 whichInterfaceShowing = QUESTIONNAIRE;
|
rt300@24
|
297
|
rt300@37
|
298
|
rt300@24
|
299 }
|
rt300@24
|
300 //--------------------------------------------------------------
|
rt300@28
|
301 void testApp::questionnaireHidden(vector<int> answers, const char* userComments){
|
rt300@24
|
302 // send answers to server as json
|
rt300@28
|
303 eventLogger.questionnaireAnswersObtained(answers, userComments);
|
rt300@39
|
304
|
rt300@39
|
305 freeUseMode();
|
rt300@37
|
306
|
rt300@39
|
307 }
|
rt300@39
|
308 //--------------------------------------------------------------
|
rt300@39
|
309 // shortcut function for testing
|
rt300@39
|
310 void testApp::justStart(){
|
rt300@39
|
311 freeUseMode();
|
rt300@39
|
312 }
|
rt300@39
|
313 //--------------------------------------------------------------
|
rt300@39
|
314 void testApp::freeUseMode(){
|
rt300@38
|
315 interfaceSelected(1);
|
rt300@32
|
316 [bottomTabViewController show:(id)this withSelection:1];
|
rt300@24
|
317
|
rt300@38
|
318 [topButtonViewController enableSmoothSwitch:(id)this];
|
rt300@37
|
319
|
rt300@39
|
320 sendMIDIAndOSC = true;
|
rt300@38
|
321 }
|
rt300@38
|
322 //--------------------------------------------------------------
|
rt300@38
|
323 void testApp::setInterp(int state){
|
rt300@38
|
324 if(state == 0){
|
rt300@38
|
325 theGridView.setInterpolation(Grid::NO_INTERPOLATION);
|
rt300@39
|
326 eventLogger.logEvent(SMOOTHING_OFF);
|
rt300@38
|
327 }else if(state == 1){
|
rt300@38
|
328 theGridView.setInterpolation(Grid::INTERPOLATE_GRID);
|
rt300@39
|
329 eventLogger.logEvent(SMOOTHING_ON);
|
rt300@38
|
330 }
|
rt300@38
|
331 // tell sliders and PD
|
rt300@38
|
332 setAllGUISliders(theGridView.getParams());
|
rt300@39
|
333
|
rt300@33
|
334 }
|
rt300@33
|
335 //--------------------------------------------------------------
|
rt300@24
|
336 void testApp::showIntro(){
|
rt300@37
|
337
|
rt300@24
|
338 cout << "SHOW INTRO\n";
|
rt300@37
|
339
|
rt300@29
|
340 [tsc cancelTimers];
|
rt300@29
|
341 bottomTabViewController.view.hidden = YES;
|
rt300@24
|
342 introViewController = [[IntroViewController alloc] initWithNibName:@"IntroViewController" bundle:nil];
|
rt300@24
|
343 [ofxiPhoneGetGLParentView() addSubview:introViewController.view];
|
rt300@24
|
344
|
rt300@24
|
345 [introViewController setAppRef:(id)this];
|
rt300@24
|
346 [introViewController show:(id)this];
|
rt300@24
|
347
|
rt300@24
|
348
|
rt300@24
|
349 whichInterfaceShowing = INTRO;
|
rt300@24
|
350
|
rt300@24
|
351 }
|
rt300@24
|
352 //--------------------------------------------------------------
|
rt300@24
|
353 void testApp::introHidden(bool OK){
|
rt300@24
|
354 if(OK){
|
rt300@25
|
355 eventLogger.consentGiven = true;
|
rt300@29
|
356 //
|
rt300@29
|
357 // clear presets?
|
rt300@29
|
358 presetManager.clearAll();
|
rt300@25
|
359 // show username prompt
|
rt300@25
|
360 [usernameAlertViewController showUserNamePrompt];
|
rt300@32
|
361 // reset top buttons
|
rt300@32
|
362 [topButtonViewController unlockAll];
|
rt300@32
|
363 randomise();
|
rt300@24
|
364 }
|
rt300@24
|
365 // no unOK
|
rt300@24
|
366 }
|
rt300@24
|
367 //--------------------------------------------------------------
|
rt300@42
|
368 void testApp::startTimedSession(){
|
rt300@42
|
369 [tsc startTimer];
|
rt300@42
|
370 // timer will show alert and set interface
|
rt300@42
|
371 }
|
rt300@42
|
372 //--------------------------------------------------------------
|
rt300@39
|
373 // called from BottomTabViewController iOS segmented thing, also timed session controller
|
rt300@24
|
374 void testApp::interfaceSelected(int which){
|
rt300@24
|
375 switch (which){
|
rt300@39
|
376 case 0: // slider
|
rt300@37
|
377
|
rt300@24
|
378 whichInterfaceShowing = SLIDERS;
|
rt300@24
|
379 sliderGUI->setVisible(true);
|
rt300@24
|
380 // set the slider values to stuff got from zoomer
|
rt300@24
|
381 sliderVals = theGridView.getParams();
|
rt300@24
|
382 setAllGUISliders(sliderVals);
|
rt300@25
|
383
|
rt300@24
|
384 break;
|
rt300@39
|
385 case 1: // both
|
rt300@37
|
386
|
rt300@24
|
387 whichInterfaceShowing = BOTH;
|
rt300@24
|
388 sliderGUI->setVisible(true);
|
rt300@24
|
389 // set the slider values to stuff got from zoomer
|
rt300@24
|
390 sliderVals = theGridView.getParams();
|
rt300@24
|
391 setAllGUISliders(sliderVals);
|
rt300@39
|
392
|
rt300@24
|
393 break;
|
rt300@39
|
394 case 2: // zoomer
|
rt300@37
|
395
|
rt300@24
|
396 sliderGUI->setVisible(false);
|
rt300@24
|
397 whichInterfaceShowing = ZOOMER;
|
rt300@24
|
398 break;
|
rt300@24
|
399 }
|
rt300@39
|
400 eventLogger.logEvent(SWAP_VIEW,theGridView.getCoord(),theGridView.getScale(), which);
|
rt300@24
|
401 }
|
rt300@24
|
402 //--------------------------------------------------------------
|
rt300@24
|
403 //--------------------------------------------------------------
|
rt300@24
|
404 void testApp::setupSliderGui(){
|
rt300@39
|
405
|
rt300@24
|
406 float length = SLIDER_GUI_WIDTH - (OFX_UI_GLOBAL_WIDGET_SPACING*2);
|
rt300@24
|
407
|
rt300@24
|
408
|
rt300@24
|
409 //float dim = 42;
|
rt300@24
|
410
|
rt300@24
|
411 // make this iphone size...?
|
rt300@24
|
412 int height = 480;
|
rt300@39
|
413
|
rt300@24
|
414 float dim = (height-10.0*OFX_UI_GLOBAL_WIDGET_SPACING)/10.0;
|
rt300@24
|
415 // LEFT GUI
|
rt300@42
|
416 sliderGUI = new ofxUICanvas(10,160,SLIDER_GUI_WIDTH,getHeight());
|
rt300@37
|
417
|
rt300@24
|
418 // Uh.. loop this
|
rt300@24
|
419 for(int i = 1; i<=10;i++){
|
rt300@37
|
420
|
rt300@24
|
421 ofxUISlider *slider;
|
rt300@25
|
422 slider = (ofxUISlider *)sliderGUI->addWidgetDown(new ofxUISlider(length,dim,0.0,127,64,sliderParamNames[i-1]));
|
rt300@24
|
423 slider->setDrawPadding(true);
|
rt300@28
|
424 slider->setDrawPaddingOutline(true);
|
rt300@24
|
425 if(i <= 5){
|
rt300@24
|
426 slider->setColorFill(ofColor(0,0,255));
|
rt300@24
|
427 slider->setColorFillHighlight(ofColor(0,0,255));
|
rt300@24
|
428 }else{
|
rt300@24
|
429 slider->setColorFill(ofColor(255,0,0));
|
rt300@24
|
430 slider->setColorFillHighlight(ofColor(255,0,0));
|
rt300@24
|
431 }
|
rt300@24
|
432
|
rt300@24
|
433 sliders.push_back(slider);
|
rt300@24
|
434 }
|
rt300@24
|
435
|
rt300@37
|
436
|
rt300@24
|
437
|
rt300@24
|
438 ofAddListener(sliderGUI->newGUIEvent, this, &testApp::sliderGUIEvent);
|
rt300@37
|
439
|
rt300@24
|
440 }
|
rt300@24
|
441 //--------------------------------------------------------------
|
rt300@24
|
442 void testApp::sliderGUIEvent(ofxUIEventArgs &e){
|
rt300@24
|
443 if(whichInterfaceShowing == ZOOMER){
|
rt300@24
|
444 cout << "GUI ERROR";
|
rt300@24
|
445 return;
|
rt300@24
|
446 }
|
rt300@37
|
447
|
rt300@0
|
448 // "normal" parameter changes
|
rt300@0
|
449 for(int i = 1; i<=10;i++){
|
rt300@0
|
450
|
rt300@24
|
451 if(e.widget->getName() == sliderParamNames[i-1])
|
rt300@0
|
452 {
|
rt300@0
|
453 //cout << "param change: " << p;
|
rt300@0
|
454 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@3
|
455 sliderMoved(i-1,slider->getScaledValue()); // internal array 0 indexed
|
rt300@0
|
456 }
|
rt300@0
|
457 }
|
rt300@37
|
458
|
rt300@0
|
459 }
|
rt300@0
|
460 //--------------------------------------------------------------
|
rt300@3
|
461 void testApp::sliderMoved(int which, float value){
|
rt300@3
|
462 // an update caused by slider view being touched
|
rt300@0
|
463 sliderVals[which] = (int)value;
|
rt300@0
|
464 theGridView.setParams(sliderVals);
|
rt300@37
|
465
|
rt300@3
|
466 sendParametersToPD();
|
rt300@39
|
467 if(sendMIDIAndOSC){
|
rt300@39
|
468
|
rt300@39
|
469 sendMidiParam(which);
|
rt300@39
|
470 sendOSCParams();
|
rt300@39
|
471 }
|
rt300@5
|
472
|
rt300@9
|
473 eventLogger.logEvent(CHANGE_SLIDER, TwoVector(),0.0,which , value);
|
rt300@5
|
474
|
rt300@0
|
475 }
|
rt300@0
|
476 //--------------------------------------------------------------
|
rt300@3
|
477 void testApp::setAllGUISliders(vector<int> vals){
|
rt300@3
|
478 // an update caused by zoomer view being moved
|
rt300@25
|
479 for(int i = 0; i<NUM_PARAMS;i++){
|
rt300@0
|
480 sliders[i]->setValue(vals[i]);
|
rt300@1
|
481 sliderVals[i] = vals[i];
|
rt300@0
|
482 }
|
rt300@3
|
483
|
rt300@39
|
484 sendParametersToPD();
|
rt300@39
|
485 if(sendMIDIAndOSC){
|
rt300@39
|
486
|
rt300@39
|
487 sendMidiParams();
|
rt300@39
|
488 sendOSCParams();
|
rt300@39
|
489 }
|
rt300@39
|
490
|
rt300@0
|
491 }
|
rt300@0
|
492 //--------------------------------------------------------------
|
rt300@25
|
493 void testApp::randomise(){
|
rt300@25
|
494 // pick random settings for all params
|
rt300@39
|
495
|
rt300@39
|
496 // random zoom? no.
|
rt300@25
|
497 for(int i=0; i < NUM_PARAMS ; i++){
|
rt300@25
|
498 sliderVals[i] = ofRandom(0, 127);
|
rt300@25
|
499
|
rt300@25
|
500 }
|
rt300@37
|
501 currentSequence = ofRandom(0, sequences.size()-1);
|
rt300@25
|
502 // send to grid, sliders and PD
|
rt300@25
|
503 theGridView.setParams(sliderVals);
|
rt300@25
|
504 setAllGUISliders(sliderVals);
|
rt300@39
|
505
|
rt300@39
|
506
|
rt300@25
|
507 eventLogger.logEvent(RANDOMISE, theGridView.getCoord() ,0.0);
|
rt300@25
|
508
|
rt300@25
|
509 }
|
rt300@39
|
510 //--------------------------------------------------------------
|
rt300@27
|
511 void testApp::showHelp(){
|
rt300@29
|
512 whichInterfaceShowing = HELP;
|
rt300@27
|
513 seqStartStop(false);
|
rt300@27
|
514 [topButtonViewController pausePressed:(id)this];
|
rt300@27
|
515 helpViewController.view.hidden = NO;
|
rt300@27
|
516 eventLogger.logEvent(HELP_PRESSED);
|
rt300@27
|
517 }
|
rt300@27
|
518 void testApp::helpHidden(){
|
rt300@29
|
519 whichInterfaceShowing = BOTH;
|
rt300@27
|
520 // start seq?
|
rt300@27
|
521
|
rt300@27
|
522 }
|
rt300@25
|
523 //--------------------------------------------------------------
|
rt300@36
|
524 void testApp::nextSequence(){
|
rt300@36
|
525 currentSequence++;
|
rt300@36
|
526 if(currentSequence >= sequences.size()){
|
rt300@36
|
527 currentSequence = 0;
|
rt300@36
|
528 }
|
rt300@36
|
529 sendParametersToPD();
|
rt300@36
|
530 }
|
rt300@36
|
531 //--------------------------------------------------------------
|
rt300@39
|
532 //--------------------------------------------------------------
|
rt300@39
|
533 #pragma mark sending to pd and midi
|
rt300@3
|
534 void testApp::sendParametersToPD(){
|
rt300@37
|
535 static int previousSequence;
|
rt300@37
|
536 // frequencer stuff to get 16 steps
|
rt300@36
|
537
|
rt300@37
|
538 vector<double> vals;
|
rt300@37
|
539
|
rt300@37
|
540
|
rt300@37
|
541 vals.push_back((sliderVals[0]+32)*8.); // DC offset
|
rt300@37
|
542 for(int i=1; i<5;i++){
|
rt300@37
|
543 vals.push_back((sliderVals[i] - 64)*2.);
|
rt300@37
|
544 }
|
rt300@37
|
545
|
rt300@37
|
546 vector<double> steps = frequencer.freqMagEdit(freqIndexes, vals);
|
rt300@37
|
547 List seqSteps;
|
rt300@37
|
548 seqSteps.addSymbol("seqSteps");
|
rt300@37
|
549 for(int i=0; i < 16; i++){
|
rt300@37
|
550 seqSteps.addFloat(round(steps[i]));
|
rt300@37
|
551 }
|
rt300@37
|
552 core.pd.sendList("fromOF", seqSteps);
|
rt300@37
|
553
|
rt300@36
|
554 /*
|
rt300@37
|
555 if(currentSequence != previousSequence){
|
rt300@37
|
556 List seqSteps;
|
rt300@37
|
557
|
rt300@37
|
558 seqSteps.addSymbol("seqSteps");
|
rt300@37
|
559 if(currentSequence >= sequences.size() || currentSequence < 0){
|
rt300@37
|
560 cout << "ERROR: not a valid sequence index\n";
|
rt300@37
|
561 for(int i=0; i < 16; i++){
|
rt300@37
|
562 seqSteps.addFloat(50);
|
rt300@37
|
563 }
|
rt300@37
|
564 }else{
|
rt300@37
|
565 for(int i=0; i < 16; i++){
|
rt300@37
|
566 seqSteps.addFloat(round(sequences[currentSequence][i]));
|
rt300@37
|
567 }
|
rt300@37
|
568 }
|
rt300@37
|
569
|
rt300@37
|
570 core.pd.sendList("fromOF", seqSteps);
|
rt300@37
|
571 previousSequence = currentSequence;
|
rt300@3
|
572 }
|
rt300@36
|
573 */
|
rt300@36
|
574
|
rt300@37
|
575 // send synth params
|
rt300@3
|
576 sendOscShape(sliderVals[5]);
|
rt300@3
|
577 sendFiltType(sliderVals[6]);
|
rt300@3
|
578 sendFiltFreq(sliderVals[7]);
|
rt300@3
|
579 sendEnvShape(sliderVals[8]);
|
rt300@3
|
580 sendModFreq(sliderVals[9]);
|
rt300@39
|
581
|
rt300@3
|
582
|
rt300@3
|
583 }
|
rt300@39
|
584 //--------------------------------------------------------------
|
rt300@39
|
585 void testApp::sendMidiParam(int which){
|
rt300@39
|
586 int midiChannel = 7;
|
rt300@39
|
587 int offset = 0;
|
rt300@39
|
588
|
rt300@39
|
589 for(int i = 0; i < outputs.size(); ++i) {
|
rt300@39
|
590 outputs[i]->sendControlChange(midiChannel, offset+which, sliderVals[which]);
|
rt300@39
|
591 }
|
rt300@39
|
592
|
rt300@39
|
593
|
rt300@39
|
594 }
|
rt300@39
|
595 //--------------------------------------------------------------
|
rt300@39
|
596 void testApp::sendMidiParams(){
|
rt300@39
|
597
|
rt300@39
|
598 for(int i = 0; i< sliderVals.size(); i++){
|
rt300@39
|
599 for(int j = 0; j < outputs.size(); ++j) {
|
rt300@39
|
600 outputs[j]->sendControlChange(midiChannel, midiOffset+i, sliderVals[i]);
|
rt300@39
|
601 }
|
rt300@39
|
602 }
|
rt300@39
|
603
|
rt300@39
|
604 }
|
rt300@39
|
605 //--------------------------------------------------------------
|
rt300@39
|
606 void testApp::sendOSCParams(){
|
rt300@39
|
607
|
rt300@39
|
608 ofxOscMessage m;
|
rt300@39
|
609 m.setAddress( "sonicZoom" );
|
rt300@39
|
610
|
rt300@39
|
611 for(int i = 0; i< sliderVals.size(); i++){
|
rt300@39
|
612
|
rt300@39
|
613 m.addFloatArg(sliderVals[i]);
|
rt300@39
|
614
|
rt300@39
|
615 }
|
rt300@39
|
616 sender.sendMessage( m );
|
rt300@39
|
617 }
|
rt300@39
|
618 //--------------------------------------------------------------
|
rt300@39
|
619
|
rt300@27
|
620 void testApp::setupNewUser(){
|
rt300@27
|
621 // this function is for supervised trials with my ipad
|
rt300@27
|
622 eventLogger.newUser();
|
rt300@27
|
623 }
|
rt300@8
|
624 //--------------------------------------------------------------
|
rt300@3
|
625 #pragma mark STANDARD OF FUNCTIONS
|
rt300@3
|
626 //--------------------------------------------------------------
|
rt300@0
|
627 void testApp::update(){
|
rt300@37
|
628
|
rt300@16
|
629 if(paused) return;
|
rt300@16
|
630
|
rt300@32
|
631 if(ofxiPhoneExternalDisplay::isExternalScreenConnected()){
|
rt300@32
|
632 if(!ofxiPhoneExternalDisplay::isMirroring()){
|
rt300@32
|
633 ofxiPhoneExternalDisplay::mirrorOn();
|
rt300@32
|
634 printf("turned on Mirroring!\n");
|
rt300@32
|
635 }
|
rt300@32
|
636 }
|
rt300@32
|
637
|
rt300@27
|
638 // continiue to move or zoom at velocity, unless snapped
|
rt300@3
|
639
|
rt300@3
|
640 if (numActiveTouches == 0){ // no touches, use momentum
|
rt300@32
|
641 // ZOOM MOMENTUM
|
rt300@32
|
642 // continiue to zoom at velocity
|
rt300@32
|
643 if (numActiveTouches < 2 && abs(zoomVel)>0.001){
|
rt300@32
|
644 theGridView.zoom(zoomVel + 1.0); // +1 because zoomVel factor is + or - , wheras zoom is a multiplier near 1
|
rt300@32
|
645 zoomVel = zoomVel*slowFactor;
|
rt300@32
|
646 moveVel.setCoord(0.0,0.0);; // don't move if zooming! Too many events!
|
rt300@35
|
647
|
rt300@37
|
648 setAllGUISliders(theGridView.getParams());
|
rt300@39
|
649
|
rt300@32
|
650 }
|
rt300@32
|
651
|
rt300@22
|
652 if(moveVel.norm() > 0.3){
|
rt300@22
|
653 if(theGridView.snapped){
|
rt300@28
|
654 // stop it (snap check sends snap event)
|
rt300@22
|
655 moveVel.setCoord(0.0,0.0);
|
rt300@22
|
656 }else{
|
rt300@22
|
657 theGridView.move(moveVel);
|
rt300@22
|
658 moveVel = moveVel*slowFactor;
|
rt300@22
|
659 }
|
rt300@37
|
660 // and get new parameter values
|
rt300@5
|
661 setAllGUISliders(theGridView.getParams());
|
rt300@39
|
662
|
rt300@22
|
663 }else if(moveVel.norm() > 0.01){ // and less than 0.3
|
rt300@3
|
664 // stop it
|
rt300@3
|
665 moveVel.setCoord(0.0,0.0);
|
rt300@5
|
666 setAllGUISliders(theGridView.getParams());
|
rt300@39
|
667
|
rt300@5
|
668 eventLogger.logEvent(SCROLL_STOPPED, theGridView.getCoord() );
|
rt300@22
|
669
|
rt300@3
|
670 }else{
|
rt300@3
|
671 // stopped - do nothing
|
rt300@3
|
672 }
|
rt300@37
|
673
|
rt300@0
|
674 }
|
rt300@37
|
675
|
rt300@0
|
676 }
|
rt300@39
|
677
|
rt300@0
|
678 //--------------------------------------------------------------
|
rt300@39
|
679
|
rt300@0
|
680 void testApp::draw(){
|
rt300@37
|
681
|
rt300@24
|
682 switch (whichInterfaceShowing){
|
rt300@24
|
683 case SLIDERS:
|
rt300@24
|
684 break;
|
rt300@24
|
685 case ZOOMER:
|
rt300@24
|
686 theGridView.draw();
|
rt300@37
|
687
|
rt300@24
|
688 break;
|
rt300@24
|
689 case BOTH:
|
rt300@33
|
690
|
rt300@33
|
691 theGridView.draw();
|
rt300@37
|
692
|
rt300@24
|
693 break;
|
rt300@24
|
694 case INTRO:
|
rt300@24
|
695 break;
|
rt300@24
|
696
|
rt300@24
|
697 case QUESTIONNAIRE:
|
rt300@24
|
698 break;
|
rt300@24
|
699
|
rt300@0
|
700 }
|
rt300@4
|
701
|
rt300@0
|
702 }
|
rt300@0
|
703
|
rt300@0
|
704 //--------------------------------------------------------------
|
rt300@0
|
705 void testApp::touchDown(ofTouchEventArgs &touch){
|
rt300@27
|
706 // in slider gui area?
|
rt300@24
|
707 if(whichInterfaceShowing == SLIDERS){
|
rt300@24
|
708 return;
|
rt300@24
|
709 }else if (whichInterfaceShowing == BOTH && touch.x < (SLIDER_GUI_WIDTH+10)){
|
rt300@24
|
710 return;
|
rt300@24
|
711
|
rt300@24
|
712 }// otherwise we're good to let the zoomer handle touch
|
rt300@0
|
713
|
rt300@0
|
714 numActiveTouches++;
|
rt300@27
|
715 preventingMovePostScroll = false;
|
rt300@37
|
716
|
rt300@0
|
717 if(touch.id == 0){
|
rt300@0
|
718 touch0.setCoord(touch.x,touch.y);
|
rt300@0
|
719 prevTouch0 = touch0;
|
rt300@32
|
720 // stop zoom
|
rt300@32
|
721 zoomVel = 0.0;
|
rt300@0
|
722 }else if(touch.id == 1){
|
rt300@0
|
723
|
rt300@0
|
724 touch1.setCoord(touch.x,touch.y);
|
rt300@0
|
725 prevTouch1 = touch1;
|
rt300@0
|
726
|
rt300@0
|
727 }
|
rt300@0
|
728 if(numActiveTouches == 1){
|
rt300@0
|
729 moveVel.setCoord(0.0, 0.0);
|
rt300@0
|
730 prevMove.setCoord(0.0, 0.0);
|
rt300@0
|
731 prevMove2.setCoord(0.0, 0.0);
|
rt300@27
|
732
|
rt300@0
|
733 }else if(numActiveTouches == 2){
|
rt300@0
|
734 zoomVel = 0.0;
|
rt300@0
|
735 prevZoom = 0.0;
|
rt300@0
|
736 prevZoom2 = 0.0;
|
rt300@0
|
737 double dist = touch1.distanceTo(touch0);
|
rt300@0
|
738 prevDist = dist;
|
rt300@0
|
739 }
|
rt300@37
|
740
|
rt300@0
|
741 }
|
rt300@0
|
742
|
rt300@0
|
743 //--------------------------------------------------------------
|
rt300@0
|
744 void testApp::touchMoved(ofTouchEventArgs &touch){
|
rt300@1
|
745
|
rt300@24
|
746 // TODO check if in gui area!!!
|
rt300@24
|
747 if(whichInterfaceShowing == SLIDERS){
|
rt300@24
|
748 return;
|
rt300@24
|
749 }else if (whichInterfaceShowing == BOTH && touch.x < (SLIDER_GUI_WIDTH+10)){
|
rt300@24
|
750 return;
|
rt300@24
|
751
|
rt300@27
|
752 }
|
rt300@24
|
753
|
rt300@27
|
754 // otherwise we're good to let the zoomer handle touch
|
rt300@37
|
755
|
rt300@1
|
756 // which one? keep track of each touch point
|
rt300@0
|
757 if(touch.id == 0){
|
rt300@0
|
758 touch0.setCoord(touch.x,touch.y);
|
rt300@0
|
759
|
rt300@0
|
760 }else if(touch.id == 1){
|
rt300@0
|
761
|
rt300@0
|
762 touch1.setCoord(touch.x,touch.y);
|
rt300@0
|
763 }
|
rt300@37
|
764
|
rt300@1
|
765 if(numActiveTouches == 1){
|
rt300@27
|
766 if(preventingMovePostScroll) return;
|
rt300@1
|
767 handleScroll();
|
rt300@0
|
768 }else if(numActiveTouches == 2){
|
rt300@1
|
769 handleZoom();
|
rt300@0
|
770
|
rt300@0
|
771 }
|
rt300@0
|
772 prevTouch0 = touch0;
|
rt300@37
|
773
|
rt300@0
|
774
|
rt300@0
|
775 }
|
rt300@5
|
776
|
rt300@1
|
777 //--------------------------------------------------------------
|
rt300@27
|
778 // handle a finger being dragged
|
rt300@1
|
779 void testApp::handleScroll(){
|
rt300@37
|
780
|
rt300@1
|
781 TwoVector move = touch0 - prevTouch0;
|
rt300@5
|
782 if(yLocked){
|
rt300@5
|
783 move.y = 0.0;
|
rt300@5
|
784 }
|
rt300@5
|
785 if(xLocked){
|
rt300@5
|
786 move.x = 0.0;
|
rt300@5
|
787 }
|
rt300@37
|
788
|
rt300@6
|
789 // check time since last move - if
|
rt300@6
|
790 unsigned int moveTime = ofGetSystemTimeMicros();
|
rt300@6
|
791 if(moveTime - lastMoveTime > 100000){
|
rt300@6
|
792 moveVel = TwoVector(); // zero
|
rt300@6
|
793 }else{
|
rt300@6
|
794 moveVel = (move*0.3 + prevMove*0.34 + prevMove2*0.38); // use the time
|
rt300@6
|
795
|
rt300@6
|
796 }
|
rt300@6
|
797 lastMoveTime = moveTime;
|
rt300@6
|
798
|
rt300@37
|
799
|
rt300@1
|
800 prevMove2 = prevMove;
|
rt300@1
|
801 prevMove = move;
|
rt300@1
|
802
|
rt300@37
|
803
|
rt300@3
|
804 theGridView.move(move);
|
rt300@3
|
805
|
rt300@3
|
806 // and get new parameter values
|
rt300@3
|
807 setAllGUISliders(theGridView.getParams());
|
rt300@39
|
808
|
rt300@1
|
809 }
|
rt300@1
|
810 //--------------------------------------------------------------
|
rt300@27
|
811 // handle pinch movememnt
|
rt300@1
|
812 void testApp::handleZoom(){
|
rt300@1
|
813 // work out change in difference
|
rt300@1
|
814 double dist = touch1.distanceTo(touch0);
|
rt300@1
|
815 double zoomFactor = prevDist/dist;
|
rt300@1
|
816
|
rt300@1
|
817 //TODO check for sensible maximums, e.g. spurious touch data
|
rt300@1
|
818 if(zoomFactor > 2.0 || zoomFactor < 0.5){
|
rt300@1
|
819 cout << "Zoom too much!!!!" << zoomFactor;
|
rt300@1
|
820 zoomFactor = 1.0;
|
rt300@1
|
821 }
|
rt300@1
|
822
|
rt300@1
|
823 zoomVel = (zoomFactor-1)*0.3 + prevZoom*0.34 + prevZoom2*0.38;
|
rt300@1
|
824 prevZoom2 = prevZoom;
|
rt300@1
|
825 prevZoom = (zoomFactor-1);
|
rt300@1
|
826
|
rt300@1
|
827 theGridView.zoom(zoomFactor);
|
rt300@1
|
828
|
rt300@1
|
829 prevDist = dist;
|
rt300@35
|
830
|
rt300@3
|
831
|
rt300@37
|
832 setAllGUISliders(theGridView.getParams());
|
rt300@39
|
833
|
rt300@37
|
834
|
rt300@37
|
835
|
rt300@1
|
836 }
|
rt300@0
|
837 //--------------------------------------------------------------
|
rt300@0
|
838 void testApp::touchUp(ofTouchEventArgs &touch){
|
rt300@1
|
839 if(numActiveTouches > 0) numActiveTouches--; // dirty
|
rt300@27
|
840 preventingMovePostScroll = false;
|
rt300@24
|
841 // TODO check if in gui area!!!
|
rt300@24
|
842 if(whichInterfaceShowing == SLIDERS){
|
rt300@24
|
843 return;
|
rt300@24
|
844 }else if (whichInterfaceShowing == BOTH && touch.x < 256){
|
rt300@24
|
845 return;
|
rt300@1
|
846
|
rt300@24
|
847 }// otherwise we're good to let the zoomer handle touch
|
rt300@24
|
848
|
rt300@37
|
849
|
rt300@0
|
850 // which one?
|
rt300@0
|
851 if(touch.id == 0){
|
rt300@0
|
852 // tricky situation - we tried to zoom but may have left non-move finger on
|
rt300@0
|
853 prevTouch0.setCoord(touch.x,touch.y);
|
rt300@0
|
854
|
rt300@0
|
855 }else if(touch.id == 1){
|
rt300@0
|
856
|
rt300@37
|
857
|
rt300@0
|
858 prevTouch1.setCoord(0,0);
|
rt300@6
|
859
|
rt300@6
|
860 }
|
rt300@6
|
861 if(numActiveTouches == 0){
|
rt300@6
|
862 // check time since last move
|
rt300@6
|
863 // check time since last move - if
|
rt300@6
|
864 unsigned int moveTime = ofGetSystemTimeMicros();
|
rt300@6
|
865 if(moveTime - lastMoveTime > 100000){
|
rt300@6
|
866 moveVel = TwoVector(); // zero
|
rt300@6
|
867 }else{
|
rt300@6
|
868 moveVel = (move*0.3 + prevMove*0.34 + prevMove2*0.38); // use the time
|
rt300@6
|
869
|
rt300@6
|
870 }
|
rt300@6
|
871 lastMoveTime = moveTime;
|
rt300@27
|
872 }else if (numActiveTouches == 1){
|
rt300@27
|
873 // just zoomed , but now lifted one of the fingers
|
rt300@27
|
874 // can be bad if moved so create special mode to stop scroll (special modes bad!)
|
rt300@27
|
875 preventingMovePostScroll = true;
|
rt300@0
|
876 }
|
rt300@37
|
877
|
rt300@0
|
878 }
|
rt300@0
|
879
|
rt300@0
|
880 //--------------------------------------------------------------
|
rt300@0
|
881 void testApp::touchDoubleTap(ofTouchEventArgs &touch){
|
rt300@0
|
882 // preset?
|
rt300@25
|
883
|
rt300@25
|
884 /* ballses everything for some reason
|
rt300@37
|
885 TwoVector centre = TwoVector(getWidth()*0.5,getHeight()*0.5);
|
rt300@37
|
886 // if near centre
|
rt300@37
|
887 if((touch.x < centre.x+10) && (touch.x > centre.x-10) && (touch.y < centre.y+10) && (touch.y > centre.y-10)){
|
rt300@37
|
888 numActiveTouches = 0; // dirty
|
rt300@37
|
889 presetManager.showNameDialog();
|
rt300@37
|
890
|
rt300@37
|
891 }
|
rt300@25
|
892 */
|
rt300@25
|
893
|
rt300@0
|
894 }
|
rt300@0
|
895
|
rt300@0
|
896 //--------------------------------------------------------------
|
rt300@0
|
897 void testApp::lostFocus(){
|
rt300@37
|
898
|
rt300@0
|
899 }
|
rt300@0
|
900
|
rt300@0
|
901 //--------------------------------------------------------------
|
rt300@0
|
902 void testApp::gotFocus(){
|
rt300@37
|
903
|
rt300@0
|
904 }
|
rt300@0
|
905
|
rt300@0
|
906 //--------------------------------------------------------------
|
rt300@0
|
907 void testApp::gotMemoryWarning(){
|
rt300@37
|
908
|
rt300@0
|
909 }
|
rt300@0
|
910
|
rt300@0
|
911 //--------------------------------------------------------------
|
rt300@0
|
912 void testApp::deviceOrientationChanged(int newOrientation){
|
rt300@37
|
913 /*
|
rt300@37
|
914 cout << "orientation: " << newOrientation;
|
rt300@37
|
915
|
rt300@37
|
916 if(newOrientation == 4){
|
rt300@37
|
917 ofxiPhoneSetOrientation( OF_ORIENTATION_DEFAULT );
|
rt300@37
|
918
|
rt300@37
|
919 }else if(newOrientation == 3){
|
rt300@37
|
920 ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT );
|
rt300@37
|
921 }else if(newOrientation == 3){
|
rt300@37
|
922 ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT );
|
rt300@37
|
923 }
|
rt300@37
|
924
|
rt300@37
|
925
|
rt300@37
|
926 [ofxiPhoneGetGLView() updateDimensions];
|
rt300@37
|
927 */
|
rt300@0
|
928 }
|
rt300@0
|
929
|
rt300@0
|
930
|
rt300@0
|
931 //--------------------------------------------------------------
|
rt300@0
|
932 void testApp::touchCancelled(ofTouchEventArgs& args){
|
rt300@37
|
933
|
rt300@0
|
934 }
|
rt300@3
|
935 //---------------------------------------------------------------
|
rt300@3
|
936 // AUDIO STUFF
|
rt300@3
|
937 //---------------------------------------------------------------
|
rt300@3
|
938
|
rt300@3
|
939 #pragma mark AUDIO STREAMS
|
rt300@3
|
940 //--------------------------------------------------------------
|
rt300@3
|
941 void testApp::audioReceived(float * input, int bufferSize, int nChannels) {
|
rt300@3
|
942 core.audioReceived(input, bufferSize, nChannels);
|
rt300@3
|
943 }
|
rt300@3
|
944
|
rt300@3
|
945 void testApp::audioRequested(float * output, int bufferSize, int nChannels) {
|
rt300@3
|
946 core.audioRequested(output, bufferSize, nChannels);
|
rt300@3
|
947 }
|
rt300@3
|
948 //---------------------------------------------------------------
|
rt300@3
|
949 #pragma mark UTILITIES
|
rt300@0
|
950
|
rt300@0
|
951 // 5hz cut off
|
rt300@0
|
952 const double fB[3] = {0.049489956268677, 0.098979912537354, 0.049489956268677};
|
rt300@0
|
953
|
rt300@0
|
954 const double fA[3] = {1.000000000000000, -1.279632424997809, 0.477592250072517};
|
rt300@0
|
955
|
rt300@0
|
956 // 1hz cut off
|
rt300@0
|
957 //const double fB[3] = {0.002550535158536, 0.005101070317073, 0.002550535158536};
|
rt300@0
|
958
|
rt300@0
|
959 //const double fA[3] = {1.000000000000000, -1.852146485395936, 0.862348626030081};
|
rt300@0
|
960
|
rt300@0
|
961
|
rt300@0
|
962 //a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)- a(2)*y(n-1) - ... - a(na+1)*y(n-na)
|
rt300@0
|
963 //---------------------------------------------------------------
|
rt300@0
|
964 vector<float> testApp::vectorFilter(vector<float> newVec){
|
rt300@0
|
965 static vector<float> x0(10,0);
|
rt300@0
|
966 static vector<float> x1(10,0);
|
rt300@0
|
967 static vector<float> x2(10,0);
|
rt300@0
|
968 static vector<float> y0(10,0);
|
rt300@0
|
969 static vector<float> y1(10,0);
|
rt300@0
|
970 static vector<float> y2(10,0);
|
rt300@0
|
971
|
rt300@0
|
972 x0 = newVec;
|
rt300@0
|
973
|
rt300@0
|
974 // this low passes a bunch of params values all at once
|
rt300@0
|
975 int sz = newVec.size();
|
rt300@0
|
976 for(int i=0; i<sz; i++){
|
rt300@0
|
977 y0[i] = fB[0]*x0[i] + fB[1]*x1[i] + fB[2]*x2[i] - fA[1]*y1[i] - fA[2]*y2[i];
|
rt300@0
|
978 }
|
rt300@0
|
979 // shift
|
rt300@0
|
980 x2 = x1;
|
rt300@0
|
981 x1 = x0;
|
rt300@0
|
982 y2 = y1;
|
rt300@0
|
983 y1 = y0;
|
rt300@0
|
984
|
rt300@0
|
985 return y0;
|
rt300@2
|
986 }
|
rt300@35
|
987 //---------------------------------------------------------------
|
rt300@24
|
988 float ctrlSmoother(float newsamp){
|
rt300@24
|
989 static float x1,x2,y1,y2;
|
rt300@24
|
990 float x0, y0;
|
rt300@37
|
991
|
rt300@24
|
992 x0 = newsamp;
|
rt300@37
|
993
|
rt300@24
|
994 y0 = fB[0]*x0 + fB[1]*x1 + fB[2]*x2 - fA[1]*y1 - fA[2]*y2;
|
rt300@37
|
995
|
rt300@24
|
996 // shift
|
rt300@24
|
997 x2 = x1;
|
rt300@24
|
998 x1 = x0;
|
rt300@24
|
999 y2 = y1;
|
rt300@24
|
1000 y1 = y0;
|
rt300@24
|
1001
|
rt300@24
|
1002 return y0;
|
rt300@24
|
1003 }
|
rt300@8
|
1004 //---------------------------------------------------------------
|
rt300@3
|
1005 void testApp::sendOscShape(int ctrlin){
|
rt300@35
|
1006 if(ctrlin < 0 || ctrlin > 127){
|
rt300@35
|
1007 cout << "ERROR: bad slider value!";
|
rt300@35
|
1008 return;
|
rt300@35
|
1009 }
|
rt300@3
|
1010
|
rt300@3
|
1011 static int numpoints = 5;
|
rt300@3
|
1012 static int numcontrols = 5;
|
rt300@3
|
1013 //float values[points][controls] =
|
rt300@3
|
1014 float ctrlout[numcontrols];
|
rt300@3
|
1015 string ctrlName[5] = {"pWidth" , "sqVol", "sawVol", "sineVol", "FMAmt"};
|
rt300@3
|
1016 float values[5][5] =
|
rt300@37
|
1017 {{0.5, 0., 0., 1., 1.}, // 0
|
rt300@37
|
1018 {0.5, 0., 0., 1., 0.}, // 32
|
rt300@3
|
1019 {0.5, 0., 1., 0., 0.}, // 64
|
rt300@3
|
1020 {0.5, 1., 1., 0., 0.}, // 96
|
rt300@3
|
1021 {0.01,1., 1., 0., 0.}}; // 127
|
rt300@37
|
1022
|
rt300@3
|
1023 float fidx = (numpoints-1)*ctrlin/128.;
|
rt300@3
|
1024 int idx = floor(fidx);
|
rt300@3
|
1025 float frac = fidx - idx;
|
rt300@3
|
1026 for(int i=0; i < numcontrols; i++){
|
rt300@3
|
1027 ctrlout[i] = (1 - frac)*values[idx][i] + (frac)*values[idx+1][i];
|
rt300@3
|
1028 // send to PD
|
rt300@3
|
1029 List toPD;
|
rt300@3
|
1030
|
rt300@3
|
1031 toPD.addSymbol(ctrlName[i]);
|
rt300@3
|
1032 toPD.addFloat(ctrlout[i]); // rounding here??
|
rt300@37
|
1033
|
rt300@3
|
1034 core.pd.sendList("fromOF", toPD);
|
rt300@3
|
1035 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
|
rt300@3
|
1036 }
|
rt300@3
|
1037
|
rt300@2
|
1038 }
|
rt300@8
|
1039 //---------------------------------------------------------------
|
rt300@3
|
1040 void testApp::sendFiltType(int ctrlin){
|
rt300@35
|
1041 if(ctrlin < 0 || ctrlin > 127){
|
rt300@35
|
1042 cout << "ERROR: bad slider value!";
|
rt300@35
|
1043 return;
|
rt300@35
|
1044 }
|
rt300@3
|
1045 static int numpoints = 3;
|
rt300@3
|
1046 static int numcontrols = 4;
|
rt300@3
|
1047 //float values[points][controls] =
|
rt300@3
|
1048 float ctrlout[numcontrols];
|
rt300@3
|
1049 string ctrlName[4] = {"lpLev" , "bpLev", "hpLev", "reson"};
|
rt300@3
|
1050 float values[3][4] =
|
rt300@37
|
1051 {{2., 0., 0., 1.}, // 0
|
rt300@24
|
1052 {0., 10., 0., 10.}, // 64
|
rt300@24
|
1053 {0., 0., 1., 1.}}; // 127
|
rt300@3
|
1054
|
rt300@3
|
1055 float fidx = (numpoints-1)*ctrlin/128.;
|
rt300@3
|
1056 int idx = floor(fidx);
|
rt300@3
|
1057 float frac = fidx - idx;
|
rt300@3
|
1058 for(int i=0; i < numcontrols; i++){
|
rt300@3
|
1059 ctrlout[i] = (1 - frac)*values[idx][i] + (frac)*values[idx+1][i];
|
rt300@3
|
1060 // send to PD
|
rt300@3
|
1061 List toPD;
|
rt300@3
|
1062
|
rt300@3
|
1063 toPD.addSymbol(ctrlName[i]);
|
rt300@3
|
1064 toPD.addFloat(ctrlout[i]); // rounding here??
|
rt300@3
|
1065
|
rt300@3
|
1066 core.pd.sendList("fromOF", toPD);
|
rt300@3
|
1067 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
|
rt300@3
|
1068 }
|
rt300@2
|
1069 }
|
rt300@8
|
1070 //---------------------------------------------------------------
|
rt300@3
|
1071 void testApp::sendFiltFreq(int ctrlin){
|
rt300@35
|
1072 if(ctrlin < 0 || ctrlin > 127){
|
rt300@35
|
1073 cout << "ERROR: bad slider value!";
|
rt300@35
|
1074 return;
|
rt300@35
|
1075 }
|
rt300@24
|
1076 // smooth this
|
rt300@24
|
1077 float fin = ctrlin;
|
rt300@24
|
1078 float fout;
|
rt300@24
|
1079 fout = (int)ctrlSmoother(fin);
|
rt300@3
|
1080 List toPD;
|
rt300@3
|
1081
|
rt300@3
|
1082 toPD.addSymbol("filtFreq");
|
rt300@37
|
1083 toPD.addFloat(fout);
|
rt300@3
|
1084
|
rt300@3
|
1085 core.pd.sendList("fromOF", toPD);
|
rt300@3
|
1086 }
|
rt300@8
|
1087 //---------------------------------------------------------------
|
rt300@3
|
1088 void testApp::sendEnvShape(int ctrlin){
|
rt300@35
|
1089 if(ctrlin < 0 || ctrlin > 127){
|
rt300@35
|
1090 cout << "ERROR: bad slider value!";
|
rt300@35
|
1091 return;
|
rt300@35
|
1092 }
|
rt300@3
|
1093 static int numpoints = 5;
|
rt300@3
|
1094 static int numcontrols = 3;
|
rt300@3
|
1095 //float values[points][controls] =
|
rt300@3
|
1096 float ctrlout[numcontrols];
|
rt300@3
|
1097 string ctrlName[3] = {"attack" , "decay", "sustain"};
|
rt300@3
|
1098 float values[5][3] =
|
rt300@37
|
1099 {{0., 0., 0.}, // 0
|
rt300@3
|
1100 {0., 0.5, 0.}, // 32
|
rt300@3
|
1101 {0.0, 1., 0.8}, // 64
|
rt300@3
|
1102 {0.99, 0.3, 0.}, // 96
|
rt300@3
|
1103 {0.3, 0.1, 0.}}; // 127
|
rt300@3
|
1104
|
rt300@3
|
1105 float fidx = (numpoints-1)*ctrlin/128.;
|
rt300@3
|
1106 int idx = floor(fidx);
|
rt300@3
|
1107 float frac = fidx - idx;
|
rt300@3
|
1108 for(int i=0; i < numcontrols; i++){
|
rt300@3
|
1109 ctrlout[i] = (1 - frac)*values[idx][i] + (frac)*values[idx+1][i];
|
rt300@3
|
1110 // send to PD
|
rt300@3
|
1111 List toPD;
|
rt300@3
|
1112
|
rt300@3
|
1113 toPD.addSymbol(ctrlName[i]);
|
rt300@3
|
1114 toPD.addFloat(ctrlout[i]); // rounding here??
|
rt300@3
|
1115
|
rt300@3
|
1116 core.pd.sendList("fromOF", toPD);
|
rt300@3
|
1117 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
|
rt300@3
|
1118 }
|
rt300@3
|
1119 }
|
rt300@8
|
1120 //---------------------------------------------------------------
|
rt300@3
|
1121 void testApp::sendModFreq(int ctrlin){
|
rt300@35
|
1122 if(ctrlin < 0 || ctrlin > 127){
|
rt300@35
|
1123 cout << "ERROR: bad slider value!";
|
rt300@35
|
1124 return;
|
rt300@35
|
1125 }
|
rt300@3
|
1126 float fm = ctrlin/127.;
|
rt300@3
|
1127 List toPD;
|
rt300@3
|
1128
|
rt300@3
|
1129 toPD.addSymbol("FMFreq");
|
rt300@3
|
1130 toPD.addFloat(fm); // rounding here??
|
rt300@3
|
1131
|
rt300@3
|
1132 core.pd.sendList("fromOF", toPD);
|
rt300@8
|
1133 }
|
rt300@35
|
1134 //---------------------------------------------------------------
|
rt300@35
|
1135
|
rt300@35
|
1136
|
rt300@35
|
1137
|
rt300@35
|
1138 //---------------------------------------------------------------------------
|
rt300@35
|
1139 void saveSequences(){
|
rt300@35
|
1140 ofFile sequenceFile(ofxiPhoneGetDocumentsDirectory() + "pilot_sequences.json" ,ofFile::WriteOnly);
|
rt300@35
|
1141
|
rt300@35
|
1142 // the 5 harmonics for the frequencer
|
rt300@35
|
1143 vector<int> freqIndexes;
|
rt300@35
|
1144 freqIndexes.push_back(0);
|
rt300@35
|
1145 freqIndexes.push_back(4);
|
rt300@35
|
1146 freqIndexes.push_back(6);
|
rt300@35
|
1147 freqIndexes.push_back(7);
|
rt300@35
|
1148 freqIndexes.push_back(8);
|
rt300@35
|
1149
|
rt300@35
|
1150 // loop thru all presets
|
rt300@35
|
1151 int N = presetManager.thePresets.size();
|
rt300@35
|
1152
|
rt300@35
|
1153 vector<int> sliderVals;
|
rt300@35
|
1154
|
rt300@35
|
1155 Json::Value root;
|
rt300@35
|
1156
|
rt300@35
|
1157 vector<double> vals;
|
rt300@35
|
1158
|
rt300@35
|
1159 for(int i = 0; i< N ; i++){
|
rt300@35
|
1160 sliderVals = theGridView.calculateParamsFromCoord(presetManager.thePresets[i]->coordinates);
|
rt300@35
|
1161
|
rt300@35
|
1162 vals.push_back((sliderVals[0]+32)*8.); // DC offset
|
rt300@35
|
1163 for(int i=1; i<5;i++){
|
rt300@35
|
1164 vals.push_back((sliderVals[i] - 64)*2.);
|
rt300@35
|
1165 }
|
rt300@35
|
1166
|
rt300@35
|
1167
|
rt300@35
|
1168 vector<double> steps = frequencer.freqMagEdit(freqIndexes, vals);
|
rt300@35
|
1169
|
rt300@35
|
1170 for(int j = 0; j<16;j++){
|
rt300@35
|
1171 root["sequences"][i][j] = int(steps[j]);
|
rt300@35
|
1172 }
|
rt300@35
|
1173 vals.clear();
|
rt300@35
|
1174 }
|
rt300@35
|
1175
|
rt300@35
|
1176 //cout << root;
|
rt300@35
|
1177 sequenceFile << root;
|
rt300@35
|
1178 }
|
rt300@35
|
1179 //=--------------------------------------------------------------------
|
rt300@36
|
1180 void testApp::loadSequences(){
|
rt300@36
|
1181
|
rt300@36
|
1182 // read in sequence preset file
|
rt300@36
|
1183 string jsonFile = ofxiPhoneGetDocumentsDirectory() + "pilot_sequences.json";
|
rt300@37
|
1184
|
rt300@36
|
1185 Json::Value root;
|
rt300@36
|
1186 Json::Reader reader;
|
rt300@37
|
1187
|
rt300@36
|
1188 ifstream theFile(jsonFile.c_str());
|
rt300@36
|
1189 stringstream fileText;
|
rt300@36
|
1190 string line;
|
rt300@36
|
1191 if(!theFile){
|
rt300@36
|
1192 cout<<"can't find sequence file: " << jsonFile.c_str() << "\n";
|
rt300@36
|
1193 return;
|
rt300@36
|
1194 }else{
|
rt300@36
|
1195
|
rt300@36
|
1196 while(theFile){
|
rt300@36
|
1197 theFile >> line;
|
rt300@36
|
1198 // cout << line << "\n"; // lots?
|
rt300@37
|
1199 fileText << line;
|
rt300@36
|
1200 }
|
rt300@36
|
1201
|
rt300@36
|
1202 theFile.close();
|
rt300@36
|
1203 }
|
rt300@36
|
1204
|
rt300@36
|
1205 bool parsingSuccessful = reader.parse( fileText.str(), root );
|
rt300@36
|
1206
|
rt300@36
|
1207 if ( !parsingSuccessful )
|
rt300@36
|
1208 {
|
rt300@36
|
1209 // report to the user the failure and their locations in the document.
|
rt300@36
|
1210 std::cout << "Failed to parse sequence JSON: \n"
|
rt300@36
|
1211 << reader.getFormattedErrorMessages();
|
rt300@36
|
1212 return;
|
rt300@36
|
1213 }
|
rt300@36
|
1214
|
rt300@36
|
1215 // now put into variables
|
rt300@36
|
1216 const Json::Value jseqs = root["sequences"];
|
rt300@36
|
1217 int N = jseqs.size();
|
rt300@36
|
1218 for(int i=0; i<N; i++){
|
rt300@36
|
1219 sequences.push_back(vector<int>());
|
rt300@36
|
1220 for(int j=0; j<jseqs[i].size(); j++){
|
rt300@36
|
1221 sequences.back().push_back(jseqs[i][j].asInt());
|
rt300@36
|
1222 }
|
rt300@36
|
1223 }
|
rt300@36
|
1224 // currentSequence
|
rt300@37
|
1225
|
rt300@37
|
1226 currentSequence = ofRandom(0,N-1);
|
rt300@36
|
1227
|
rt300@36
|
1228 }
|
rt300@39
|
1229 //-------------------------------------------------------------------------
|
rt300@39
|
1230 //--------------------------------------------------------------
|
rt300@39
|
1231
|
rt300@39
|
1232 #pragma mark MIDI
|
rt300@39
|
1233 void testApp::addMessage(string msg) {
|
rt300@39
|
1234 cout << msg << endl;
|
rt300@39
|
1235 messages.push_back(msg);
|
rt300@39
|
1236 while(messages.size() > maxMessages)
|
rt300@39
|
1237 messages.pop_front();
|
rt300@39
|
1238 }
|
rt300@39
|
1239
|
rt300@39
|
1240 //--------------------------------------------------------------
|
rt300@39
|
1241 void testApp::newMidiMessage(ofxMidiMessage& msg) {
|
rt300@39
|
1242 //addMessage(msg.toString());
|
rt300@39
|
1243
|
rt300@39
|
1244 // look at what it is
|
rt300@39
|
1245
|
rt300@39
|
1246 if(msg.channel == midiChannel && msg.status == MIDI_CONTROL_CHANGE){
|
rt300@39
|
1247 int ctl_num = msg.control;
|
rt300@39
|
1248 int ctl_val = msg.value;
|
rt300@39
|
1249 if(ctl_num - midiOffset >= 0 && ctl_num - midiOffset < sliderVals.size()){
|
rt300@39
|
1250 sliderVals[ctl_num] = (int)ctl_val;
|
rt300@39
|
1251 sliders[ctl_num]->setValue(ctl_val);
|
rt300@39
|
1252 theGridView.setParams(sliderVals);
|
rt300@39
|
1253 }
|
rt300@39
|
1254 }
|
rt300@39
|
1255
|
rt300@39
|
1256 }
|
rt300@39
|
1257
|
rt300@39
|
1258 //--------------------------------------------------------------
|
rt300@39
|
1259 void testApp::midiInputAdded(string name, bool isNetwork) {
|
rt300@39
|
1260 stringstream msg;
|
rt300@39
|
1261 msg << "ofxMidi: input added: " << name << " network: " << isNetwork;
|
rt300@39
|
1262 cout << msg.str();
|
rt300@39
|
1263 addMessage(msg.str());
|
rt300@39
|
1264
|
rt300@39
|
1265 // create and open a new input port
|
rt300@39
|
1266 ofxMidiIn * newInput = new ofxMidiIn;
|
rt300@39
|
1267 newInput->openPort(name);
|
rt300@39
|
1268 newInput->addListener(this);
|
rt300@39
|
1269 inputs.push_back(newInput);
|
rt300@39
|
1270 }
|
rt300@39
|
1271
|
rt300@39
|
1272 //--------------------------------------------------------------
|
rt300@39
|
1273 void testApp::midiInputRemoved(string name, bool isNetwork) {
|
rt300@39
|
1274 stringstream msg;
|
rt300@39
|
1275 msg << "ofxMidi: input removed: " << name << " network: " << isNetwork << endl;
|
rt300@39
|
1276 cout << msg.str();
|
rt300@39
|
1277 addMessage(msg.str());
|
rt300@39
|
1278
|
rt300@39
|
1279 // close and remove input port
|
rt300@39
|
1280 vector<ofxMidiIn*>::iterator iter;
|
rt300@39
|
1281 for(iter = inputs.begin(); iter != inputs.end(); ++iter) {
|
rt300@39
|
1282 ofxMidiIn * input = (*iter);
|
rt300@39
|
1283 if(input->getName() == name) {
|
rt300@39
|
1284 input->closePort();
|
rt300@39
|
1285 input->removeListener(this);
|
rt300@39
|
1286 delete input;
|
rt300@39
|
1287 inputs.erase(iter);
|
rt300@39
|
1288 break;
|
rt300@39
|
1289 }
|
rt300@39
|
1290 }
|
rt300@39
|
1291 }
|
rt300@39
|
1292
|
rt300@39
|
1293 //--------------------------------------------------------------
|
rt300@39
|
1294 void testApp::midiOutputAdded(string name, bool isNetwork) {
|
rt300@39
|
1295 stringstream msg;
|
rt300@39
|
1296 msg << "ofxMidi: output added: " << name << " network: " << isNetwork << endl;
|
rt300@39
|
1297 cout << msg.str();
|
rt300@39
|
1298 addMessage(msg.str());
|
rt300@39
|
1299
|
rt300@39
|
1300 // create and open new output port
|
rt300@39
|
1301 ofxMidiOut * newOutput = new ofxMidiOut;
|
rt300@39
|
1302 newOutput->openPort(name);
|
rt300@39
|
1303 outputs.push_back(newOutput);
|
rt300@39
|
1304 }
|
rt300@39
|
1305
|
rt300@39
|
1306 //--------------------------------------------------------------
|
rt300@39
|
1307 void testApp::midiOutputRemoved(string name, bool isNetwork) {
|
rt300@39
|
1308 stringstream msg;
|
rt300@39
|
1309 msg << "ofxMidi: output removed: " << name << " network: " << isNetwork << endl;
|
rt300@39
|
1310 cout << msg.str();
|
rt300@39
|
1311 addMessage(msg.str());
|
rt300@39
|
1312
|
rt300@39
|
1313 // close and remove output port
|
rt300@39
|
1314 vector<ofxMidiOut*>::iterator iter;
|
rt300@39
|
1315 for(iter = outputs.begin(); iter != outputs.end(); ++iter) {
|
rt300@39
|
1316 ofxMidiOut * output = (*iter);
|
rt300@39
|
1317 if(output->getName() == name) {
|
rt300@39
|
1318 output->closePort();
|
rt300@39
|
1319 delete output;
|
rt300@39
|
1320 outputs.erase(iter);
|
rt300@39
|
1321 break;
|
rt300@39
|
1322 }
|
rt300@39
|
1323 }
|
rt300@39
|
1324 }
|
rt300@39
|
1325 //-------------------------------------------------------------- |