Mercurial > hg > wabletios
changeset 12:5bf377b4c780
Saving.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 20 May 2013 11:09:14 +0100 |
parents | 274864620848 |
children | 426d645d8e69 |
files | PresetAlertViewController.mm globalForces.mm lump.mm mesh.mm testApp.h testApp.mm |
diffstat | 6 files changed, 81 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/PresetAlertViewController.mm Wed May 15 17:43:51 2013 +0100 +++ b/PresetAlertViewController.mm Mon May 20 11:09:14 2013 +0100 @@ -5,14 +5,10 @@ // Created by Robert Tubb on 07/01/2013. // // -#include "presetManager.h" #include "testApp.h" #import "PresetAlertViewController.h" -extern PresetManager presetManager; -extern EventLogger eventLogger; - @implementation PresetAlertViewController - (PresetAlertViewController *) init{ [super init]; @@ -52,36 +48,18 @@ }else{ // save it self.alertShowing = NO; - if([[[alertView textFieldAtIndex:0] text] isEqualToString:@"newuser"]){ - // call new user stufff - eventLogger.newUser(); - }else if([[[alertView textFieldAtIndex:0] text] isEqualToString:@"printall"]){ - presetManager.printAll(); - eventLogger.printAll(); - }else if([[[alertView textFieldAtIndex:0] text] isEqualToString:@"questionnaire"]){ - ((testApp *)ofGetAppPtr())->showQuestionnaire(); - - }else{ - presetManager.addPreset([[[alertView textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]); - } + + ((testApp *)ofGetAppPtr())->savePreset([[[self.alert textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]); + } } -(BOOL)textFieldShouldReturn:(UITextField *)textField{ // save it self.alertShowing = NO; - if([[[self.alert textFieldAtIndex:0] text] isEqualToString:@"newuser"]){ - // call new user stufff - eventLogger.newUser(); - }else if([[[self.alert textFieldAtIndex:0] text] isEqualToString:@"printall"]){ - presetManager.printAll(); - eventLogger.printAll(); - }else if([[[self.alert textFieldAtIndex:0] text] isEqualToString:@"questionnaire"]){ - ((testApp *)ofGetAppPtr())->showQuestionnaire(); - - }else{ - presetManager.addPreset([[[self.alert textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]); - } + + ((testApp *)ofGetAppPtr())->savePreset([[[self.alert textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]); + [self.alert dismissWithClickedButtonIndex:self.alert.firstOtherButtonIndex animated:YES]; return YES; }
--- a/globalForces.mm Wed May 15 17:43:51 2013 +0100 +++ b/globalForces.mm Mon May 20 11:09:14 2013 +0100 @@ -28,8 +28,11 @@ maxForcePoints = 11; excitationType = POSITION; - excitationShape = NOISE; + excitationShape = SINE; + excitationStrength = 2; + exciteShapeX = 2; + exciteShapeY = 3; forceTouchPoints = new forceTouchPoint[maxForcePoints]; for(int i = 0; i< 11; i++){ forceTouchPoints[i].x = 0.0;
--- a/lump.mm Wed May 15 17:43:51 2013 +0100 +++ b/lump.mm Mon May 20 11:09:14 2013 +0100 @@ -116,6 +116,7 @@ ofCircle(xpos, ypos, 35.0); ofFill(); }else if(isInScanPath){ + /* ofSetColor(0, 200, 20); int xpos = position.x * ofGetHeight() + globalUI.borderSize; int ypos = position.y * ofGetHeight(); @@ -133,7 +134,7 @@ ofFill(); } // code to display restpos and displacement - /* + ofSetColor(0, 0, 0); int rxpos = zeroRefPos.x * ofGetHeight() + 128; int rypos = zeroRefPos.y * ofGetHeight();
--- a/mesh.mm Wed May 15 17:43:51 2013 +0100 +++ b/mesh.mm Mon May 20 11:09:14 2013 +0100 @@ -750,7 +750,7 @@ double amt = 0.0; TwoVector diff; // get all the lumps and smack em - int xamt = globalForces.exciteShapeX; + int xamt = globalForces.exciteShapeX; // harmonic number of sine int yamt = globalForces.exciteShapeY; switch(aEShape){
--- a/testApp.h Wed May 15 17:43:51 2013 +0100 +++ b/testApp.h Mon May 20 11:09:14 2013 +0100 @@ -101,7 +101,7 @@ void deleteMesh(); Json::Value convertToJsonForSaving(); - void savePreset(); + void savePreset(const string name); void constructPresetFromJson(Json::Value& presetJson); void loadPreset(); Json::Value loadPresetFile(); @@ -132,10 +132,12 @@ ofxUILabel *counter; + void showPresetNameDialog(); + //--------------------------------- // MIDI STUFF // message - + void initialiseMidi(); int midiChannel; // what channel are we recieving on? void addMessage(string msg);
--- a/testApp.mm Wed May 15 17:43:51 2013 +0100 +++ b/testApp.mm Mon May 20 11:09:14 2013 +0100 @@ -77,6 +77,7 @@ globalForces.gravityAmt = 0.0; globalForces.avFilterAmt = 0.01; + initialiseMidi(); // ofSoundStreamSetup(2,0,this, SAMPLE_RATE,256, 2); @@ -108,8 +109,59 @@ [ofxiPhoneGetGLView() updateDimensions]; - presetSaveNumber = } + +//-------------------------------------------------------------------------- +void testApp::initialiseMidi(){ + + ///////////////////////// + // MIDI + + midiChannel = 7; + + // enables the network midi session between iOS and Mac OSX on a + // local wifi network + // + // in ofxMidi: open the input/outport network ports named "Session 1" + // + // on OSX: use the Audio MIDI Setup Utility to connect to the iOS device + // + ofxMidi::enableNetworking(); + + // list the number of available input & output ports + ofxMidiIn::listPorts(); + ofxMidiOut::listPorts(); + + // create and open input ports + for(int i = 0; i < ofxMidiIn::getNumPorts(); ++i) { + + // new object + inputs.push_back(new ofxMidiIn); + + // set this class to receive incoming midi events + inputs[i]->addListener(this); + + // open input port via port number + inputs[i]->openPort(i); + } + + // create and open output ports + for(int i = 0; i < ofxMidiOut::getNumPorts(); ++i) { + + // new object + outputs.push_back(new ofxMidiOut); + + // open input port via port number + outputs[i]->openPort(i); + } + + // set this class to receieve midi device (dis)connection events + ofxMidi::setConnectionListener(this); + + // END MIDI + +} + //-------------------------------------------------------------- Json::Value testApp::convertToJsonForSaving(){ Json::Value root; @@ -132,8 +184,10 @@ } //-------------------------------------------------------------- -void testApp::savePreset(const string name ){ - presetNumber ++; +void testApp::savePreset(const string name = "default" ){ + static int presetNumber; + + presetNumber++; Json::Value jpreset = convertToJsonForSaving(); //save json to file string fname = ofxiPhoneGetDocumentsDirectory() + "presetFile"; @@ -317,7 +371,7 @@ } }else if(type % numTypes ==2){ - theMesh = new LineMesh(4096); + theMesh = new DropletMesh(2000); }else if(type % numTypes ==3){ theMesh = new SquareCrossMesh(28,28); @@ -948,6 +1002,7 @@ cout << "touchStrength = " << m.getArgAsFloat(i) << endl; globalForces.touchStrength = m.getArgAsFloat(i); + globalForces.excitationStrength = globalForces.touchStrength; } } } @@ -1567,9 +1622,12 @@ // TODO handle note on here if(v > 0){ - cout << "note pitch = " << p << endl; + //cout << "note pitch = " << p << endl; pitch = 440.0/pow(2.0,((69.0 - double(p))/12.0)); - theMesh->hit(0.5,0.5,v,globalForces.excitationType,globalForces.excitationShape); + globalForces.excitationShape = GlobalForces::SINE; + if(theMesh != NULL && !meshConstructionFlag){ + theMesh->hit(0.5,0.5,v,globalForces.excitationType,globalForces.excitationShape); + } }else{ //theMesh->damp(); }