rt300@0
|
1 #include "testApp.h"
|
rt300@0
|
2
|
rt300@7
|
3 /*
|
rt300@7
|
4 TODO list
|
rt300@7
|
5
|
rt300@7
|
6 video out !!!!!
|
rt300@7
|
7
|
rt300@7
|
8 ios buttons etc
|
rt300@7
|
9 circular line string with invisible "identify" between two points
|
rt300@7
|
10
|
rt300@7
|
11 symmetry touch mode
|
rt300@7
|
12
|
rt300@7
|
13 new mesh popup menu
|
rt300@7
|
14 type x,y rings spokes
|
rt300@7
|
15
|
rt300@14
|
16 update to ofx0.8
|
rt300@7
|
17
|
rt300@7
|
18 save presets:
|
rt300@7
|
19 create mesh methods: save to json, construct from json
|
rt300@7
|
20
|
rt300@7
|
21 all the stuff in control (and off screen OSC ones)
|
rt300@7
|
22 lump positions, constraints
|
rt300@7
|
23 the scan path
|
rt300@7
|
24 the touch mode
|
rt300@7
|
25 the midi hit mode (rewrite this whole thing!)
|
rt300@7
|
26
|
rt300@7
|
27 preset recall list
|
rt300@7
|
28
|
rt300@7
|
29 modulation points:
|
rt300@7
|
30 make filter
|
rt300@7
|
31 new touch mode, drop modulation point
|
rt300@7
|
32 pop up list of destinations (or drag line?)
|
rt300@7
|
33
|
rt300@7
|
34
|
rt300@7
|
35
|
rt300@7
|
36 new super knobs
|
rt300@7
|
37 new supermenus
|
rt300@7
|
38
|
rt300@7
|
39 algorithmic scan path
|
rt300@7
|
40 auto- join up scan path...?
|
rt300@7
|
41
|
rt300@7
|
42 floating scan path, with interpolation
|
rt300@7
|
43
|
rt300@7
|
44 band limited touch points (invisible springs connecting to mesh?)
|
rt300@8
|
45
|
rt300@15
|
46 iphone
|
rt300@7
|
47 */
|
rt300@0
|
48 extern GlobalForces globalForces;
|
rt300@0
|
49 extern GlobalUI globalUI;
|
rt300@3
|
50 extern ScanPath scanPath;
|
rt300@10
|
51 extern PresetAlertViewController *presetAlertViewController;
|
rt300@0
|
52 //--------------------------------------------------------------
|
rt300@8
|
53 void testApp::setup(){
|
rt300@13
|
54
|
rt300@0
|
55 theMesh = NULL;
|
rt300@8
|
56
|
rt300@0
|
57 ofxAccelerometer.setup();
|
rt300@0
|
58
|
rt300@14
|
59 try{
|
rt300@14
|
60 receiver.setup( INPORT );
|
rt300@14
|
61 OscOK = true;
|
rt300@14
|
62 }
|
rt300@14
|
63 catch (std::runtime_error e){
|
rt300@14
|
64 cout << "OSC couldn't connect. Exception: " << e.what() << '\n';
|
rt300@14
|
65 OscOK = false;
|
rt300@14
|
66 }
|
rt300@0
|
67
|
rt300@14
|
68 try{
|
rt300@14
|
69 sender.setup( HOST, OUTPORT );
|
rt300@14
|
70 OscOK = true;
|
rt300@14
|
71 }
|
rt300@14
|
72 catch (std::runtime_error e){
|
rt300@14
|
73 cout << "OSC couldn't connect. Exception: " << e.what() << '\n';
|
rt300@14
|
74 OscOK = false;
|
rt300@14
|
75 }
|
rt300@14
|
76
|
rt300@0
|
77 ofBackground(0, 0, 0);
|
rt300@0
|
78 ofSetFullscreen(true);
|
rt300@0
|
79 ofSetFrameRate(60);
|
rt300@0
|
80
|
rt300@0
|
81 timeStep = 1/ofGetFrameRate();
|
rt300@0
|
82
|
rt300@0
|
83 ofEnableSmoothing();
|
rt300@0
|
84 ofEnableAlphaBlending();
|
rt300@0
|
85
|
rt300@13
|
86
|
rt300@0
|
87
|
rt300@0
|
88 pitch = 60.0;
|
rt300@0
|
89 phasorIncr = pitch/SAMPLE_RATE;
|
rt300@0
|
90 globalForces.gravityAmt = 0.0;
|
rt300@0
|
91 globalForces.avFilterAmt = 0.01;
|
rt300@1
|
92
|
rt300@12
|
93 initialiseMidi();
|
rt300@0
|
94 //
|
rt300@0
|
95 ofSoundStreamSetup(2,0,this, SAMPLE_RATE,256, 2);
|
rt300@5
|
96
|
rt300@5
|
97 paused = false;
|
rt300@5
|
98 audioOn = false;
|
rt300@5
|
99 drawingOn = true;
|
rt300@0
|
100
|
rt300@1
|
101 audioAccessFlag = false;
|
rt300@1
|
102 meshConstructionFlag = false;
|
rt300@13
|
103
|
rt300@14
|
104 ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT );
|
rt300@0
|
105 setupGui();
|
rt300@0
|
106
|
rt300@0
|
107
|
rt300@0
|
108 setupMesh();
|
rt300@3
|
109 scanPath.init();
|
rt300@3
|
110
|
rt300@3
|
111 globalUI.touchMode = globalUI.GRAB;
|
rt300@3
|
112 scanPath.scanMode = scanPath.DISPLACEMENT;
|
rt300@15
|
113 globalUI.borderSize = ofGetWidth()/8;
|
rt300@5
|
114 ofSoundStreamStart();
|
rt300@3
|
115
|
rt300@3
|
116 paused = false;
|
rt300@3
|
117 audioOn = true;
|
rt300@8
|
118
|
rt300@15
|
119 //ofxiPhoneExternalDisplay::mirrorOn();
|
rt300@8
|
120
|
rt300@15
|
121 cout << "Width: " << ofGetWidth() << endl;
|
rt300@15
|
122 cout << "Height: " << ofGetHeight() << endl;
|
rt300@8
|
123
|
rt300@15
|
124 // stupid hack for control vis
|
rt300@15
|
125 hideControls();
|
rt300@15
|
126 showControls();
|
rt300@13
|
127 //[ofxiPhoneGetGLView() updateDimensions];
|
rt300@8
|
128
|
rt300@8
|
129
|
rt300@0
|
130 }
|
rt300@12
|
131
|
rt300@12
|
132 //--------------------------------------------------------------------------
|
rt300@12
|
133 void testApp::initialiseMidi(){
|
rt300@12
|
134
|
rt300@12
|
135 /////////////////////////
|
rt300@12
|
136 // MIDI
|
rt300@12
|
137
|
rt300@12
|
138 midiChannel = 7;
|
rt300@12
|
139
|
rt300@12
|
140 // enables the network midi session between iOS and Mac OSX on a
|
rt300@12
|
141 // local wifi network
|
rt300@12
|
142 //
|
rt300@12
|
143 // in ofxMidi: open the input/outport network ports named "Session 1"
|
rt300@12
|
144 //
|
rt300@12
|
145 // on OSX: use the Audio MIDI Setup Utility to connect to the iOS device
|
rt300@12
|
146 //
|
rt300@12
|
147 ofxMidi::enableNetworking();
|
rt300@12
|
148
|
rt300@12
|
149 // list the number of available input & output ports
|
rt300@12
|
150 ofxMidiIn::listPorts();
|
rt300@12
|
151 ofxMidiOut::listPorts();
|
rt300@12
|
152
|
rt300@12
|
153 // create and open input ports
|
rt300@12
|
154 for(int i = 0; i < ofxMidiIn::getNumPorts(); ++i) {
|
rt300@12
|
155
|
rt300@12
|
156 // new object
|
rt300@12
|
157 inputs.push_back(new ofxMidiIn);
|
rt300@12
|
158
|
rt300@12
|
159 // set this class to receive incoming midi events
|
rt300@12
|
160 inputs[i]->addListener(this);
|
rt300@12
|
161
|
rt300@12
|
162 // open input port via port number
|
rt300@12
|
163 inputs[i]->openPort(i);
|
rt300@12
|
164 }
|
rt300@12
|
165
|
rt300@12
|
166 // create and open output ports
|
rt300@12
|
167 for(int i = 0; i < ofxMidiOut::getNumPorts(); ++i) {
|
rt300@12
|
168
|
rt300@12
|
169 // new object
|
rt300@12
|
170 outputs.push_back(new ofxMidiOut);
|
rt300@12
|
171
|
rt300@12
|
172 // open input port via port number
|
rt300@12
|
173 outputs[i]->openPort(i);
|
rt300@12
|
174 }
|
rt300@12
|
175
|
rt300@12
|
176 // set this class to receieve midi device (dis)connection events
|
rt300@12
|
177 ofxMidi::setConnectionListener(this);
|
rt300@12
|
178
|
rt300@12
|
179 // END MIDI
|
rt300@12
|
180
|
rt300@12
|
181 }
|
rt300@12
|
182
|
rt300@9
|
183 //--------------------------------------------------------------
|
rt300@8
|
184 Json::Value testApp::convertToJsonForSaving(){
|
rt300@8
|
185 Json::Value root;
|
rt300@8
|
186
|
rt300@8
|
187 root["pitch"] = pitch; //
|
rt300@9
|
188
|
rt300@8
|
189
|
rt300@9
|
190 root["globalForces"] = globalForces.convertToJsonForSaving();
|
rt300@8
|
191
|
rt300@8
|
192 root["mesh"] = theMesh->convertToJsonForSaving();
|
rt300@8
|
193
|
rt300@8
|
194 return root;
|
rt300@8
|
195 }
|
rt300@10
|
196 //
|
rt300@13
|
197 //--------------------------------------------------------------
|
rt300@10
|
198 void testApp::showPresetNameDialog(){
|
rt300@10
|
199 if(!presetAlertViewController.alertShowing){ // this is to stop wierd infinite loop in ios5 (simulator)
|
rt300@10
|
200 [presetAlertViewController showPresetNamePrompt];
|
rt300@10
|
201
|
rt300@10
|
202 }
|
rt300@10
|
203
|
rt300@10
|
204 }
|
rt300@9
|
205 //--------------------------------------------------------------
|
rt300@12
|
206 void testApp::savePreset(const string name = "default" ){
|
rt300@12
|
207 static int presetNumber;
|
rt300@12
|
208
|
rt300@12
|
209 presetNumber++;
|
rt300@9
|
210 Json::Value jpreset = convertToJsonForSaving();
|
rt300@8
|
211 //save json to file
|
rt300@9
|
212 string fname = ofxiPhoneGetDocumentsDirectory() + "presetFile";
|
rt300@8
|
213
|
rt300@9
|
214 // write to file
|
rt300@9
|
215
|
rt300@9
|
216 ofFile logFile(fname,ofFile::WriteOnly);
|
rt300@9
|
217 logFile << jpreset;
|
rt300@9
|
218 logFile.close();
|
rt300@8
|
219 }
|
rt300@9
|
220 //--------------------------------------------------------------
|
rt300@9
|
221 Json::Value testApp::loadPresetFile(){
|
rt300@9
|
222 Json::Value jpreset;
|
rt300@9
|
223 //save json to file
|
rt300@9
|
224 string fname = ofxiPhoneGetDocumentsDirectory() + "presetFile";
|
rt300@9
|
225
|
rt300@9
|
226 Json::Value root;
|
rt300@9
|
227 Json::Reader reader;
|
rt300@9
|
228
|
rt300@9
|
229 /////////////
|
rt300@9
|
230 // read file
|
rt300@9
|
231
|
rt300@9
|
232 ifstream theFile(fname.c_str());
|
rt300@9
|
233 stringstream fileText;
|
rt300@9
|
234 string line;
|
rt300@9
|
235 if(!theFile){
|
rt300@9
|
236 cout<<"No preset file found\n";
|
rt300@9
|
237 return root;
|
rt300@9
|
238 }else{
|
rt300@9
|
239 while(theFile){
|
rt300@9
|
240 theFile >> line;
|
rt300@9
|
241 // cout << line; // lots!!!!
|
rt300@9
|
242 fileText << line;
|
rt300@9
|
243 }
|
rt300@9
|
244 theFile.close();
|
rt300@9
|
245 }
|
rt300@9
|
246
|
rt300@9
|
247 cout << "size of preset JSON string:" << fileText.str().length() << "BYTES \n";
|
rt300@9
|
248
|
rt300@9
|
249 bool parsingSuccessful = reader.parse( fileText.str(), root );
|
rt300@9
|
250
|
rt300@9
|
251 if ( !parsingSuccessful )
|
rt300@9
|
252 {
|
rt300@9
|
253 // report to the user the failure and their locations in the document.
|
rt300@9
|
254 std::cout << "Failed to parse preset JSON: \n" << reader.getFormattedErrorMessages();
|
rt300@9
|
255 return root; // will be null
|
rt300@9
|
256 }
|
rt300@9
|
257
|
rt300@9
|
258 return root;
|
rt300@9
|
259 }
|
rt300@9
|
260 //--------------------------------------------------------------
|
rt300@9
|
261 void testApp::constructPresetFromJson(Json::Value& presetJson){
|
rt300@8
|
262
|
rt300@8
|
263 // construct mesh with right type and size
|
rt300@8
|
264 // impose saved constraints
|
rt300@8
|
265 // make saved scanpath
|
rt300@8
|
266 // recall global settings
|
rt300@8
|
267 pitch = presetJson["pitch"].asDouble();
|
rt300@9
|
268
|
rt300@9
|
269 theMesh = new Mesh(presetJson["mesh"]);
|
rt300@10
|
270
|
rt300@10
|
271 globalForces.setFromJson(presetJson["globalForces"]);
|
rt300@9
|
272 }
|
rt300@13
|
273 //--------------------------------------------------------------
|
rt300@9
|
274 void testApp::loadPreset(){
|
rt300@9
|
275 if(audioAccessFlag) return; // or rather wait !
|
rt300@9
|
276 meshConstructionFlag = TRUE;
|
rt300@9
|
277
|
rt300@9
|
278 deleteMesh();
|
rt300@9
|
279
|
rt300@9
|
280 Json::Value jp = loadPresetFile();
|
rt300@9
|
281
|
rt300@9
|
282 constructPresetFromJson(jp);
|
rt300@9
|
283
|
rt300@9
|
284 // check these stupid tyhings
|
rt300@9
|
285 numTouches = 0;
|
rt300@9
|
286 meshConstructionFlag = FALSE;
|
rt300@9
|
287 paused = false;
|
rt300@9
|
288 audioOn = true;
|
rt300@9
|
289 drawingOn = true;
|
rt300@9
|
290 ofSoundStreamStart();
|
rt300@9
|
291
|
rt300@9
|
292 cout << "PRESET WAS LOADED\n";
|
rt300@9
|
293
|
rt300@8
|
294 }
|
rt300@0
|
295 //--------------------------------------------------------------
|
rt300@0
|
296 //--------------------------------------------------------------
|
rt300@0
|
297 // App running stuff
|
rt300@0
|
298 //--------------------------------------------------------------
|
rt300@0
|
299 //--------------------------------------------------------------
|
rt300@0
|
300 //--------------------------------------------------------------
|
rt300@0
|
301 void testApp::exit(){
|
rt300@0
|
302 ofSoundStreamClose();
|
rt300@0
|
303
|
rt300@0
|
304 // save everything...
|
rt300@5
|
305
|
rt300@0
|
306 delete guiL;
|
rt300@0
|
307
|
rt300@0
|
308 if(theMesh != NULL){
|
rt300@3
|
309 scanPath.clear();
|
rt300@0
|
310 delete theMesh;
|
rt300@0
|
311 }
|
rt300@0
|
312
|
rt300@0
|
313 }
|
rt300@0
|
314
|
rt300@0
|
315 //--------------------------------------------------------------
|
rt300@0
|
316 void testApp::update(){
|
rt300@0
|
317
|
rt300@0
|
318 if(!paused){
|
rt300@0
|
319 if (theMesh != NULL){
|
rt300@0
|
320 theMesh->update();
|
rt300@5
|
321
|
rt300@0
|
322 }
|
rt300@5
|
323
|
rt300@0
|
324 }
|
rt300@0
|
325 handleMessages(); // !?!??
|
rt300@15
|
326 // if(ofxiPhoneExternalDisplay::isExternalScreenConnected()){
|
rt300@15
|
327 // if(!ofxiPhoneExternalDisplay::isMirroring()){
|
rt300@15
|
328 // ofxiPhoneExternalDisplay::mirrorOn();
|
rt300@15
|
329 // //printf("turned on Mirroring!\n");
|
rt300@15
|
330 // }
|
rt300@15
|
331 // }
|
rt300@8
|
332
|
rt300@0
|
333 }
|
rt300@0
|
334
|
rt300@0
|
335 //--------------------------------------------------------------
|
rt300@0
|
336 void testApp::draw(){
|
rt300@0
|
337 if(drawingOn){
|
rt300@0
|
338 if(theMesh != NULL)
|
rt300@0
|
339 theMesh->draw();
|
rt300@0
|
340 }
|
rt300@8
|
341 if(controlsShowing){
|
rt300@8
|
342 drawSidePanels();
|
rt300@8
|
343 }else{
|
rt300@15
|
344 if (!controlsShowing) scanPath.draw(); // uncomment if you want to see the output waveform
|
rt300@8
|
345 }
|
rt300@0
|
346 }
|
rt300@0
|
347 //--------------------------------------------------------------
|
rt300@0
|
348 // background for UI
|
rt300@0
|
349 void testApp::drawSidePanels(){
|
rt300@0
|
350 ofSetColor(123, 123, 123);
|
rt300@15
|
351 ofRect(0, 0, globalUI.borderSize, ofGetHeight());
|
rt300@15
|
352 ofRect(ofGetWidth()-globalUI.borderSize, 0, globalUI.borderSize, ofGetHeight());
|
rt300@0
|
353 }
|
rt300@0
|
354 //--------------------------------------------------------------
|
rt300@0
|
355 void testApp::drawMessages(){
|
rt300@0
|
356 for ( int i=0; i<NUM_MSG_STRINGS; i++ )
|
rt300@0
|
357 {
|
rt300@0
|
358 ofDrawBitmapString( msg_strings[i], 10, 40+15*i );
|
rt300@0
|
359 }
|
rt300@0
|
360 }
|
rt300@0
|
361
|
rt300@0
|
362 //--------------------------------------------------------------
|
rt300@0
|
363 //--------------------------------------------------------------
|
rt300@0
|
364 //------------------------CHANGING MESH----------------------------
|
rt300@0
|
365 //--------------------------------------------------------------
|
rt300@0
|
366 //--------------------------------------------------------------
|
rt300@0
|
367 //--------------------------------------------------------------
|
rt300@5
|
368 //--------------------------------------------------------------
|
rt300@5
|
369 void testApp::setupMesh(){
|
rt300@5
|
370 // SET UP THE MESH STRUCTURE
|
rt300@5
|
371 if(audioAccessFlag) return; // or rather wait !
|
rt300@5
|
372 meshConstructionFlag = TRUE;
|
rt300@5
|
373 static int type = 0;
|
rt300@14
|
374 int numTypes = 8;
|
rt300@5
|
375
|
rt300@9
|
376
|
rt300@9
|
377
|
rt300@5
|
378
|
rt300@6
|
379 if(type % numTypes == 0){
|
rt300@9
|
380 theMesh = new SquareCrossMesh(6,6);
|
rt300@9
|
381
|
rt300@6
|
382 }else if (type % numTypes == 1){
|
rt300@9
|
383
|
rt300@5
|
384 // different for iphone
|
rt300@5
|
385 if(ofGetWidth() == 480){ //PHONE
|
rt300@5
|
386 theMesh = new SpiderCrossMesh(60,5);
|
rt300@5
|
387 }else{ //PAD
|
rt300@5
|
388 //theMesh = new SpiderCrossMesh(140,5);
|
rt300@5
|
389
|
rt300@5
|
390 theMesh = new SpiderCrossMesh(100,9);
|
rt300@5
|
391 }
|
rt300@6
|
392 }else if(type % numTypes ==2){
|
rt300@9
|
393
|
rt300@12
|
394 theMesh = new DropletMesh(2000);
|
rt300@5
|
395
|
rt300@6
|
396 }else if(type % numTypes ==3){
|
rt300@6
|
397 theMesh = new SquareCrossMesh(28,28);
|
rt300@5
|
398
|
rt300@6
|
399 }else if(type % numTypes ==4){
|
rt300@5
|
400
|
rt300@5
|
401 theMesh = new TriangleMesh(34,34);
|
rt300@6
|
402 }else if(type % numTypes ==5){
|
rt300@6
|
403 theMesh = new SpiderCrossMesh(30,30);
|
rt300@5
|
404
|
rt300@6
|
405 }else if(type % numTypes ==6){
|
rt300@5
|
406
|
rt300@5
|
407 theMesh = new DropletMesh(128);
|
rt300@14
|
408 }else if(type % numTypes ==7){
|
rt300@14
|
409
|
rt300@14
|
410 theMesh = new LineMesh(4000);
|
rt300@5
|
411 }
|
rt300@5
|
412 type++;
|
rt300@5
|
413 //theMesh = new LineMesh(123);
|
rt300@5
|
414 //theMesh = new GroundedLineMesh(400);
|
rt300@5
|
415 //theMesh = new TriangleMesh(40,40);
|
rt300@5
|
416 //theMesh = new LineMesh(100);
|
rt300@5
|
417
|
rt300@5
|
418 // SET CONSTANTS UP FOR MESH
|
rt300@5
|
419 theMesh->setSpringConstant(0.8);
|
rt300@5
|
420 theMesh->setMass(1);
|
rt300@5
|
421 theMesh->setFriction(0.99991);
|
rt300@5
|
422
|
rt300@5
|
423 numTouches = 0;
|
rt300@5
|
424 meshConstructionFlag = FALSE;
|
rt300@5
|
425 paused = false;
|
rt300@5
|
426 audioOn = true;
|
rt300@5
|
427 drawingOn = true;
|
rt300@5
|
428 ofSoundStreamStart();
|
rt300@5
|
429 cout << "MESH SETUP\n";
|
rt300@5
|
430 }
|
rt300@5
|
431 //--------------------------------------------------------------
|
rt300@0
|
432 void testApp::deleteMesh(){
|
rt300@0
|
433 // TODO - OTHER THREADS FUCK THIS UP
|
rt300@1
|
434 if(audioAccessFlag) return; // or rather wait !
|
rt300@0
|
435 //stop everything
|
rt300@5
|
436
|
rt300@5
|
437 scanPath.clear();
|
rt300@0
|
438 ofSoundStreamStop();
|
rt300@0
|
439
|
rt300@0
|
440 paused = true;
|
rt300@0
|
441 audioOn = false;
|
rt300@0
|
442 drawingOn = false;
|
rt300@0
|
443
|
rt300@3
|
444 scanPath.clear();
|
rt300@0
|
445 // trash it
|
rt300@0
|
446 delete theMesh;
|
rt300@0
|
447 theMesh = NULL;
|
rt300@0
|
448
|
rt300@0
|
449 cout << "MESH DELETED\n";
|
rt300@0
|
450 }
|
rt300@0
|
451 //--------------------------------------------------------------
|
rt300@0
|
452 void testApp::regenerateMesh(string meshType, int dim1, int dim2){
|
rt300@5
|
453
|
rt300@5
|
454 // more customisable version of setupMesh()
|
rt300@5
|
455 if(audioAccessFlag) return;
|
rt300@1
|
456
|
rt300@0
|
457 if (theMesh != NULL) return;
|
rt300@0
|
458
|
rt300@0
|
459 if (meshType == "LineMesh"){
|
rt300@0
|
460
|
rt300@0
|
461 theMesh = new LineMesh(dim1);
|
rt300@0
|
462 }else if (meshType == "DropletMesh"){
|
rt300@0
|
463
|
rt300@0
|
464 theMesh = new DropletMesh(dim1);
|
rt300@0
|
465 }else if (meshType == "SpiderMesh"){
|
rt300@0
|
466
|
rt300@0
|
467 theMesh = new SpiderMesh(dim1,dim2);
|
rt300@0
|
468 }else if (meshType == "SpiderCrossMesh"){
|
rt300@0
|
469
|
rt300@0
|
470 theMesh = new SpiderCrossMesh(dim1,dim2);
|
rt300@0
|
471 }else if (meshType == "SquareCrossMesh"){
|
rt300@0
|
472
|
rt300@0
|
473 theMesh = new SquareCrossMesh(dim1,dim2);
|
rt300@0
|
474 }else if (meshType == "TriangleMesh"){
|
rt300@0
|
475
|
rt300@0
|
476 theMesh = new TriangleMesh(dim1,dim2);
|
rt300@0
|
477 }else if (meshType == "GroundedLineMesh"){
|
rt300@0
|
478
|
rt300@0
|
479 theMesh = new GroundedLineMesh(dim1);
|
rt300@0
|
480 }else{
|
rt300@0
|
481 cout << "OSC message error: unrecognised mesh type" << endl;
|
rt300@0
|
482 return;
|
rt300@0
|
483 }
|
rt300@0
|
484 ofSoundStreamStart();
|
rt300@0
|
485 drawingOn = true;
|
rt300@0
|
486 paused = false;
|
rt300@0
|
487 audioOn = true;
|
rt300@0
|
488 cout << "MESH REGENERATED\n";
|
rt300@0
|
489
|
rt300@0
|
490 }
|
rt300@0
|
491
|
rt300@0
|
492
|
rt300@0
|
493
|
rt300@0
|
494 //--------------------------------------------------------------
|
rt300@0
|
495 //--------------------------------------------------------------
|
rt300@0
|
496 //------------------------KEYS (OSX)----------------------------
|
rt300@0
|
497 //--------------------------------------------------------------
|
rt300@0
|
498 //--------------------------------------------------------------
|
rt300@0
|
499 // all this is now osc messages
|
rt300@0
|
500 void testApp::keyPressed(int key){
|
rt300@0
|
501
|
rt300@0
|
502 if (key == 'p'){
|
rt300@0
|
503
|
rt300@0
|
504 paused = !paused;
|
rt300@0
|
505 }
|
rt300@0
|
506 if (key == 's'){
|
rt300@0
|
507 theMesh->toggleSyrup(true);
|
rt300@0
|
508 }
|
rt300@0
|
509 if (key == 'f'){
|
rt300@0
|
510 theMesh->toggleSpringForces(false);
|
rt300@0
|
511 }
|
rt300@0
|
512 if (key == '='){
|
rt300@0
|
513 theMesh->increasePropagationSpeed();
|
rt300@0
|
514 }
|
rt300@0
|
515 if (key == '-'){
|
rt300@0
|
516 theMesh->decreasePropagationSpeed();
|
rt300@0
|
517 }
|
rt300@0
|
518 if (key == 'a'){
|
rt300@0
|
519 if(audioOn){
|
rt300@0
|
520 audioOn = false;
|
rt300@0
|
521 }else{
|
rt300@0
|
522 audioOn = true;
|
rt300@0
|
523 }
|
rt300@0
|
524 }
|
rt300@0
|
525 if (key == 'r'){
|
rt300@0
|
526 theMesh->resetPositions();
|
rt300@0
|
527 theMesh->resetVelocities();
|
rt300@0
|
528
|
rt300@0
|
529 }
|
rt300@0
|
530 if (key == 'e'){
|
rt300@0
|
531 theMesh->constrain(.0,.0,Mesh::CONSTRAIN_EDGES);
|
rt300@0
|
532 }
|
rt300@0
|
533 if (key == 'c'){
|
rt300@0
|
534 theMesh->constrain(.0,.0,Mesh::CONSTRAIN_CORNERS);
|
rt300@0
|
535 }
|
rt300@0
|
536 if (key == 'u'){
|
rt300@0
|
537 theMesh->unconstrain();
|
rt300@0
|
538 }
|
rt300@0
|
539 if (key == 'l'){
|
rt300@0
|
540 theMesh->setRestLength();
|
rt300@0
|
541 }
|
rt300@0
|
542 if (key == '0'){
|
rt300@0
|
543 theMesh->zeroRestLength();
|
rt300@0
|
544 }
|
rt300@0
|
545 if (key == 'd'){
|
rt300@0
|
546 drawingOn = !drawingOn;
|
rt300@0
|
547 }
|
rt300@0
|
548 }
|
rt300@0
|
549
|
rt300@0
|
550 //---------------------------------------------------------------
|
rt300@0
|
551
|
rt300@0
|
552 void testApp::keyReleased(int key){
|
rt300@0
|
553 if (key == 's'){
|
rt300@0
|
554 theMesh->toggleSyrup(false);
|
rt300@0
|
555 }
|
rt300@0
|
556 if (key == 'f'){
|
rt300@0
|
557 theMesh->toggleSpringForces(true);
|
rt300@0
|
558 }
|
rt300@0
|
559 }
|
rt300@0
|
560
|
rt300@0
|
561
|
rt300@0
|
562
|
rt300@0
|
563 //--------------------------------------------------------------
|
rt300@0
|
564 //--------------------------------------------------------------
|
rt300@0
|
565 //------------------------TOUCH---------------------------------
|
rt300@0
|
566 //--------------------------------------------------------------
|
rt300@0
|
567 //--------------------------------------------------------------
|
rt300@0
|
568
|
rt300@0
|
569
|
rt300@0
|
570
|
rt300@0
|
571
|
rt300@0
|
572 void testApp::touchDown(ofTouchEventArgs &touch){
|
rt300@0
|
573 if(theMesh == NULL) return;
|
rt300@0
|
574
|
rt300@0
|
575 double dax, day;
|
rt300@0
|
576 // touchDown
|
rt300@0
|
577 //cout << "touchDown ID: " << touch.id << endl;
|
rt300@0
|
578 if(globalUI.handleTouchDown(touch.x, touch.y)) return;
|
rt300@0
|
579
|
rt300@0
|
580
|
rt300@0
|
581 addTouch();
|
rt300@0
|
582
|
rt300@0
|
583
|
rt300@0
|
584
|
rt300@0
|
585 dax = (double(touch.x) - globalUI.borderSize)/ofGetHeight();
|
rt300@0
|
586 day = double(touch.y)/ofGetHeight();
|
rt300@0
|
587
|
rt300@0
|
588 switch (globalUI.touchMode){
|
rt300@0
|
589 case globalUI.GRAB:
|
rt300@0
|
590 theMesh->grab(dax,day,touch.id);
|
rt300@0
|
591 break;
|
rt300@0
|
592 case globalUI.INSCRIBE_PATH:
|
rt300@0
|
593 // start a new path, with touch id? ie:polyphonic paths!??!
|
rt300@0
|
594 break;
|
rt300@0
|
595 case globalUI.FORCE_FIELD:
|
rt300@0
|
596 globalForces.createForceTouchPoint(dax,day, touch.id);
|
rt300@0
|
597 break;
|
rt300@0
|
598 case globalUI.SPATIAL_HARMONIC:
|
rt300@0
|
599 // work out
|
rt300@0
|
600 theMesh->spatialHarmonic(numTouches, 0);
|
rt300@0
|
601 break;
|
rt300@0
|
602 case globalUI.CONSTRAIN:
|
rt300@0
|
603 theMesh->constrain(dax,day,Mesh::CONSTRAIN_GRAB_REGION);
|
rt300@0
|
604 break;
|
rt300@0
|
605 case globalUI.UNCONSTRAIN:
|
rt300@0
|
606 theMesh->unconstrain(dax,day,Mesh::CONSTRAIN_GRAB_REGION);
|
rt300@0
|
607 break;
|
rt300@0
|
608 case globalUI.VIBRATE:
|
rt300@0
|
609 break;
|
rt300@0
|
610 default:
|
rt300@0
|
611
|
rt300@0
|
612 break;
|
rt300@0
|
613 }
|
rt300@0
|
614
|
rt300@0
|
615
|
rt300@0
|
616 }
|
rt300@0
|
617
|
rt300@0
|
618 //--------------------------------------------------------------
|
rt300@0
|
619 void testApp::touchMoved(ofTouchEventArgs &touch){
|
rt300@0
|
620 if(theMesh == NULL) return;
|
rt300@0
|
621 if(globalUI.handleTouchMove(touch.x, touch.y)) return;
|
rt300@0
|
622 //cout << "touchMoved ID: " << touch.id << endl;
|
rt300@0
|
623
|
rt300@0
|
624
|
rt300@0
|
625 double dax, day;
|
rt300@0
|
626 dax = (double(touch.x) - globalUI.borderSize)/ofGetHeight();
|
rt300@0
|
627 day = double(touch.y)/ofGetHeight();
|
rt300@0
|
628
|
rt300@0
|
629
|
rt300@0
|
630
|
rt300@0
|
631 /*
|
rt300@0
|
632 if(kslider->checkForTouch(touch.x, touch.y)){
|
rt300@0
|
633 cout << "kslider touched";
|
rt300@0
|
634 kslider->adjust(touch.x,touch.y);
|
rt300@0
|
635 return;
|
rt300@0
|
636 }
|
rt300@0
|
637 */
|
rt300@0
|
638
|
rt300@0
|
639 switch (globalUI.touchMode){
|
rt300@0
|
640 case globalUI.GRAB:
|
rt300@0
|
641 theMesh->drag(dax,day,touch.id);
|
rt300@0
|
642 break;
|
rt300@0
|
643 case globalUI.INSCRIBE_PATH:
|
rt300@0
|
644 theMesh->inscribeScanPath(dax,day);
|
rt300@0
|
645 break;
|
rt300@0
|
646 case globalUI.FORCE_FIELD:
|
rt300@0
|
647 //theMesh->forceField(dax,day,touch.id);
|
rt300@13
|
648
|
rt300@0
|
649 globalForces.moveForceTouchPoint(dax,day, touch.id);
|
rt300@0
|
650 break;
|
rt300@0
|
651 case globalUI.SPATIAL_HARMONIC:
|
rt300@0
|
652 // makes no sense
|
rt300@0
|
653 break;
|
rt300@0
|
654 case globalUI.CONSTRAIN:
|
rt300@0
|
655 theMesh->constrain(dax,day,Mesh::CONSTRAIN_GRAB_REGION);
|
rt300@0
|
656 break;
|
rt300@0
|
657 case globalUI.UNCONSTRAIN:
|
rt300@0
|
658 theMesh->unconstrain(dax,day,Mesh::CONSTRAIN_GRAB_REGION);
|
rt300@0
|
659 break;
|
rt300@0
|
660 case globalUI.VIBRATE:
|
rt300@0
|
661 break;
|
rt300@0
|
662 default:
|
rt300@0
|
663
|
rt300@0
|
664 break;
|
rt300@0
|
665 }
|
rt300@0
|
666 }
|
rt300@0
|
667
|
rt300@0
|
668 //--------------------------------------------------------------
|
rt300@0
|
669 void testApp::touchUp(ofTouchEventArgs &touch){
|
rt300@0
|
670 if(theMesh == NULL) return;
|
rt300@0
|
671 if(globalUI.handleTouchUp(touch.x, touch.y)) return;
|
rt300@0
|
672
|
rt300@0
|
673
|
rt300@0
|
674 removeTouch();
|
rt300@0
|
675
|
rt300@0
|
676
|
rt300@0
|
677 switch (globalUI.touchMode){
|
rt300@0
|
678 case globalUI.GRAB:
|
rt300@0
|
679 theMesh->unGrab(touch.id);
|
rt300@0
|
680 break;
|
rt300@0
|
681 case globalUI.INSCRIBE_PATH:
|
rt300@0
|
682 theMesh->disconnectDraw();
|
rt300@0
|
683 break;
|
rt300@0
|
684 case globalUI.FORCE_FIELD:
|
rt300@0
|
685 globalForces.removeForceTouchPoint(touch.id);
|
rt300@0
|
686 break;
|
rt300@0
|
687 case globalUI.SPATIAL_HARMONIC:
|
rt300@0
|
688 break;
|
rt300@0
|
689 case globalUI.CONSTRAIN:
|
rt300@0
|
690
|
rt300@0
|
691 break;
|
rt300@0
|
692 case globalUI.UNCONSTRAIN:
|
rt300@0
|
693
|
rt300@0
|
694 break;
|
rt300@0
|
695 case globalUI.VIBRATE:
|
rt300@0
|
696 break;
|
rt300@0
|
697 default:
|
rt300@0
|
698
|
rt300@0
|
699 break;
|
rt300@0
|
700 }
|
rt300@0
|
701
|
rt300@0
|
702 }
|
rt300@0
|
703
|
rt300@0
|
704 //--------------------------------------------------------------
|
rt300@0
|
705 void testApp::touchDoubleTap(ofTouchEventArgs &touch){
|
rt300@0
|
706 // pretty much useless.
|
rt300@0
|
707 /*
|
rt300@0
|
708 ofxOscMessage m;
|
rt300@0
|
709 m.setAddress( "/test" );
|
rt300@0
|
710 m.addIntArg( 1 );
|
rt300@0
|
711 m.addFloatArg( 3.5f );
|
rt300@0
|
712 m.addStringArg( "hello" );
|
rt300@0
|
713 m.addFloatArg( ofGetElapsedTimef() );
|
rt300@0
|
714 sender.sendMessage( m );
|
rt300@0
|
715 */
|
rt300@0
|
716
|
rt300@0
|
717 //ofxiPhoneScreenGrab(NULL);
|
rt300@0
|
718 }
|
rt300@0
|
719
|
rt300@0
|
720
|
rt300@0
|
721 //--------------------------------------------------------------
|
rt300@0
|
722 void testApp::addTouch(){
|
rt300@0
|
723 numTouches++;
|
rt300@14
|
724 //cout << "numtouches " << numTouches << endl;
|
rt300@0
|
725 }
|
rt300@0
|
726 //--------------------------------------------------------------
|
rt300@0
|
727 void testApp::removeTouch(){
|
rt300@0
|
728 numTouches--;
|
rt300@0
|
729
|
rt300@0
|
730 }
|
rt300@0
|
731
|
rt300@0
|
732 //--------------------------------------------------------------
|
rt300@0
|
733 //--------------------------------------------------------------
|
rt300@0
|
734 // MOUSE - NOT NEEDED FOR IPAD
|
rt300@0
|
735 //--------------------------------------------------------------
|
rt300@0
|
736 //--------------------------------------------------------------
|
rt300@0
|
737 void testApp::mouseMoved(int x, int y ){
|
rt300@0
|
738 //cout << "mouse moved " << x << 'y' << y << '\n';
|
rt300@0
|
739 /*
|
rt300@0
|
740 double dax, day;
|
rt300@0
|
741
|
rt300@0
|
742 // normalise
|
rt300@0
|
743 dax = double(x)/ofGetWidth();
|
rt300@0
|
744 day = double(y)/ofGetHeight();
|
rt300@0
|
745
|
rt300@0
|
746 theMesh->checkHover(dax,day);
|
rt300@0
|
747
|
rt300@0
|
748 */
|
rt300@0
|
749 }
|
rt300@0
|
750
|
rt300@0
|
751 //--------------------------------------------------------------
|
rt300@0
|
752 void testApp::mouseDragged(int x, int y, int button){
|
rt300@0
|
753 //cout << "mouse DRAGGED " << x << 'y' << y << '\n';
|
rt300@0
|
754 /*
|
rt300@0
|
755 double dax, day;
|
rt300@0
|
756 dax = double(x)/ofGetWidth();
|
rt300@0
|
757 day = double(y)/ofGetHeight();
|
rt300@0
|
758
|
rt300@0
|
759 if(button == 0){
|
rt300@0
|
760 if(!paused){
|
rt300@0
|
761 theMesh->drag(dax,day, 0);
|
rt300@0
|
762 }else{
|
rt300@0
|
763 // pause mode - draw a scan path!
|
rt300@0
|
764
|
rt300@0
|
765 theMesh->drawScanPath(dax,day);
|
rt300@0
|
766 audioOn = false;
|
rt300@0
|
767 }
|
rt300@0
|
768 }else if(button == 2){
|
rt300@0
|
769
|
rt300@0
|
770 }
|
rt300@0
|
771 */
|
rt300@0
|
772
|
rt300@0
|
773 }
|
rt300@0
|
774
|
rt300@0
|
775 //--------------------------------------------------------------
|
rt300@0
|
776 void testApp::mousePressed(int x, int y, int button){
|
rt300@0
|
777 /*
|
rt300@0
|
778 double dax, day;
|
rt300@0
|
779 // normalise
|
rt300@0
|
780 dax = double(x)/ofGetWidth();
|
rt300@0
|
781 day = double(y)/ofGetHeight();
|
rt300@0
|
782
|
rt300@0
|
783 if(button == 0){
|
rt300@0
|
784 if(paused){
|
rt300@0
|
785 // draw a path
|
rt300@0
|
786 audioOn = false;
|
rt300@0
|
787 theMesh->deleteScanPath();
|
rt300@0
|
788 }else{
|
rt300@0
|
789 theMesh->grab(dax,day, 0);
|
rt300@0
|
790 }
|
rt300@0
|
791 }else if(button == 2){
|
rt300@0
|
792 theMesh->constrain(dax,day,Mesh::CONSTRAIN_GRAB_REGION);
|
rt300@0
|
793 }else{
|
rt300@0
|
794 cout << "OTHER BUTTON?\n";
|
rt300@0
|
795 }
|
rt300@0
|
796 */
|
rt300@0
|
797
|
rt300@0
|
798
|
rt300@0
|
799 }
|
rt300@0
|
800
|
rt300@0
|
801 //--------------------------------------------------------------
|
rt300@0
|
802 void testApp::mouseReleased(int x, int y, int button){
|
rt300@0
|
803 /*
|
rt300@0
|
804 if(button == 0){
|
rt300@0
|
805 theMesh->unGrab(0);
|
rt300@0
|
806 }else if(button == 2){
|
rt300@0
|
807 }else{
|
rt300@0
|
808 cout << "butt other";
|
rt300@0
|
809 }
|
rt300@0
|
810 */
|
rt300@0
|
811
|
rt300@0
|
812 }
|
rt300@0
|
813 //--------------------------------------------------------------
|
rt300@0
|
814 //--------------------------------------------------------------
|
rt300@0
|
815 //-------------------------AUDIO-----------------------------
|
rt300@0
|
816 //--------------------------------------------------------------
|
rt300@0
|
817 //--------------------------------------------------------------
|
rt300@0
|
818 void testApp::restartAudioStream(){
|
rt300@0
|
819 ofSoundStreamStart();
|
rt300@0
|
820 audioOn = true;
|
rt300@0
|
821
|
rt300@0
|
822 }
|
rt300@0
|
823 //--------------------------------------------------------------
|
rt300@0
|
824
|
rt300@0
|
825 void testApp::audioReceived(float * input, int bufferSize, int nChannels){
|
rt300@0
|
826
|
rt300@0
|
827 }
|
rt300@0
|
828 //--------------------------------------------------------------
|
rt300@0
|
829 void testApp::audioRequested (float * output, int bufferSize, int nChannels){
|
rt300@0
|
830 float sample;
|
rt300@0
|
831 static double phasor;
|
rt300@4
|
832
|
rt300@1
|
833 if(meshConstructionFlag) return;
|
rt300@5
|
834 // if no mesh , scanpath will still be there, but empty should be fine
|
rt300@0
|
835
|
rt300@0
|
836 phasorIncr = pitch/SAMPLE_RATE;
|
rt300@0
|
837
|
rt300@3
|
838 if(audioOn){
|
rt300@1
|
839 audioAccessFlag = TRUE;
|
rt300@0
|
840 for (int i = 0; i < bufferSize; i++){
|
rt300@0
|
841
|
rt300@3
|
842 sample = float(scanPath.getNextSample(phasor));
|
rt300@0
|
843
|
rt300@0
|
844 // hipass to get rid of DC
|
rt300@0
|
845 //sample = mydspTools.highpass1(sample);
|
rt300@0
|
846 sample = mydspTools.butter(sample);
|
rt300@14
|
847 // clip after volume
|
rt300@14
|
848 sample = sample*globalForces.volume;
|
rt300@14
|
849 if (sample >= 1.0){
|
rt300@14
|
850 sample = 0.999999999;
|
rt300@14
|
851 }else if (sample <= -1.0){
|
rt300@14
|
852 sample = -0.999999999;
|
rt300@14
|
853 }
|
rt300@14
|
854
|
rt300@14
|
855 output[i*nChannels ] = sample;
|
rt300@14
|
856 output[i*nChannels + 1] = sample;
|
rt300@0
|
857
|
rt300@0
|
858 phasor += phasorIncr;
|
rt300@0
|
859
|
rt300@0
|
860 if(phasor >= 1.0){
|
rt300@0
|
861 phasor -= 1.0;
|
rt300@0
|
862 }
|
rt300@1
|
863 }
|
rt300@1
|
864 audioAccessFlag = FALSE;
|
rt300@0
|
865 }else{
|
rt300@0
|
866 for (int i = 0; i < bufferSize; i++){
|
rt300@0
|
867 output[i*nChannels ] = 0.0;
|
rt300@0
|
868 output[i*nChannels + 1] = 0.0;
|
rt300@0
|
869 }
|
rt300@0
|
870 }
|
rt300@0
|
871
|
rt300@1
|
872
|
rt300@0
|
873
|
rt300@0
|
874 }
|
rt300@0
|
875
|
rt300@0
|
876 //--------------------------------------------------------------
|
rt300@0
|
877 //--------------------------------------------------------------
|
rt300@0
|
878 //-------------------------OSC MSGS--------------------------------
|
rt300@0
|
879 //--------------------------------------------------------------
|
rt300@0
|
880 //--------------------------------------------------------------
|
rt300@0
|
881
|
rt300@0
|
882 void testApp::handleMessages(){
|
rt300@0
|
883
|
rt300@0
|
884 // hide old messages
|
rt300@0
|
885 for ( int i=0; i<NUM_MSG_STRINGS; i++ )
|
rt300@0
|
886 {
|
rt300@0
|
887 if ( timers[i] < ofGetElapsedTimef() )
|
rt300@0
|
888 msg_strings[i] = "";
|
rt300@0
|
889 }
|
rt300@0
|
890
|
rt300@0
|
891 // check for waiting messages
|
rt300@0
|
892 while( receiver.hasWaitingMessages() )
|
rt300@0
|
893 {
|
rt300@0
|
894 // get the next message
|
rt300@0
|
895 ofxOscMessage m;
|
rt300@0
|
896 receiver.getNextMessage( &m );
|
rt300@0
|
897 //cout << "OSC message: " << m.getAddress() << endl;
|
rt300@0
|
898
|
rt300@0
|
899 /****************/
|
rt300@0
|
900 /* REGENERATION OF NEW MESH */
|
rt300@0
|
901 /****************/
|
rt300@0
|
902
|
rt300@0
|
903 // if the mesh is not there check for regenerate , otherwise ignore everything
|
rt300@0
|
904 if(theMesh == NULL){
|
rt300@0
|
905 if ( m.getAddress() == "regenerate" )
|
rt300@0
|
906 {
|
rt300@0
|
907 string meshType;
|
rt300@0
|
908 int dim1, dim2;
|
rt300@0
|
909 int numArgs = m.getNumArgs();
|
rt300@0
|
910 cout << "REGEN num args: " << numArgs << endl;
|
rt300@0
|
911 // we want to do some error checking here
|
rt300@0
|
912 meshType = m.getArgAsString(0);
|
rt300@0
|
913 cout << "REGEN meshType: " << meshType << endl;
|
rt300@0
|
914 dim1 = m.getArgAsInt32(1);
|
rt300@0
|
915 if(numArgs == 3){
|
rt300@0
|
916 dim2 = m.getArgAsInt32(2);
|
rt300@0
|
917 }else{
|
rt300@0
|
918 dim2 = 3;
|
rt300@0
|
919 }
|
rt300@3
|
920
|
rt300@0
|
921 regenerateMesh(meshType,dim1,dim2);
|
rt300@0
|
922
|
rt300@0
|
923
|
rt300@0
|
924 }else{
|
rt300@0
|
925 return;
|
rt300@0
|
926 }
|
rt300@0
|
927 }
|
rt300@0
|
928 else if ( m.getAddress() == "restartNewMesh" )
|
rt300@0
|
929 {
|
rt300@0
|
930 ofSoundStreamStart();
|
rt300@0
|
931 drawingOn = true;
|
rt300@0
|
932 paused = false;
|
rt300@0
|
933 audioOn = true;
|
rt300@0
|
934
|
rt300@0
|
935 }
|
rt300@0
|
936 /****************/
|
rt300@0
|
937 /* NOTE HANDLER */
|
rt300@0
|
938 /****************/
|
rt300@0
|
939
|
rt300@0
|
940 else if ( m.getAddress() == "note" )
|
rt300@0
|
941 {
|
rt300@0
|
942 int note = m.getArgAsInt32(0);
|
rt300@0
|
943
|
rt300@0
|
944 int velocity = m.getArgAsInt32(1);
|
rt300@0
|
945 if(velocity > 0){
|
rt300@0
|
946 cout << "note pitch = " << pitch << endl;
|
rt300@0
|
947 pitch = 440.0/pow(2.0,((69.0 - double(note))/12.0));
|
rt300@0
|
948 theMesh->hit(0.5,0.5,velocity,globalForces.excitationType,globalForces.excitationShape);
|
rt300@0
|
949 }else{
|
rt300@0
|
950 theMesh->damp();
|
rt300@0
|
951 }
|
rt300@0
|
952
|
rt300@0
|
953
|
rt300@0
|
954 }
|
rt300@0
|
955 else if ( m.getAddress() == "excitationStrength" )
|
rt300@0
|
956 {
|
rt300@0
|
957 globalForces.excitationStrength = m.getArgAsFloat(0);
|
rt300@0
|
958
|
rt300@0
|
959
|
rt300@0
|
960 }
|
rt300@0
|
961
|
rt300@0
|
962 else if ( m.getAddress() == "excitationType" )
|
rt300@0
|
963 {
|
rt300@0
|
964
|
rt300@0
|
965 // set MIDI twanger mode
|
rt300@0
|
966 if(m.getArgAsString(0) == "POSITION"){
|
rt300@0
|
967 globalForces.excitationType = GlobalForces::POSITION;
|
rt300@0
|
968
|
rt300@0
|
969 }else if (m.getArgAsString(0) == "VELOCITY"){
|
rt300@0
|
970 cout << "excitationType = VELOCITY" << endl;
|
rt300@0
|
971 globalForces.excitationType = GlobalForces::VELOCITY;
|
rt300@0
|
972 }
|
rt300@0
|
973 }
|
rt300@0
|
974 else if ( m.getAddress() == "excitationShape" )
|
rt300@0
|
975 {
|
rt300@0
|
976
|
rt300@0
|
977 // set MIDI twanger twang shape
|
rt300@0
|
978 if(m.getArgAsString(0) == "NOISE"){
|
rt300@0
|
979 globalForces.excitationShape = GlobalForces::NOISE;
|
rt300@0
|
980
|
rt300@0
|
981 }else if (m.getArgAsString(0) == "GAUSS"){
|
rt300@0
|
982 cout << "excitationType = GAUSS" << endl;
|
rt300@0
|
983 globalForces.excitationShape = GlobalForces::GAUSS;
|
rt300@0
|
984 }else if (m.getArgAsString(0) == "SINE"){
|
rt300@0
|
985 cout << "excitationType = SINE" << endl;
|
rt300@0
|
986 globalForces.excitationShape = GlobalForces::SINE;
|
rt300@0
|
987
|
rt300@0
|
988 }
|
rt300@0
|
989 // set size
|
rt300@0
|
990 globalForces.exciteShapeX = m.getArgAsInt32(1);
|
rt300@0
|
991 globalForces.exciteShapeY = m.getArgAsInt32(2);
|
rt300@0
|
992 }
|
rt300@0
|
993
|
rt300@0
|
994 // touchModes: {GRAB,FORCE_FIELD,SPATIAL_HARMONIC,CONSTRAIN,VIBRATE,INSCRIBE_PATH};
|
rt300@0
|
995 else if ( m.getAddress() == "touchMode" )
|
rt300@0
|
996 {
|
rt300@0
|
997
|
rt300@0
|
998 // set touch mode
|
rt300@0
|
999 if(m.getArgAsString(0) == "GRAB"){
|
rt300@0
|
1000 globalUI.touchMode = globalUI.GRAB;
|
rt300@0
|
1001
|
rt300@0
|
1002 }else if (m.getArgAsString(0) == "FORCE_FIELD"){
|
rt300@0
|
1003 cout << "touchMode = FORCE_FIELD" << endl;
|
rt300@0
|
1004 globalUI.touchMode = globalUI.FORCE_FIELD;
|
rt300@0
|
1005 }else if (m.getArgAsString(0) == "SPATIAL_HARMONIC"){
|
rt300@0
|
1006 //cout << "touchMode = SPATIAL_HARMONIC" << endl;
|
rt300@0
|
1007 globalUI.touchMode = globalUI.SPATIAL_HARMONIC;
|
rt300@0
|
1008 }else if (m.getArgAsString(0) == "CONSTRAIN"){
|
rt300@0
|
1009 //cout << "touchMode = CONSTRAIN" << endl;
|
rt300@0
|
1010 globalUI.touchMode = globalUI.CONSTRAIN;
|
rt300@0
|
1011 }else if (m.getArgAsString(0) == "VIBRATE"){
|
rt300@0
|
1012 //cout << "touchMode = VIBRATE" << endl;
|
rt300@0
|
1013 globalUI.touchMode = globalUI.VIBRATE;
|
rt300@0
|
1014 }else if (m.getArgAsString(0) == "UNCONSTRAIN"){
|
rt300@0
|
1015 //cout << "touchMode = UNCONSTRAIN" << endl;
|
rt300@0
|
1016 globalUI.touchMode = globalUI.UNCONSTRAIN;
|
rt300@0
|
1017 }else if (m.getArgAsString(0) == "INSCRIBE_PATH"){
|
rt300@0
|
1018 //cout << "touchMode = INSCRIBE_PATH" << endl;
|
rt300@0
|
1019 globalUI.touchMode = globalUI.INSCRIBE_PATH;
|
rt300@0
|
1020 theMesh->clearScanPath();
|
rt300@0
|
1021 }
|
rt300@0
|
1022 }
|
rt300@0
|
1023
|
rt300@0
|
1024 else if ( m.getAddress() == "pause" )
|
rt300@0
|
1025 {
|
rt300@0
|
1026 paused = !paused;
|
rt300@0
|
1027 }
|
rt300@0
|
1028 else if ( m.getAddress() == "touchStrength" )
|
rt300@0
|
1029 {
|
rt300@0
|
1030 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1031 {
|
rt300@0
|
1032 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT ){
|
rt300@0
|
1033 cout << "touchStrength = " << m.getArgAsFloat(i) << endl;
|
rt300@0
|
1034
|
rt300@0
|
1035 globalForces.touchStrength = m.getArgAsFloat(i);
|
rt300@12
|
1036 globalForces.excitationStrength = globalForces.touchStrength;
|
rt300@0
|
1037 }
|
rt300@0
|
1038 }
|
rt300@0
|
1039 }
|
rt300@0
|
1040 else if ( m.getAddress() == "homingAmt" )
|
rt300@0
|
1041 {
|
rt300@0
|
1042 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1043 {
|
rt300@0
|
1044 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT ){
|
rt300@0
|
1045 globalForces.homingAmt = m.getArgAsFloat(i);
|
rt300@0
|
1046 }
|
rt300@0
|
1047 }
|
rt300@0
|
1048 }
|
rt300@0
|
1049 else if ( m.getAddress() == "avFilterAmt" )
|
rt300@0
|
1050 {
|
rt300@0
|
1051 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1052 {
|
rt300@0
|
1053 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT ){
|
rt300@0
|
1054 globalForces.avFilterAmt = m.getArgAsFloat(i);
|
rt300@0
|
1055 }
|
rt300@0
|
1056 }
|
rt300@0
|
1057 }
|
rt300@0
|
1058 else if ( m.getAddress() == "scanMode" )
|
rt300@0
|
1059 {
|
rt300@0
|
1060 // set scan mode
|
rt300@0
|
1061 if (m.getArgAsString(0) == "DISPLACEMENT"){
|
rt300@0
|
1062 cout << "touchMode = DISPLACEMENT" << endl;
|
rt300@3
|
1063 scanPath.scanMode = scanPath.DISPLACEMENT;
|
rt300@0
|
1064 }else if (m.getArgAsString(0) == "SPEED"){
|
rt300@0
|
1065
|
rt300@0
|
1066 cout << "scanMode = SPEED" << endl;
|
rt300@3
|
1067 scanPath.scanMode = scanPath.SPEED;
|
rt300@0
|
1068 }else if (m.getArgAsString(0) == "SPRING_FORCE"){
|
rt300@0
|
1069 cout << "scanMode = SPRING_FORCE" << endl;
|
rt300@3
|
1070 scanPath.scanMode = scanPath.SPRING_FORCE;
|
rt300@0
|
1071 }else if (m.getArgAsString(0) == "YPOS"){
|
rt300@0
|
1072 cout << "scanMode = YPOS" << endl;
|
rt300@3
|
1073 scanPath.scanMode = scanPath.YPOS;
|
rt300@0
|
1074 }else if (m.getArgAsString(0) == "OTHER"){
|
rt300@0
|
1075 cout << "scanMode = OTHER" << endl;
|
rt300@0
|
1076 //scanMode = OTHER;
|
rt300@0
|
1077 }
|
rt300@0
|
1078 }
|
rt300@0
|
1079 else if ( m.getAddress() == "inscribeScanPath" )
|
rt300@0
|
1080 {
|
rt300@0
|
1081 if (globalUI.touchMode != globalUI.INSCRIBE_PATH){
|
rt300@0
|
1082 theMesh->resetPositions();
|
rt300@0
|
1083 theMesh->resetVelocities();
|
rt300@0
|
1084 paused = true;
|
rt300@0
|
1085 audioOn = false;
|
rt300@0
|
1086 globalUI.touchMode = globalUI.INSCRIBE_PATH;
|
rt300@0
|
1087 theMesh->clearScanPath();
|
rt300@0
|
1088 theMesh->update();
|
rt300@0
|
1089 }else{
|
rt300@0
|
1090
|
rt300@0
|
1091 paused = false;
|
rt300@0
|
1092 audioOn = true;
|
rt300@0
|
1093 globalUI.touchMode = globalUI.GRAB;
|
rt300@0
|
1094 }
|
rt300@0
|
1095
|
rt300@0
|
1096 }
|
rt300@0
|
1097 else if ( m.getAddress() == "clearScanPath" )
|
rt300@0
|
1098 {
|
rt300@0
|
1099 theMesh->clearScanPath();
|
rt300@0
|
1100 }
|
rt300@0
|
1101 else if ( m.getAddress() == "toggleForce" )
|
rt300@0
|
1102 {
|
rt300@0
|
1103 theMesh->toggleSpringForces();
|
rt300@0
|
1104 }
|
rt300@0
|
1105 else if ( m.getAddress() == "toggleGravity" )
|
rt300@0
|
1106 {
|
rt300@0
|
1107 theMesh->toggleGravity();
|
rt300@0
|
1108 }
|
rt300@0
|
1109 else if ( m.getAddress() == "resetPositions" )
|
rt300@0
|
1110 {
|
rt300@0
|
1111 theMesh->resetPositions();
|
rt300@0
|
1112 }
|
rt300@0
|
1113 else if ( m.getAddress() == "resetVelocities" )
|
rt300@0
|
1114 {
|
rt300@0
|
1115 theMesh->resetVelocities();
|
rt300@0
|
1116 }
|
rt300@0
|
1117
|
rt300@0
|
1118
|
rt300@0
|
1119 else if ( m.getAddress() == "reset" )
|
rt300@0
|
1120 {
|
rt300@0
|
1121 theMesh->resetPositions();
|
rt300@0
|
1122 theMesh->resetVelocities();
|
rt300@0
|
1123 theMesh->update();
|
rt300@0
|
1124
|
rt300@0
|
1125 }
|
rt300@0
|
1126 else if ( m.getAddress() == "deleteMesh" )
|
rt300@0
|
1127 {
|
rt300@0
|
1128 deleteMesh();
|
rt300@0
|
1129 }
|
rt300@0
|
1130 else if ( m.getAddress() == "regenerate" )
|
rt300@0
|
1131 {
|
rt300@0
|
1132 // ignore it - the mesh is not deleted
|
rt300@0
|
1133
|
rt300@0
|
1134
|
rt300@0
|
1135 }
|
rt300@0
|
1136 else if ( m.getAddress() == "zeroRestLength" )
|
rt300@0
|
1137 {
|
rt300@0
|
1138 theMesh->zeroRestLength();
|
rt300@0
|
1139 }
|
rt300@0
|
1140 else if ( m.getAddress() == "setThisRestLength" )
|
rt300@0
|
1141 {
|
rt300@0
|
1142 theMesh->setRestLength();
|
rt300@0
|
1143 }
|
rt300@0
|
1144 else if ( m.getAddress() == "setZeroAudioLine" )
|
rt300@0
|
1145 {
|
rt300@0
|
1146 theMesh->setZeroAudioLine();
|
rt300@0
|
1147 }
|
rt300@0
|
1148 else if ( m.getAddress() == "speedLimit" )
|
rt300@0
|
1149 {
|
rt300@0
|
1150 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1151 {
|
rt300@0
|
1152 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT ){
|
rt300@0
|
1153 globalForces.speedLimit = m.getArgAsFloat(i);
|
rt300@0
|
1154 }
|
rt300@0
|
1155 }
|
rt300@0
|
1156 }
|
rt300@0
|
1157 else if ( m.getAddress() == "gravityAmt" )
|
rt300@0
|
1158 {
|
rt300@0
|
1159 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1160 {
|
rt300@0
|
1161 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT ){
|
rt300@0
|
1162 globalForces.gravityAmt = m.getArgAsFloat(i);
|
rt300@0
|
1163 }
|
rt300@0
|
1164 }
|
rt300@0
|
1165 }
|
rt300@0
|
1166 else if ( m.getAddress() == "pressureAmt" )
|
rt300@0
|
1167 {
|
rt300@0
|
1168 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1169 {
|
rt300@0
|
1170 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT ){
|
rt300@0
|
1171 globalForces.pressureAmt = m.getArgAsFloat(i);
|
rt300@0
|
1172 }
|
rt300@0
|
1173 }
|
rt300@0
|
1174 }
|
rt300@0
|
1175 else if ( m.getAddress() == "wallBounce" )
|
rt300@0
|
1176 {
|
rt300@0
|
1177 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1178 {
|
rt300@0
|
1179 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT ){
|
rt300@0
|
1180 //params::wallBounce = m.getArgAsFloat(i);
|
rt300@0
|
1181 }
|
rt300@0
|
1182 }
|
rt300@0
|
1183 }
|
rt300@0
|
1184 else if ( m.getAddress() == "toggleSyrup" )
|
rt300@0
|
1185 {
|
rt300@0
|
1186 theMesh->toggleSyrup();
|
rt300@0
|
1187 }
|
rt300@0
|
1188 else if ( m.getAddress() == "toggleAudio" )
|
rt300@0
|
1189 {
|
rt300@0
|
1190 if(audioOn){
|
rt300@0
|
1191 ofSoundStreamStop();
|
rt300@0
|
1192 audioOn = false;
|
rt300@0
|
1193 }else{
|
rt300@0
|
1194 restartAudioStream();
|
rt300@0
|
1195 }
|
rt300@0
|
1196
|
rt300@0
|
1197 }
|
rt300@0
|
1198
|
rt300@0
|
1199 else if ( m.getAddress() == "constrainEdges" )
|
rt300@0
|
1200 {
|
rt300@0
|
1201 theMesh->constrain(.0,.0,Mesh::CONSTRAIN_EDGES);
|
rt300@0
|
1202 }
|
rt300@0
|
1203 else if ( m.getAddress() == "constrainCorners" )
|
rt300@0
|
1204 {
|
rt300@0
|
1205 theMesh->constrain(.0,.0,Mesh::CONSTRAIN_CORNERS );
|
rt300@0
|
1206 }
|
rt300@0
|
1207 else if ( m.getAddress() == "unconstrain" )
|
rt300@0
|
1208 {
|
rt300@0
|
1209 theMesh->unconstrain();
|
rt300@0
|
1210 }
|
rt300@0
|
1211 else if ( m.getAddress() == "mass" )
|
rt300@0
|
1212 {
|
rt300@0
|
1213 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1214 {
|
rt300@0
|
1215 if( m.getArgType( i ) == OFXOSC_TYPE_INT32 ){
|
rt300@0
|
1216 theMesh->setMass(m.getArgAsInt32( i ));
|
rt300@0
|
1217 }
|
rt300@0
|
1218 else if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
|
rt300@0
|
1219 {
|
rt300@0
|
1220 theMesh->setMass(m.getArgAsFloat( i )<0.01?0.01:m.getArgAsFloat( i ) );
|
rt300@0
|
1221 }
|
rt300@0
|
1222
|
rt300@0
|
1223 }
|
rt300@0
|
1224 }
|
rt300@0
|
1225 else if ( m.getAddress() == "springk" )
|
rt300@0
|
1226 {
|
rt300@0
|
1227 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1228 {
|
rt300@0
|
1229 if( m.getArgType( i ) == OFXOSC_TYPE_INT32 ){
|
rt300@0
|
1230 theMesh->setSpringConstant(m.getArgAsInt32( i ));
|
rt300@0
|
1231 }
|
rt300@0
|
1232 else if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
|
rt300@0
|
1233 {
|
rt300@0
|
1234 theMesh->setSpringConstant(m.getArgAsFloat( i )<0.01?0.01:m.getArgAsFloat( i ) );
|
rt300@0
|
1235 }
|
rt300@0
|
1236
|
rt300@0
|
1237 }
|
rt300@0
|
1238 }
|
rt300@0
|
1239 else if ( m.getAddress() == "friction" )
|
rt300@0
|
1240 {
|
rt300@0
|
1241 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1242 {
|
rt300@0
|
1243 if( m.getArgType( i ) == OFXOSC_TYPE_INT32 ){
|
rt300@0
|
1244 theMesh->setFriction(m.getArgAsInt32( i ));
|
rt300@0
|
1245 }
|
rt300@0
|
1246 else if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
|
rt300@0
|
1247 {
|
rt300@0
|
1248 theMesh->setFriction(m.getArgAsFloat( i )<0.01?0.01:m.getArgAsFloat( i ) );
|
rt300@0
|
1249 }
|
rt300@0
|
1250
|
rt300@0
|
1251 }
|
rt300@0
|
1252 }
|
rt300@0
|
1253 //////////////// asym
|
rt300@0
|
1254 else if ( m.getAddress() == "massAsym" )
|
rt300@0
|
1255 {
|
rt300@0
|
1256 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1257 {
|
rt300@0
|
1258 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
|
rt300@0
|
1259 {
|
rt300@0
|
1260 theMesh->setMassAsym(m.getArgAsFloat( i )<0.01?0.01:m.getArgAsFloat( i ) );
|
rt300@0
|
1261 }
|
rt300@0
|
1262
|
rt300@0
|
1263 }
|
rt300@0
|
1264 }
|
rt300@0
|
1265 else if ( m.getAddress() == "springkAsym" )
|
rt300@0
|
1266 {
|
rt300@0
|
1267 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1268 {
|
rt300@0
|
1269 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
|
rt300@0
|
1270 {
|
rt300@0
|
1271 theMesh->setSpringConstantAsym(m.getArgAsFloat( i )<0.00?0.00:m.getArgAsFloat( i ) );
|
rt300@0
|
1272 }
|
rt300@0
|
1273
|
rt300@0
|
1274 }
|
rt300@0
|
1275 }
|
rt300@0
|
1276 else if ( m.getAddress() == "frictionAsym" )
|
rt300@0
|
1277 {
|
rt300@0
|
1278 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1279 {
|
rt300@0
|
1280 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
|
rt300@0
|
1281 {
|
rt300@0
|
1282 theMesh->setFrictionAsym(m.getArgAsFloat( i )<0.01?0.01:m.getArgAsFloat( i ) );
|
rt300@0
|
1283 }
|
rt300@0
|
1284
|
rt300@0
|
1285 }
|
rt300@0
|
1286 }
|
rt300@0
|
1287 else if ( m.getAddress() == "volume" )
|
rt300@0
|
1288 {
|
rt300@0
|
1289 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1290 {
|
rt300@0
|
1291 if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
|
rt300@0
|
1292 {
|
rt300@0
|
1293 cout << "change volume\n";
|
rt300@0
|
1294 globalForces.volume = m.getArgAsFloat( i );
|
rt300@0
|
1295 }
|
rt300@0
|
1296
|
rt300@0
|
1297 }
|
rt300@0
|
1298 }
|
rt300@0
|
1299 ///////////////////////
|
rt300@0
|
1300 else
|
rt300@0
|
1301 {
|
rt300@0
|
1302 // unrecognized message: display on the bottom of the screen
|
rt300@0
|
1303 string msg_string;
|
rt300@0
|
1304 msg_string = m.getAddress();
|
rt300@0
|
1305 msg_string += ": ";
|
rt300@0
|
1306 for ( int i=0; i<m.getNumArgs(); i++ )
|
rt300@0
|
1307 {
|
rt300@0
|
1308 // get the argument type
|
rt300@0
|
1309 msg_string += m.getArgTypeName( i );
|
rt300@0
|
1310 msg_string += ":";
|
rt300@0
|
1311 // display the argument - make sure we get the right type
|
rt300@0
|
1312 if( m.getArgType( i ) == OFXOSC_TYPE_INT32 )
|
rt300@0
|
1313 pitch = m.getArgAsInt32( i );
|
rt300@0
|
1314 else if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
|
rt300@0
|
1315 msg_string += ofToString( m.getArgAsFloat( i ) );
|
rt300@0
|
1316 else if( m.getArgType( i ) == OFXOSC_TYPE_STRING )
|
rt300@0
|
1317 msg_string += m.getArgAsString( i );
|
rt300@0
|
1318 else
|
rt300@0
|
1319 msg_string += "unknown";
|
rt300@0
|
1320 }
|
rt300@0
|
1321 // add to the list of strings to display
|
rt300@0
|
1322 msg_strings[current_msg_string] = msg_string;
|
rt300@0
|
1323 timers[current_msg_string] = ofGetElapsedTimef() + 5.0f;
|
rt300@0
|
1324 current_msg_string = ( current_msg_string + 1 ) % NUM_MSG_STRINGS;
|
rt300@0
|
1325 // clear the next line
|
rt300@0
|
1326 msg_strings[current_msg_string] = "";
|
rt300@0
|
1327 }
|
rt300@0
|
1328
|
rt300@0
|
1329 }
|
rt300@0
|
1330 }
|
rt300@5
|
1331
|
rt300@5
|
1332 //--------------------------------------------------------------
|
rt300@5
|
1333 //--------------------------------------------------------------
|
rt300@5
|
1334 // GUI stuff
|
rt300@5
|
1335 //--------------------------------------------------------------
|
rt300@5
|
1336 //--------------------------------------------------------------
|
rt300@5
|
1337 void testApp::loadLogXML(){
|
rt300@5
|
1338 ofxXmlSettings XMLlog;
|
rt300@5
|
1339
|
rt300@5
|
1340 string message;
|
rt300@5
|
1341 if( XMLlog.loadFile(ofxiPhoneGetDocumentsDirectory() + "wabletlogs.xml") ){
|
rt300@5
|
1342 message = "mySettings.xml loaded from documents folder!";
|
rt300@5
|
1343
|
rt300@5
|
1344 }else if( XMLlog.loadFile("Logs/wabletlogs.xml") ){
|
rt300@5
|
1345 message = "mySettings.xml loaded from data folder!";
|
rt300@5
|
1346
|
rt300@5
|
1347
|
rt300@5
|
1348 }else{
|
rt300@5
|
1349 message = "unable to load mySettings.xml check data/ folder";
|
rt300@5
|
1350 return;
|
rt300@5
|
1351 }
|
rt300@5
|
1352 cout << message << "\n";
|
rt300@5
|
1353
|
rt300@5
|
1354 // get all the values from log
|
rt300@5
|
1355 timesOpened = XMLlog.getValue("wabletlogs:timesOpened", 0);
|
rt300@5
|
1356 timesOpened++;
|
rt300@5
|
1357
|
rt300@5
|
1358 }
|
rt300@5
|
1359 //--------------------------------------------------------------
|
rt300@5
|
1360 void testApp::saveLogXML(){
|
rt300@5
|
1361 ofxXmlSettings XMLlog;
|
rt300@5
|
1362
|
rt300@5
|
1363 XMLlog.setValue("wabletlogs:timesOpened", timesOpened);
|
rt300@5
|
1364
|
rt300@5
|
1365 if(XMLlog.saveFile(ofxiPhoneGetDocumentsDirectory() + "wabletlogs.xml")){
|
rt300@5
|
1366 cout << "Saved wabletlogs.XML in iphone documents OK";
|
rt300@5
|
1367 }else if(XMLlog.saveFile("Logs/wabletlogs.xml")){
|
rt300@5
|
1368 cout << "Saved wabletlogs.XML in data folder";
|
rt300@5
|
1369 }else{
|
rt300@5
|
1370 cout << "wabletlogs file did not save :(";
|
rt300@5
|
1371 }
|
rt300@5
|
1372
|
rt300@5
|
1373
|
rt300@5
|
1374
|
rt300@5
|
1375 }
|
rt300@5
|
1376 //--------------------------------------------------------------
|
rt300@5
|
1377 void testApp::setupGui(){
|
rt300@5
|
1378 float xInit = OFX_UI_GLOBAL_WIDGET_SPACING;
|
rt300@5
|
1379
|
rt300@15
|
1380 int heightS = ofGetHeight();
|
rt300@15
|
1381 int widthS = ofGetWidth();
|
rt300@5
|
1382
|
rt300@15
|
1383 float sidebarWidth = widthS/8;
|
rt300@15
|
1384 float length = sidebarWidth-xInit*2;
|
rt300@5
|
1385
|
rt300@15
|
1386
|
rt300@15
|
1387 float widgetHeight = heightS/18;
|
rt300@15
|
1388
|
rt300@15
|
1389 /*
|
rt300@15
|
1390 setWidgetColor(OFX_UI_WIDGET_COLOR_BACK, cb);
|
rt300@15
|
1391 setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE, co);
|
rt300@15
|
1392 setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE_HIGHLIGHT, coh);
|
rt300@15
|
1393 setWidgetColor(OFX_UI_WIDGET_COLOR_FILL, cf);
|
rt300@15
|
1394 setWidgetColor(OFX_UI_WIDGET_COLOR_FILL_HIGHLIGHT, cfh);
|
rt300@15
|
1395 setWidgetColor(OFX_UI_WIDGET_COLOR_PADDED, cp);
|
rt300@15
|
1396 setWidgetColor(OFX_UI_WIDGET_COLOR_PADDED_OUTLINE, cpo);
|
rt300@15
|
1397 */
|
rt300@15
|
1398
|
rt300@15
|
1399 ofColor bgCol = ofColor(23,23,23);
|
rt300@15
|
1400 ofColor paddingCol = ofColor(56,56,56);
|
rt300@15
|
1401 ofColor padOutlineCol = ofColor(200,0,0);
|
rt300@15
|
1402 ofColor fillCol = ofColor(0,0,205);
|
rt300@15
|
1403 ofColor fillHicol = ofColor(0,0,255);
|
rt300@15
|
1404 ofColor outlineCol = ofColor(255,255,255);
|
rt300@15
|
1405 ofColor outlineHiCol = ofColor(255,255,255);
|
rt300@5
|
1406 // LEFT GUI ------------------
|
rt300@15
|
1407
|
rt300@15
|
1408
|
rt300@15
|
1409 guiL = new ofxUICanvas(0,0,sidebarWidth,heightS);
|
rt300@5
|
1410 guiL->addSpacer(length-xInit, 2);
|
rt300@15
|
1411 //guiL->setUIColors(bgCol, outlineCol, outlineHiCol, fillCol, fillHicol, paddingCol, padOutlineCol);
|
rt300@15
|
1412
|
rt300@15
|
1413
|
rt300@5
|
1414 guiL->addWidgetDown(new ofxUILabel("Physics", OFX_UI_FONT_LARGE));
|
rt300@5
|
1415
|
rt300@5
|
1416 ofxUIWidget *slider;
|
rt300@15
|
1417 //ofxUISlider_<<#typename T#>>(<#string _name#>, <#T _min#>, <#T _max#>, <#T _value#>, <#float w#>, <#float h#>)
|
rt300@15
|
1418 slider = guiL->addWidgetDown(new ofxUISlider("SPRING K",0.0,0.8,0.4,length,widgetHeight));
|
rt300@5
|
1419 slider->setDrawPadding(true);
|
rt300@15
|
1420 slider->setDrawPaddingOutline(true);
|
rt300@15
|
1421 slider->setColorFill(fillHicol);
|
rt300@15
|
1422 slider->setColorFillHighlight(fillHicol);
|
rt300@5
|
1423
|
rt300@15
|
1424 slider = guiL->addWidgetDown(new ofxUISlider("GRAVITY", 0.0, 4.0, 0.0,length,widgetHeight ));
|
rt300@5
|
1425 slider->setDrawPadding(true);
|
rt300@15
|
1426 slider->setDrawPaddingOutline(true);
|
rt300@15
|
1427 slider->setColorFill(fillHicol);
|
rt300@15
|
1428 slider->setColorFillHighlight(fillHicol);
|
rt300@15
|
1429
|
rt300@15
|
1430 slider = guiL->addWidgetDown(new ofxUISlider("HOMING",0.0,0.3,0.0,length,widgetHeight));
|
rt300@5
|
1431 slider->setDrawPadding(true);
|
rt300@15
|
1432 slider->setDrawPaddingOutline(true);
|
rt300@15
|
1433 slider->setColorFill(fillHicol);
|
rt300@15
|
1434 slider->setColorFillHighlight(fillHicol);
|
rt300@15
|
1435
|
rt300@15
|
1436 slider = guiL->addWidgetDown(new ofxUISlider("SMOOTHING", 0.0, 0.5, 0.01,length,widgetHeight));
|
rt300@5
|
1437 slider->setDrawPadding(true);
|
rt300@15
|
1438 slider->setDrawPaddingOutline(true);
|
rt300@15
|
1439 slider->setColorFill(fillHicol);
|
rt300@15
|
1440 slider->setColorFillHighlight(fillHicol);
|
rt300@5
|
1441
|
rt300@5
|
1442
|
rt300@5
|
1443 guiL->addSpacer(length-xInit, 2);
|
rt300@15
|
1444
|
rt300@5
|
1445
|
rt300@15
|
1446 //guiL->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN);
|
rt300@15
|
1447 slider = guiL->addSlider("PITCH", 2.0, 100.0, 80.0, length, heightS/2);
|
rt300@5
|
1448 slider->setDrawPadding(true);
|
rt300@15
|
1449 slider->setDrawPaddingOutline(true);
|
rt300@15
|
1450 slider->setColorFill(fillHicol);
|
rt300@15
|
1451 slider->setColorFillHighlight(fillHicol);
|
rt300@15
|
1452
|
rt300@5
|
1453 ofAddListener(guiL->newGUIEvent, this, &testApp::guiLEvent);
|
rt300@5
|
1454
|
rt300@15
|
1455 //guiL->setUIColors( ofColor(56,56,56), ofColor(255,255,56), ofColor(255,255,56), ofColor(0,0,255), ofColor(0,0,255), ofColor(0,0,255), ofColor(0,0,255) );
|
rt300@15
|
1456 // RIGHT GUI -----------------------
|
rt300@5
|
1457
|
rt300@15
|
1458 guiR = new ofxUICanvas(ofGetWidth()-sidebarWidth, 0, sidebarWidth, ofGetHeight()-64);
|
rt300@5
|
1459
|
rt300@5
|
1460
|
rt300@5
|
1461 guiR->addSpacer(length-xInit, 2);
|
rt300@5
|
1462
|
rt300@5
|
1463 vector<string> names;
|
rt300@5
|
1464 names.push_back("GRAB");
|
rt300@5
|
1465 names.push_back("FORCE");
|
rt300@5
|
1466 names.push_back("SINE");
|
rt300@5
|
1467 names.push_back("STICK");
|
rt300@5
|
1468 names.push_back("UNSTICK");
|
rt300@5
|
1469 names.push_back("NEWPATH");
|
rt300@5
|
1470
|
rt300@5
|
1471
|
rt300@5
|
1472 ofxUIRadio* radio;
|
rt300@15
|
1473 radio = guiR->addRadio("TOUCH MODE", names, OFX_UI_ORIENTATION_VERTICAL, widgetHeight, widgetHeight);
|
rt300@5
|
1474 radio->setDrawPadding(true);
|
rt300@15
|
1475 radio->setColorFill(fillHicol);
|
rt300@15
|
1476 radio->setColorFillHighlight(fillHicol);
|
rt300@5
|
1477
|
rt300@15
|
1478 slider = guiR->addWidgetDown(new ofxUISlider( "TOUCH AMT", -0.4, 4.0, 1.0,length,widgetHeight));
|
rt300@5
|
1479 slider->setDrawPadding(true);
|
rt300@15
|
1480 slider->setColorFill(fillHicol);
|
rt300@15
|
1481 slider->setColorFillHighlight(fillHicol);
|
rt300@5
|
1482
|
rt300@5
|
1483 guiR->addSpacer(length-xInit, 2);
|
rt300@5
|
1484
|
rt300@15
|
1485 guiR->addToggle("PAUSE", false, widgetHeight, widgetHeight);
|
rt300@15
|
1486 guiR->addButton("RESET", false, widgetHeight, widgetHeight);
|
rt300@15
|
1487 guiR->addButton("NEW", false, widgetHeight, widgetHeight);
|
rt300@15
|
1488 guiR->addButton("SAVE", false, widgetHeight, widgetHeight);
|
rt300@15
|
1489 guiR->addButton("LOAD", false, widgetHeight, widgetHeight);
|
rt300@5
|
1490
|
rt300@5
|
1491 ofAddListener(guiR->newGUIEvent, this, &testApp::guiREvent);
|
rt300@5
|
1492 //guiR->loadSettings(ofxiPhoneGetDocumentsDirectory() + "guiSettings.xml");
|
rt300@5
|
1493 radio->activateToggle("GRAB");
|
rt300@5
|
1494
|
rt300@8
|
1495 // show hide ctrls
|
rt300@15
|
1496 guiSH = new ofxUICanvas(ofGetWidth() - sidebarWidth, ofGetHeight()-64, sidebarWidth, 64);
|
rt300@8
|
1497
|
rt300@8
|
1498
|
rt300@8
|
1499 guiSH->addSpacer(length-xInit, 2);
|
rt300@15
|
1500 ofxUIToggle* t = guiSH->addToggle("CTRLS", false, widgetHeight, widgetHeight);
|
rt300@15
|
1501 // turn toggle on
|
rt300@15
|
1502 t->setState(true);
|
rt300@15
|
1503
|
rt300@8
|
1504 ofAddListener(guiSH->newGUIEvent, this, &testApp::guiSHEvent);
|
rt300@8
|
1505
|
rt300@5
|
1506 }
|
rt300@5
|
1507 //--------------------------------------------------------------
|
rt300@5
|
1508 void testApp::UIcallBack(int buttID){
|
rt300@5
|
1509 cout << " BUTT ID " << buttID << "\n";
|
rt300@5
|
1510
|
rt300@5
|
1511 }
|
rt300@15
|
1512 void testApp::hideControls(){
|
rt300@15
|
1513 cout << "CTRLS ooff";
|
rt300@15
|
1514 guiR->setVisible(false);
|
rt300@15
|
1515 guiL->setVisible(false);
|
rt300@15
|
1516 controlsShowing = false;
|
rt300@15
|
1517 }
|
rt300@15
|
1518 void testApp::showControls(){
|
rt300@15
|
1519 cout << "CTRLS onnn";
|
rt300@15
|
1520 guiR->setVisible(true);
|
rt300@15
|
1521 guiL->setVisible(true);
|
rt300@15
|
1522 controlsShowing = true;
|
rt300@15
|
1523 }
|
rt300@5
|
1524 //--------------------------------------------------------------
|
rt300@8
|
1525 void testApp::guiSHEvent(ofxUIEventArgs &e)
|
rt300@8
|
1526 {
|
rt300@8
|
1527 if(e.widget->getName() == "CTRLS"){
|
rt300@8
|
1528 // ????
|
rt300@8
|
1529
|
rt300@8
|
1530 cout << ((ofxUIButton *)e.widget)->getValue();
|
rt300@8
|
1531
|
rt300@8
|
1532 if( ((ofxUIButton *)e.widget)->getValue() == 0) {
|
rt300@15
|
1533 hideControls();
|
rt300@8
|
1534 }else{
|
rt300@15
|
1535 showControls();
|
rt300@8
|
1536 }
|
rt300@8
|
1537
|
rt300@8
|
1538 }
|
rt300@8
|
1539 }
|
rt300@8
|
1540
|
rt300@8
|
1541 //--------------------------------------------------------------
|
rt300@5
|
1542 void testApp::guiREvent(ofxUIEventArgs &e)
|
rt300@5
|
1543 {
|
rt300@5
|
1544 if(e.widget->getName() == "TOUCH MODE")
|
rt300@5
|
1545 {
|
rt300@5
|
1546 cout << "TOUCH MODE";
|
rt300@5
|
1547
|
rt300@5
|
1548 }
|
rt300@5
|
1549 if(e.widget->getName() == "GRAB"){
|
rt300@5
|
1550 cout << "GRAB";
|
rt300@5
|
1551 globalUI.touchMode = globalUI.GRAB;
|
rt300@5
|
1552 }else if(e.widget->getName() == "FORCE"){
|
rt300@5
|
1553
|
rt300@5
|
1554 globalUI.touchMode = globalUI.FORCE_FIELD;
|
rt300@5
|
1555 }else if(e.widget->getName() == "STICK"){
|
rt300@5
|
1556
|
rt300@5
|
1557 globalUI.touchMode = globalUI.CONSTRAIN;
|
rt300@5
|
1558 }else if(e.widget->getName() == "UNSTICK"){
|
rt300@5
|
1559
|
rt300@5
|
1560 globalUI.touchMode = globalUI.UNCONSTRAIN;
|
rt300@5
|
1561 }else if(e.widget->getName() == "NEWPATH"){
|
rt300@5
|
1562 if(globalUI.touchMode != globalUI.INSCRIBE_PATH){
|
rt300@5
|
1563 theMesh->resetPositions();
|
rt300@5
|
1564 theMesh->resetVelocities();
|
rt300@5
|
1565 globalUI.touchMode = globalUI.INSCRIBE_PATH;
|
rt300@5
|
1566 theMesh->clearScanPath();
|
rt300@5
|
1567 theMesh->update();
|
rt300@5
|
1568 }
|
rt300@5
|
1569 }else if(e.widget->getName() == "SINE"){
|
rt300@5
|
1570 globalUI.touchMode = globalUI.SPATIAL_HARMONIC;
|
rt300@5
|
1571 }else if(e.widget->getName() == "RESET"){
|
rt300@5
|
1572 theMesh->resetAll();
|
rt300@5
|
1573 numTouches = 0;
|
rt300@5
|
1574 }else if(e.widget->getName() == "NEW"){
|
rt300@5
|
1575 // ????
|
rt300@5
|
1576
|
rt300@5
|
1577 cout << ((ofxUIButton *)e.widget)->getValue();
|
rt300@5
|
1578
|
rt300@5
|
1579 if( ((ofxUIButton *)e.widget)->getValue() == 0) {
|
rt300@9
|
1580
|
rt300@5
|
1581 deleteMesh();
|
rt300@5
|
1582 setupMesh();
|
rt300@5
|
1583 }else{
|
rt300@9
|
1584
|
rt300@5
|
1585 }
|
rt300@9
|
1586 }else if(e.widget->getName() == "SAVE"){
|
rt300@9
|
1587 // save the preset somehow
|
rt300@9
|
1588 if( ((ofxUIButton *)e.widget)->getValue() == 0) {
|
rt300@9
|
1589 savePreset();
|
rt300@9
|
1590 }
|
rt300@9
|
1591 }else if(e.widget->getName() == "LOAD"){
|
rt300@9
|
1592 // save the preset somehow
|
rt300@9
|
1593 if( ((ofxUIButton *)e.widget)->getValue() == 0) {
|
rt300@9
|
1594 loadPreset();
|
rt300@9
|
1595 }
|
rt300@5
|
1596 }else if(e.widget->getName() == "PAUSE"){
|
rt300@5
|
1597 paused = !paused;
|
rt300@5
|
1598 }else if(e.widget->getName() == "TOUCH AMT"){
|
rt300@5
|
1599 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@5
|
1600 slider->setDrawPadding(true);
|
rt300@5
|
1601 globalForces.touchStrength = slider->getScaledValue();
|
rt300@5
|
1602 }
|
rt300@5
|
1603
|
rt300@5
|
1604 }
|
rt300@5
|
1605 //--------------------------------------------------------------
|
rt300@5
|
1606 void testApp::guiLEvent(ofxUIEventArgs &e)
|
rt300@5
|
1607 {
|
rt300@5
|
1608 if(e.widget->getName() == "SPRING K")
|
rt300@5
|
1609 {
|
rt300@5
|
1610 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@5
|
1611
|
rt300@5
|
1612 theMesh->setSpringConstant( slider->getScaledValue() );
|
rt300@5
|
1613 }else if(e.widget->getName() == "GRAVITY")
|
rt300@5
|
1614 {
|
rt300@5
|
1615 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@5
|
1616 slider->setDrawPadding(true);
|
rt300@5
|
1617 globalForces.gravityAmt = slider->getScaledValue();
|
rt300@5
|
1618 //radio->getScaledValue() );
|
rt300@5
|
1619 }else if(e.widget->getName() == "HOMING")
|
rt300@5
|
1620 {
|
rt300@5
|
1621 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@5
|
1622 globalForces.homingAmt = slider->getScaledValue();
|
rt300@5
|
1623 //radio->getScaledValue() );
|
rt300@5
|
1624 }else if(e.widget->getName() == "SMOOTHING")
|
rt300@5
|
1625 {
|
rt300@5
|
1626
|
rt300@5
|
1627
|
rt300@5
|
1628 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@5
|
1629 globalForces.avFilterAmt = slider->getScaledValue();
|
rt300@5
|
1630 //radio->getScaledValue() );
|
rt300@5
|
1631 }else if(e.widget->getName() == "FRICTION")
|
rt300@5
|
1632 {
|
rt300@5
|
1633
|
rt300@5
|
1634
|
rt300@5
|
1635 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@5
|
1636 theMesh->setFriction(slider->getScaledValue());
|
rt300@5
|
1637 //radio->getScaledValue() );
|
rt300@5
|
1638 }else if(e.widget->getName() == "PITCH")
|
rt300@5
|
1639 {
|
rt300@5
|
1640
|
rt300@5
|
1641
|
rt300@5
|
1642 ofxUISlider *slider = (ofxUISlider *) e.widget;
|
rt300@5
|
1643 pitch = slider->getScaledValue();
|
rt300@5
|
1644 //radio->getScaledValue() );
|
rt300@5
|
1645 }
|
rt300@5
|
1646
|
rt300@5
|
1647
|
rt300@5
|
1648 }
|
rt300@8
|
1649
|
rt300@8
|
1650 //--------------------------------------------------------------
|
rt300@13
|
1651
|
rt300@8
|
1652 void testApp::deviceOrientationChanged(int newOrientation){
|
rt300@8
|
1653
|
rt300@8
|
1654 cout << "orientation: " << newOrientation;
|
rt300@13
|
1655
|
rt300@8
|
1656 if(newOrientation == 4){
|
rt300@13
|
1657 ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT );
|
rt300@8
|
1658
|
rt300@8
|
1659 }
|
rt300@13
|
1660
|
rt300@8
|
1661 }
|
rt300@13
|
1662
|
rt300@10
|
1663
|
rt300@10
|
1664 //-------------------------------------------------------------------------
|
rt300@10
|
1665 //--------------------------------------------------------------
|
rt300@10
|
1666
|
rt300@10
|
1667 #pragma mark MIDI
|
rt300@10
|
1668 void testApp::addMessage(string msg) {
|
rt300@10
|
1669 cout << msg << endl;
|
rt300@10
|
1670 messages.push_back(msg);
|
rt300@10
|
1671 while(messages.size() > maxMessages)
|
rt300@10
|
1672 messages.pop_front();
|
rt300@10
|
1673 }
|
rt300@10
|
1674
|
rt300@10
|
1675 //--------------------------------------------------------------
|
rt300@10
|
1676 void testApp::newMidiMessage(ofxMidiMessage& msg) {
|
rt300@10
|
1677 // recieved one
|
rt300@10
|
1678 static int p; // remembers last note on
|
rt300@10
|
1679 int v;
|
rt300@10
|
1680 // look at what it is
|
rt300@10
|
1681
|
rt300@10
|
1682 if(msg.status == MIDI_CONTROL_CHANGE){
|
rt300@10
|
1683 int ctl_num = msg.control;
|
rt300@10
|
1684 int ctl_val = msg.value;
|
rt300@10
|
1685 // TODO route control change message here
|
rt300@10
|
1686 }
|
rt300@10
|
1687
|
rt300@10
|
1688 if(msg.status == MIDI_NOTE_ON){
|
rt300@10
|
1689 p = msg.pitch;
|
rt300@10
|
1690 v = msg.velocity;
|
rt300@10
|
1691
|
rt300@10
|
1692 // TODO handle note on here
|
rt300@10
|
1693 if(v > 0){
|
rt300@12
|
1694 //cout << "note pitch = " << p << endl;
|
rt300@10
|
1695 pitch = 440.0/pow(2.0,((69.0 - double(p))/12.0));
|
rt300@12
|
1696 globalForces.excitationShape = GlobalForces::SINE;
|
rt300@12
|
1697 if(theMesh != NULL && !meshConstructionFlag){
|
rt300@12
|
1698 theMesh->hit(0.5,0.5,v,globalForces.excitationType,globalForces.excitationShape);
|
rt300@12
|
1699 }
|
rt300@10
|
1700 }else{
|
rt300@10
|
1701 //theMesh->damp();
|
rt300@10
|
1702 }
|
rt300@10
|
1703 }
|
rt300@10
|
1704 if(msg.status == MIDI_NOTE_OFF){
|
rt300@10
|
1705 if(msg.pitch == p){
|
rt300@10
|
1706 //theMesh->damp();
|
rt300@10
|
1707 }
|
rt300@10
|
1708 // otherwise ignore it, it's not the currenttly playing note
|
rt300@10
|
1709 }
|
rt300@10
|
1710
|
rt300@10
|
1711 }
|
rt300@10
|
1712
|
rt300@10
|
1713 //--------------------------------------------------------------
|
rt300@10
|
1714 void testApp::midiInputAdded(string name, bool isNetwork) {
|
rt300@10
|
1715 stringstream msg;
|
rt300@10
|
1716 msg << "ofxMidi: input added: " << name << " network: " << isNetwork;
|
rt300@10
|
1717 cout << msg.str();
|
rt300@10
|
1718 addMessage(msg.str());
|
rt300@10
|
1719
|
rt300@10
|
1720 // create and open a new input port
|
rt300@10
|
1721 ofxMidiIn * newInput = new ofxMidiIn;
|
rt300@10
|
1722 newInput->openPort(name);
|
rt300@10
|
1723 newInput->addListener(this);
|
rt300@10
|
1724 inputs.push_back(newInput);
|
rt300@10
|
1725 }
|
rt300@10
|
1726
|
rt300@10
|
1727 //--------------------------------------------------------------
|
rt300@10
|
1728 void testApp::midiInputRemoved(string name, bool isNetwork) {
|
rt300@10
|
1729 stringstream msg;
|
rt300@10
|
1730 msg << "ofxMidi: input removed: " << name << " network: " << isNetwork << endl;
|
rt300@10
|
1731 cout << msg.str();
|
rt300@10
|
1732 addMessage(msg.str());
|
rt300@10
|
1733
|
rt300@10
|
1734 // close and remove input port
|
rt300@10
|
1735 vector<ofxMidiIn*>::iterator iter;
|
rt300@10
|
1736 for(iter = inputs.begin(); iter != inputs.end(); ++iter) {
|
rt300@10
|
1737 ofxMidiIn * input = (*iter);
|
rt300@10
|
1738 if(input->getName() == name) {
|
rt300@10
|
1739 input->closePort();
|
rt300@10
|
1740 input->removeListener(this);
|
rt300@10
|
1741 delete input;
|
rt300@10
|
1742 inputs.erase(iter);
|
rt300@10
|
1743 break;
|
rt300@10
|
1744 }
|
rt300@10
|
1745 }
|
rt300@10
|
1746 }
|
rt300@10
|
1747
|
rt300@10
|
1748 //--------------------------------------------------------------
|
rt300@10
|
1749 void testApp::midiOutputAdded(string name, bool isNetwork) {
|
rt300@10
|
1750 stringstream msg;
|
rt300@10
|
1751 msg << "ofxMidi: output added: " << name << " network: " << isNetwork << endl;
|
rt300@10
|
1752 cout << msg.str();
|
rt300@10
|
1753 addMessage(msg.str());
|
rt300@10
|
1754
|
rt300@10
|
1755 // create and open new output port
|
rt300@10
|
1756 ofxMidiOut * newOutput = new ofxMidiOut;
|
rt300@10
|
1757 newOutput->openPort(name);
|
rt300@10
|
1758 outputs.push_back(newOutput);
|
rt300@10
|
1759 }
|
rt300@10
|
1760
|
rt300@10
|
1761 //--------------------------------------------------------------
|
rt300@10
|
1762 void testApp::midiOutputRemoved(string name, bool isNetwork) {
|
rt300@10
|
1763 stringstream msg;
|
rt300@10
|
1764 msg << "ofxMidi: output removed: " << name << " network: " << isNetwork << endl;
|
rt300@10
|
1765 cout << msg.str();
|
rt300@10
|
1766 addMessage(msg.str());
|
rt300@10
|
1767
|
rt300@10
|
1768 // close and remove output port
|
rt300@10
|
1769 vector<ofxMidiOut*>::iterator iter;
|
rt300@10
|
1770 for(iter = outputs.begin(); iter != outputs.end(); ++iter) {
|
rt300@10
|
1771 ofxMidiOut * output = (*iter);
|
rt300@10
|
1772 if(output->getName() == name) {
|
rt300@10
|
1773 output->closePort();
|
rt300@10
|
1774 delete output;
|
rt300@10
|
1775 outputs.erase(iter);
|
rt300@10
|
1776 break;
|
rt300@10
|
1777 }
|
rt300@10
|
1778 }
|
rt300@10
|
1779 }
|
rt300@10
|
1780 //--------------------------------------------------------------
|