Mercurial > hg > wabletios
changeset 14:4ba81a12b008
Fixed OSC crash.
Fixed really nasty clipping with less nasty clipping.
V1.2
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 14 Jul 2014 16:26:30 +0100 |
parents | 426d645d8e69 |
children | d5758530a039 |
files | globalForces.mm mesh.mm scanpath.mm testApp.h testApp.mm |
diffstat | 5 files changed, 38 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/globalForces.mm Wed Jun 26 17:23:30 2013 +0100 +++ b/globalForces.mm Mon Jul 14 16:26:30 2014 +0100 @@ -24,7 +24,7 @@ avFilterAmt = 0.0; pressure = 0.0; - volume = 2.0; + volume = 6.0; maxForcePoints = 11; excitationType = POSITION;
--- a/mesh.mm Wed Jun 26 17:23:30 2013 +0100 +++ b/mesh.mm Mon Jul 14 16:26:30 2014 +0100 @@ -1915,7 +1915,7 @@ void LineMesh::makeDefaultScanPath(){ cout << "LineMesh class makeDefaultScanPath\n"; - for(int i = 0; i < numSegments; i++){ + for(int i = 1; i < numSegments-1; i++){ scanPath.addElement(&lumps[i], &springs[i]); } }
--- a/scanpath.mm Wed Jun 26 17:23:30 2013 +0100 +++ b/scanpath.mm Mon Jul 14 16:26:30 2014 +0100 @@ -295,16 +295,7 @@ double sample = (1 - frameInterpolator)*oldsample + frameInterpolator*newsample; //cout << sample << endl; // keep within the bounds of acceptability - sample = sample*3.0; - - if(sample > 0.99){ - cout << "BIG" << endl; - - sample = 0.99; - }else if(sample < -0.0){ - cout << "SMALL" << endl; - sample = 0.0; - } + return sample; }
--- a/testApp.h Wed Jun 26 17:23:30 2013 +0100 +++ b/testApp.h Mon Jul 14 16:26:30 2014 +0100 @@ -46,7 +46,7 @@ int presetSaveNumber; bool paused; //bool inscribeScanPathMode; - + bool OscOK; // crappy pseudo mutex bool audioAccessFlag; bool meshConstructionFlag;
--- a/testApp.mm Wed Jun 26 17:23:30 2013 +0100 +++ b/testApp.mm Mon Jul 14 16:26:30 2014 +0100 @@ -13,7 +13,7 @@ new mesh popup menu type x,y rings spokes - + update to ofx0.8 save presets: create mesh methods: save to json, construct from json @@ -56,11 +56,24 @@ ofxAccelerometer.setup(); - // listen on the given port - cout << "listening for osc messages on port " << INPORT << "\n"; - receiver.setup( INPORT ); - sender.setup( HOST, OUTPORT ); + try{ + receiver.setup( INPORT ); + OscOK = true; + } + catch (std::runtime_error e){ + cout << "OSC couldn't connect. Exception: " << e.what() << '\n'; + OscOK = false; + } + try{ + sender.setup( HOST, OUTPORT ); + OscOK = true; + } + catch (std::runtime_error e){ + cout << "OSC couldn't connect. Exception: " << e.what() << '\n'; + OscOK = false; + } + ofBackground(0, 0, 0); ofSetFullscreen(true); ofSetFrameRate(60); @@ -88,7 +101,7 @@ audioAccessFlag = false; meshConstructionFlag = false; - ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT ); + ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT ); setupGui(); @@ -355,7 +368,7 @@ if(audioAccessFlag) return; // or rather wait ! meshConstructionFlag = TRUE; static int type = 0; - int numTypes = 7; + int numTypes = 8; @@ -389,6 +402,9 @@ }else if(type % numTypes ==6){ theMesh = new DropletMesh(128); + }else if(type % numTypes ==7){ + + theMesh = new LineMesh(4000); } type++; //theMesh = new LineMesh(123); @@ -702,7 +718,7 @@ //-------------------------------------------------------------- void testApp::addTouch(){ numTouches++; - cout << "numtouches " << numTouches << endl; + //cout << "numtouches " << numTouches << endl; } //-------------------------------------------------------------- void testApp::removeTouch(){ @@ -825,8 +841,16 @@ // hipass to get rid of DC //sample = mydspTools.highpass1(sample); sample = mydspTools.butter(sample); - output[i*nChannels ] = sample*globalForces.volume; - output[i*nChannels + 1] = sample*globalForces.volume; + // clip after volume + sample = sample*globalForces.volume; + if (sample >= 1.0){ + sample = 0.999999999; + }else if (sample <= -1.0){ + sample = -0.999999999; + } + + output[i*nChannels ] = sample; + output[i*nChannels + 1] = sample; phasor += phasorIncr; @@ -1587,10 +1611,6 @@ if(newOrientation == 4){ ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT ); - }else if(newOrientation == 3){ - ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT ); - }else if(newOrientation == 5){ - ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT ); } }