From 3d7eea02aa7a155b84c8c74ecbfd55a1941a9297 Mon Sep 17 00:00:00 2001 From: Comment Date: Fri, 26 Jul 2013 22:46:00 +0100 Subject: tidy files --- rotord/rotor.cpp | 361 ------------------------------------------------------- 1 file changed, 361 deletions(-) delete mode 100755 rotord/rotor.cpp (limited to 'rotord/rotor.cpp') diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp deleted file mode 100755 index 8b72c50..0000000 --- a/rotord/rotor.cpp +++ /dev/null @@ -1,361 +0,0 @@ -#include "rotor.h" -#include "nodes_audio_analysis.h" -#include "nodes_drawing.h" - -using namespace Rotor; -Node_factory::Node_factory(){ - //for now, statically load prototype map in constructor - add_type("audio_analysis",new Audio_analysis()); - add_type("divide",new Signal_divide()); - add_type("bang",new Is_new_integer()); - add_type("signal_output",new Signal_output()); - add_type("testcard",new Testcard()); - add_type("video_output",new Video_output()); - add_type("video_loader",new Video_loader()); - add_type("on_off",new On_off()); - add_type("invert",new Invert()); - add_type("video_cycler",new Video_cycler()); - add_type("luma_levels",new Luma_levels()); - add_type("echo_trails",new Echo_trails()); - add_type("time",new Time()); - add_type("track_time",new Track_time()); - add_type("comparison",new Comparison()); //TODO: alias to symbols - add_type("arithmetic",new Arithmetic()); //TODO: alias to symbols - add_type("signal_colour",new Signal_colour()); - add_type("signal_greyscale",new Signal_greyscale()); - add_type("image_arithmetic",new Image_arithmetic()); - add_type("random",new Random()); - add_type("blend",new Blend()); - add_type("mirror",new Mirror()); - add_type("monochrome",new Monochrome()); - add_type("transform",new Transform()); - add_type("alpha_merge",new Alpha_merge()); - add_type("draw",new Draw()); -} - -bool Signal_input::connect(Signal_node* source) { - if (source->output_type=="signal") { - connection=(Node*)source; - return true; - } - else return false; -} -void Parameter_input::update(const Time_spec& time){ //gets input and updates variable - if (receiver){ - *receiver=((Signal_node*)connection)->get_output(time); - } -} -bool Image_input::connect(Image_node* source) { - if (source->output_type=="image") { - connection=(Node*)source; - return true; - } - else return false; -} -void Node::update_params(const Time_spec& time){ //compute connected parameters - for (auto p:parameter_inputs){ - p->update(time); - } -} -bool Signal_output::render(const float duration, const float framerate,string &xml_out){ - //testing signal routes - cerr << "Rotor: Signal_output rendering " << duration << " seconds at " << framerate << " frames per second" << endl; - float step=1.0f/framerate; - float v=0.0f; - float min=10000000.0f; - float max=-10000000.0f; - for (float f=0.0f;f"+ofToString(u)+"\n"); - v=u; - if (v>max) max=v; - if (v\n"); - return true; -} - -bool Audio_thumbnailer::init(int _channels,int _bits,int _samples,int _rate) { - //base_audio_processor::init(_channels,_bits,_samples); - channels=_channels; - bits=_bits; - samples=_samples; - samples_per_column=samples/width; - column=0; //point thumbnail bitmap - out_sample=0; //sample in whole track - offset=0x1<<(bits-1); //signed audio - scale=1.0/offset; - sample=0; - samples=0; - accum=0.0; - return true; -} -int Audio_thumbnailer::process_frame(uint8_t *_data,int samples_in_frame){ - //begin by processing remaining samples - //samples per column could be larger than a frame! (probably is) - //but all we are doing is averaging - int bytes=(bits>>3); - int stride=channels*bytes; - int in_sample=0; - while (in_sample>1; - for (int i=0;iwrite((char*)data,width*height); - //tring output; - /* - for (int j=0;jclose(); - delete enc; - return output.str(); -} -bool Audio_analysis::init(int _channels,int _bits,int _samples, int _rate) { - //need these to make sense of data - channels=_channels; - bits=_bits; - samples=_samples; - - return analyser.init(soname,id,_channels,_bits,_samples,_rate,outputNo,params); - - - //attempt to load vamp plugin and prepare to receive frames of data - //should the audio analysis contain a vamphost or should it inherit? - //maybe neater to contain it in terms of headers etc - -} -int Audio_analysis::process_frame(uint8_t *data,int samples_in_frame) { - analyser.process_frame(data,samples_in_frame); - return 1; -} -void Audio_analysis::cleanup() { - analyser.cleanup(); - //print_features(); -} -void Audio_analysis::print_features(){ - for (auto i: analyser.features) { - cerr<<" ["<RGBdata); - - } - vf+=vstep; - progress=vf/duration; - } - - exporter.finishRecord(); - - gettimeofday(&end, NULL); - - float mtime = ((end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0) + 0.5; - - printf("Rotor Video_output: rendered in %02f seconds\n", mtime); - - if (usingaudio) audioloader.close(); - - return true; - } - } - - return false; -} - -bool Video_loader::load(const string &filename){ - /* - //gstreamer needs absolute paths ALWAYS - //string uri="file:///home/tim/workspace/rotor/rotord/"+filename; - Poco::Path path; - string uri="file://"+path.current()+filename; - //cerr << "video input: loading "<loadMovie(uri)){ - player->play(); - player->setPaused(true); - player->setFrameByFrame(true); - player->update(); - cerr<<"Rotor::Video_loader: "<getDuration()<<" seconds "<<", "<getWidth()<<"x"<getHeight()<setup_fromRGB(player->getWidth(),player->getHeight(),(uint8_t*) player->getPixels()); - return true; - } - */ - if (isLoaded) { - player.cleanup(); ///should be in decoder class? - isLoaded=false; - } - Poco::Path path; - string uri="file://"+filename; - isLoaded=player.open(uri); - if (isLoaded){ - cerr<<"Rotor::Video_loader: "<isLoaded()){ - //player->setPosition(frame.time); - int wanted=((int) (frame.time*frame.framerate))%(player->getTotalNumFrames()-2); //-2?? - player->setFrame(wanted); - //while (player->getCurrentFrame()!=wanted){ - // cerr << "seeking to "<getCurrentFrame()<setFrame(wanted); - //player->update(); - // sleep(.001); - //} - player->update(); - image->RGBdata=player->getPixels(); //don't really know why this is needed every frame - //cerr<<"Video_loader: retrieving frame "<<((int) (frame.time*frame.framerate))<0) return ℑ //just return the previous frame if possible - else return nullptr; - }; - //cerr<<"Video_loader: setting up frame: lineoffset="<<(player.pFrameRGB->linesize[0]-(frame.w*3))<data[0],player.pFrameRGB->linesize[0]-(frame.w*3)); - return ℑ - } - - //confusingly, crashes with files not made with short files? - //seems to be on last frame? - returns nullptr - still tries to clone? - //can't really return 1st frame instead, should get # of frames right 1st? - //think about what echo trails does on the last frame - - return nullptr; -}; -- cgit v1.2.3