Mercurial > hg > soniczoomios
diff presetManager.h @ 46:1e266647840d
beta 2.
interpolation movement , smoothing (crap) and timbre only.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Wed, 24 Apr 2013 17:58:08 +0100 |
parents | c2fffc8ea84d |
children |
line wrap: on
line diff
--- a/presetManager.h Tue Apr 23 18:29:55 2013 +0100 +++ b/presetManager.h Wed Apr 24 17:58:08 2013 +0100 @@ -15,6 +15,7 @@ #define PRESET_FILENAME "presets.json" #define PILOT_PRESET_FILENAME "pilot_presets.json" +#define FACTORY_PRESET_FILENAME "factory_presets.json" #include <iostream> #include <string> @@ -40,11 +41,11 @@ vector<ofColor> pixVals; // hmmm TwoVector coordinates; // position on grid vector<int> params; // actual parameters??? - int whichSequence; - // not so important - not uploaded + unsigned int whichSequence; // the sequence number that this preset was saved with. + // from save button press - Preset(TwoVector acoord, string aname,int aID, string un, unsigned int uid){ + Preset(TwoVector acoord, string aname,int aID, string un, unsigned int uid, unsigned int sequence){ coordinates = acoord; name = aname; creatorUserName = un; @@ -54,7 +55,7 @@ cout << "Create preset sys time: " << creationTime << "\n"; pixVals = makePresetPicture(coordinates); - //whichSequence = seq; + whichSequence = sequence; }; // from json value @@ -66,16 +67,17 @@ coordinates.x = jval["coordinates"].get("x", 0.0).asFloat(); coordinates.y = jval["coordinates"].get("y", 0.0).asFloat(); creationTime = jval["creationTime"].asLargestInt(); // dodgy? + whichSequence = jval["whichSequence"].asUInt(); pixVals = makePresetPicture(coordinates); - } + }; // from preset file load - Preset(TwoVector acoord, string aname,int aID, long long stime){ + Preset(TwoVector acoord, string aname,int aID, long long stime, unsigned int seq){ coordinates = acoord; name = aname; creationTime = stime; pixVals = makePresetPicture(coordinates); - + whichSequence = seq; }; // from download request?? @@ -90,7 +92,7 @@ NSString *dateText = [ocdate description]; const char *date_str = [dateText cStringUsingEncoding:NSASCIIStringEncoding]; stringstream ss; - ss << "Name: \t" << name << "\nCreation time: \t" << date_str << "\nCreator: \t" << creatorUserName << '\n'; + ss << "Name: \t" << name << "\nCreation time: \t" << date_str << "\nCreator: \t" << creatorUserName << '\n' << "\nSequence: \t" << whichSequence << '\n'; return ss.str(); } @@ -109,8 +111,7 @@ vector<Preset> thePresets; int addPreset(string name); - int loadPreset(const TwoVector coord, const string name, long long stime); - + TwoVector recallPreset(int presetID); // by name ? id? TwoVector recallPreset(string name); // by name ? id? vector<Preset *> getPresetsInRange(TwoVector min, TwoVector max); @@ -127,43 +128,5 @@ void saveSessionToFile(string userName); }; - -//--------------------------------------------------------------------------- -// this is the function that 'saves' a single preset as formatted text -// replaced with presetToJson -inline ostream& operator<<(ostream & os, const Preset& p){ - os.setf(ios_base::fixed,ios_base::floatfield); - os.precision(1); - - // change this to JSON - - os << p.creationTime << p.coordinates.x << ',' << p.coordinates.y << '\n'; - - return os; -} - -//--------------------------------------------------------------------------- -// this is the function that 'reads' all presets as formatted text - // replaced with jsonFromPreset or somesuch - inline istream& operator>>(istream & is, PresetManager& p) - { - //um - string pname = "BLANK"; - char delim; - double px, py; - long long stime; - - - is.setf(ios_base::fixed,ios_base::floatfield); - is.precision(1); - - is >> stime >> delim >> px >> delim >> py; - if(!is){ - return(is); - } - TwoVector pcoord(px,py); - p.loadPreset(pcoord, pname, stime); - return(is); - } #endif /* defined(__oscSenderExample__presetManager__) */