summaryrefslogtreecommitdiff
path: root/rotord/rotor.h
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-04-10 16:31:40 +0100
committerTim Redfern <tim@herge.(none)>2013-04-10 16:31:40 +0100
commita29217ecc368cdeee7e908fc7db3c717cc51fd70 (patch)
tree1f6447cfecc19c90a98ff86cb575ad7109371267 /rotord/rotor.h
parent6275e8f15b63f85c2206f0acb64023610c711f24 (diff)
signal and audio stuff working
Diffstat (limited to 'rotord/rotor.h')
-rwxr-xr-xrotord/rotor.h35
1 files changed, 22 insertions, 13 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h
index 7dbb18d..36ef0aa 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -139,7 +139,15 @@ namespace Rotor {
AVPacket packet;
};
-
+ class Time_spec{
+ public:
+ Time_spec(float _seconds,float _framerate){ seconds=_seconds; framerate=_framerate; };
+ float seconds;
+ float framerate;
+ const Time_spec lastframe(){
+ return Time_spec(seconds-(1.0f/framerate),framerate);
+ }
+ };
class Render_status{
public:
int id;
@@ -196,7 +204,7 @@ namespace Rotor {
};
class Signal_node: public Node{
public:
- virtual float get_output(const float &time) { return 0.0f; };
+ virtual float get_output(const Time_spec &time) { return 0.0f; };
/*{ //default is to pass through first input, if disconnected returns 0
cerr << "getting output for " << type << "," << ID << endl;
@@ -210,14 +218,14 @@ namespace Rotor {
class Image_node: public Node{
public:
vector<Image_input> image_inputs; //image node also has image inputs and outputs
- Image* get_output(float time){ //sample implementation
+ Image* get_output(const Time_spec &time){ //sample implementation
//do something with the inputs
//and then
return ((Image_node*)image_inputs[0].connection)->get_output(time);
}
- void get_preview(float time);
+ void get_preview(const Time_spec &time);
Image* image; //this can be privately allocated or just passed on as the node see fit
private:
float image_time;
@@ -243,15 +251,15 @@ namespace Rotor {
bool init(int _channels,int _bits,int _samples,int _rate);
void cleanup();
int process_frame(uint8_t *data,int samples_in_frame);
- float get_output(const float &time) {
+ float get_output(const Time_spec &time) {
if (analyser.features.size()) {
- auto i=analyser.features.lower_bound(time);
+ auto i=analyser.features.lower_bound(time.seconds);
if (i!=analyser.features.end()){
float lk=i->first;
int ln=i->second;
if (i++!=analyser.features.end()){
float uk=i->first;
- return (((time-lk)/(uk-lk))+ln);
+ return (((time.seconds-lk)/(uk-lk))+ln);
}
else return (float)ln;
}
@@ -273,7 +281,7 @@ namespace Rotor {
divide_amount=ofToFloat(check(settings,"amount"));
};
Signal_divide* clone(map<string,string> &_settings) { return new Signal_divide(_settings);};
- float get_output(const float &time) {
+ float get_output(const Time_spec &time) {
if (inputs[0]->connection) {
return (((Signal_node*)inputs[0]->connection)->get_output(time))/divide_amount;
}
@@ -282,7 +290,8 @@ namespace Rotor {
float divide_amount;
};
class Is_new_integer: public Signal_node {
- //does this require knowing what the framerate is?
+ //outputs a 1 every time a signal passes a new integer, otherwise a 0.
+ //this requires knowing what the framerate is? how to do this?
//for now, assume 25
//what to cache? for now, don't cache
public:
@@ -291,10 +300,10 @@ namespace Rotor {
base_settings(settings);
};
Is_new_integer* clone(map<string,string> &_settings) { return new Is_new_integer(_settings);};
- float get_output(const float &time) {
+ float get_output(const Time_spec &time) {
if (inputs[0]->connection) {
float s1=(((Signal_node*)(inputs[0]->connection))->get_output(time));
- float s2=(((Signal_node*)(inputs[0]->connection))->get_output(time-.04));
+ float s2=(((Signal_node*)(inputs[0]->connection))->get_output(time.lastframe()));
if (((int)s1)>((int)s2)) {
return 1.0f;
}
@@ -310,7 +319,7 @@ namespace Rotor {
};
Signal_output* clone(map<string,string> &_settings) { return new Signal_output(_settings);};
bool render(const float duration, const float framerate,string &xml_out);
- float get_output(const float &time) {
+ float get_output(const Time_spec &time) {
if (inputs[0]->connection) {
return ((Signal_node*)(inputs[0]->connection))->get_output(time);
}
@@ -369,11 +378,11 @@ namespace Rotor {
bool load(string &graph_filename);
UUID save(); //save to DB, returns UUID of saved graph
bool loaded;
+ float duration;
const string toString();
private:
Node_factory factory;
float framerate;
- float duration;
xmlIO xml;
};
class Audio_thumbnailer: public Base_audio_processor {