diff options
| -rw-r--r-- | rotord/src/cvimage.cpp | 26 | ||||
| -rw-r--r-- | rotord/src/cvimage.h | 22 | ||||
| -rw-r--r-- | rotord/src/graph.cpp | 30 | ||||
| -rw-r--r-- | rotord/src/graph.h | 20 | ||||
| -rw-r--r-- | rotord/src/image.h | 20 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.cpp | 2 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.h | 16 | ||||
| -rw-r--r-- | rotord/src/nodes_audio_analysis.cpp | 44 | ||||
| -rw-r--r-- | rotord/src/nodes_audio_analysis.h | 32 | ||||
| -rw-r--r-- | rotord/src/nodes_channels.h | 108 | ||||
| -rw-r--r-- | rotord/src/nodes_drawing.h | 42 | ||||
| -rw-r--r-- | rotord/src/nodes_filters.h | 10 | ||||
| -rw-r--r-- | rotord/src/nodes_maths.h | 72 | ||||
| -rw-r--r-- | rotord/src/nodes_signals.h | 18 | ||||
| -rw-r--r-- | rotord/src/nodes_source.h | 2 | ||||
| -rw-r--r-- | rotord/src/nodes_transform.h | 36 | ||||
| -rw-r--r-- | rotord/src/rendercontext.cpp | 8 | ||||
| -rw-r--r-- | rotord/src/rendercontext.h | 10 | ||||
| -rw-r--r-- | rotord/src/rotor.cpp | 22 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 218 | ||||
| -rw-r--r-- | rotord/src/tinyxml.h | 4 | ||||
| -rw-r--r-- | rotord/src/utils.cpp | 24 | ||||
| -rw-r--r-- | rotord/src/utils.h | 16 | ||||
| -rw-r--r-- | rotord/src/vampHost.cpp | 42 | ||||
| -rw-r--r-- | rotord/src/vampHost.h | 12 |
25 files changed, 428 insertions, 428 deletions
diff --git a/rotord/src/cvimage.cpp b/rotord/src/cvimage.cpp index 7aae63e..21e4e2f 100644 --- a/rotord/src/cvimage.cpp +++ b/rotord/src/cvimage.cpp @@ -191,47 +191,47 @@ namespace Rotor { //scalar operations allocate a new image. //maybe this could not be the case if the data is owned by this image? //need to look into auto_ptr - Image & Image::operator*=(const float &amount) { + Image & Image::operator*=(const double &amount) { //cerr<<"amount: "<<amount<<endl; //rgb*=amount; - uint8_t amt=(uint8_t)(amount*255.0f); + uint8_t amt=(uint8_t)(amount*255.0); for (int i=0;i<h*w*3;i++) { rgb.data[i]=pixels.multiply[rgb.data[i]][amt]; } //again this is faster return *this; } - Image & Image::operator+=(const float &amount) { - rgb+=(amount*255.0f); + Image & Image::operator+=(const double &amount) { + rgb+=(amount*255.0); return *this; } - Image & Image::operator-=(const float &amount) { - rgb-=(amount*255.0f); + Image & Image::operator-=(const double &amount) { + rgb-=(amount*255.0); return *this; } - Image & Image::operator/=(const float &amount) { + Image & Image::operator/=(const double &amount) { rgb/=amount; return *this; } - Image * Image::operator*(const float &amount) { + Image * Image::operator*(const double &amount) { //LEAK!! even if the image is deleted!! opencv?? Image *other=new Image(w,h); other->rgb=rgb*amount; return other; } - Image * Image::operator+(const float &amount) { - uint8_t amt=(uint8_t)(amount*255.0f); + Image * Image::operator+(const double &amount) { + uint8_t amt=(uint8_t)(amount*255.0); Image *other=new Image(w,h); other->rgb=rgb+amt; return other; } - Image * Image::operator-(const float &amount) { - uint8_t amt=(uint8_t)(amount*255.0f); + Image * Image::operator-(const double &amount) { + uint8_t amt=(uint8_t)(amount*255.0); Image *other=new Image(w,h); other->rgb=rgb-amt; return other; } - Image * Image::operator/(const float &amount) { + Image * Image::operator/(const double &amount) { Image *other=new Image(w,h); other->rgb=rgb/amount; return other; diff --git a/rotord/src/cvimage.h b/rotord/src/cvimage.h index ee39edf..0a91715 100644 --- a/rotord/src/cvimage.h +++ b/rotord/src/cvimage.h @@ -40,18 +40,18 @@ namespace Rotor { max[i]=new uint8_t[256]; for (int j=0;j<256;j++){ add[i][j]=(uint8_t)std::min(i+j,0xFF); - multiply[i][j]=(uint8_t)(((float)i)*(((float)j)/255.0f)); + multiply[i][j]=(uint8_t)(((double)i)*(((double)j)/255.0)); overlay[i][j]=j<128?(uint8_t)((i*j)>>7):255-(((0xFF-i)*(0xFF-j))>>7); min[i][j]=j<i?j:i; max[i][j]=j>i?j:i; } } mono_weights=new uint8_t*[3]; - float weights[3]={0.2989, 0.5870, 0.1140}; + double weights[3]={0.2989, 0.5870, 0.1140}; for (int i=0;i<3;i++) { mono_weights[i]=new uint8_t[256]; for (int j=0;j<256;j++){ - mono_weights[i][j]=(uint8_t)(((float)j)*weights[i]); + mono_weights[i][j]=(uint8_t)(((double)j)*weights[i]); } } } @@ -221,14 +221,14 @@ namespace Rotor { Image & overlay(const Image &other); Image & min(const Image &other); Image & max(const Image &other); - Image & operator*=(const float &amount); - Image & operator+=(const float &amount); - Image & operator-=(const float &amount); - Image & operator/=(const float &amount); - Image * operator*(const float &amount); - Image * operator+(const float &amount); - Image * operator-(const float &amount); - Image * operator/(const float &amount); + Image & operator*=(const double &amount); + Image & operator+=(const double &amount); + Image & operator-=(const double &amount); + Image & operator/=(const double &amount); + Image * operator*(const double &amount); + Image * operator+(const double &amount); + Image * operator-(const double &amount); + Image * operator/(const double &amount); uint8_t *RGBdata; uint8_t *Adata; uint16_t *Zdata; diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 5d8d368..96c313f 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -24,17 +24,17 @@ Node* Graph::find_node(const string &type){ } return nullptr; //can be tested against }; -bool Graph::signal_render(xmlIO &XML,const string &node,const float framerate) { +bool Graph::signal_render(xmlIO &XML,const string &node,const double framerate) { if (nodes.find(node)!=nodes.end()){ Signal_node *signal_output=dynamic_cast<Signal_node*>(nodes[node]); if (signal_output) { //return signal_output->render(duration,framerate,signal_xml); XML.addValue("signal_duration",duration); XML.addValue("signal_framerate",framerate); - //float sig=0.0f; + //double sig=0.0; string val=""; - for (float i=0;i<duration;i+=1.0f/framerate){ - float s=(signal_output->get_output(Time_spec(i,framerate,duration))); + for (double i=0;i<duration;i+=1.0/framerate){ + double s=(signal_output->get_output(Time_spec(i,framerate,duration))); //if (!fequal(sig,s)){ val+=toString(i)+" "+toString(s)+","; // sig=s; @@ -65,17 +65,17 @@ bool Graph::print_features(xmlIO &XML,string &node){ } bool Graph::preview(xmlIO &XML,string &node,string &_format,int frame,int w,int h){ if (nodes.find(node)!=nodes.end()){ - float t=frame/framerate; + double t=frame/framerate; XML.addTag("preview"); XML.addAttribute("preview","frame",toString(frame),0); XML.addAttribute("preview","nodeID",node,0); XML.pushTag("preview"); if (dynamic_cast<Signal_node*>(nodes[node])){ - Time_spec ts=Time_spec(t,framerate,0.0f); + Time_spec ts=Time_spec(t,framerate,0.0); XML.addValue("signal",dynamic_cast<Signal_node*>(nodes[node])->get_output(ts)); } if (dynamic_cast<Image_node*>(nodes[node])){ - Frame_spec fs=Frame_spec(t,framerate,0.0f,w,h); + Frame_spec fs=Frame_spec(t,framerate,0.0,w,h); Image *img=dynamic_cast<Image_node*>(nodes[node])->get_image_output(fs); vector<unsigned char> buf; string format=(_format==""?".png":_format); @@ -95,7 +95,7 @@ bool Graph::preview(xmlIO &XML,string &node,string &_format,int frame,int w,int return false; } -bool Graph::video_render(const string &output_filename,const float framerate,int start, int stop) { +bool Graph::video_render(const string &output_filename,const double framerate,int start, int stop) { if (output_filename.size()==0) return false; //https://www.adobe.com/devnet/video/articles/mp4_movie_atom.html //https://www.google.ie/search?q=ffmbc&aq=f&oq=ffmbc&aqs=chrome.0.57j0l2j60j0j60.4360j0&sourceid=chrome&ie=UTF-8#q=ffmbc+git @@ -162,9 +162,9 @@ bool Graph::video_render(const string &output_filename,const float framerate,int audio=new uint16_t[samples_in_frame*audioloader.get_number_channels()]; } - float vstep=1.0f/framerate; - float vf=start*vstep; - float af=start*vstep; + double vstep=1.0/framerate; + double vf=start*vstep; + double af=start*vstep; int aoffs=0; int audioend=0; Audio_frame *a; @@ -239,7 +239,7 @@ bool Graph::video_render(const string &output_filename,const float framerate,int gettimeofday(&_end, NULL); - float mtime = ((_end.tv_sec-_start.tv_sec) + (_end.tv_usec-_start.tv_usec)/1000000.0); + double mtime = ((_end.tv_sec-_start.tv_sec) + (_end.tv_usec-_start.tv_usec)/1000000.0); logger.information("Video_output: rendered "+output_filename+": in "+toString(mtime)+" seconds"); logger.information("compression codec took "+toString(mtime-video_output->time_taken)+" seconds"); @@ -364,7 +364,7 @@ bool Graph::parseJson(string &data,string &media_path){ attr->init(vals); } if (attr->type=="lyrics"){ - std::map<float,std::pair<string,float> > lyrics; + std::map<double,std::pair<string,double> > lyrics; for (auto k:jnodes[i]["attributes"][m]["value"]){ if (k.size()>2&&k[0].isString()&&k[1].isNumeric()&&k[2].isNumeric()) { lyrics[k[1].asFloat()]=std::make_pair(k[0].asString(),k[2].asFloat()); @@ -450,7 +450,7 @@ bool Graph::parseJson(string &data,string &media_path){ string parameter=jnodes[i]["parameters"][l]["name"].asString(); if (nodes[nodeID]->parameters.find(parameter)!=nodes[nodeID]->parameters.end()) { - float val=jnodes[i]["parameters"][l]["value"].asFloat(); + double val=jnodes[i]["parameters"][l]["value"].asFloat(); if (val!=nodes[nodeID]->parameters.find(parameter)->second->value){ nodes[nodeID]->parameters.find(parameter)->second->value=val; cerr << "Rotor: set parameter '"<<parameter<<"' of "<<nodeID<<" to "<<val<<endl; @@ -670,7 +670,7 @@ bool Graph::load_audio(const string &filename,vector<Audio_processor*> processor } sample+=1024; //mutex.lock(); - progress=((float)sample)/samples; //atomic on 64 bit? + progress=((double)sample)/samples; //atomic on 64 bit? //mutex.unlock(); } diff --git a/rotord/src/graph.h b/rotord/src/graph.h index b9647bc..153bc5a 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -25,7 +25,7 @@ copy nodes ` namespace Rotor { class Graph{ public: - Graph(){duration=20.0f;loaded = false;audio_loaded=false;bitRate=0;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();use_fragmentation=false;analysis_seed=0;}; + Graph(){duration=20.0;loaded = false;audio_loaded=false;bitRate=0;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();use_fragmentation=false;analysis_seed=0;}; Graph(const string& _uid,const string& _desc){ Graph(); init(_uid,_desc); @@ -33,8 +33,8 @@ namespace Rotor { void init(const string& _uid,const string& _desc){ uid=_uid; description=_desc; - duration=20.0f; - framerate=25.0f; + duration=20.0; + framerate=25.0; cancelled=false; }; ~Graph(){ clear(); delete audio_thumb;}; @@ -51,8 +51,8 @@ namespace Rotor { std::unordered_map<string,Node*> nodes; vector<Node*> find_nodes(const string &type); //could be a way of finding a set based on capabilities? Node* find_node(const string &type); - bool signal_render(xmlIO &XML,const string &node,const float framerate); - bool video_render(const string &output_filename,const float framerate,int start, int end); + bool signal_render(xmlIO &XML,const string &node,const double framerate); + bool video_render(const string &output_filename,const double framerate,int start, int end); bool load(string data,string media_path); bool loadFile(string &filename,string media_path); bool parseXml(string media_path); @@ -75,14 +75,14 @@ namespace Rotor { return true; } bool loaded; - float duration; - float framerate; + double duration; + double framerate; const string graphToString(); xmlIO xml; bool audio_loaded; string audio_filename; bool cancelled; - float progress; + double progress; int bitRate; //Poco::Mutex mutex; //lock for access from parent thread @@ -112,7 +112,7 @@ namespace Rotor { w*4); cairo_t * cr = cairo_create (cs); cairo_translate(cr, w/2, h/2); - cairo_scale(cr, ((float)w)/640.0f,((float)w)/640.0f); + cairo_scale(cr, ((double)w)/640.0,((double)w)/640.0); cairo_translate(cr, -w/2, -h/2); cairo_translate(cr, w/2-(dims.width/2), h/2-(dims.height/2)); rsvg_handle_render_cairo(rsvg,cr); @@ -158,7 +158,7 @@ namespace Rotor { uchar* r=co.ptr(i); //pointer to row for (int j=0;j<w;j++){ //audio rms in 0..1 range - if (at.audiodata[j]>abs(((float)i-h/2)/(h/2))) op=0xFF; + if (at.audiodata[j]>abs(((double)i-h/2)/(h/2))) op=0xFF; else op=0x00; r[j*3]=op/4; r[j*3+1]=op; diff --git a/rotord/src/image.h b/rotord/src/image.h index 68aea09..0f089d1 100644 --- a/rotord/src/image.h +++ b/rotord/src/image.h @@ -14,15 +14,15 @@ namespace Rotor { multiply[i]=new uint8_t[256]; for (int j=0;j<256;j++){ add[i][j]=(uint8_t)min(i+j,0xFF); - multiply[i][j]=(uint8_t)((((float)i)/255.0f)*(((float)j)/255.0f)*255.0f); + multiply[i][j]=(uint8_t)((((double)i)/255.0)*(((double)j)/255.0)*255.0); } } mono_weights=new uint8_t*[3]; - float weights[3]={0.2989, 0.5870, 0.1140}; + double weights[3]={0.2989, 0.5870, 0.1140}; for (int i=0;i<3;i++) { mono_weights[i]=new uint8_t[256]; for (int j=0;j<256;j++){ - mono_weights[i][j]=(uint8_t)(((float)j)*weights[i]); + mono_weights[i][j]=(uint8_t)(((double)j)*weights[i]); } } } @@ -173,7 +173,7 @@ namespace Rotor { //scalar operations allocate a new image. //maybe this could not be the case if the data is owned by this image? //need to look into auto_ptr - Image & operator*=(const float &amount) { + Image & operator*=(const double &amount) { uint8_t *LUT=new uint8_t[256]; for (int i=0;i<256;i++) { LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i*amount))); @@ -185,7 +185,7 @@ namespace Rotor { delete[] LUT; return *this; } - Image * operator*(const float &amount) { + Image * operator*(const double &amount) { Image *other=new Image(w,h); uint8_t *LUT=new uint8_t[256]; for (int i=0;i<256;i++) { @@ -197,11 +197,11 @@ namespace Rotor { delete[] LUT; return other; } - Image * operator+(const float &amount) { + Image * operator+(const double &amount) { Image *other=new Image(w,h); uint8_t *LUT=new uint8_t[256]; for (int i=0;i<256;i++) { - LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i+(amount*255.0f)))); + LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i+(amount*255.0)))); } for (int i=0;i<w*h*3;i++){ other->RGBdata[i]=LUT[RGBdata[i]]; @@ -209,11 +209,11 @@ namespace Rotor { delete[] LUT; return other; } - Image * operator-(const float &amount) { + Image * operator-(const double &amount) { Image *other=new Image(w,h); uint8_t *LUT=new uint8_t[256]; for (int i=0;i<256;i++) { - LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i-(amount*255.0f)))); + LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i-(amount*255.0)))); } for (int i=0;i<w*h*3;i++){ other->RGBdata[i]=LUT[RGBdata[i]]; @@ -221,7 +221,7 @@ namespace Rotor { delete[] LUT; return other; } - Image * operator/(const float &amount) { + Image * operator/(const double &amount) { Image *other=new Image(w,h); uint8_t *LUT=new uint8_t[256]; for (int i=0;i<256;i++) { diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index 225d01e..d48cbc3 100644 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -244,7 +244,7 @@ bool libav::exporter::record(std::string filename){ } if (audio_st) { audioframesize=open_audio(oc, audio_codec, audio_st); - audiostep=((float)audioframesize)/(audio_st->codec->sample_rate); + audiostep=((double)audioframesize)/(audio_st->codec->sample_rate); std::cerr << "opened audio codec with "<<audioframesize<<" frame size and "<<audiostep<<" seconds per frame"<<std::endl; } diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h index 7822323..162a77e 100644 --- a/rotord/src/libavwrapper.h +++ b/rotord/src/libavwrapper.h @@ -55,9 +55,9 @@ namespace libav { } void cleanup(); bool open(const std::string& filename); - float get_framerate(){ - if (loaded) return (((float)props->FPSNumerator)/((float)props->FPSDenominator)); - else return -1.0f; + double get_framerate(){ + if (loaded) return (((double)props->FPSNumerator)/((double)props->FPSDenominator)); + else return -1.0; } int get_number_frames(){ if (loaded) return props->NumFrames; @@ -138,8 +138,8 @@ namespace libav { if (props) return props->ChannelLayout; else return 0; } - float get_duration(){ - if (props) return ((float)props->NumSamples)/props->SampleRate; + double get_duration(){ + if (props) return ((double)props->NumSamples)/props->SampleRate; else return 0; } bool get_samples(void *buf,int64_t start, int64_t count){ @@ -181,7 +181,7 @@ namespace libav { bool encodeFrame(uint16_t *samples); void finishRecord(); int get_audio_framesize(){return audioframesize;}; - float get_audio_step(){return audiostep;}; + double get_audio_step(){return audiostep;}; AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,enum AVCodecID codec_id); //AVCodecID bool open_video(AVFormatContext *oc, AVCodec *codec, AVStream *st); @@ -204,7 +204,7 @@ namespace libav { struct SwsContext *sws_ctx; int audioframesize; - float audiostep; + double audiostep; int w; int h; int bitRate; @@ -226,7 +226,7 @@ namespace libav { //************************************************************// // audio output // - float t, tincr, tincr2; + double t, tincr, tincr2; int audio_input_frame_size; diff --git a/rotord/src/nodes_audio_analysis.cpp b/rotord/src/nodes_audio_analysis.cpp index 9ad33f6..a6aa4ec 100644 --- a/rotord/src/nodes_audio_analysis.cpp +++ b/rotord/src/nodes_audio_analysis.cpp @@ -8,7 +8,7 @@ namespace Rotor{ samples=_samples; samples_per_column=samples/width; offset=0x1<<(bits-1); //signed audio - scale=1.0f/offset; + scale=1.0/offset; out_sample=0; //sample in whole track sample=0; @@ -106,7 +106,7 @@ namespace Rotor{ } return data; } - bool sortsegments(std::pair<int,float> i,std::pair<int,float> j){ + bool sortsegments(std::pair<int,double> i,std::pair<int,double> j){ return (i.second<j.second); } void Intensity_segmenter::cleanup(){ @@ -124,22 +124,22 @@ namespace Rotor{ cerr<<analysers["tempo"].features.size()<<" tempo features"<<endl; cerr<<analysers["intensity"].features.size()<<" intensity features"<<endl; uint32_t i=0; - float min_tempo=9999999.0f; - float min_intensity=9999999.0f; - float max_tempo=0.0f; - float max_intensity=0.0f; - vector<float> tempos; - vector<float> intensities; - vector<float> times; + double min_tempo=9999999.0; + double min_intensity=9999999.0; + double max_tempo=0.0; + double max_intensity=0.0; + vector<double> tempos; + vector<double> intensities; + vector<double> times; auto g=++analysers["segmenter"].features.begin(); for (auto f=analysers["segmenter"].features.begin();g!=analysers["segmenter"].features.end();f++,g++,i++){ cerr<<"segment "<<i<<": "<<f->first<<" to "<<g->first<<endl; times.push_back(f->first); //integrate tempo and intensity algorithmically - float tempo=0; + double tempo=0; if (analysers["tempo"].features.size()) { - float pt=f->first; - float pv=analysers["tempo"].get_value(f->first); + double pt=f->first; + double pv=analysers["tempo"].get_value(f->first); for (auto u=analysers["tempo"].features.upper_bound(f->first);u!=analysers["tempo"].features.upper_bound(g->first);u++){ tempo +=(u->first-pt)*(u->second.values[0]+pv)*0.5f; //area of the slice pt=u->first; @@ -153,10 +153,10 @@ namespace Rotor{ tempos.push_back(tempo); cerr<<"segment "<<i<<" average tempo: "<<tempo<<endl; - float intensity=0; + double intensity=0; if (analysers["intensity"].features.size()) { - float pt=f->first; - float pv=analysers["intensity"].get_value(f->first); + double pt=f->first; + double pv=analysers["intensity"].get_value(f->first); for (auto u=analysers["intensity"].features.upper_bound(f->first);u!=analysers["intensity"].features.upper_bound(g->first);u++){ intensity +=(u->first-pt)*(u->second.values[0]+pv)*0.5f; //area of the slice pt=u->first; @@ -170,7 +170,7 @@ namespace Rotor{ intensities.push_back(intensity); } //make relative scale 0.0-1.0 and save weighted totals - vector< pair<int,float>> totals; + vector< pair<int,double>> totals; for (i=0;i<tempos.size();i++){ tempos[i]=(tempos[i]-min_tempo)/(max_tempo-min_tempo); intensities[i]=(intensities[i]-min_intensity)/(max_intensity-min_intensity); @@ -181,13 +181,13 @@ namespace Rotor{ for (i=0;i<totals.size();i++) { cerr<<"segment "<<totals[i].first<<" average intensity: "<<totals[i].second<<endl; } - vector<float> bucketoffsets; - for (auto t:totals) bucketoffsets.push_back(0.0f); - if (parameters["levels"]->value>0.0f&¶meters["levels"]->value<totals.size()){ + vector<double> bucketoffsets; + for (auto t:totals) bucketoffsets.push_back(0.0); + if (parameters["levels"]->value>0.0&¶meters["levels"]->value<totals.size()){ //use bucketoffsets to redistribute into smaller number of buckets int numbertoredistribute=totals.size()-((int)parameters["levels"]->value); - float numberperbin=((float)numbertoredistribute/totals.size()); - float toadd=0.5f; + double numberperbin=((double)numbertoredistribute/totals.size()); + double toadd=0.5f; int added=0; for (int j=0;j<totals.size();j++){ int numbertoadd=min(numbertoredistribute-added,(int)toadd); @@ -205,7 +205,7 @@ namespace Rotor{ } for (i=0;i<totals.size();i++){ vampHost::feature f; - f.values.push_back((float)i-bucketoffsets[i]); + f.values.push_back((double)i-bucketoffsets[i]); features[times[totals[i].first]]=f; } } diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h index 8cb70d0..7c4893a 100644 --- a/rotord/src/nodes_audio_analysis.h +++ b/rotord/src/nodes_audio_analysis.h @@ -39,11 +39,11 @@ namespace Rotor { void cleanup(){}; int process_frame(uint8_t *data,int samples_in_frame); void print_vector(xmlIO XML); - vector<float> audiodata; + vector<double> audiodata; int height,width,samples_per_column; int out_sample,sample,samples; int offset; - float scale,accum; + double scale,accum; }; class Vamp_node: public Audio_processor { //base class for vamp plugin hosts @@ -54,23 +54,23 @@ namespace Rotor { bool init(int _channels,int _bits,int _samples,int _rate); void cleanup(); int process_frame(uint8_t *data,int samples_in_frame); - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { if (features.size()) { auto i=features.upper_bound(time.time); //the first element in the container whose key is considered to go after k if (i==features.end()) i--; - float uk=i->first; - float v1,v2; - v1=v2=0.0f; + double uk=i->first; + double v1,v2; + v1=v2=0.0; if (i->second.values.size()) v2=i->second.values[0]; i--; - float lk=i->first; + double lk=i->first; int ln=i->second.number; if (i->second.values.size()) v1=i->second.values[0]; switch (attributes["mode"]->intVal){ case VAMPHOST_Timeline: return (((time.time-lk)/(uk-lk))+ln); case VAMPHOST_Timesteps: - return (float)ln; + return (double)ln; case VAMPHOST_Valueline: return ((((time.time-lk)/(uk-lk))*(v2-v1))+v1); case VAMPHOST_Values: @@ -79,7 +79,7 @@ namespace Rotor { //} //return (--features.end())->second.values[0]; } - return 0.0f; + return 0.0; } string get_features(); void print_summary(){ @@ -100,7 +100,7 @@ namespace Rotor { //create_attribute("soname","Plugin library to use","Plugin library","vamp-example-plugins"); //create_attribute("id","ID of Plugin to use","Plugin ID","percussiononsets"); //create_attribute("analyser","Analyser Plugin to use","Analyser plugin","barbeattracker",{"barbeattracker","segmenter"}); - create_parameter("outputNo","number","Plugin output to use","Output number",0.0f); + create_parameter("outputNo","number","Plugin output to use","Output number",0.0); //title="Audio analysis"; //description="Analyse audio and output"; NODEID="b769f54e-2d0b-11e3-87dd-f73fc7b1c636"; @@ -122,7 +122,7 @@ namespace Rotor { //create_attribute("soname","Plugin library to use","Plugin library","vamp-example-plugins",{"horiz","vert","horizR","vertR"}); //create_attribute("id","ID of Plugin to use","Plugin ID","percussiononsets",{"horiz","vert","horizR","vertR"}); create_attribute("analyser","Analyser Plugin to use","Analyser plugin","barbeattracker",{"adaptivespectrum","barbeattracker","chromagram","dwt","mfcc","onsetdetector","segmenter","similarity","tempotracker","transcription"}); - create_parameter("outputNo","number","Plugin output to use","Output number",0.0f); + create_parameter("outputNo","number","Plugin output to use","Output number",0.0); title="Audio analysis"; description="Analyse audio and output"; NODEID="b769f54e-2d0b-11e3-87dd-f73fc7b1c636"; @@ -161,8 +161,8 @@ namespace Rotor { //vamp node that applies a ruleset to manage a set of acts via a cycler public: Act_segmenter(){ - create_parameter("outputNo","number","Plugin output to use","Output number",0.0f); - create_parameter("acts","number","Number of acts defined","Acts",1.0f); + create_parameter("outputNo","number","Plugin output to use","Output number",0.0); + create_parameter("acts","number","Number of acts defined","Acts",1.0); title="Act manager"; description="Applies a ruleset to manage acts based on segments"; NODEID="c55359a2-2d0b-11e3-8a3d-53fa9c2b8859"; @@ -287,9 +287,9 @@ namespace Rotor { analysers["segmenter"]=vampHost::Analyser(); analysers["tempo"]=vampHost::Analyser(); analysers["intensity"]=vampHost::Analyser(); - create_parameter("intensity_weight","number","intensity weight","Intensity weighting",1.0f); - create_parameter("tempo_weight","number","tempo weight","Tempo weighting",1.0f); - create_parameter("levels","number","levels","Number of intensity levels",0.0f); + create_parameter("intensity_weight","number","intensity weight","Intensity weighting",1.0); + create_parameter("tempo_weight","number","tempo weight","Tempo weighting",1.0); + create_parameter("levels","number","levels","Number of intensity levels",0.0); }; Intensity_segmenter(map<string,string> &settings):Intensity_segmenter() { base_settings(settings); diff --git a/rotord/src/nodes_channels.h b/rotord/src/nodes_channels.h index 20fc86c..4782e00 100644 --- a/rotord/src/nodes_channels.h +++ b/rotord/src/nodes_channels.h @@ -8,7 +8,7 @@ namespace Rotor { public: Invert(){ create_image_input("Image to invert","Image input"); - create_parameter("invert","number","Invert when greater than 0.0","Negative",1.0f,0.0f,1.0f); + create_parameter("invert","number","Invert when greater than 0.0","Negative",1.0,0.0,1.0); title="Negative"; description="Inverts the input picture"; NODEID="8676c25c-2d09-11e3-80a7-db36c774523c"; @@ -21,7 +21,7 @@ namespace Rotor { Image *output(const Frame_spec &frame){ Image *in=image_inputs[0]->get(frame); if (in) { - if (parameters["invert"]->value>0.0f){ + if (parameters["invert"]->value>0.0){ for (int i=0;i<in->w*in->h*3;i++) { image.RGBdata[i]=255-in->RGBdata[i]; } @@ -77,7 +77,7 @@ namespace Rotor { Blend(){ create_image_input("image input 1","Image input 1"); create_image_input("image input 2","Image input 2"); - create_parameter("amount","number","amount to blend input 2","Blend amount",0.5f,0.0f,1.0f); + create_parameter("amount","number","amount to blend input 2","Blend amount",0.5f,0.0,1.0); create_attribute("mode","Blend mode","Blend mode","blend",{"blend","screen","multiply","alpha","wrap","xor","overlay","min","max"}); title ="Blend"; description="Blend images in various modes"; @@ -121,7 +121,7 @@ namespace Rotor { break; case BLEND_blend: //has to be last because of initialser of *in? go figure - image*=(1.0f-parameters["amount"]->value); + image*=(1.0-parameters["amount"]->value); /* //problem here with leak //opencv handles not being released Image *in=(*in2)*parameters["amount"]->value; @@ -152,7 +152,7 @@ namespace Rotor { public: Image_arithmetic(){ create_image_input("image input","Image input"); - create_parameter("value","number","Value or signal for operation","Value",1.0f); + create_parameter("value","number","Value or signal for operation","Value",1.0); create_attribute("operator","operator for image","Operator","+",{"+","-","*","/"}); title="Image arithmetic"; description="Performs arithmetic on an image with a signal or value"; @@ -225,17 +225,17 @@ namespace Rotor { Difference_matte(){ create_image_input("image input","Image input"); create_image_input("background input","Background input"); - create_parameter("threshold","number","Difference threshold","Threshold",0.2f,0.0f,1.0f); - create_parameter("feather","number","Feather width","Feather",0.1f,0.0f,1.0f); - create_parameter("weight_h","number","H component weight","Weight H",0.5f,0.0f,1.0f); - create_parameter("weight_s","number","S component weight","Weight S",0.5f,0.0f,1.0f); - create_parameter("weight_v","number","V component weight","Weight V",0.5f,0.0f,1.0f); - create_parameter("blursize","number","Blur size","Blur size",2.0f,0.0f,10.0f); + create_parameter("threshold","number","Difference threshold","Threshold",0.2f,0.0,1.0); + create_parameter("feather","number","Feather width","Feather",0.1f,0.0,1.0); + create_parameter("weight_h","number","H component weight","Weight H",0.5f,0.0,1.0); + create_parameter("weight_s","number","S component weight","Weight S",0.5f,0.0,1.0); + create_parameter("weight_v","number","V component weight","Weight V",0.5f,0.0,1.0); + create_parameter("blursize","number","Blur size","Blur size",2.0,0.0,10.0); create_attribute("mode","Output {image|alpha}","output mode","alpha",{"image","alpha"}); title="Difference matte"; description="Create an alpha channel using a background reference picture"; LUT=nullptr; - NODEID="4db4d2c8-2d0a-11e3-b08b-7fb00f8c562a"; + NODEID="4db4d2c8-2d0a-11e3-b08b-7fb.08c562a"; }; Difference_matte(map<string,string> &settings):Difference_matte() { base_settings(settings); @@ -269,8 +269,8 @@ namespace Rotor { //get euclidean distance in HSV space int dist,d; - float weights[3] = {parameters["weight_h"]->value,parameters["weight_s"]->value,parameters["weight_v"]->value}; - float weight_total=255.0f/pow(pow(weights[0]*255,2)+pow(weights[1]*255,2)+pow(weights[2]*255,2),0.5); + double weights[3] = {parameters["weight_h"]->value,parameters["weight_s"]->value,parameters["weight_v"]->value}; + double weight_total=255.0/pow(pow(weights[0]*255,2)+pow(weights[1]*255,2)+pow(weights[2]*255,2),0.5); for (int i=0;i<frame.w*frame.h;i++){ dist=0; @@ -278,7 +278,7 @@ namespace Rotor { d=((int)hsv1.data[i*3+j])-((int)hsv2.data[i*3+j]); dist+=(d*d)*weights[j]; } - uint8_t id=(uint8_t)(sqrt((float)dist)*weight_total); + uint8_t id=(uint8_t)(sqrt((double)dist)*weight_total); mask.data[i]=id; } @@ -290,7 +290,7 @@ namespace Rotor { d=((int)hsv1.data[i*3+j])-((int)hsv2.data[i*3+j]); dist+=(abs(d))*weights[j]; } - uint8_t id=(uint8_t)(((float)dist)/weight_total); + uint8_t id=(uint8_t)(((double)dist)/weight_total); m=LUT[id]; mask.data[i]=m; } @@ -329,10 +329,10 @@ namespace Rotor { //cerr<<"generating LUT: threshold "<<parameters["threshold"]->value<<", feather "<<parameters["feather"]->value<<endl; if (LUT) delete[] LUT; LUT=new uint8_t[256]; - float minf=max(0.0f,parameters["threshold"]->value-(parameters["feather"]->value*0.5f)); - float maxf=min(1.0f,parameters["threshold"]->value+(parameters["feather"]->value*0.5f)); + double minf=max(0.0,parameters["threshold"]->value-(parameters["feather"]->value*0.5f)); + double maxf=min(1.0,parameters["threshold"]->value+(parameters["feather"]->value*0.5f)); for (int i=0;i<256;i++){ - LUT[i]=(uint8_t)(min(1.0f,max(0.0f,((((float)i)/255.0f)-minf)/(maxf-minf)))*255.0f); + LUT[i]=(uint8_t)(min(1.0,max(0.0,((((double)i)/255.0)-minf)/(maxf-minf)))*255.0); // cerr<<((int)LUT[i])<<" "; } //cerr<<endl; @@ -346,11 +346,11 @@ namespace Rotor { public: Luma_levels(){ create_image_input("image input","Image input"); - create_parameter("black_in","number","input black point","Input black point",0.0f,0.0f,1.0f); - create_parameter("white_in","number","input white point","Input white point",1.0f,0.0f,1.0f); - create_parameter("gamma","number","gamma level","Gamma",1.0f,0.0f,10.0f); - create_parameter("black_out","number","output black point","Output black point",0.0f,0.0f,1.0f); - create_parameter("white_out","number","output white point","Output white point",1.0f,0.0f,1.0f); + create_parameter("black_in","number","input black point","Input black point",0.0,0.0,1.0); + create_parameter("white_in","number","input white point","Input white point",1.0,0.0,1.0); + create_parameter("gamma","number","gamma level","Gamma",1.0,0.0,10.0); + create_parameter("black_out","number","output black point","Output black point",0.0,0.0,1.0); + create_parameter("white_out","number","output white point","Output white point",1.0,0.0,1.0); title="Luma levels"; description="Remap luma values of image"; LUT=nullptr; @@ -364,9 +364,9 @@ namespace Rotor { //can check here if anything has changed if (LUT) delete[] LUT; LUT=new unsigned char[256]; - float fltmax=(255.0f/256.0f); + double fltmax=(255.0/256.0); for (int i=0;i<256;i++){ - LUT[i]=(unsigned char)(((pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-parameters["black_in"]->value)/(parameters["white_in"]->value-parameters["black_in"]->value)))),(1.0/parameters["gamma"]->value))*(parameters["white_out"]->value-parameters["black_out"]->value))+parameters["black_out"]->value)*255.0f); + LUT[i]=(unsigned char)(((pow(min(fltmax,max(0.0,(((((double)i)/256.0)-parameters["black_in"]->value)/(parameters["white_in"]->value-parameters["black_in"]->value)))),(1.0/parameters["gamma"]->value))*(parameters["white_out"]->value-parameters["black_out"]->value))+parameters["black_out"]->value)*255.0); } } void apply_LUT(const Image& in){ @@ -418,9 +418,9 @@ namespace Rotor { public: Echo_trails(){ //calls base class constructor first - create_parameter("number","number","number of echoes","Number echoes",25.0f); - create_parameter("fadeto","number","amount that echoes fade out","Fadout amount",1.0f,0.0f,1.0f); - create_parameter("interval","number","number of frames between echoes","",1.0f,0.0f,1.0f); + create_parameter("number","number","number of echoes","Number echoes",25.0); + create_parameter("fadeto","number","amount that echoes fade out","Fadout amount",1.0,0.0,1.0); + create_parameter("interval","number","number of frames between echoes","",1.0,0.0,1.0); create_attribute("mode","blend mode for echoes","Blend mode","screen",{"screen","wrap","min","max"}); title="Echo trails"; description="Draw trail frames additively that fade off over time"; @@ -478,9 +478,9 @@ namespace Rotor { if (in2) apply_LUT(*(in2),*(images[absframe])); else images[absframe]->clear(); } - if (fless(1.0f,parameters["fadeto"]->value)){ - float fadetime=((float)i)/((float)duration); //0 to 1 - float amount=1.0f-(fadetime*(1.0f-parameters["fadeto"]->value)); + if (fless(1.0,parameters["fadeto"]->value)){ + double fadetime=((double)i)/((double)duration); //0 to 1 + double amount=1.0-(fadetime*(1.0-parameters["fadeto"]->value)); Image *temp=*images[absframe]*amount; if (attributes["mode"]->value=="screen") { image+=*temp; @@ -529,21 +529,21 @@ namespace Rotor { public: RGB_levels(){ create_image_input("image input","Image input"); - create_parameter("red_black_in","number","Red input black-point","Red input black-point",0.0f,0.0f,1.0f); - create_parameter("red_white_in","number","Red input white-point","Red input white-point",1.0f,0.0f,1.0f); - create_parameter("red_gamma","number","Red gamma level","Red gamma",1.0f,0.01f,10.0f); - create_parameter("red_black_out","number","Red output black point","Red output black point",0.0f,0.0f,1.0f); - create_parameter("red_white_out","number","Red output white point","Red output white point",1.0f,0.0f,1.0f); - create_parameter("green_black_in","number","Green input black point","Green input black point",0.0f,0.0f,1.0f); - create_parameter("green_white_in","number","Green input white point","Green input white point",1.0f,0.0f,1.0f); - create_parameter("green_gamma","number","Green gamma level","Green gamma",1.0f,0.01f,10.0f); - create_parameter("green_black_out","number","Green output black point","Green output black point",0.0f,0.0f,1.0f); - create_parameter("green_white_out","number","Green output white point","Green output white point",1.0f,0.0f,1.0f); - create_parameter("blue_black_in","number","Blue input black point","Blue input black point",0.0f,0.0f,1.0f); - create_parameter("blue_white_in","number","Blue input white point","Blue input white point",1.0f,0.0f,1.0f); - create_parameter("blue_gamma","number","Blue gamma level","Blue gamma",1.0f,0.01f,10.0f); - create_parameter("blue_black_out","number","Blue output black point","Blue output black point",0.0f,0.0f,1.0f); - create_parameter("blue_white_out","number","Blue output white point","Blue output white point",1.0f,0.0f,1.0f); + create_parameter("red_black_in","number","Red input black-point","Red input black-point",0.0,0.0,1.0); + create_parameter("red_white_in","number","Red input white-point","Red input white-point",1.0,0.0,1.0); + create_parameter("red_gamma","number","Red gamma level","Red gamma",1.0,0.01f,10.0); + create_parameter("red_black_out","number","Red output black point","Red output black point",0.0,0.0,1.0); + create_parameter("red_white_out","number","Red output white point","Red output white point",1.0,0.0,1.0); + create_parameter("green_black_in","number","Green input black point","Green input black point",0.0,0.0,1.0); + create_parameter("green_white_in","number","Green input white point","Green input white point",1.0,0.0,1.0); + create_parameter("green_gamma","number","Green gamma level","Green gamma",1.0,0.01f,10.0); + create_parameter("green_black_out","number","Green output black point","Green output black point",0.0,0.0,1.0); + create_parameter("green_white_out","number","Green output white point","Green output white point",1.0,0.0,1.0); + create_parameter("blue_black_in","number","Blue input black point","Blue input black point",0.0,0.0,1.0); + create_parameter("blue_white_in","number","Blue input white point","Blue input white point",1.0,0.0,1.0); + create_parameter("blue_gamma","number","Blue gamma level","Blue gamma",1.0,0.01f,10.0); + create_parameter("blue_black_out","number","Blue output black point","Blue output black point",0.0,0.0,1.0); + create_parameter("blue_white_out","number","Blue output white point","Blue output white point",1.0,0.0,1.0); title="RGB levels"; description="Remap RGB values of image"; LUT=nullptr; @@ -572,20 +572,20 @@ namespace Rotor { for (int i=0;i<3;i++){ LUT[i]=new unsigned char[256]; } - float fltmax=(255.0f/256.0f); + double fltmax=(255.0/256.0); for (int i=0;i<256;i++){ LUT[0][i]=(unsigned char)(((\ - pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-parameters["red_black_in"]->value)/(parameters["red_white_in"]->value-parameters["red_black_in"]->value))))\ + pow(min(fltmax,max(0.0,(((((double)i)/256.0)-parameters["red_black_in"]->value)/(parameters["red_white_in"]->value-parameters["red_black_in"]->value))))\ ,(1.0/parameters["red_gamma"]->value))\ - *(parameters["red_white_out"]->value-parameters["red_black_out"]->value))+parameters["red_black_out"]->value)*255.0f); + *(parameters["red_white_out"]->value-parameters["red_black_out"]->value))+parameters["red_black_out"]->value)*255.0); LUT[1][i]=(unsigned char)(((\ - pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-parameters["green_black_in"]->value)/(parameters["green_white_in"]->value-parameters["green_black_in"]->value))))\ + pow(min(fltmax,max(0.0,(((((double)i)/256.0)-parameters["green_black_in"]->value)/(parameters["green_white_in"]->value-parameters["green_black_in"]->value))))\ ,(1.0/parameters["green_gamma"]->value))\ - *(parameters["green_white_out"]->value-parameters["green_black_out"]->value))+parameters["green_black_out"]->value)*255.0f); + *(parameters["green_white_out"]->value-parameters["green_black_out"]->value))+parameters["green_black_out"]->value)*255.0); LUT[2][i]=(unsigned char)(((\ - pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-parameters["blue_black_in"]->value)/(parameters["blue_white_in"]->value-parameters["blue_black_in"]->value))))\ + pow(min(fltmax,max(0.0,(((((double)i)/256.0)-parameters["blue_black_in"]->value)/(parameters["blue_white_in"]->value-parameters["blue_black_in"]->value))))\ ,(1.0/parameters["blue_gamma"]->value))\ - *(parameters["blue_white_out"]->value-parameters["blue_black_out"]->value))+parameters["blue_black_out"]->value)*255.0f); + *(parameters["blue_white_out"]->value-parameters["blue_black_out"]->value))+parameters["blue_black_out"]->value)*255.0); } } void apply_LUT(const Image& in){ diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h index 8fe5d71..f2ed0ae 100644 --- a/rotord/src/nodes_drawing.h +++ b/rotord/src/nodes_drawing.h @@ -10,10 +10,10 @@ namespace Rotor { public: Draw_node(){ create_image_input("image input","Image input"); - create_parameter("x","number","X coordinate","X",0.0f); - create_parameter("y","number","Y coordinate","Y",0.0f); - create_parameter("scale","number","Scale","Scale",1.0f); - create_parameter("rotation","number","Rotation","Rotation",0.0f); + create_parameter("x","number","X coordinate","X",0.0); + create_parameter("y","number","Y coordinate","Y",0.0); + create_parameter("scale","number","Scale","Scale",1.0); + create_parameter("rotation","number","Rotation","Rotation",0.0); //no title or description as it isn't intended for the user }; Draw_node(map<string,string> &settings):Draw_node() { @@ -51,7 +51,7 @@ namespace Rotor { cairo_translate(cr, frame.w/2, frame.h/2); cairo_translate(cr, parameters["x"]->value * frame.w, parameters["y"]->value * frame.h); cairo_scale(cr, parameters["scale"]->value , parameters["scale"]->value ); - cairo_rotate(cr,(parameters["rotation"]->value/180.0f)*M_PI); + cairo_rotate(cr,(parameters["rotation"]->value/180.0)*M_PI); } protected: Colour colour; @@ -63,8 +63,8 @@ namespace Rotor { Text_base(){ create_attribute("colour","Colour to fill","Colour","FFFFFF"); create_attribute("font","font to use","Font","Akzidenz",{"Sans","Sans Mono","Serif","Akzidenz"}); - create_parameter("size","number","Point size of font","size",50.0f); - NODEID="7da93b94-2d0b-11e3-8940-77bce0f9d3e8"; + create_parameter("size","number","Point size of font","size",50.0); + NODEID="7da93b94-2d0b-11e3-8940-77bc.09d3e8"; }; Text_base(map<string,string> &settings):Text_base() { base_settings(settings); @@ -75,7 +75,7 @@ namespace Rotor { colour=Colour(attributes["colour"]->value); string text=select_text(frame); cairo_text_extents_t te; - cairo_set_source_rgb(cr, colour.Rfloat(),colour.Gfloat(),colour.Bfloat()); + cairo_set_source_rgb(cr, colour.Rdouble(),colour.Gdouble(),colour.Bdouble()); string fontname; switch (attributes["font"]->intVal){ case 1: @@ -89,7 +89,7 @@ namespace Rotor { } cairo_select_font_face (cr,fontname.c_str(), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); - cairo_set_font_size (cr, parameters["size"]->value*(((float)frame.w)/360.0f)); + cairo_set_font_size (cr, parameters["size"]->value*(((double)frame.w)/360.0)); cairo_text_extents(cr, text.c_str(), &te); cairo_move_to (cr,-te.width/2,te.height/2); cairo_show_text (cr, text.c_str()); @@ -106,7 +106,7 @@ namespace Rotor { title="Text"; description="Draws text"; create_attribute("text","Text to draw","Text","hello, world!"); - create_parameter("number","number","Number to draw","Number",-99999999.0f); + create_parameter("number","number","Number to draw","Number",-99999999.0); NODEID="fdea0b88-4de7-11e3-9235-74d02b29f6a6"; }; Text(map<string,string> &settings):Text() { @@ -115,7 +115,7 @@ namespace Rotor { ~Text(){}; Text* clone(map<string,string> &_settings) { return new Text(_settings);}; string select_text(const Frame_spec &frame){ - if (parameters["number"]->value>-99999998.0f){ + if (parameters["number"]->value>-99999998.0){ return toString(parameters["number"]->value,4); } else return attributes["text"]->value; @@ -178,7 +178,7 @@ namespace Rotor { Shape* clone(map<string,string> &_settings) { return new Shape(_settings);}; void vector_output(cairo_t * cr,const Frame_spec &frame){ colour=Colour(attributes["colour"]->value); - cairo_set_source_rgb(cr, colour.Rfloat(),colour.Gfloat(),colour.Bfloat()); + cairo_set_source_rgb(cr, colour.Rdouble(),colour.Gdouble(),colour.Bdouble()); switch(attributes["shape"]->intVal) { case SHAPE_square: cairo_rectangle(cr,-frame.w/2,-frame.w/2,frame.w,frame.w); @@ -239,9 +239,9 @@ namespace Rotor { create_attribute("fill","Colour of line fill","Fill","11AA11"); create_attribute("mode","Drawing mode","Mode","line",{"line","fill","both"}); create_attribute("channel","Channel to draw","Channel","left",{"left","right"}); - create_parameter("width","number","Line width","Width",1.0f,0.0f,25.0f); - create_parameter("height","number","Height","Height",1.0f); - create_parameter("alpha","number","Alpha blend","Alpha",1.0f,0.0f,1.0f); + create_parameter("width","number","Line width","Width",1.0,0.0,25.0); + create_parameter("height","number","Height","Height",1.0); + create_parameter("alpha","number","Alpha blend","Alpha",1.0,0.0,1.0); } Waves(map<string,string> &settings):Waves() { base_settings(settings); @@ -253,11 +253,11 @@ namespace Rotor { fill=Colour(attributes["fill"]->value); int channel=attributes["channel"]->intVal-1; if (attributes["mode"]->value=="fill"||attributes["mode"]->value=="both") { - cairo_set_source_rgba(cr, fill.Rfloat(),fill.Gfloat(),fill.Bfloat(),parameters["alpha"]->value); + cairo_set_source_rgba(cr, fill.Rdouble(),fill.Gdouble(),fill.Bdouble(),parameters["alpha"]->value); cairo_save(cr); //cairo_translate(cr, 0, frame.h/2); cairo_translate(cr,-frame.w/2,0); - cairo_scale(cr,1.0f,parameters["height"]->value); + cairo_scale(cr,1.0,parameters["height"]->value); //cairo_line_to(cr, 0, 0); for (int i=0;i<frame.w;i++){ cairo_line_to(cr,i,(((int16_t)frame.audio->samples[i*frame.audio->channels]+channel)*frame.h)>>16); @@ -269,10 +269,10 @@ namespace Rotor { cairo_fill(cr); } if (attributes["mode"]->value=="line"||attributes["mode"]->value=="both") { - cairo_set_source_rgba(cr, stroke.Rfloat(),stroke.Gfloat(),stroke.Bfloat(),parameters["alpha"]->value); + cairo_set_source_rgba(cr, stroke.Rdouble(),stroke.Gdouble(),stroke.Bdouble(),parameters["alpha"]->value); cairo_save(cr); cairo_translate(cr,-frame.w/2,0); - cairo_scale(cr,1.0f,parameters["height"]->value); + cairo_scale(cr,1.0,parameters["height"]->value); cairo_set_line_width (cr, parameters["width"]->value); cairo_line_to(cr, 0, 0); for (int i=0;i<frame.w;i++){ @@ -322,11 +322,11 @@ namespace Rotor { if (rsvg) { //to make it resolution independent //translate the difference between screen and drawing - float scale=frame.w/dims.width; + double scale=frame.w/dims.width; cairo_translate(cr, frame.w/2, frame.h/2); cairo_translate(cr, parameters["x"]->value * frame.w, parameters["y"]->value * frame.h); cairo_scale(cr, parameters["scale"]->value*scale, parameters["scale"]->value*scale); - cairo_rotate(cr,(parameters["rotation"]->value/180.0f)*M_PI); + cairo_rotate(cr,(parameters["rotation"]->value/180.0)*M_PI); cairo_translate(cr, -frame.w/2, -frame.h/2); cairo_translate(cr, frame.w/2-(dims.width/2), frame.h/2-(dims.height/2)); } diff --git a/rotord/src/nodes_filters.h b/rotord/src/nodes_filters.h index a1e020a..2b8f787 100644 --- a/rotord/src/nodes_filters.h +++ b/rotord/src/nodes_filters.h @@ -9,9 +9,9 @@ namespace Rotor { Blur(){ title="Blur"; description="Gaussian blur filter"; - create_parameter("size","number","Blur window size","Size",1.0f); + create_parameter("size","number","Blur window size","Size",1.0); create_image_input("image input","Image input"); - NODEID="3650f412-2d0b-11e3-b86b-a31ab5838db2"; + NODEID="36.0412-2d0b-11e3-b86b-a31ab5838db2"; }; Blur(map<string,string> &settings):Blur() { base_settings(settings); @@ -30,14 +30,14 @@ namespace Rotor { return nullptr; } private: - float size; + double size; }; class VHS: public Image_node { public: VHS(){ title="VHS"; description="VHS degradation filter"; - create_parameter("generation_loss","number","VHS generation loss amount","Generation loss",1.0f); + create_parameter("generation_loss","number","VHS generation loss amount","Generation loss",1.0); create_image_input("image input","Image input"); NODEID="3f62bdb0-2d0b-11e3-a4eb-a712839b837d"; }; @@ -65,7 +65,7 @@ namespace Rotor { return nullptr; } private: - float size; + double size; cv::Mat hsv,hsv1; }; diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h index 2bf8b48..0f92f0a 100644 --- a/rotord/src/nodes_maths.h +++ b/rotord/src/nodes_maths.h @@ -20,7 +20,7 @@ namespace Rotor { public: Comparison(){ create_signal_input("signal","Signal"); - create_parameter("value","number","Value or signal for operation","Value",0.0f); + create_parameter("value","number","Value or signal for operation","Value",0.0); create_attribute("operator","Operator for comparison","operator","==",{"==","!=",">","<",">=","<="}); title="Comparison"; description="Compares the signal with a value or signal according to the operator"; @@ -30,31 +30,31 @@ namespace Rotor { base_settings(settings); } Comparison* clone(map<string,string> &_settings) { return new Comparison(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { if (inputs[0]->connection) { switch (attributes["operator"]->intVal) { case COMPARISON_Equal: - return fequal(parameters["value"]->value,inputs[0]->get(time))?1.0f:0.0f; + return fequal(parameters["value"]->value,inputs[0]->get(time))?1.0:0.0; break; case COMPARISON_Not_equal: - return fequal(parameters["value"]->value,inputs[0]->get(time))?0.0f:1.0f; + return fequal(parameters["value"]->value,inputs[0]->get(time))?0.0:1.0; break; case COMPARISON_Greater: - return fgreater(parameters["value"]->value,inputs[0]->get(time))?1.0f:0.0f; + return fgreater(parameters["value"]->value,inputs[0]->get(time))?1.0:0.0; break; case COMPARISON_Less: - return fless(parameters["value"]->value,inputs[0]->get(time))?1.0f:0.0f; + return fless(parameters["value"]->value,inputs[0]->get(time))?1.0:0.0; break; case COMPARISON_Greater_or_equal: - return fgreater_or_equal(parameters["value"]->value,inputs[0]->get(time))?1.0f:0.0f; + return fgreater_or_equal(parameters["value"]->value,inputs[0]->get(time))?1.0:0.0; break; case COMPARISON_Less_or_equal: - return fless_or_equal(parameters["value"]->value,inputs[0]->get(time))?1.0f:0.0f; + return fless_or_equal(parameters["value"]->value,inputs[0]->get(time))?1.0:0.0; break; } } - return 0.0f; + return 0.0; } }; #define ARITHMETIC_plus 1 @@ -74,27 +74,27 @@ namespace Rotor { public: Arithmetic(){ create_signal_input("signal","Signal"); - create_parameter("value","number","Value or signal for operation","Value",1.0f); + create_parameter("value","number","Value or signal for operation","Value",1.0); create_attribute("operator","operator for image","Operator","+",{"+","-","*","/","%","^","sin","cos","ease","jolt","floor","2pow","reciprocal"}); title="Arithmetic"; description="Performs arithmetic on a signal with a signal or value"; - NODEID="f35e5f82-2d0a-11e3-83d8-0fed336db813"; + NODEID="f35e5f82-2d0a-11e3-83d8.0ed336db813"; }; Arithmetic(map<string,string> &settings):Arithmetic() { base_settings(settings); }; Arithmetic* clone(map<string,string> &_settings) { return new Arithmetic(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { //if (attributes["operator"]->intVal==ARITHMETIC_divide||attributes["operator"]->intVal==ARITHMETIC_modulo){ - // if (value==0.0f) { + // if (value==0.0) { // Poco::Logger& logger = Poco::Logger::get("Rotor"); // logger.error("Arithmetic node: caught division by zero, frame "+time.frame()); - // return 0.0f; + // return 0.0; // } //} if (inputs.size()) { //there should there be a way to specify number of inputs in the code rather than in xml if (inputs[0]->connection) { - float in= inputs[0]->get(time); + double in= inputs[0]->get(time); int inint; //this old chestnut switch (attributes["operator"]->intVal) { case ARITHMETIC_plus: @@ -124,10 +124,10 @@ namespace Rotor { return cos(in)*parameters["value"]->value; break; case ARITHMETIC_ease: - return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((cos((fmod(in,1.0f)+1.0f)*M_PI))*0.5f))); + return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((cos((fmod(in,1.0)+1.0)*M_PI))*0.5f))); break; case ARITHMETIC_jolt: - return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((sin((fmod(in,1.0f)+1.0f)*M_PI))*0.5f))); + return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((sin((fmod(in,1.0)+1.0)*M_PI))*0.5f))); break; case ARITHMETIC_floor: return floor(in); @@ -141,10 +141,10 @@ namespace Rotor { } } } - return 0.0f; + return 0.0; } int op; - float value; + double value; }; class Is_new_integer: public Signal_node { public: @@ -158,11 +158,11 @@ namespace Rotor { base_settings(settings); }; Is_new_integer* clone(map<string,string> &_settings) { return new Is_new_integer(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { if (((int)inputs[0]->get(time))>((int)inputs[0]->get(time.lastframe()))) { - return 1.0f; + return 1.0; } - return 0.0f; + return 0.0; } }; class On_off: public Signal_node { @@ -177,12 +177,12 @@ namespace Rotor { base_settings(settings); }; On_off* clone(map<string,string> &_settings) { return new On_off(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { if (inputs[0]->connection) { - float s1=(((Signal_node*)(inputs[0]->connection))->get_output(time)); - if ((int)s1%2) return 1.0f; + double s1=(((Signal_node*)(inputs[0]->connection))->get_output(time)); + if ((int)s1%2) return 1.0; } - return 0.0f; + return 0.0; } }; //pseudo random hash function @@ -230,7 +230,7 @@ namespace Rotor { title="Random"; description="Randomises integer part of signal (seedable)"; create_signal_input("signal","Signal"); - create_parameter("seed","number","Seed value","Seed",1.0f); + create_parameter("seed","number","Seed value","Seed",1.0); NODEID="1de86932-2d0b-11e3-96d3-77aa4558e6cd"; std::uniform_int_distribution<> d(-9999, 9999); }; @@ -238,21 +238,21 @@ namespace Rotor { base_settings(settings); }; Random* clone(map<string,string> &_settings) { return new Random(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { - float o; + double o; if (inputs[0]->connection){ o=inputs[0]->get(time); } else o=time.time; uint32_t m=(int)o; PRNG.seed(m^(int)parameters["seed"]->value); - return ((float)(PRNG()&0xf))+(o-m); + return ((double)(PRNG()&0xffff))+(o-m); //uint32_t seed=Seed+parameters["seed"]->value; //hash the integer part and add the fractional part back on // - //return ((float)(fnv1a(m,seed)))+(o-m); //%((uint32_t)time.duration)) + //return ((double)(fnv1a(m,seed)))+(o-m); //%((uint32_t)time.duration)) } MTRand_int32 PRNG; }; @@ -263,17 +263,17 @@ namespace Rotor { title="Noise"; description="Fractal noise (seedable)"; create_signal_input("signal","Signal"); - create_parameter("seed","number","Seed value","Seed",1.0f); - create_parameter("octaves","number","Octaves of noise","octaves",6.0f); - create_parameter("frequency","number","Frequency of noise","frequency",1.0f); - create_parameter("scale","number","scale of noise","scale",1.0f); + create_parameter("seed","number","Seed value","Seed",1.0); + create_parameter("octaves","number","Octaves of noise","octaves",6.0); + create_parameter("frequency","number","Frequency of noise","frequency",1.0); + create_parameter("scale","number","scale of noise","scale",1.0); NODEID="28b3c154-2d0b-11e3-bdf2-1b9b2678a2f6"; }; Noise(map<string,string> &settings):Noise() { base_settings(settings); }; Noise* clone(map<string,string> &_settings) { return new Noise(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { perlin.SetOctaveCount(parameters["octaves"]->value); perlin.SetFrequency(parameters["frequency"]->value); perlin.SetSeed(Seed+parameters["seed"]->value); diff --git a/rotord/src/nodes_signals.h b/rotord/src/nodes_signals.h index a351170..785999c 100644 --- a/rotord/src/nodes_signals.h +++ b/rotord/src/nodes_signals.h @@ -15,7 +15,7 @@ namespace Rotor { base_settings(settings); }; Time* clone(map<string,string> &_settings) { return new Time(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { return time.time; } }; @@ -30,7 +30,7 @@ namespace Rotor { base_settings(settings); }; Track_time* clone(map<string,string> &_settings) { return new Track_time(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { return time.time/time.duration; } }; @@ -38,7 +38,7 @@ namespace Rotor { public: At_track_time(){ create_signal_input("signal","Signal Input"); - create_parameter("time","number","Track time to evaluate","Time",0.0f); + create_parameter("time","number","Track time to evaluate","Time",0.0); title="@Track time"; description="Gets input from a different point in the track"; NODEID="6a3edb9c-2d09-11e3-975c-df9df6d19f0a"; @@ -47,7 +47,7 @@ namespace Rotor { base_settings(settings); }; At_track_time* clone(map<string,string> &_settings) { return new At_track_time(_settings);}; - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { Time_spec t=Time_spec(parameters["time"]->value*time.duration,time.framerate,time.duration); return inputs[0]->get(t); } @@ -64,11 +64,11 @@ namespace Rotor { base_settings(settings); }; Signal_output* clone(map<string,string> &_settings) { return new Signal_output(_settings);}; - bool render(const float duration, const float framerate,string &xml_out){ + bool render(const double duration, const double framerate,string &xml_out){ //lost this somewhere return true; } - const float output(const Time_spec &time) { + const double output(const Time_spec &time) { return inputs[0]->get(time); } }; @@ -83,11 +83,11 @@ namespace Rotor { ~Testcard(){}; Testcard* clone(map<string,string> &_settings) { return new Testcard(_settings);}; Image *output(const Frame_spec &frame){ - float hs=(255.0f/frame.h); + double hs=(255.0/frame.h); for (int i=0;i<frame.h;i++){ for (int j=0;j<frame.w;j++){ - image.RGBdata[(i*frame.w+j)*3]=(uint8_t)((int)((i+(frame.time*25.0f)*hs))%255); - image.RGBdata[((i*frame.w+j)*3)+1]=(uint8_t)((int)((j+(frame.time*100.0f)*hs))%255); + image.RGBdata[(i*frame.w+j)*3]=(uint8_t)((int)((i+(frame.time*25.0)*hs))%255); + image.RGBdata[((i*frame.w+j)*3)+1]=(uint8_t)((int)((j+(frame.time*100.0)*hs))%255); image.RGBdata[((i*frame.w+j)*3)+2]=(uint8_t)(0); //image->Adata[i*frame.w+j]=(uint8_t)255; //image->Zdata[i*frame.w+j]=(uint16_t)512; //1.0 in fixed point 8.8 bits diff --git a/rotord/src/nodes_source.h b/rotord/src/nodes_source.h index 0e37fc7..2659185 100644 --- a/rotord/src/nodes_source.h +++ b/rotord/src/nodes_source.h @@ -57,7 +57,7 @@ namespace Rotor { }; ~Signal_greyscale(){}; Image *output(const Frame_spec &frame){ - uint8_t col=((uint8_t)(inputs[0]->get((Time_spec)frame)*255.0f)); + uint8_t col=((uint8_t)(inputs[0]->get((Time_spec)frame)*255.0)); if (col!=prevcol){ //how about when starting a new render? //for (int i=0;i<image.w*image.h*3;i++){ // image.RGBdata[i]=col; diff --git a/rotord/src/nodes_transform.h b/rotord/src/nodes_transform.h index ea8f474..c4a29ea 100644 --- a/rotord/src/nodes_transform.h +++ b/rotord/src/nodes_transform.h @@ -17,12 +17,12 @@ namespace Rotor { //aspect: scaled or homogenous public: Transformer(){ - create_parameter("transformX","number","X transformation","Transform X",0.0f); - create_parameter("transformY","number","Y transformation","Transform Y",0.0f); + create_parameter("transformX","number","X transformation","Transform X",0.0); + create_parameter("transformY","number","Y transformation","Transform Y",0.0); create_parameter("originX","number","X transformation origin","Origin X",0.5f); create_parameter("originY","number","Y transformation origin","Origin Y",0.5f); - create_parameter("rotation","number","Rotation about origin","Rotation",0.0f); - create_parameter("scale","number","Scale about origin","Scale",1.0f); + create_parameter("rotation","number","Rotation about origin","Rotation",0.0); + create_parameter("scale","number","Scale about origin","Scale",1.0); create_attribute("filter","Filtering mode","Filter mode","linear",{"nearest","linear","area","cubic","lanczos"}); }; Image *transform(Image *in){ @@ -51,12 +51,12 @@ namespace Rotor { break; } - float tX=parameters["transformX"]->value; - float tY=parameters["transformY"]->value; - float oX=parameters["originX"]->value; - float oY=parameters["originY"]->value; - float r=(parameters["rotation"]->value/180)*3.1415926f; - float s=parameters["scale"]->value; + double tX=parameters["transformX"]->value; + double tY=parameters["transformY"]->value; + double oX=parameters["originX"]->value; + double oY=parameters["originY"]->value; + double r=(parameters["rotation"]->value/180)*3.1415926f; + double s=parameters["scale"]->value; //do opencv transform cv::Point2f srcTri[3], dstTri[3]; @@ -70,18 +70,18 @@ namespace Rotor { //using mipmaps: cv::Mat inter; - //int level=(int)ceil(log(1.0f/(s*((float)in.w/(float)image.w)))/log(2)); + //int level=(int)ceil(log(1.0/(s*((double)in.w/(double)image.w)))/log(2)); //if (s<1){ // if (s<.01) s=.01; - // float scalefac=((float)image.w/in->w)*s; + // double scalefac=((double)image.w/in->w)*s; // cv::resize(in->rgb,inter,cv::Size(in->w*scalefac,in->h*scalefac),s,s); //double fx=0, double fy=0, int interpolation=INTER_LINEAR )¶ - // s=1.0f; + // s=1.0; //} //else { inter=in->rgb; - s=((float)image.w/in->w)*s; + s=((double)image.w/in->w)*s; //} // Compute matrix by creating triangle and transforming @@ -103,8 +103,8 @@ namespace Rotor { dstTri[i].x*=s; dstTri[i].y*=s; - float dx=(dstTri[i].x*cos(r))-(dstTri[i].y*sin(r)); - float dy=(dstTri[i].x*sin(r))+(dstTri[i].y*cos(r)); + double dx=(dstTri[i].x*cos(r))-(dstTri[i].y*sin(r)); + double dy=(dstTri[i].x*sin(r))+(dstTri[i].y*cos(r)); dstTri[i].x=dx; dstTri[i].y=dy; @@ -129,8 +129,8 @@ namespace Rotor { //trans_mat.resize(3); //rot_mat.resize(3); - //trans_mat.data[8]=1.0f; - //rot_mat.data[8]=1.0f; + //trans_mat.data[8]=1.0; + //rot_mat.data[8]=1.0; //out_mat=rot_mat*trans_mat; //out_mat.resize(2); diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index e73f0d3..0015488 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -297,9 +297,9 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H if (command.method=="GET") { //generate xml from 1st signal output if (state==IDLE) { if (command.commands.size()>2) { - float framerate; + double framerate; framerate=toFloat(command.body); - if (framerate==0.0f) framerate=graph.framerate; + if (framerate==0.0) framerate=graph.framerate; if (graph.signal_render(XML,command.commands[2],framerate)){ status=HTTPResponse::HTTP_OK; logger.information("rendering signal to xml"); @@ -471,8 +471,8 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H if (t1.count()>2){ stop=toInt(t1[2]); if (t1.count()>3){ - float framerate=toFloat(t1[3]); - if (framerate>0.0f) { + double framerate=toFloat(t1[3]); + if (framerate>0.0) { output_framerate=framerate; } } diff --git a/rotord/src/rendercontext.h b/rotord/src/rendercontext.h index b0f8649..380e197 100644 --- a/rotord/src/rendercontext.h +++ b/rotord/src/rendercontext.h @@ -48,10 +48,10 @@ namespace Rotor { }; class Render_status { public: - Render_status():status(0),progress(0.0f){}; - Render_status(int _status):status(_status),progress(0.0f){}; + Render_status():status(0),progress(0.0){}; + Render_status(int _status):status(_status),progress(0.0){}; int status; - float progress; + double progress; }; class Render_context: public Poco::Task { //Poco task object //manages a 'patchbay' @@ -60,7 +60,7 @@ namespace Rotor { public: Render_context(const std::string& name): Task(name) { state=IDLE; - output_framerate=25.0f; + output_framerate=25.0; start=0; stop=999999; xmlIO xml; @@ -112,7 +112,7 @@ namespace Rotor { Audio_thumbnailer *audio_thumb; Graph graph; - float output_framerate; + double output_framerate; int start,stop; }; } diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index 83a0fa7..afb47e0 100644 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -81,40 +81,40 @@ Node_factory::Node_factory(){ add_type("ui_text",new UI_text(),category["UI"]); } -float Signal_input::get_time_used(){ +double Signal_input::get_time_used(){ if (connection){ return ((Signal_node*)connection)->get_time_used(); } - return 0.0f; + return 0.0; } -float Signal_input::get_time_taken(){ +double Signal_input::get_time_taken(){ if (connection){ return ((Signal_node*)connection)->time_taken; } - return 0.0f; + return 0.0; } bool Signal_input::connect(Node* source) { connection=dynamic_cast<Signal_node*>(source); if (connection) return true; else return false; } -float Signal_input::get(const Time_spec& time){ //gets input and updates variable +double Signal_input::get(const Time_spec& time){ //gets input and updates variable if (connection){ return (((Signal_node*)connection)->get_output(time)); } - else return 0.0f; + else return 0.0; } -float Image_input::get_time_used(){ +double Image_input::get_time_used(){ if (connection){ return ((Image_node*)connection)->get_time_used(); } - return 0.0f; + return 0.0; } -float Image_input::get_time_taken(){ +double Image_input::get_time_taken(){ if (connection){ return ((Image_node*)connection)->time_taken; } - return 0.0f; + return 0.0; } bool Image_input::connect(Node* source) { connection=dynamic_cast<Image_node*>(source); @@ -127,7 +127,7 @@ Image* Image_input::get(const Frame_spec& time){ //gets input and updates variab } else return nullptr; } -float Parameter::get(const Time_spec& time){ //gets input and updates variable +double Parameter::get(const Time_spec& time){ //gets input and updates variable if (connection){ value = ((Signal_node*)connection)->get_output(time); } diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index e00ebd6..0013313 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -162,16 +162,16 @@ namespace Rotor { class Time_spec{ public: Time_spec(){}; - Time_spec(float _time,float _framerate,float _duration,Audio_frame *_audio=nullptr){ time=_time; framerate=_framerate; duration=_duration; audio=_audio;}; - float time; //num/denom ? - float framerate; - float duration; + Time_spec(double _time,double _framerate,double _duration,Audio_frame *_audio=nullptr){ time=_time; framerate=_framerate; duration=_duration; audio=_audio;}; + double time; //num/denom ? + double framerate; + double duration; Audio_frame *audio; Time_spec lastframe() const{ - return Time_spec(time-(1.0f/framerate),framerate,duration); + return Time_spec(time-(1.0/framerate),framerate,duration); } Time_spec nextframe() const{ - return Time_spec(time+(1.0f/framerate),framerate,duration); + return Time_spec(time+(1.0/framerate),framerate,duration); } int frame(){ return (int)((time*framerate)+0.5); //rounded to the nearest frame @@ -179,16 +179,16 @@ namespace Rotor { }; class Frame_spec: public Time_spec{ public: - Frame_spec(float _time,float _framerate,float _duration,int _w,int _h,Audio_frame *_audio=nullptr) + Frame_spec(double _time,double _framerate,double _duration,int _w,int _h,Audio_frame *_audio=nullptr) { time=_time; framerate=_framerate; duration=_duration; w=_w; h=_h;audio=_audio;}; - Frame_spec(int _frame,float _framerate,float _duration,int _w,int _h,Audio_frame *_audio=nullptr) - { time=((float)_frame)/_framerate; framerate=_framerate; duration=_duration; w=_w; h=_h;audio=_audio;}; + Frame_spec(int _frame,double _framerate,double _duration,int _w,int _h,Audio_frame *_audio=nullptr) + { time=((double)_frame)/_framerate; framerate=_framerate; duration=_duration; w=_w; h=_h;audio=_audio;}; int h,w; Frame_spec lastframe() const{ - return Frame_spec(time-(1.0f/framerate),framerate,duration,w,h); + return Frame_spec(time-(1.0/framerate),framerate,duration,w,h); } Frame_spec nextframe() const{ - return Frame_spec(time+(1.0f/framerate),framerate,duration,w,h); + return Frame_spec(time+(1.0/framerate),framerate,duration,w,h); } }; class Colour{ @@ -206,14 +206,14 @@ namespace Rotor { g=(uint8_t)hexToChar(s.substr(2,2)); b=(uint8_t)hexToChar(s.substr(4,2)); } - float Rfloat(){ - return ((float)r)/255.0f; + double Rdouble(){ + return ((double)r)/255.0; } - float Gfloat(){ - return ((float)g)/255.0f; + double Gdouble(){ + return ((double)g)/255.0; } - float Bfloat(){ - return ((float)b)/255.0f; + double Bdouble(){ + return ((double)b)/255.0; } uint8_t r,g,b; }; @@ -229,8 +229,8 @@ namespace Rotor { Node* connection; string description; string title; - virtual float get_time_used()=0; - virtual float get_time_taken()=0; + virtual double get_time_used()=0; + virtual double get_time_taken()=0; }; class Image_input: public Input{ public: @@ -240,8 +240,8 @@ namespace Rotor { connect(_connect); }; Image* get(const Frame_spec& time); - float get_time_used(); - float get_time_taken(); + double get_time_used(); + double get_time_taken(); }; class Signal_input: public Input{ public: @@ -250,19 +250,19 @@ namespace Rotor { Signal_input(const string &_desc,const string &_title,Node* _connect): Input(_desc,_title){ connect(_connect); }; - float get(const Time_spec& time); - float get_time_used(); - float get_time_taken(); + double get(const Time_spec& time); + double get_time_used(); + double get_time_taken(); }; class Parameter: public Signal_input{ public: virtual ~Parameter(){}; - void init(const float &_val){ + void init(const double &_val){ value=_val; } - Parameter(const string &_type,const string &_desc,const string &_title,float _value,float _min,float _max,float _step,Node* _connect): Signal_input(_desc,_title,_connect),value(_value),min(_min),max(_max),step(_step),type(_type){}; - float value,min,max,step; - float get(const Time_spec& time); + Parameter(const string &_type,const string &_desc,const string &_title,double _value,double _min,double _max,double _step,Node* _connect): Signal_input(_desc,_title,_connect),value(_value),min(_min),max(_max),step(_step),type(_type){}; + double value,min,max,step; + double get(const Time_spec& time); string type; }; /* @@ -316,12 +316,12 @@ namespace Rotor { type="lyrics"; blank_response=""; }; - void init(const std::map<float,std::pair<string,float> > _lyrics){ + void init(const std::map<double,std::pair<string,double> > _lyrics){ lyrics=_lyrics; for (auto l:lyrics){ cerr<<l.first<<":"<<l.second.first<<" ("<<l.second.second<<")"<<endl; } - lyrics[-1.0f]=make_pair("",0.0f); //start with an empty entry + lyrics[-1.0]=make_pair("",0.0); //start with an empty entry } const string &get_lyric(const Time_spec &time){ if (lyrics.size()) { @@ -333,7 +333,7 @@ namespace Rotor { return blank_response; } private: - std::map<float,std::pair<string,float> > lyrics; //lyrics[startime]=pair<lyric,endtime> + std::map<double,std::pair<string,double> > lyrics; //lyrics[startime]=pair<lyric,endtime> std::string blank_response; }; class Node{ @@ -351,7 +351,7 @@ namespace Rotor { void create_signal_input(const string &_desc,const string &_title,Node* _connect=nullptr ) { inputs.push_back(new Signal_input(_desc,_title,_connect)); }; - void create_parameter(const string &_name,const string &_type,const string &_desc,const string &_title,float _value=1.0f,float _min=0.0f,float _max=0.0f,float _step=0.0f,Node* _connect=nullptr) { + void create_parameter(const string &_name,const string &_type,const string &_desc,const string &_title,double _value=1.0,double _min=0.0,double _max=0.0,double _step=0.0,Node* _connect=nullptr) { parameters[_name]=new Parameter(_type,_desc,_title,_value,_min,_max,_step,_connect); }; void create_attribute(const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={},std::string _type="string") { @@ -382,7 +382,7 @@ namespace Rotor { string UItype; bool duplicate_inputs; string find_setting(map<string,string> &settings,string key,string def=""){ if (settings.find(key)!=settings.end()) return settings[key]; else return def;}; - float find_setting(map<string,string> &settings,string key,float def){ if (settings.find(key)!=settings.end()) return toFloat(settings[key]); else return def;}; + double find_setting(map<string,string> &settings,string key,double def){ if (settings.find(key)!=settings.end()) return toFloat(settings[key]); else return def;}; int find_setting(map<string,string> &settings,string key,int def){ if (settings.find(key)!=settings.end()) return toInt(settings[key]); else return def;}; void base_settings(map<string,string> &settings) { description=find_setting(settings,"description"); @@ -397,8 +397,8 @@ namespace Rotor { } for (auto p: parameters){ if (find_setting(settings,p.first,"")!="") { - parameters[p.first]->init(find_setting(settings,p.first,0.0f)); - cerr<<"setting parameter '"<<p.first<<"' to "<<find_setting(settings,p.first,0.0f)<<endl; + parameters[p.first]->init(find_setting(settings,p.first,0.0)); + cerr<<"setting parameter '"<<p.first<<"' to "<<find_setting(settings,p.first,0.0)<<endl; } } } @@ -412,7 +412,7 @@ namespace Rotor { if (parameters.find(key)!=parameters.end()) parameters[key]->value=toFloat(value); }; void reset(){ - time_taken=0.0f; + time_taken=0.0; int(); } void time_frame(){ @@ -420,26 +420,26 @@ namespace Rotor { gettimeofday(&end_time, NULL); time_taken+=((end_time.tv_sec-frame_time.tv_sec) + (end_time.tv_usec-frame_time.tv_usec)/1000000.0); } - virtual float get_time_used()=0; - float time_taken; + virtual double get_time_used()=0; + double time_taken; protected: struct timeval frame_time; }; class Signal_node: public Node{ public: virtual ~Signal_node(){}; - const float get_output(const Time_spec &time) { + const double get_output(const Time_spec &time) { update(time); - float o=output(time); + double o=output(time); time_frame(); return o; }; - const float get_time_for_value(const float &value) { - return 0.0f; + const double get_time_for_value(const double &value) { + return 0.0; }; - virtual const float output(const Time_spec &time) { return 0.0f; }; - float get_time_used(){ - float t=time_taken; + virtual const double output(const Time_spec &time) { return 0.0; }; + double get_time_used(){ + double t=time_taken; for (auto i:inputs) t-=i->get_time_taken(); for (auto p:parameters) t-=p.second->get_time_taken(); return t; @@ -467,8 +467,8 @@ namespace Rotor { image.clear(); } Image image; - float get_time_used(){ - float t=time_taken; + double get_time_used(){ + double t=time_taken; for (auto i:inputs) t-=i->get_time_taken(); for (auto p:parameters) t-=p.second->get_time_taken(); for (auto i:image_inputs) t-=i->get_time_taken(); @@ -476,7 +476,7 @@ namespace Rotor { } private: - float image_time; //? could be used to detect image reuse? + double image_time; //? could be used to detect image reuse? }; class LUT { @@ -484,13 +484,13 @@ namespace Rotor { lut=nullptr; }; ~LUT(){if (lut) { delete[] lut;} }; - void generate(float black_in,float white_in,float black_out,float white_out,float gamma){ + void generate(double black_in,double white_in,double black_out,double white_out,double gamma){ //can check here if anything has changed if (lut) delete[] lut; lut=new unsigned char[256]; - float fltmax=(255.0f/256.0f); + double fltmax=(255.0/256.0); for (int i=0;i<256;i++){ - lut[i]=(unsigned char)(((pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-black_in)/(white_in-black_in)))),(1.0/gamma))*(white_out-black_out))+black_out)*255.0f); + lut[i]=(unsigned char)(((pow(min(fltmax,max((double)0.0,(((((double)i)/256.0)-black_in)/(white_in-black_in)))),(1.0/gamma))*(white_out-black_out))+black_out)*255.0); } } void apply(const cv::Mat& in,cv::Mat &out){ //facility to apply to other images for inherited classes @@ -551,7 +551,7 @@ namespace Rotor { create_attribute("mode","Cycling mode","Mode","cut",{"cut","mix","screen","multiply","alpha","wrap","xor","overlay","min","max"}); create_attribute("length_mode","Transition length mode","Length mode","fraction",{"seconds","fraction"}); create_attribute("time_mode","Time mode","time mode","absolute",{"absolute","relative"}); - create_parameter("transition_length","number","transition length","Transition length",1.0f,0.0f,0.0f); + create_parameter("transition_length","number","transition length","Transition length",1.0,0.0,0.0); title="Video cycler"; description="Cycles through video inputs according to selector signal"; duplicate_inputs=true; @@ -564,15 +564,15 @@ namespace Rotor { bool load(const string &filename); void init(){ segment=0; - segment_start=0.0f; - prevseg_start=0.0f; + segment_start=0.0; + prevseg_start=0.0; lastframe=0; } Image *output(const Frame_spec &frame){ //work out timing //can this be a general purpose function of node - float ph=inputs[0]->get((Time_spec)frame); + double ph=inputs[0]->get((Time_spec)frame); int seg=((int)ph); int thisframe=((Time_spec)frame).frame(); if(thisframe==lastframe||thisframe==lastframe+1){ @@ -594,7 +594,7 @@ namespace Rotor { } else { if (thisframe==0){ - segment_start=0.0f; + segment_start=0.0; segment=seg; } else { @@ -625,12 +625,12 @@ namespace Rotor { } } lastframe=thisframe; - //float start_time=(((Time_spec)frame).time-segment_start); - //float end_time=(((Time_spec)frame).time-segment_end); + //double start_time=(((Time_spec)frame).time-segment_start); + //double end_time=(((Time_spec)frame).time-segment_end); - float in_time=(((Time_spec)frame).time-segment_start); + double in_time=(((Time_spec)frame).time-segment_start); //time in seconds for the incoming sequence: starts at 0 - float out_time=(((Time_spec)frame).time-prevseg_start); + double out_time=(((Time_spec)frame).time-prevseg_start); //time in seconds for the outgoing sequence: //starts at how many seconds the outgoing has got to //so we need the previous segmente duration @@ -660,29 +660,29 @@ namespace Rotor { int im1=seg%image_inputs.size(); int im2=prevseg%image_inputs.size(); - float f; + double f; switch (attributes["length_mode"]->intVal){ case CYCLER_seconds: - f=min(1.0f,in_time/parameters["transition_length"]->value); + f=min(1.0,in_time/parameters["transition_length"]->value); break; case CYCLER_fraction: - f=min(1.0f,(in_time/(segment_end-segment_start))/parameters["transition_length"]->value); + f=min(1.0,(in_time/(segment_end-segment_start))/parameters["transition_length"]->value); break; } - //cerr<<f<<" of input "<<(seg%image_inputs.size())<<" & "<<(1.0f-f)<<" of input "<<(prevseg%image_inputs.size())<<endl; + //cerr<<f<<" of input "<<(seg%image_inputs.size())<<" & "<<(1.0-f)<<" of input "<<(prevseg%image_inputs.size())<<endl; Image *in1=image_inputs[im1]->get(attributes["time_mode"]->intVal==CYCLER_abs?frame:inframe); if (in1){ - if (f<1.0f) { + if (f<1.0) { Image *in2=image_inputs[im2]->get(attributes["time_mode"]->intVal==CYCLER_abs?frame:outframe); if (in2){ image=(*in1); image*=f; Image i2=(*in2); - i2*=(1.0f-f); + i2*=(1.0-f); switch(attributes["mode"]->intVal){ case CYCLER_screen: image+=i2; @@ -730,8 +730,8 @@ namespace Rotor { } Video_cycler* clone(map<string,string> &_settings) { return new Video_cycler(_settings);}; private: - float segment_start,segment_end; - float prevseg_start; + double segment_start,segment_end; + double prevseg_start; int segment,prevseg; int lastframe; }; @@ -743,11 +743,11 @@ namespace Rotor { public: Base_video(){ create_signal_input("playhead","Playhead"); - //floating point control of playback time + //doubleing point control of playback time //if signal is connected it overrides normal playback //time_mode dictates whether control is seconds, or duration - create_parameter("speed","number","video playback speed","Speed",1.0f,0.0f,0.0f); - create_parameter("framerate","number","framerate override","Frame rate",0.0f,0.0f,0.0f); + create_parameter("speed","number","video playback speed","Speed",1.0,0.0,0.0); + create_parameter("framerate","number","framerate override","Frame rate",0.0,0.0,0.0); create_attribute("frame_mode","frame mode","Frame mode","frame",{"frame","blend"}); create_attribute("time_mode","time mode","Time mode","play",{"play","stretch"}); create_attribute("media_id","media_id","media_id","media_id"); //for rotorW @@ -769,7 +769,7 @@ namespace Rotor { logger.error("libav::decoder failed to load "+filename); return false; } - bool get_frame(float wanted,const Frame_spec &frame){ + bool get_frame(double wanted,const Frame_spec &frame){ if (attributes["frame_mode"]->intVal==VIDEOFRAMES_blend){ if (((int)wanted)!=Base_video::lastframe){ //get a new pair of frames possibly by switching the next one @@ -788,13 +788,13 @@ namespace Rotor { in2=temp; lastframe=wanted; } - float amt=1.0f-(wanted-((int)wanted)); + double amt=1.0-(wanted-((int)wanted)); //cout<<"video loader time:"<<frame.time<<" frames "<<((int)wanted)<<" (x"<<amt<<"),"<<(((int)wanted+1)%max(1,player.get_number_frames()))<<endl; image=in1; image*=amt; //Image in2t=in2; //DOES NOT WORK, copies pointer by assignation in2t=in2; - in2t*=(1.0f-amt); + in2t*=(1.0-amt); image+=in2t; } else { @@ -813,29 +813,29 @@ namespace Rotor { } Image *output(const Frame_spec &frame){ if (isLoaded){ - float clipframerate=(parameters["framerate"]->value==0.0f?player.get_framerate():parameters["framerate"]->value); - float clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value; - float wanted=0.0f; + double clipframerate=(parameters["framerate"]->value==0.0?player.get_framerate():parameters["framerate"]->value); + double clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value; + double wanted=0.0; if (inputs[0]->connection) { //using playhead //should speed affect it? //if you want absolute control then you just want absolute control? switch (attributes["frame_mode"]->intVal){ case VIDEOTIME_play: - wanted=fmod(inputs[0]->get((Time_spec)frame)*frame.framerate*clipspeed,(float)player.get_number_frames()); + wanted=fmod(inputs[0]->get((Time_spec)frame)*frame.framerate*clipspeed,(double)player.get_number_frames()); break; case VIDEOTIME_stretch: - wanted=fmod(fmod(inputs[0]->get((Time_spec)frame),1.0f)*((float)player.get_number_frames())*clipspeed,(float)player.get_number_frames()); + wanted=fmod(fmod(inputs[0]->get((Time_spec)frame),1.0)*((double)player.get_number_frames())*clipspeed,(double)player.get_number_frames()); break; } } else { switch (attributes["frame_mode"]->intVal){ case VIDEOTIME_play: - wanted=fmod(frame.time*frame.framerate*clipspeed,(float)player.get_number_frames()); + wanted=fmod(frame.time*frame.framerate*clipspeed,(double)player.get_number_frames()); break; case VIDEOTIME_stretch: - wanted=fmod((frame.time/frame.duration)*((float)player.get_number_frames())*clipspeed,(float)player.get_number_frames()); + wanted=fmod((frame.time/frame.duration)*((double)player.get_number_frames())*clipspeed,(double)player.get_number_frames()); break; } } @@ -898,7 +898,7 @@ namespace Rotor { clip_loaded=-1; isLoaded=false; segment=0; - segment_start=0.0f; + segment_start=0.0; lastframe=0; }; Video_bank(map<string,string> &settings): Video_bank() { @@ -924,7 +924,7 @@ namespace Rotor { logger.error("libav::decoder failed to load "+filename); return false; } - bool get_frame(float wanted,const Frame_spec &frame){ + bool get_frame(double wanted,const Frame_spec &frame){ if (attributes["frame_mode"]->intVal==VIDEOFRAMES_blend){ if (((int)wanted)!=Base_video::lastframe){ //get a new pair of frames possibly by switching the next one @@ -943,13 +943,13 @@ namespace Rotor { in2=temp; lastframe=wanted; } - float amt=1.0f-(wanted-((int)wanted)); + double amt=1.0-(wanted-((int)wanted)); //cout<<"video loader time:"<<frame.time<<" frames "<<((int)wanted)<<" (x"<<amt<<"),"<<(((int)wanted+1)%max(1,player.get_number_frames()))<<endl; image=in1; image*=amt; //Image in2t=in2; //DOES NOT WORK, copies pointer by assignation in2t=in2; - in2t*=(1.0f-amt); + in2t*=(1.0-amt); image+=in2t; } else { @@ -982,7 +982,7 @@ namespace Rotor { return nullptr; } if (attributes["filenames"]->vals.size()){ - float ph=inputs[0]->get((Time_spec)frame); + double ph=inputs[0]->get((Time_spec)frame); int seg=((int)ph); int wv=seg%attributes["filenames"]->vals.size(); players.resize(attributes["filenames"]->vals.size()); @@ -998,10 +998,10 @@ namespace Rotor { //} } if (isLoaded){ - int wanted=0.0f; + int wanted=0.0; int thisframe=((Time_spec)frame).frame(); - float clipframerate=(parameters["framerate"]->value==0.0f?players[clip_loaded].get_framerate():parameters["framerate"]->value); - float clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value; + double clipframerate=(parameters["framerate"]->value==0.0?players[clip_loaded].get_framerate():parameters["framerate"]->value); + double clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value; switch (attributes["time_mode"]->intVal){ case VIDEOTIME_play: if(thisframe==lastframe||thisframe==lastframe+1){ @@ -1014,7 +1014,7 @@ namespace Rotor { } else { if (thisframe==0){ - segment_start=0.0f; + segment_start=0.0; segment=seg; } else { @@ -1045,7 +1045,7 @@ namespace Rotor { private: vector<libav::video_decoder> players; int clip_loaded; - float segment_start; + double segment_start; int segment; int lastframe; }; @@ -1058,7 +1058,7 @@ namespace Rotor { create_attribute("end_mode","mode to end movie","End mode","cut",{"cut","blank silence","fade peak"}); title="Video output"; description="Output to video"; - start_silence=start_peak=end_silence=end_peak=-1.0f; + start_silence=start_peak=end_silence=end_peak=-1.0; silence_threshold=0.01f; NODEID="693d2220-2d0a-11e3-9312-232908c3cc33"; }; @@ -1066,18 +1066,18 @@ namespace Rotor { base_settings(settings); }; ~Video_output(){ }; - void create_envelope(const vector<float> &audio){ + void create_envelope(const vector<double> &audio){ if (audio.size()){ uint32_t i=1; while (i<audio.size()&&audio[i]<silence_threshold) i++; - start_silence=((float)i)/audio.size(); + start_silence=((double)i)/audio.size(); while (i<audio.size()&&audio[i]>audio[i-1]) i++; - start_peak=((float)i-1)/audio.size(); + start_peak=((double)i-1)/audio.size(); i=audio.size(); while (i>0&&audio[i]<silence_threshold) i--; - end_silence=((float)i)/audio.size(); + end_silence=((double)i)/audio.size(); while (i<audio.size()&&audio[i]>audio[i+1]) i--; - end_peak=((float)i+1)/audio.size(); + end_peak=((double)i+1)/audio.size(); cerr<<"Video_output sound envelope: silence - "<<start_silence<<" : peak "<<start_peak<<" : peak "<<end_peak<<" silence - "<<end_silence<<endl; } else cerr<<"Video_output sound envelope: no data"<<endl; @@ -1087,11 +1087,11 @@ namespace Rotor { if (in){ //make copy of the image, for feedback //optimise? - float amount=1.0f; - float track_time=frame.time/frame.duration; + double amount=1.0; + double track_time=frame.time/frame.duration; if (attributes["begin_mode"]->value=="fade peak"||attributes["begin_mode"]->value=="blank silence"){ if (track_time<start_silence){ - amount=0.0f; + amount=0.0; } else if (track_time<start_peak&&attributes["begin_mode"]->value=="fade peak"&&start_peak>start_silence){ amount = (track_time-start_silence)/(start_peak-start_silence); @@ -1099,17 +1099,17 @@ namespace Rotor { } if (attributes["end_mode"]->value=="fade peak"||attributes["end_mode"]->value=="blank silence"){ if (track_time>end_silence){ - amount=0.0f; + amount=0.0; } else if (track_time>end_peak&&attributes["end_mode"]->value=="fade peak"&&end_silence>end_peak){ - amount = 1.0f-((track_time-end_peak)/(end_silence-end_peak)); + amount = 1.0-((track_time-end_peak)/(end_silence-end_peak)); } } - if (amount<(1.0f/256.0f)){ + if (amount<(1.0/256.0)){ image.clear(); } image=(*in); - if (amount<(255.0f/256.0f)){ + if (amount<(255.0/256.0)){ image*=amount; } //seems to be outputting correctly but not saving frames @@ -1120,11 +1120,11 @@ namespace Rotor { Video_output* clone(map<string,string> &_settings) { return new Video_output(_settings);}; private: - float silence_threshold; - float start_silence; - float start_peak; - float end_silence; - float end_peak; + double silence_threshold; + double start_silence; + double start_peak; + double end_silence; + double end_peak; }; class Video_feedback: public Image_node { public: diff --git a/rotord/src/tinyxml.h b/rotord/src/tinyxml.h index 7958de5..e61528c 100644 --- a/rotord/src/tinyxml.h +++ b/rotord/src/tinyxml.h @@ -992,11 +992,11 @@ public: /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). int QueryDoubleAttribute( const char* name, double* _value ) const; /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). - int QueryFloatAttribute( const char* name, float* _value ) const { + int QueryFloatAttribute( const char* name, double* _value ) const { double d; int result = QueryDoubleAttribute( name, &d ); if ( result == TIXML_SUCCESS ) { - *_value = (float)d; + *_value = (double)d; } return result; } diff --git a/rotord/src/utils.cpp b/rotord/src/utils.cpp index 53c79ee..a3f0f8a 100644 --- a/rotord/src/utils.cpp +++ b/rotord/src/utils.cpp @@ -2,27 +2,27 @@ using namespace std; -//float equality -bool fequal(const float u,const float v){ +//double equality +bool fequal(const double u,const double v){ if (abs(u-v)<FLOAT_THRESHOLD) return true; else return false; }; -bool fless_or_equal(const float u,const float v){ +bool fless_or_equal(const double u,const double v){ //v is less or equal to u if (u-v>-FLOAT_THRESHOLD) return true; else return false; }; -bool fgreater_or_equal(const float u,const float v){ +bool fgreater_or_equal(const double u,const double v){ //v is more or equal to u if (v-u>-FLOAT_THRESHOLD) return true; else return false; }; -bool fless(const float u,const float v){ +bool fless(const double u,const double v){ //v is less than u if (u-v>FLOAT_THRESHOLD) return true; else return false; }; -bool fgreater(const float u,const float v){ +bool fgreater(const double u,const double v){ //v is greater than u if (v-u>FLOAT_THRESHOLD) return true; else return false; @@ -73,13 +73,13 @@ char hexToChar(const string& charHexString) { } //---------------------------------------- -float hexToFloat(const string& floatHexString) { +double hexToFloat(const string& doubleHexString) { union intFloatUnion { int x; - float f; + double f; } myUnion; myUnion.x = 0; - istringstream cur(floatHexString); + istringstream cur(doubleHexString); cur >> hex >> myUnion.x; return myUnion.f; } @@ -106,9 +106,9 @@ string hexToString(const string& stringHexString) { } //---------------------------------------- -float toFloat(const string& floatString) { - float x = 0; - istringstream cur(floatString); +double toFloat(const string& doubleString) { + double x = 0; + istringstream cur(doubleString); cur >> x; return x; } diff --git a/rotord/src/utils.h b/rotord/src/utils.h index a36088b..61e2c42 100644 --- a/rotord/src/utils.h +++ b/rotord/src/utils.h @@ -11,12 +11,12 @@ #define FLOAT_THRESHOLD .001f -//float equality -bool fequal(const float u,const float v); -bool fless_or_equal(const float u,const float v); -bool fgreater_or_equal(const float u,const float v); -bool fless(const float u,const float v); -bool fgreater(const float u,const float v); +//double equality +bool fequal(const double u,const double v); +bool fless_or_equal(const double u,const double v); +bool fgreater_or_equal(const double u,const double v); +bool fless(const double u,const double v); +bool fgreater(const double u,const double v); //----------------------------------------with thanks to openframeworks @@ -86,12 +86,12 @@ std::string toHex(const char* value); int hexToInt(const std::string& intHexstring); char hexToChar(const std::string& charHexString); -float hexToFloat(const std::string& floatHexString); +double hexToFloat(const std::string& doubleHexString); std::string hexToString(const std::string& stringHexString); int toInt(const std::string& intString); char toChar(const std::string& charString); -float toFloat(const std::string& floatString); +double toFloat(const std::string& doubleString); bool toBool(const std::string& boolString); #endif diff --git a/rotord/src/vampHost.cpp b/rotord/src/vampHost.cpp index e2b1e63..3f18473 100644 --- a/rotord/src/vampHost.cpp +++ b/rotord/src/vampHost.cpp @@ -58,7 +58,7 @@ void vampHost::printFeatures(int frame, int sr, int output, -void vampHost::rotorGetFeatures(int frame, int sr, int output,Plugin::FeatureSet features, vector<float>& out, float& progress) +void vampHost::rotorGetFeatures(int frame, int sr, int output,Plugin::FeatureSet features, vector<double>& out, double& progress) { if (features[output].size()) { cout << "." << features[output].size(); @@ -84,7 +84,7 @@ void vampHost::rotorGetFeatures(int frame, int sr, int output,Plugin::FeatureSet -void vampHost::getTimestamps(int output,Plugin::FeatureSet features, vector<float>& out){ +void vampHost::getTimestamps(int output,Plugin::FeatureSet features, vector<double>& out){ /* vamp-simple-host qm-vamp-plugins:qm-tempotracker 01.wav @@ -118,14 +118,14 @@ void vampHost::getTimestamps(int output,Plugin::FeatureSet features, vector<floa 1 sec = 10^9 nanosec actually maybe this would be the way to go for rotor- avoiding rounding errors etc - for now - ideally will get a float representation + for now - ideally will get a double representation - features[output][i].values is a vector of floats + a description + features[output][i].values is a vector of doubles + a description WE DON'T CARE ABOUT ANYTHING <.01 seconds static long realTime2Frame(const RealTime &r, unsigned int sampleRate); - get a vector of floats out, using frames, presuming data has a timestamp + get a vector of doubles out, using frames, presuming data has a timestamp this is crashing with "Aborted (core dumped)" @@ -140,7 +140,7 @@ void vampHost::getTimestamps(int output,Plugin::FeatureSet features, vector<floa //}_ //else { for (unsigned int i = 0; i < features[output].size(); ++i) { - out.push_back( ((float)RealTime::realTime2Frame(features[output][i].timestamp, 1000))*.001f); + out.push_back( ((double)RealTime::realTime2Frame(features[output][i].timestamp, 1000))*.001f); cout << "feature found.\n"; } //} @@ -160,10 +160,10 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_ //libsndfile returns -1..1 for fp data bytes=(bits>>3); stride=channels*bytes; - scale=(1.0f/pow(2.0f,bits)); + scale=(1.0/pow(2.0,bits)); features.clear(); //in case of reuse - features[0.0f]=feature(); + features[0.0]=feature(); loader = PluginLoader::getInstance(); key = loader->composePluginKey(soname, id); @@ -307,7 +307,7 @@ void vampHost::Analyser::process_frame(uint8_t *data,int samples_in_frame){ //unsigned int this_val=0; // this_val+=data[(sample*stride)+(i*bytes)+j]<<((1-j)*8); //} - //plugbuf[i][in_block]=((float)((int16_t)this_val))*scale; + //plugbuf[i][in_block]=((double)((int16_t)this_val))*scale; plugbuf[i][in_block]=((float)_data[sample])*scale; } in_block++; @@ -323,14 +323,14 @@ void vampHost::Analyser::process_frame(uint8_t *data,int samples_in_frame){ Plugin::FeatureSet feat=plugin->process(plugbuf, rt); - float t; + double t; for (unsigned int i = 0; i < feat[outputNo].size(); ++i) { feature f; f.number=featureNo; f.values=feat[outputNo][i].values; //fix for plugins that don't set timestamp properly - t=((float)feat[outputNo][i].timestamp.sec)+(((float)feat[outputNo][i].timestamp.nsec)*.000000001); + t=((double)feat[outputNo][i].timestamp.sec)+(((double)feat[outputNo][i].timestamp.nsec)*.000000001); if (t<.01) t=((rt.sec)+(rt.nsec)*.000000001); features[t]=f; featureNo++; @@ -356,7 +356,7 @@ void vampHost::Analyser::cleanup(){ //process final block while(in_block<blockSize) { for (int i=0;i<channels;i++) { - plugbuf[i][in_block]=0.0f; + plugbuf[i][in_block]=0.0; } in_block++; } @@ -369,7 +369,7 @@ void vampHost::Analyser::cleanup(){ feature f; f.number=featureNo; f.values=feat[outputNo][i].values; - features[((float)feat[outputNo][i].timestamp.sec)+(((float)feat[outputNo][i].timestamp.nsec)*.000000001)]=f; + features[((double)feat[outputNo][i].timestamp.sec)+(((double)feat[outputNo][i].timestamp.nsec)*.000000001)]=f; featureNo++; } @@ -379,7 +379,7 @@ void vampHost::Analyser::cleanup(){ feature f; f.number=featureNo; f.values=feat[outputNo][i].values; - features[((float)feat[outputNo][i].timestamp.sec)+(((float)feat[outputNo][i].timestamp.nsec)*.000000001)]=f; + features[((double)feat[outputNo][i].timestamp.sec)+(((double)feat[outputNo][i].timestamp.nsec)*.000000001)]=f; featureNo++; } @@ -387,7 +387,7 @@ void vampHost::Analyser::cleanup(){ //feature f; //f.number=featureNo; //f.values={0}; - //features[((float)rt.sec)+(((float)rt.nsec)*.000000001f)]=f; + //features[((double)rt.sec)+(((double)rt.nsec)*.000000001f)]=f; //cerr<<plugin->getIdentifier()<<" found "<<(features.size()-1)<<" features"<<endl; //deal with left over data? @@ -397,20 +397,20 @@ void vampHost::Analyser::cleanup(){ delete[] plugbuf; delete plugin; } -float vampHost::Analyser::get_value(const float &time) { +double vampHost::Analyser::get_value(const double &time) { if (features.size()) { auto i=features.upper_bound(time); //the first element in the container whose key is considered to go after k if (i!=features.end()){ - float uk=i->first; - float v1,v2; - v1=v2=0.0f; + double uk=i->first; + double v1,v2; + v1=v2=0.0; if (i->second.values.size()) v2=i->second.values[0]; i--; - float lk=i->first; + double lk=i->first; if (i->second.values.size()) v1=i->second.values[0]; return ((((time-lk)/(uk-lk))*(v2-v1))+v1); } } - return 0.0f; + return 0.0; } diff --git a/rotord/src/vampHost.h b/rotord/src/vampHost.h index 856a2cc..e44e981 100644 --- a/rotord/src/vampHost.h +++ b/rotord/src/vampHost.h @@ -52,10 +52,10 @@ namespace vampHost { class QMAnalyser{ public: int process(const string soundfile); - float get_progress(); + double get_progress(); vector<float> beats; private: - float progress; + double progress; Poco::Mutex mutex; //lock for progress data }; class Analyser{ @@ -64,7 +64,7 @@ namespace vampHost { bool init(const string &soname,const string &id,const int &_channels,const int &_bits,const int &_samples,const int &_rate,int outputNo,const map<string,float> ¶ms); void process_frame(uint8_t *data,int samples_in_frame); void cleanup(); - float get_value(const float &time); + double get_value(const double &time); //map<double,int> features; map<float,feature> features; //map<time,featureNo> @@ -77,7 +77,7 @@ namespace vampHost { RealTime rt; int channels,bits,samples,rate; int bytes,stride; - float scale; + double scale; int blockSize,stepSize,overlapSize,finalStepsRemaining,currentStep,outputNo; int in_block,blocks_processed; string output; @@ -89,7 +89,7 @@ namespace vampHost { string getQMBeats(const string soundfile); void printFeatures(int, int, int, Plugin::FeatureSet, ostream &, bool frames); - void getTimestamps(int output,Plugin::FeatureSet features, vector<float>& out); - void rotorGetFeatures(int frame, int sr, int output,Plugin::FeatureSet features, vector<float>& out, float& progress); + void getTimestamps(int output,Plugin::FeatureSet features, vector<double>& out); + void rotorGetFeatures(int frame, int sr, int output,Plugin::FeatureSet features, vector<double>& out, double& progress); } |
