rt300@0
|
1 #include "testApp.h"
|
rt300@2
|
2
|
rt300@24
|
3 #define SLIDER_GUI_WIDTH 256
|
rt300@25
|
4 #define NUM_PARAMS 10
|
rt300@0
|
5 extern Grid theGridView;
|
rt300@0
|
6 extern PresetManager presetManager;
|
rt300@1
|
7 extern EventLogger eventLogger;
|
rt300@3
|
8 extern Frequencer frequencer;
|
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@7
|
16 //DeviceID3523537000
|
rt300@0
|
17 //--------------------------------------------------------------
|
rt300@0
|
18 void testApp::setup(){
|
rt300@16
|
19 paused = true;
|
rt300@16
|
20
|
rt300@24
|
21
|
rt300@16
|
22 ofBackground( 0, 0, 0 );
|
rt300@0
|
23 ofEnableAlphaBlending();
|
rt300@21
|
24 //ofEnableSmoothing();
|
rt300@0
|
25
|
rt300@0
|
26 // open an outgoing connection to HOST:PORT
|
rt300@0
|
27 sender.setup( HOST, PORT );
|
rt300@28
|
28 ofSetFrameRate(50);
|
rt300@0
|
29 // reciever
|
rt300@6
|
30 lastMoveTime = ofGetSystemTimeMicros();
|
rt300@0
|
31 prevTouchX = 0;
|
rt300@0
|
32 prevTouchY = 0;
|
rt300@0
|
33
|
rt300@0
|
34 xLocked = false;
|
rt300@0
|
35 yLocked = false;
|
rt300@0
|
36
|
rt300@0
|
37 numActiveTouches = 0;
|
rt300@3
|
38 touch0.setCoord(17./7., 2./3.);
|
rt300@0
|
39 touch1.setCoord(10,20);
|
rt300@3
|
40
|
rt300@0
|
41 prevTouch0.setCoord(1,2);
|
rt300@0
|
42 prevTouch1.setCoord(10,20);
|
rt300@0
|
43 prevDist = 10;
|
rt300@16
|
44 slowFactor = 0.98;
|
rt300@27
|
45 preventingMovePostScroll = false;
|
rt300@16
|
46
|
rt300@16
|
47 // the 5 harmonics for the frequencer
|
rt300@16
|
48 freqIndexes.push_back(0);
|
rt300@16
|
49 freqIndexes.push_back(4);
|
rt300@16
|
50 freqIndexes.push_back(6);
|
rt300@16
|
51 freqIndexes.push_back(7);
|
rt300@16
|
52 freqIndexes.push_back(8);
|
rt300@16
|
53
|
rt300@16
|
54
|
rt300@16
|
55 ofxiPhoneSetOrientation( OFXIPHONE_ORIENTATION_PORTRAIT ); // do this before setting up all the other objects
|
rt300@0
|
56
|
rt300@24
|
57 // initialise the interfaces
|
rt300@0
|
58 theGridView.init();
|
rt300@0
|
59
|
rt300@24
|
60 setupSliderGui();
|
rt300@24
|
61 sliderGUI->setVisible(true);
|
rt300@0
|
62
|
rt300@0
|
63 // initial slider vals
|
rt300@0
|
64 for(int i=0; i<10;i++){
|
rt300@0
|
65 sliderVals.push_back(64);
|
rt300@0
|
66 }
|
rt300@8
|
67
|
rt300@24
|
68 // initialise PD
|
rt300@24
|
69
|
rt300@2
|
70 int ticksPerBuffer = 8; // 8 * 64 = buffer len of 512
|
rt300@2
|
71
|
rt300@2
|
72 // setup the app core
|
rt300@2
|
73 core.setup(2, 1, 44100, ticksPerBuffer);
|
rt300@2
|
74
|
rt300@2
|
75 // setup OF sound stream
|
rt300@2
|
76 ofSoundStreamSetup(2, 1, this, 44100, ofxPd::blockSize()*ticksPerBuffer, 3);
|
rt300@1
|
77
|
rt300@24
|
78
|
rt300@24
|
79
|
rt300@24
|
80 // set up iOS gui stuff
|
rt300@24
|
81 bottomTabViewController = [[BottomTabViewController alloc] initWithNibName:@"BottomTabViewController" bundle:nil];
|
rt300@24
|
82 [ofxiPhoneGetGLParentView() addSubview:bottomTabViewController.view];
|
rt300@24
|
83
|
rt300@24
|
84 [bottomTabViewController setAppRef:(id)this];
|
rt300@24
|
85 bottomTabViewController.view.frame = CGRectMake(0,getHeight()-44,getWidth(),44);
|
rt300@24
|
86
|
rt300@28
|
87
|
rt300@24
|
88 /////
|
rt300@24
|
89
|
rt300@24
|
90 topButtonViewController = [[TopButtonViewController alloc] initWithNibName:@"TopButtonViewController" bundle:nil];
|
rt300@24
|
91 [ofxiPhoneGetGLParentView() addSubview:topButtonViewController.view];
|
rt300@24
|
92 [topButtonViewController setAppRef:(id)this];
|
rt300@24
|
93 [topButtonViewController show:(id)this];
|
rt300@24
|
94 topButtonViewController.view.frame = CGRectMake(0,0,getWidth(),44);
|
rt300@24
|
95
|
rt300@25
|
96 usernameAlertViewController = [[UsernameAlertViewController alloc] init];
|
rt300@26
|
97
|
rt300@27
|
98 helpViewController = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil];
|
rt300@27
|
99 [ofxiPhoneGetGLParentView() addSubview:helpViewController.view];
|
rt300@27
|
100 [helpViewController setAppRef:(id)this];
|
rt300@27
|
101 helpViewController.view.hidden = YES;
|
rt300@27
|
102
|
rt300@25
|
103 /*
|
rt300@25
|
104 sliderViewController = [[SliderViewController alloc] initWithNibName:@"SLiderViewController" bundle:nil];
|
rt300@25
|
105 [ofxiPhoneGetGLParentView() addSubview:sliderViewController.view];
|
rt300@25
|
106
|
rt300@25
|
107 [sliderViewController setAppRef:(id)this];
|
rt300@25
|
108 [sliderViewController show:(id)this];
|
rt300@25
|
109
|
rt300@25
|
110 sliderViewController.view.frame = CGRectMake(0,getHeight()-43 - 363,getWidth(),44);
|
rt300@25
|
111 */
|
rt300@25
|
112
|
rt300@24
|
113 // initialise user logging stuff
|
rt300@5
|
114 presetManager.startupLoadAll();
|
rt300@7
|
115 eventLogger.init();
|
rt300@24
|
116
|
rt300@28
|
117 // timer.init();
|
rt300@28
|
118
|
rt300@27
|
119 whichInterfaceShowing = SLIDERS;
|
rt300@27
|
120 setAllGUISliders(theGridView.getParams());
|
rt300@24
|
121 // GO
|
rt300@16
|
122 paused = false;
|
rt300@16
|
123
|
rt300@24
|
124 }
|
rt300@24
|
125
|
rt300@24
|
126
|
rt300@24
|
127 //--------------------------------------------------------------
|
rt300@24
|
128 void testApp::exit(){
|
rt300@25
|
129
|
rt300@25
|
130 presetManager.exitAndSaveAll();
|
rt300@25
|
131 eventLogger.exitAndSave();
|
rt300@25
|
132
|
rt300@24
|
133 core.exit();
|
rt300@24
|
134
|
rt300@25
|
135 // are these handled automatically?
|
rt300@25
|
136 //[introViewController release];
|
rt300@25
|
137 //[topButtonViewController release];
|
rt300@25
|
138 //[bottomTabViewController release];
|
rt300@24
|
139
|
rt300@24
|
140 delete sliderGUI;
|
rt300@24
|
141
|
rt300@24
|
142 cout << "exit done \n";
|
rt300@0
|
143 }
|
rt300@24
|
144
|
rt300@24
|
145 //--------------------------------------------------------------
|
rt300@3
|
146 #pragma mark GUI
|
rt300@16
|
147 //--
|
rt300@16
|
148 float testApp::getWidth(){
|
rt300@16
|
149 // depends on orientation
|
rt300@16
|
150 return ofGetWidth();
|
rt300@16
|
151
|
rt300@16
|
152 }
|
rt300@16
|
153 float testApp::getHeight(){
|
rt300@16
|
154 // depends on orientation
|
rt300@16
|
155 return ofGetHeight();
|
rt300@16
|
156
|
rt300@16
|
157 }
|
rt300@24
|
158 #pragma mark GUI
|
rt300@24
|
159 ////////////////////////////
|
rt300@24
|
160 // These functions called from iOS toolbars
|
rt300@24
|
161 //--------------------------------------------------------------
|
rt300@24
|
162 void testApp::lockSequencerPressed(bool locked){
|
rt300@24
|
163 theGridView.shiftCentreToSnapped();
|
rt300@24
|
164 xLocked = locked;
|
rt300@25
|
165 eventLogger.logEvent(SEQ_LOCKED);
|
rt300@25
|
166
|
rt300@24
|
167
|
rt300@24
|
168 }
|
rt300@24
|
169 //--------------------------------------------------------------
|
rt300@24
|
170 void testApp::lockSynthPressed(bool locked){
|
rt300@24
|
171 theGridView.shiftCentreToSnapped();
|
rt300@24
|
172 yLocked = locked;
|
rt300@25
|
173 eventLogger.logEvent(SYNTH_LOCKED);
|
rt300@24
|
174
|
rt300@24
|
175 }
|
rt300@24
|
176 //--------------------------------------------------------------
|
rt300@24
|
177 void testApp::seqStartStop(bool go){
|
rt300@24
|
178 if(!go){ //stop
|
rt300@24
|
179 core.pd.startMessage();
|
rt300@24
|
180 core.pd.addFloat(0);
|
rt300@24
|
181 core.pd.finishMessage("fromOF", "seqStartStop");
|
rt300@25
|
182 eventLogger.logEvent(PAUSE_PRESSED);
|
rt300@24
|
183 }else { // play
|
rt300@24
|
184 //stopSequencer();
|
rt300@24
|
185 core.pd.startMessage();
|
rt300@24
|
186 core.pd.addFloat(1);
|
rt300@24
|
187 core.pd.finishMessage("fromOF", "seqStartStop");
|
rt300@25
|
188 eventLogger.logEvent(PLAY_PRESSED);
|
rt300@24
|
189 }
|
rt300@24
|
190 }
|
rt300@24
|
191 //--------------------------------------------------------------
|
rt300@24
|
192 void testApp::showQuestionnaire(){
|
rt300@24
|
193 // stop updating / drawing
|
rt300@24
|
194
|
rt300@24
|
195 // if(eventLogger.questionnaireCompleted) return;
|
rt300@24
|
196
|
rt300@27
|
197 paused = true; // need to set button
|
rt300@27
|
198 [topButtonViewController pausePressed:(id)this];
|
rt300@24
|
199
|
rt300@24
|
200 //stopSequencer
|
rt300@27
|
201 seqStartStop(false);
|
rt300@24
|
202
|
rt300@24
|
203 questionnaireViewController = [[QuestionnaireViewController alloc] initWithNibName:@"QuestionnaireViewController" bundle:nil];
|
rt300@24
|
204 [ofxiPhoneGetGLParentView() addSubview:questionnaireViewController.view];
|
rt300@24
|
205
|
rt300@24
|
206 [questionnaireViewController setAppRef:(id)this];
|
rt300@24
|
207 [questionnaireViewController show:(id)this];
|
rt300@24
|
208
|
rt300@24
|
209 whichInterfaceShowing = QUESTIONNAIRE;
|
rt300@24
|
210
|
rt300@24
|
211
|
rt300@24
|
212 }
|
rt300@24
|
213 //--------------------------------------------------------------
|
rt300@28
|
214 void testApp::questionnaireHidden(vector<int> answers, const char* userComments){
|
rt300@24
|
215 // send answers to server as json
|
rt300@28
|
216 eventLogger.questionnaireAnswersObtained(answers, userComments);
|
rt300@24
|
217
|
rt300@24
|
218 // set "we've done questionnaire" to true in event logger
|
rt300@24
|
219 paused = false;
|
rt300@27
|
220
|
rt300@24
|
221 whichInterfaceShowing = BOTH;
|
rt300@24
|
222 // tell bottomtabviewcontroller
|
rt300@28
|
223 [bottomTabViewController show:(id)this];
|
rt300@24
|
224 }
|
rt300@24
|
225 //--------------------------------------------------------------
|
rt300@24
|
226 void testApp::showIntro(){
|
rt300@24
|
227 paused = true;
|
rt300@25
|
228
|
rt300@24
|
229 cout << "SHOW INTRO\n";
|
rt300@24
|
230
|
rt300@24
|
231 introViewController = [[IntroViewController alloc] initWithNibName:@"IntroViewController" bundle:nil];
|
rt300@24
|
232 [ofxiPhoneGetGLParentView() addSubview:introViewController.view];
|
rt300@24
|
233
|
rt300@24
|
234 [introViewController setAppRef:(id)this];
|
rt300@24
|
235 [introViewController show:(id)this];
|
rt300@24
|
236
|
rt300@24
|
237
|
rt300@24
|
238 whichInterfaceShowing = INTRO;
|
rt300@24
|
239
|
rt300@24
|
240 }
|
rt300@24
|
241 //--------------------------------------------------------------
|
rt300@24
|
242 void testApp::introHidden(bool OK){
|
rt300@24
|
243 if(OK){
|
rt300@25
|
244 eventLogger.consentGiven = true;
|
rt300@24
|
245 whichInterfaceShowing = BOTH;
|
rt300@25
|
246 // show username prompt
|
rt300@25
|
247 [usernameAlertViewController showUserNamePrompt];
|
rt300@24
|
248 }
|
rt300@24
|
249 // no unOK
|
rt300@24
|
250 }
|
rt300@24
|
251 //--------------------------------------------------------------
|
rt300@24
|
252 // called from BottomTabViewController iOS segmented thing
|
rt300@24
|
253 void testApp::interfaceSelected(int which){
|
rt300@24
|
254 switch (which){
|
rt300@24
|
255 case 0:
|
rt300@24
|
256
|
rt300@24
|
257 whichInterfaceShowing = SLIDERS;
|
rt300@24
|
258 sliderGUI->setVisible(true);
|
rt300@24
|
259 // set the slider values to stuff got from zoomer
|
rt300@24
|
260 sliderVals = theGridView.getParams();
|
rt300@24
|
261 setAllGUISliders(sliderVals);
|
rt300@25
|
262
|
rt300@24
|
263 break;
|
rt300@24
|
264 case 1:
|
rt300@24
|
265
|
rt300@24
|
266 whichInterfaceShowing = BOTH;
|
rt300@24
|
267 sliderGUI->setVisible(true);
|
rt300@24
|
268 // set the slider values to stuff got from zoomer
|
rt300@24
|
269 sliderVals = theGridView.getParams();
|
rt300@24
|
270 setAllGUISliders(sliderVals);
|
rt300@24
|
271 break;
|
rt300@24
|
272 case 2:
|
rt300@24
|
273
|
rt300@24
|
274 sliderGUI->setVisible(false);
|
rt300@24
|
275 whichInterfaceShowing = ZOOMER;
|
rt300@24
|
276 break;
|
rt300@24
|
277 }
|
rt300@25
|
278 eventLogger.logEvent(SWAP_VIEW,TwoVector(),0.0, which);
|
rt300@24
|
279 }
|
rt300@24
|
280 //--------------------------------------------------------------
|
rt300@24
|
281 //--------------------------------------------------------------
|
rt300@24
|
282 void testApp::setupSliderGui(){
|
rt300@24
|
283 float xInit = OFX_UI_GLOBAL_WIDGET_SPACING;
|
rt300@24
|
284 float length = SLIDER_GUI_WIDTH - (OFX_UI_GLOBAL_WIDGET_SPACING*2);
|
rt300@24
|
285
|
rt300@24
|
286
|
rt300@24
|
287 //float dim = 42;
|
rt300@24
|
288
|
rt300@24
|
289 // make this iphone size...?
|
rt300@24
|
290 int height = 480;
|
rt300@24
|
291 int width = 320;
|
rt300@24
|
292 float dim = (height-10.0*OFX_UI_GLOBAL_WIDGET_SPACING)/10.0;
|
rt300@24
|
293 // LEFT GUI
|
rt300@24
|
294 sliderGUI = new ofxUICanvas(0,100,SLIDER_GUI_WIDTH,getHeight());
|
rt300@24
|
295
|
rt300@24
|
296 // Uh.. loop this
|
rt300@24
|
297 for(int i = 1; i<=10;i++){
|
rt300@24
|
298
|
rt300@24
|
299 ofxUISlider *slider;
|
rt300@25
|
300 slider = (ofxUISlider *)sliderGUI->addWidgetDown(new ofxUISlider(length,dim,0.0,127,64,sliderParamNames[i-1]));
|
rt300@24
|
301 slider->setDrawPadding(true);
|
rt300@28
|
302 slider->setDrawPaddingOutline(true);
|
rt300@24
|
303 if(i <= 5){
|
rt300@24
|
304 slider->setColorFill(ofColor(0,0,255));
|
rt300@24
|
305 slider->setColorFillHighlight(ofColor(0,0,255));
|
rt300@24
|
306 }else{
|
rt300@24
|
307 slider->setColorFill(ofColor(255,0,0));
|
rt300@24
|
308 slider->setColorFillHighlight(ofColor(255,0,0));
|
rt300@24
|
309 }
|
rt300@24
|
310
|
rt300@24
|
311 sliders.push_back(slider);
|
rt300@24
|
312 }
|
rt300@24
|
313
|
rt300@24
|
314
|
rt300@24
|
315
|
rt300@24
|
316 ofAddListener(sliderGUI->newGUIEvent, this, &testApp::sliderGUIEvent);
|
rt300@24
|
317
|
rt300@24
|
318 }
|
rt300@24
|
319 //--------------------------------------------------------------
|
rt300@24
|
320 void testApp::sliderGUIEvent(ofxUIEventArgs &e){
|
rt300@24
|
321 if(whichInterfaceShowing == ZOOMER){
|
rt300@24
|
322 cout << "GUI ERROR";
|
rt300@24
|
323 return;
|
rt300@24
|
324 }
|
rt300@24
|
325
|
rt300@0
|
326 // "normal" parameter changes
|
rt300@0
|
327 for(int i = 1; i<=10;i++){
|
rt300@0
|
328
|
rt300@24
|
329 if(e.widget->getName() == sliderParamNames[i-1])
|
rt300@0
|
330 {
|
rt300@0
|
331 //cout << "param change: " << p;
|
rt300@0
|
332 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@3
|
333 sliderMoved(i-1,slider->getScaledValue()); // internal array 0 indexed
|
rt300@0
|
334 }
|
rt300@0
|
335 }
|
rt300@24
|
336
|
rt300@0
|
337 }
|
rt300@0
|
338 //--------------------------------------------------------------
|
rt300@3
|
339 void testApp::sliderMoved(int which, float value){
|
rt300@3
|
340 // an update caused by slider view being touched
|
rt300@0
|
341 sliderVals[which] = (int)value;
|
rt300@0
|
342 theGridView.setParams(sliderVals);
|
rt300@24
|
343
|
rt300@3
|
344 sendParametersToPD();
|
rt300@5
|
345
|
rt300@9
|
346 eventLogger.logEvent(CHANGE_SLIDER, TwoVector(),0.0,which , value);
|
rt300@5
|
347
|
rt300@0
|
348 }
|
rt300@0
|
349 //--------------------------------------------------------------
|
rt300@3
|
350 void testApp::setAllGUISliders(vector<int> vals){
|
rt300@3
|
351 // an update caused by zoomer view being moved
|
rt300@25
|
352 for(int i = 0; i<NUM_PARAMS;i++){
|
rt300@0
|
353 sliders[i]->setValue(vals[i]);
|
rt300@1
|
354 sliderVals[i] = vals[i];
|
rt300@0
|
355 }
|
rt300@3
|
356
|
rt300@0
|
357 }
|
rt300@0
|
358 //--------------------------------------------------------------
|
rt300@25
|
359 void testApp::randomise(){
|
rt300@25
|
360 // pick random settings for all params
|
rt300@25
|
361 for(int i=0; i < NUM_PARAMS ; i++){
|
rt300@25
|
362 sliderVals[i] = ofRandom(0, 127);
|
rt300@25
|
363
|
rt300@25
|
364 }
|
rt300@25
|
365
|
rt300@25
|
366 // send to grid, sliders and PD
|
rt300@25
|
367 theGridView.setParams(sliderVals);
|
rt300@25
|
368 setAllGUISliders(sliderVals);
|
rt300@25
|
369 sendParametersToPD();
|
rt300@25
|
370
|
rt300@25
|
371 eventLogger.logEvent(RANDOMISE, theGridView.getCoord() ,0.0);
|
rt300@25
|
372
|
rt300@25
|
373 }
|
rt300@27
|
374 //-
|
rt300@27
|
375 void testApp::showHelp(){
|
rt300@27
|
376 paused = true;
|
rt300@27
|
377 seqStartStop(false);
|
rt300@27
|
378 [topButtonViewController pausePressed:(id)this];
|
rt300@27
|
379 helpViewController.view.hidden = NO;
|
rt300@27
|
380 eventLogger.logEvent(HELP_PRESSED);
|
rt300@27
|
381 }
|
rt300@27
|
382 void testApp::helpHidden(){
|
rt300@27
|
383 paused = false;
|
rt300@27
|
384 // start seq?
|
rt300@27
|
385
|
rt300@27
|
386 }
|
rt300@25
|
387 //--------------------------------------------------------------
|
rt300@3
|
388 void testApp::sendParametersToPD(){
|
rt300@3
|
389 // frequencer stuff to get 16 steps
|
rt300@3
|
390 vector<double> vals;
|
rt300@3
|
391
|
rt300@3
|
392
|
rt300@3
|
393 vals.push_back((sliderVals[0]+32)*8.); // DC offset
|
rt300@3
|
394 for(int i=1; i<5;i++){
|
rt300@3
|
395 vals.push_back((sliderVals[i] - 64)*2.);
|
rt300@3
|
396 }
|
rt300@3
|
397
|
rt300@3
|
398 vector<double> steps = frequencer.freqMagEdit(freqIndexes, vals);
|
rt300@3
|
399 // send a list using the List object
|
rt300@3
|
400 List seqSteps;
|
rt300@3
|
401
|
rt300@3
|
402 seqSteps.addSymbol("seqSteps");
|
rt300@3
|
403 for(int i=0; i < 16; i++){
|
rt300@3
|
404 seqSteps.addFloat(round(steps[i])); // rounding here??
|
rt300@3
|
405 }
|
rt300@3
|
406
|
rt300@3
|
407 core.pd.sendList("fromOF", seqSteps);
|
rt300@8
|
408
|
rt300@3
|
409 sendOscShape(sliderVals[5]);
|
rt300@3
|
410 sendFiltType(sliderVals[6]);
|
rt300@3
|
411 sendFiltFreq(sliderVals[7]);
|
rt300@3
|
412 sendEnvShape(sliderVals[8]);
|
rt300@3
|
413 sendModFreq(sliderVals[9]);
|
rt300@3
|
414
|
rt300@3
|
415 }
|
rt300@27
|
416 void testApp::setupNewUser(){
|
rt300@27
|
417 // this function is for supervised trials with my ipad
|
rt300@27
|
418 eventLogger.newUser();
|
rt300@27
|
419 }
|
rt300@8
|
420 //--------------------------------------------------------------
|
rt300@3
|
421 #pragma mark STANDARD OF FUNCTIONS
|
rt300@3
|
422 //--------------------------------------------------------------
|
rt300@0
|
423 void testApp::update(){
|
rt300@27
|
424
|
rt300@16
|
425 if(paused) return;
|
rt300@16
|
426
|
rt300@27
|
427 // continiue to move or zoom at velocity, unless snapped
|
rt300@3
|
428
|
rt300@3
|
429 if (numActiveTouches == 0){ // no touches, use momentum
|
rt300@3
|
430
|
rt300@22
|
431 if(moveVel.norm() > 0.3){
|
rt300@22
|
432 if(theGridView.snapped){
|
rt300@28
|
433 // stop it (snap check sends snap event)
|
rt300@22
|
434 moveVel.setCoord(0.0,0.0);
|
rt300@22
|
435 }else{
|
rt300@22
|
436 theGridView.move(moveVel);
|
rt300@22
|
437 moveVel = moveVel*slowFactor;
|
rt300@22
|
438 }
|
rt300@3
|
439 // and get new parameter values
|
rt300@5
|
440 setAllGUISliders(theGridView.getParams());
|
rt300@3
|
441 sendParametersToPD();
|
rt300@22
|
442 }else if(moveVel.norm() > 0.01){ // and less than 0.3
|
rt300@3
|
443 // stop it
|
rt300@3
|
444 moveVel.setCoord(0.0,0.0);
|
rt300@5
|
445 setAllGUISliders(theGridView.getParams());
|
rt300@3
|
446 sendParametersToPD();
|
rt300@5
|
447 eventLogger.logEvent(SCROLL_STOPPED, theGridView.getCoord() );
|
rt300@22
|
448
|
rt300@3
|
449 }else{
|
rt300@3
|
450 // stopped - do nothing
|
rt300@3
|
451 }
|
rt300@3
|
452
|
rt300@0
|
453 }
|
rt300@28
|
454 // ZOOM MOMENTUM
|
rt300@0
|
455 // continiue to zoom at velocity
|
rt300@0
|
456 if (numActiveTouches < 2 && abs(zoomVel)>0.001){
|
rt300@0
|
457 theGridView.zoom(zoomVel + 1.0); // +1 because zoomVel factor is + or - , wheras zoom is a multiplier near 1
|
rt300@0
|
458 zoomVel = zoomVel*slowFactor;
|
rt300@0
|
459 }
|
rt300@6
|
460
|
rt300@0
|
461 }
|
rt300@0
|
462 //--------------------------------------------------------------
|
rt300@0
|
463 void testApp::sendOSCParams(){
|
rt300@0
|
464
|
rt300@0
|
465 vector<int> params = theGridView.getParams(); // FILTER HERE? NEED FLOATS...
|
rt300@0
|
466 vector<int>::iterator iter = params.begin();
|
rt300@0
|
467
|
rt300@0
|
468 ofxOscMessage m;
|
rt300@0
|
469 m.setAddress( "p" );
|
rt300@0
|
470
|
rt300@0
|
471 for(;iter < params.end();iter++){
|
rt300@0
|
472
|
rt300@0
|
473 m.addFloatArg( *iter );
|
rt300@0
|
474
|
rt300@0
|
475 }
|
rt300@0
|
476 sender.sendMessage( m );
|
rt300@0
|
477 }
|
rt300@0
|
478 //--------------------------------------------------------------
|
rt300@0
|
479 void testApp::draw(){
|
rt300@16
|
480 if(paused) return;
|
rt300@24
|
481
|
rt300@24
|
482 switch (whichInterfaceShowing){
|
rt300@24
|
483 case SLIDERS:
|
rt300@24
|
484 break;
|
rt300@24
|
485 case ZOOMER:
|
rt300@24
|
486 theGridView.draw();
|
rt300@24
|
487 break;
|
rt300@24
|
488 case BOTH:
|
rt300@24
|
489
|
rt300@24
|
490 theGridView.draw();
|
rt300@24
|
491 break;
|
rt300@24
|
492 case INTRO:
|
rt300@24
|
493 break;
|
rt300@24
|
494
|
rt300@24
|
495 case QUESTIONNAIRE:
|
rt300@24
|
496 break;
|
rt300@24
|
497
|
rt300@0
|
498 }
|
rt300@4
|
499
|
rt300@0
|
500 }
|
rt300@0
|
501
|
rt300@0
|
502 //--------------------------------------------------------------
|
rt300@0
|
503 void testApp::touchDown(ofTouchEventArgs &touch){
|
rt300@27
|
504 // in slider gui area?
|
rt300@24
|
505 if(whichInterfaceShowing == SLIDERS){
|
rt300@24
|
506 return;
|
rt300@24
|
507 }else if (whichInterfaceShowing == BOTH && touch.x < (SLIDER_GUI_WIDTH+10)){
|
rt300@24
|
508 return;
|
rt300@24
|
509
|
rt300@24
|
510 }// otherwise we're good to let the zoomer handle touch
|
rt300@0
|
511
|
rt300@0
|
512 numActiveTouches++;
|
rt300@27
|
513 preventingMovePostScroll = false;
|
rt300@27
|
514
|
rt300@0
|
515 if(touch.id == 0){
|
rt300@0
|
516 touch0.setCoord(touch.x,touch.y);
|
rt300@0
|
517 prevTouch0 = touch0;
|
rt300@0
|
518 }else if(touch.id == 1){
|
rt300@0
|
519
|
rt300@0
|
520 touch1.setCoord(touch.x,touch.y);
|
rt300@0
|
521 prevTouch1 = touch1;
|
rt300@0
|
522
|
rt300@0
|
523 }
|
rt300@0
|
524 if(numActiveTouches == 1){
|
rt300@0
|
525 moveVel.setCoord(0.0, 0.0);
|
rt300@0
|
526 prevMove.setCoord(0.0, 0.0);
|
rt300@0
|
527 prevMove2.setCoord(0.0, 0.0);
|
rt300@27
|
528
|
rt300@0
|
529 }else if(numActiveTouches == 2){
|
rt300@0
|
530 zoomVel = 0.0;
|
rt300@0
|
531 prevZoom = 0.0;
|
rt300@0
|
532 prevZoom2 = 0.0;
|
rt300@0
|
533 double dist = touch1.distanceTo(touch0);
|
rt300@0
|
534 prevDist = dist;
|
rt300@0
|
535 }
|
rt300@0
|
536
|
rt300@0
|
537 }
|
rt300@0
|
538
|
rt300@0
|
539 //--------------------------------------------------------------
|
rt300@0
|
540 void testApp::touchMoved(ofTouchEventArgs &touch){
|
rt300@1
|
541
|
rt300@24
|
542 // TODO check if in gui area!!!
|
rt300@24
|
543 if(whichInterfaceShowing == SLIDERS){
|
rt300@24
|
544 return;
|
rt300@24
|
545 }else if (whichInterfaceShowing == BOTH && touch.x < (SLIDER_GUI_WIDTH+10)){
|
rt300@24
|
546 return;
|
rt300@24
|
547
|
rt300@27
|
548 }
|
rt300@24
|
549
|
rt300@27
|
550 // otherwise we're good to let the zoomer handle touch
|
rt300@0
|
551
|
rt300@1
|
552 // which one? keep track of each touch point
|
rt300@0
|
553 if(touch.id == 0){
|
rt300@0
|
554 touch0.setCoord(touch.x,touch.y);
|
rt300@0
|
555
|
rt300@0
|
556 }else if(touch.id == 1){
|
rt300@0
|
557
|
rt300@0
|
558 touch1.setCoord(touch.x,touch.y);
|
rt300@0
|
559 }
|
rt300@0
|
560
|
rt300@1
|
561 if(numActiveTouches == 1){
|
rt300@27
|
562 if(preventingMovePostScroll) return;
|
rt300@1
|
563 handleScroll();
|
rt300@0
|
564 }else if(numActiveTouches == 2){
|
rt300@1
|
565 handleZoom();
|
rt300@0
|
566
|
rt300@0
|
567 }
|
rt300@0
|
568 prevTouch0 = touch0;
|
rt300@0
|
569
|
rt300@0
|
570
|
rt300@0
|
571 }
|
rt300@5
|
572
|
rt300@1
|
573 //--------------------------------------------------------------
|
rt300@27
|
574 // handle a finger being dragged
|
rt300@1
|
575 void testApp::handleScroll(){
|
rt300@6
|
576
|
rt300@1
|
577 TwoVector move = touch0 - prevTouch0;
|
rt300@5
|
578 if(yLocked){
|
rt300@5
|
579 move.y = 0.0;
|
rt300@5
|
580 }
|
rt300@5
|
581 if(xLocked){
|
rt300@5
|
582 move.x = 0.0;
|
rt300@5
|
583 }
|
rt300@5
|
584
|
rt300@6
|
585 // check time since last move - if
|
rt300@6
|
586 unsigned int moveTime = ofGetSystemTimeMicros();
|
rt300@6
|
587 if(moveTime - lastMoveTime > 100000){
|
rt300@6
|
588 moveVel = TwoVector(); // zero
|
rt300@6
|
589 }else{
|
rt300@6
|
590 moveVel = (move*0.3 + prevMove*0.34 + prevMove2*0.38); // use the time
|
rt300@6
|
591
|
rt300@6
|
592 }
|
rt300@6
|
593 lastMoveTime = moveTime;
|
rt300@6
|
594
|
rt300@5
|
595
|
rt300@1
|
596 prevMove2 = prevMove;
|
rt300@1
|
597 prevMove = move;
|
rt300@1
|
598
|
rt300@5
|
599
|
rt300@3
|
600 theGridView.move(move);
|
rt300@3
|
601
|
rt300@3
|
602 // and get new parameter values
|
rt300@3
|
603 setAllGUISliders(theGridView.getParams());
|
rt300@3
|
604 sendParametersToPD();
|
rt300@1
|
605 }
|
rt300@1
|
606 //--------------------------------------------------------------
|
rt300@27
|
607 // handle pinch movememnt
|
rt300@1
|
608 void testApp::handleZoom(){
|
rt300@1
|
609 // work out change in difference
|
rt300@1
|
610 double dist = touch1.distanceTo(touch0);
|
rt300@1
|
611 double zoomFactor = prevDist/dist;
|
rt300@1
|
612
|
rt300@1
|
613 //TODO check for sensible maximums, e.g. spurious touch data
|
rt300@1
|
614 if(zoomFactor > 2.0 || zoomFactor < 0.5){
|
rt300@1
|
615 cout << "Zoom too much!!!!" << zoomFactor;
|
rt300@1
|
616 zoomFactor = 1.0;
|
rt300@1
|
617 }
|
rt300@1
|
618
|
rt300@1
|
619 zoomVel = (zoomFactor-1)*0.3 + prevZoom*0.34 + prevZoom2*0.38;
|
rt300@1
|
620 prevZoom2 = prevZoom;
|
rt300@1
|
621 prevZoom = (zoomFactor-1);
|
rt300@1
|
622
|
rt300@1
|
623 theGridView.zoom(zoomFactor);
|
rt300@1
|
624
|
rt300@1
|
625 prevDist = dist;
|
rt300@3
|
626
|
rt300@1
|
627 }
|
rt300@0
|
628 //--------------------------------------------------------------
|
rt300@0
|
629 void testApp::touchUp(ofTouchEventArgs &touch){
|
rt300@1
|
630 if(numActiveTouches > 0) numActiveTouches--; // dirty
|
rt300@27
|
631 preventingMovePostScroll = false;
|
rt300@24
|
632 // TODO check if in gui area!!!
|
rt300@24
|
633 if(whichInterfaceShowing == SLIDERS){
|
rt300@24
|
634 return;
|
rt300@24
|
635 }else if (whichInterfaceShowing == BOTH && touch.x < 256){
|
rt300@24
|
636 return;
|
rt300@1
|
637
|
rt300@24
|
638 }// otherwise we're good to let the zoomer handle touch
|
rt300@24
|
639
|
rt300@1
|
640
|
rt300@0
|
641 // which one?
|
rt300@0
|
642 if(touch.id == 0){
|
rt300@0
|
643 // tricky situation - we tried to zoom but may have left non-move finger on
|
rt300@0
|
644 prevTouch0.setCoord(touch.x,touch.y);
|
rt300@0
|
645
|
rt300@0
|
646 }else if(touch.id == 1){
|
rt300@0
|
647
|
rt300@0
|
648
|
rt300@0
|
649 prevTouch1.setCoord(0,0);
|
rt300@6
|
650
|
rt300@6
|
651 }
|
rt300@6
|
652 if(numActiveTouches == 0){
|
rt300@6
|
653 // check time since last move
|
rt300@6
|
654 // check time since last move - if
|
rt300@6
|
655 unsigned int moveTime = ofGetSystemTimeMicros();
|
rt300@6
|
656 if(moveTime - lastMoveTime > 100000){
|
rt300@6
|
657 moveVel = TwoVector(); // zero
|
rt300@6
|
658 }else{
|
rt300@6
|
659 moveVel = (move*0.3 + prevMove*0.34 + prevMove2*0.38); // use the time
|
rt300@6
|
660
|
rt300@6
|
661 }
|
rt300@6
|
662 lastMoveTime = moveTime;
|
rt300@27
|
663 }else if (numActiveTouches == 1){
|
rt300@27
|
664 // just zoomed , but now lifted one of the fingers
|
rt300@27
|
665 // can be bad if moved so create special mode to stop scroll (special modes bad!)
|
rt300@27
|
666 preventingMovePostScroll = true;
|
rt300@0
|
667 }
|
rt300@0
|
668
|
rt300@0
|
669 }
|
rt300@0
|
670
|
rt300@0
|
671 //--------------------------------------------------------------
|
rt300@0
|
672 void testApp::touchDoubleTap(ofTouchEventArgs &touch){
|
rt300@0
|
673 // preset?
|
rt300@25
|
674
|
rt300@25
|
675 /* ballses everything for some reason
|
rt300@25
|
676 TwoVector centre = TwoVector(getWidth()*0.5,getHeight()*0.5);
|
rt300@25
|
677 // if near centre
|
rt300@25
|
678 if((touch.x < centre.x+10) && (touch.x > centre.x-10) && (touch.y < centre.y+10) && (touch.y > centre.y-10)){
|
rt300@25
|
679 numActiveTouches = 0; // dirty
|
rt300@25
|
680 presetManager.showNameDialog();
|
rt300@25
|
681
|
rt300@25
|
682 }
|
rt300@25
|
683 */
|
rt300@25
|
684
|
rt300@0
|
685 }
|
rt300@0
|
686
|
rt300@0
|
687 //--------------------------------------------------------------
|
rt300@0
|
688 void testApp::lostFocus(){
|
rt300@0
|
689
|
rt300@0
|
690 }
|
rt300@0
|
691
|
rt300@0
|
692 //--------------------------------------------------------------
|
rt300@0
|
693 void testApp::gotFocus(){
|
rt300@0
|
694
|
rt300@0
|
695 }
|
rt300@0
|
696
|
rt300@0
|
697 //--------------------------------------------------------------
|
rt300@0
|
698 void testApp::gotMemoryWarning(){
|
rt300@0
|
699
|
rt300@0
|
700 }
|
rt300@0
|
701
|
rt300@0
|
702 //--------------------------------------------------------------
|
rt300@0
|
703 void testApp::deviceOrientationChanged(int newOrientation){
|
rt300@16
|
704 /*
|
rt300@0
|
705 cout << "orientation: " << newOrientation;
|
rt300@15
|
706
|
rt300@0
|
707 if(newOrientation == 4){
|
rt300@16
|
708 ofxiPhoneSetOrientation( OF_ORIENTATION_DEFAULT );
|
rt300@16
|
709
|
rt300@0
|
710 }else if(newOrientation == 3){
|
rt300@0
|
711 ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT );
|
rt300@16
|
712 }else if(newOrientation == 3){
|
rt300@16
|
713 ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT );
|
rt300@16
|
714 }
|
rt300@16
|
715
|
rt300@16
|
716
|
rt300@16
|
717 [ofxiPhoneGetGLView() updateDimensions];
|
rt300@16
|
718 */
|
rt300@0
|
719 }
|
rt300@0
|
720
|
rt300@0
|
721
|
rt300@0
|
722 //--------------------------------------------------------------
|
rt300@0
|
723 void testApp::touchCancelled(ofTouchEventArgs& args){
|
rt300@0
|
724
|
rt300@0
|
725 }
|
rt300@3
|
726 //---------------------------------------------------------------
|
rt300@3
|
727 // AUDIO STUFF
|
rt300@3
|
728 //---------------------------------------------------------------
|
rt300@3
|
729
|
rt300@3
|
730 #pragma mark AUDIO STREAMS
|
rt300@3
|
731 //--------------------------------------------------------------
|
rt300@3
|
732 void testApp::audioReceived(float * input, int bufferSize, int nChannels) {
|
rt300@3
|
733 core.audioReceived(input, bufferSize, nChannels);
|
rt300@3
|
734 }
|
rt300@3
|
735
|
rt300@3
|
736 void testApp::audioRequested(float * output, int bufferSize, int nChannels) {
|
rt300@3
|
737 core.audioRequested(output, bufferSize, nChannels);
|
rt300@3
|
738 }
|
rt300@3
|
739 //---------------------------------------------------------------
|
rt300@3
|
740 #pragma mark UTILITIES
|
rt300@0
|
741
|
rt300@0
|
742 // 5hz cut off
|
rt300@0
|
743 const double fB[3] = {0.049489956268677, 0.098979912537354, 0.049489956268677};
|
rt300@0
|
744
|
rt300@0
|
745 const double fA[3] = {1.000000000000000, -1.279632424997809, 0.477592250072517};
|
rt300@0
|
746
|
rt300@0
|
747 // 1hz cut off
|
rt300@0
|
748 //const double fB[3] = {0.002550535158536, 0.005101070317073, 0.002550535158536};
|
rt300@0
|
749
|
rt300@0
|
750 //const double fA[3] = {1.000000000000000, -1.852146485395936, 0.862348626030081};
|
rt300@0
|
751
|
rt300@0
|
752
|
rt300@0
|
753 //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
|
754 //---------------------------------------------------------------
|
rt300@0
|
755 vector<float> testApp::vectorFilter(vector<float> newVec){
|
rt300@0
|
756 static vector<float> x0(10,0);
|
rt300@0
|
757 static vector<float> x1(10,0);
|
rt300@0
|
758 static vector<float> x2(10,0);
|
rt300@0
|
759 static vector<float> y0(10,0);
|
rt300@0
|
760 static vector<float> y1(10,0);
|
rt300@0
|
761 static vector<float> y2(10,0);
|
rt300@0
|
762
|
rt300@0
|
763 x0 = newVec;
|
rt300@0
|
764
|
rt300@0
|
765 // this low passes a bunch of params values all at once
|
rt300@0
|
766 int sz = newVec.size();
|
rt300@0
|
767 for(int i=0; i<sz; i++){
|
rt300@0
|
768 y0[i] = fB[0]*x0[i] + fB[1]*x1[i] + fB[2]*x2[i] - fA[1]*y1[i] - fA[2]*y2[i];
|
rt300@0
|
769 }
|
rt300@0
|
770 // shift
|
rt300@0
|
771 x2 = x1;
|
rt300@0
|
772 x1 = x0;
|
rt300@0
|
773 y2 = y1;
|
rt300@0
|
774 y1 = y0;
|
rt300@0
|
775
|
rt300@0
|
776 return y0;
|
rt300@2
|
777 }
|
rt300@24
|
778 float ctrlSmoother(float newsamp){
|
rt300@24
|
779 static float x1,x2,y1,y2;
|
rt300@24
|
780 float x0, y0;
|
rt300@24
|
781
|
rt300@24
|
782 x0 = newsamp;
|
rt300@24
|
783
|
rt300@24
|
784 y0 = fB[0]*x0 + fB[1]*x1 + fB[2]*x2 - fA[1]*y1 - fA[2]*y2;
|
rt300@24
|
785
|
rt300@24
|
786 // shift
|
rt300@24
|
787 x2 = x1;
|
rt300@24
|
788 x1 = x0;
|
rt300@24
|
789 y2 = y1;
|
rt300@24
|
790 y1 = y0;
|
rt300@24
|
791
|
rt300@24
|
792 return y0;
|
rt300@24
|
793 }
|
rt300@8
|
794 //---------------------------------------------------------------
|
rt300@3
|
795 void testApp::sendOscShape(int ctrlin){
|
rt300@3
|
796
|
rt300@3
|
797 static int numpoints = 5;
|
rt300@3
|
798 static int numcontrols = 5;
|
rt300@3
|
799 //float values[points][controls] =
|
rt300@3
|
800 float ctrlout[numcontrols];
|
rt300@3
|
801 string ctrlName[5] = {"pWidth" , "sqVol", "sawVol", "sineVol", "FMAmt"};
|
rt300@3
|
802 float values[5][5] =
|
rt300@3
|
803 {{0.5, 0., 0., 1., 1.}, // 0
|
rt300@3
|
804 {0.5, 0., 0., 1., 0.}, // 32
|
rt300@3
|
805 {0.5, 0., 1., 0., 0.}, // 64
|
rt300@3
|
806 {0.5, 1., 1., 0., 0.}, // 96
|
rt300@3
|
807 {0.01,1., 1., 0., 0.}}; // 127
|
rt300@3
|
808
|
rt300@3
|
809 float fidx = (numpoints-1)*ctrlin/128.;
|
rt300@3
|
810 int idx = floor(fidx);
|
rt300@3
|
811 float frac = fidx - idx;
|
rt300@3
|
812 for(int i=0; i < numcontrols; i++){
|
rt300@3
|
813 ctrlout[i] = (1 - frac)*values[idx][i] + (frac)*values[idx+1][i];
|
rt300@3
|
814 // send to PD
|
rt300@3
|
815 List toPD;
|
rt300@3
|
816
|
rt300@3
|
817 toPD.addSymbol(ctrlName[i]);
|
rt300@3
|
818 toPD.addFloat(ctrlout[i]); // rounding here??
|
rt300@3
|
819
|
rt300@3
|
820 core.pd.sendList("fromOF", toPD);
|
rt300@3
|
821 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
|
rt300@3
|
822 }
|
rt300@3
|
823
|
rt300@2
|
824 }
|
rt300@8
|
825 //---------------------------------------------------------------
|
rt300@3
|
826 void testApp::sendFiltType(int ctrlin){
|
rt300@3
|
827 static int numpoints = 3;
|
rt300@3
|
828 static int numcontrols = 4;
|
rt300@3
|
829 //float values[points][controls] =
|
rt300@3
|
830 float ctrlout[numcontrols];
|
rt300@3
|
831 string ctrlName[4] = {"lpLev" , "bpLev", "hpLev", "reson"};
|
rt300@3
|
832 float values[3][4] =
|
rt300@24
|
833 {{2., 0., 0., 1.}, // 0
|
rt300@24
|
834 {0., 10., 0., 10.}, // 64
|
rt300@24
|
835 {0., 0., 1., 1.}}; // 127
|
rt300@3
|
836
|
rt300@3
|
837 float fidx = (numpoints-1)*ctrlin/128.;
|
rt300@3
|
838 int idx = floor(fidx);
|
rt300@3
|
839 float frac = fidx - idx;
|
rt300@3
|
840 for(int i=0; i < numcontrols; i++){
|
rt300@3
|
841 ctrlout[i] = (1 - frac)*values[idx][i] + (frac)*values[idx+1][i];
|
rt300@3
|
842 // send to PD
|
rt300@3
|
843 List toPD;
|
rt300@3
|
844
|
rt300@3
|
845 toPD.addSymbol(ctrlName[i]);
|
rt300@3
|
846 toPD.addFloat(ctrlout[i]); // rounding here??
|
rt300@3
|
847
|
rt300@3
|
848 core.pd.sendList("fromOF", toPD);
|
rt300@3
|
849 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
|
rt300@3
|
850 }
|
rt300@2
|
851 }
|
rt300@8
|
852 //---------------------------------------------------------------
|
rt300@3
|
853 void testApp::sendFiltFreq(int ctrlin){
|
rt300@24
|
854 // smooth this
|
rt300@24
|
855 float fin = ctrlin;
|
rt300@24
|
856 float fout;
|
rt300@24
|
857 fout = (int)ctrlSmoother(fin);
|
rt300@3
|
858 List toPD;
|
rt300@3
|
859
|
rt300@3
|
860 toPD.addSymbol("filtFreq");
|
rt300@24
|
861 toPD.addFloat(fout);
|
rt300@3
|
862
|
rt300@3
|
863 core.pd.sendList("fromOF", toPD);
|
rt300@3
|
864 }
|
rt300@8
|
865 //---------------------------------------------------------------
|
rt300@3
|
866 void testApp::sendEnvShape(int ctrlin){
|
rt300@3
|
867 static int numpoints = 5;
|
rt300@3
|
868 static int numcontrols = 3;
|
rt300@3
|
869 //float values[points][controls] =
|
rt300@3
|
870 float ctrlout[numcontrols];
|
rt300@3
|
871 string ctrlName[3] = {"attack" , "decay", "sustain"};
|
rt300@3
|
872 float values[5][3] =
|
rt300@3
|
873 {{0., 0., 0.}, // 0
|
rt300@3
|
874 {0., 0.5, 0.}, // 32
|
rt300@3
|
875 {0.0, 1., 0.8}, // 64
|
rt300@3
|
876 {0.99, 0.3, 0.}, // 96
|
rt300@3
|
877 {0.3, 0.1, 0.}}; // 127
|
rt300@3
|
878
|
rt300@3
|
879 float fidx = (numpoints-1)*ctrlin/128.;
|
rt300@3
|
880 int idx = floor(fidx);
|
rt300@3
|
881 float frac = fidx - idx;
|
rt300@3
|
882 for(int i=0; i < numcontrols; i++){
|
rt300@3
|
883 ctrlout[i] = (1 - frac)*values[idx][i] + (frac)*values[idx+1][i];
|
rt300@3
|
884 // send to PD
|
rt300@3
|
885 List toPD;
|
rt300@3
|
886
|
rt300@3
|
887 toPD.addSymbol(ctrlName[i]);
|
rt300@3
|
888 toPD.addFloat(ctrlout[i]); // rounding here??
|
rt300@3
|
889
|
rt300@3
|
890 core.pd.sendList("fromOF", toPD);
|
rt300@3
|
891 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
|
rt300@3
|
892 }
|
rt300@3
|
893 }
|
rt300@8
|
894 //---------------------------------------------------------------
|
rt300@3
|
895 void testApp::sendModFreq(int ctrlin){
|
rt300@3
|
896 float fm = ctrlin/127.;
|
rt300@3
|
897 List toPD;
|
rt300@3
|
898
|
rt300@3
|
899 toPD.addSymbol("FMFreq");
|
rt300@3
|
900 toPD.addFloat(fm); // rounding here??
|
rt300@3
|
901
|
rt300@3
|
902 core.pd.sendList("fromOF", toPD);
|
rt300@8
|
903 }
|
rt300@8
|
904 //--------------------------------------------------------------- |