From c2b62131b0e6984f8fea7f44e364ae5c886c211a Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 30 Jan 2014 18:13:45 +0000 Subject: making fragmenting exporter --- NT/src/nodes_audio_analysis.h | 9 ++++----- NT/src/rotor.h | 25 +++++++++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'NT/src') diff --git a/NT/src/nodes_audio_analysis.h b/NT/src/nodes_audio_analysis.h index 4542e19..aa4abeb 100644 --- a/NT/src/nodes_audio_analysis.h +++ b/NT/src/nodes_audio_analysis.h @@ -39,7 +39,6 @@ namespace Rotor { void cleanup(){}; int process_frame(uint8_t *data,int samples_in_frame); void print_vector(xmlIO XML); - const double get_output(const Frame_parameters &frame){return 0.0;}; vector audiodata; int height,width,samples_per_column; int out_sample,sample,samples; @@ -55,9 +54,9 @@ 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 double output(const Time_spec &time) { + const double& output(const Frame_parameters &frame) { if (features.size()) { - auto i=features.upper_bound(time.time); //the first element in the container whose key is considered to go after k + auto i=features.upper_bound(frame.time); //the first element in the container whose key is considered to go after k double uk; double v1,v2; v1=v2=0.0; @@ -74,11 +73,11 @@ namespace Rotor { if (i->second.values.size()) v1=i->second.values[0]; switch (attributes["mode"]->intVal){ case VAMPHOST_Timeline: - return (((time.time-lk)/(uk-lk))+ln); + return (((frame.time-lk)/(uk-lk))+ln); case VAMPHOST_Timesteps: return (double)ln; case VAMPHOST_Valueline: - return ((time.time-lk)/(uk-lk))+v1; //((((time.time-lk)/(uk-lk))*(v2-v1))+v1); + return ((frame.time-lk)/(uk-lk))+v1; //((((time.time-lk)/(uk-lk))*(v2-v1))+v1); case VAMPHOST_Values: return v1; } diff --git a/NT/src/rotor.h b/NT/src/rotor.h index 1ed02dc..d2d7d00 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -78,11 +78,22 @@ struct TypeName { + + namespace Rotor { class Node; template class Node_type; + class Enum{ + //enumerated string type for menus + public: + Enum(std::initializer_list init) : labels(init){}; + private: + std::vector labels; + int value; + }; + class Audio_frame{ public: Audio_frame(uint16_t *_samples,int _channels,int _numsamples){ @@ -117,9 +128,7 @@ namespace Rotor { }; class Variable { //pure virtual base type for variable pointers public: - Variable(){ - connection=nullptr; - }; + Variable():name(""),description(""),title(""),connection(nullptr){}; virtual ~Variable(){}; virtual Json::Value to_json()=0; virtual void init(Json::Value s)=0; @@ -133,7 +142,7 @@ namespace Rotor { std::string get_connection_id(); std::string get_name(); protected: - std::string name; + std::string name,description,title; Node* connection; bool connectable; std::string input; @@ -300,7 +309,7 @@ namespace Rotor { }; template class Node_type : public Node { public: - virtual const NT& get_output(const Frame_parameters &frame)=0; + virtual const NT& get_output(const Frame_parameters &frame){return value;}; void init(Json::Value settings){ if (!settings["vars"].empty()){ for ( uint32_t i = 0; i < settings["vars"].size(); ++i ) { @@ -316,7 +325,7 @@ namespace Rotor { vars[name]=new Variable_type(name,"",true); return (dynamic_cast*>(vars[name])); } - template Variable_type* create_attribute(std::string name){ + template Variable_type* create_attribute(std::string name="",std::string description="",std::string title="",IT _default=IT()){ vars[name]=new Variable_type(name,"",false); return (dynamic_cast*>(vars[name])); } @@ -324,6 +333,10 @@ namespace Rotor { vars[name]=new Variable_array_type(name); return (dynamic_cast*>(vars[name])); } + //enum will require specialisation + //1st, define the enum data type + protected: + NT value; //every node has a value so it can return a reference }; } -- cgit v1.2.3