Mercurial > hg > soniczoomios
diff grid.mm @ 43:b91a1859829a
used UIkit sliders
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 19 Apr 2013 18:50:04 +0100 |
parents | af06bb942d58 |
children | a1e75b94c505 |
line wrap: on
line diff
--- a/grid.mm Wed Apr 17 13:44:05 2013 +0100 +++ b/grid.mm Fri Apr 19 18:50:04 2013 +0100 @@ -15,7 +15,7 @@ extern EventLogger eventLogger; extern Hilbert hilbert; //-------------------------------------------------------------- -Grid::Grid(): maxValue(pow(32.0,7.0)-1), minValue(30), paramsPerDim(5), paramBitDepth(7){ +Grid::Grid(): minValue(30), paramsPerDim(5), paramBitDepth(7), hilbert(){ interpLevel = 4; } @@ -25,12 +25,14 @@ } void Grid::init(){ - + maxValue = pow(2.0,paramsPerDim*paramBitDepth)-1; interpolateMode = NO_INTERPOLATION; maxZoom = false; minZoom = false; + midiCC = vector<int>(paramsPerDim*2,0); + pixSize.setCoord(ofGetWidth(), ofGetHeight()); //set scale to random @@ -46,7 +48,8 @@ centre.setCoord(maxValue/2 , maxValue/2); topLeft.setCoord(centre.x - size.x/2, centre.y - size.y/2); - hilbert.init(paramBitDepth, paramsPerDim); + // do this now + hilbert.changeCurve(paramBitDepth, paramsPerDim); // set a starting param value, find coord that does it. vector<int> params(paramsPerDim*2); @@ -63,14 +66,39 @@ calculateInterpolateLevel(); // log the starting zoom level - eventLogger.logEvent(ZOOM,centre, scale); + eventLogger.logEvent(ZOOM,getCoord(), scale); + + + ///////// TEST HILBERT + + + /* + Hilbert hilbert1(7,1); + + unsigned long long inCoord = 100; + vector<int> checkParam; + checkParam = hilbert1.calculateParamsFromIndex(inCoord); + cout << "PARAMS: "; + for(int i=0; i<4;i++){ + cout << checkParam[i] << " "; + } + cout << '\n'; + unsigned long long outCoord = hilbert1.calculateIndexFromParams(checkParam); + cout << "UNIT TEST COORD = " << outCoord << "\n"; + */ } //-------------------------------------------------------------- template <typename T> int sgn(T val) { return (T(0) < val) - (val < T(0)); } - +//-------------------------------------------------------------- +void Grid::changeNumberOfParamsPerDim(){ + // experimental func + // try using different gray code, etc etc + paramsPerDim = 4; + +} //-------------------------------------------------------------- double Grid::calculateInterpolateLevel(){ if(interpolateMode == INTERPOLATE_GRID){ @@ -102,7 +130,7 @@ if(scaleLevel > paramBitDepth || scaleLevel < 0){ cout << "Error: Bad scale level: " << scaleLevel << "\n"; - scaleLevel = 5; + scaleLevel = round(paramBitDepth*0.5); } scale = pow(2.0, scaleLevel*paramsPerDim); @@ -116,7 +144,7 @@ viewWasChanged(); calculateInterpolateLevel(); - eventLogger.logEvent(ZOOM, centre, scale); + eventLogger.logEvent(ZOOM, getCoord(), scale); } //-------------------------------------------------------------- void Grid::setInterpolation(interpolateModeType mode){ @@ -208,7 +236,8 @@ }else if(colCycle == 7){ ofSetColor(255,255,255,alpha); }else{ - cout << "err colour messed up\n"; + ofSetColor(255,255,255,alpha); + cout << "colour cycle > 7\n"; } @@ -379,7 +408,7 @@ ////////-------///////// - for(int i=0;i<10;i++){ // TODO 5bit specific + for(int i=0;i<2*paramsPerDim;i++){ // TODO 5bit specific temp << midiCC[i] << " "; s = temp.str(); ofDrawBitmapString( s, 10, line ); @@ -406,7 +435,7 @@ centre = centre - moveS; viewWasChanged(); - eventLogger.logEvent(SCROLL, centre, scale); + eventLogger.logEvent(SCROLL, getCoord(), scale); } //-------------------------------------------------------------- @@ -438,7 +467,7 @@ viewWasChanged(); calculateInterpolateLevel(); - eventLogger.logEvent(ZOOM, centre, scale); + eventLogger.logEvent(ZOOM, getCoord(), scale); } //-------------------------------------------------------------- @@ -477,6 +506,9 @@ snapCentre = closestPreset->coordinates; eventLogger.logEvent(SNAPPED_TO_PRESET, getCoord(),closestPreset->creationTime ); //cout << "SNAPPED CHECK\n"; + + // causes too many problems just move it + }else{ snapped = false; closestPreset = NULL; @@ -609,12 +641,16 @@ //-------------------------------------------------------------- vector<int> Grid::getParams(){ // return a vector with midiCCs in - // should we store params somewhere and use this as a low computation get ? - vector<int> params(2*paramsPerDim,0); + // if less than 10, fill rest with zeros + + vector<int> params(10,0); // for(int i = 0;i<2*paramsPerDim;i++){ params[i] = midiCC[i]; } + for(int i = 2*paramsPerDim;i<10;i++){ + params[i] = 0; + } return params; } //-------------------------------------------------------------- @@ -622,7 +658,7 @@ // input midiCCs, and go to the appropriate coordinate for(int i = 0;i<2*paramsPerDim;i++){ - midiCC[i] = 64; + midiCC[i] = params[i]; } TwoVector coord = calculateCoordFromParams(params); setCoord(coord); @@ -786,7 +822,7 @@ //-------------------------------------------------------------- //-------------------------------------------------------------- //-------------------------------------------------------------- -#pragma mark The old algorithm +#pragma mark The OLD algorithm TwoVector Grid::calculateCoordFromParamsOld(vector<int> params) const{