summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rotord/src/graph.cpp11
-rw-r--r--rotord/src/graph.h6
-rw-r--r--rotord/src/nodes_audio_analysis.cpp8
-rw-r--r--rotord/src/nodes_audio_analysis.h10
-rw-r--r--rotord/src/nodes_filters.h2
-rw-r--r--rotord/src/rendercontext.cpp4
-rw-r--r--rotord/src/rendercontext.h3
-rw-r--r--rotord/src/rotor.cpp2
-rw-r--r--rotord/src/rotor.h8
9 files changed, 30 insertions, 24 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp
index 0cc36de..2930953 100644
--- a/rotord/src/graph.cpp
+++ b/rotord/src/graph.cpp
@@ -60,7 +60,7 @@ bool Graph::preview(xmlIO &XML,string &node,string &_format,int frame,int w,int
}
if (dynamic_cast<Image_node*>(nodes[node])){
Frame_spec fs=Frame_spec(t,framerate,0.0f,w,h);
- Image *img=dynamic_cast<Image_node*>(nodes[node])->get_output(fs);
+ Image *img=dynamic_cast<Image_node*>(nodes[node])->get_image_output(fs);
vector<uchar> buf;
string format=(_format==""?".png":_format);
if (cv::imencode(format,img->rgb,buf)){ //, const vector<int>& params=vector<int>())
@@ -93,6 +93,11 @@ bool Graph::video_render(const string &output_filename,const float framerate) {
//}
if (find_node("video_output")) {
Video_output *video_output=dynamic_cast<Video_output*>(find_node("video_output"));
+
+ if (audio_filename!=""){ //BETTER WAY TO KNOW IF WE ARE USING AUDIO?
+ video_output->create_envelope(audio_thumb->audiodata);
+ }
+
for (auto f: find_nodes("video_feedback")){
(dynamic_cast<Video_feedback*>(f))->set_feedback(&(video_output->image));
}
@@ -199,9 +204,9 @@ bool Graph::video_render(const string &output_filename,const float framerate) {
Image* i;
if (usingaudio) {
- i=video_output->get_output(Frame_spec(vf,framerate,duration,outW,outH,a));
+ i=video_output->get_image_output(Frame_spec(vf,framerate,duration,outW,outH,a));
}
- else i=video_output->get_output(Frame_spec(vf,framerate,duration,outW,outH));
+ else i=video_output->get_image_output(Frame_spec(vf,framerate,duration,outW,outH));
if (i) {
exporter.encodeFrame(i->RGBdata);
}
diff --git a/rotord/src/graph.h b/rotord/src/graph.h
index cc531cd..60e61db 100644
--- a/rotord/src/graph.h
+++ b/rotord/src/graph.h
@@ -16,7 +16,7 @@ Graph is an instance of a rotor renderer
namespace Rotor {
class Graph{
public:
- Graph(){duration=20.0f;loaded = false;outW=640;outH=360;};
+ Graph(){duration=20.0f;loaded = false;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();};
Graph(const string& _uid,const string& _desc){
init(_uid,_desc);
audio_loaded=false;
@@ -29,7 +29,7 @@ namespace Rotor {
framerate=25.0f;
cancelled=false;
};
- ~Graph(){ clear(); };
+ ~Graph(){ clear(); delete audio_thumb;};
void clear(){
for (auto n: nodes) {
delete n.second;
@@ -72,6 +72,8 @@ namespace Rotor {
bool cancelled;
float progress;
int bitRate;
+
+ Audio_thumbnailer *audio_thumb;
private:
int outW,outH;
diff --git a/rotord/src/nodes_audio_analysis.cpp b/rotord/src/nodes_audio_analysis.cpp
index 154bf79..41ca3da 100644
--- a/rotord/src/nodes_audio_analysis.cpp
+++ b/rotord/src/nodes_audio_analysis.cpp
@@ -10,7 +10,6 @@ namespace Rotor{
offset=0x1<<(bits-1); //signed audio
scale=1.0f/offset;
- column=0; //point thumbnail bitmap
out_sample=0; //sample in whole track
sample=0;
samples=0;
@@ -24,7 +23,7 @@ namespace Rotor{
int bytes=(bits>>3);
int stride=channels*bytes;
int in_sample=0;
- while (in_sample<samples_in_frame&&column<width) {
+ while (in_sample<samples_in_frame) {
//continue the column
while (sample<samples_per_column&&in_sample<samples_in_frame) {
//accumulate samples for this column until we run out of samples
@@ -47,8 +46,7 @@ namespace Rotor{
//get root-mean
//why does valgrind complain here about uninitialised vars
double mean=pow(accum/samples,0.5f);
- vectordata[column]=mean;
- column++;
+ audiodata.push_back(mean);
sample=0;
samples=0;
accum=0.0;
@@ -60,7 +58,7 @@ namespace Rotor{
string vdata;
for (int i=0;i<width;i++){
if (i>0) vdata+=",";
- vdata+=toString(vectordata[i]);
+ vdata+=toString(audiodata[i]);
}
XML.addValue("data",vdata);
}
diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h
index bf55beb..c59fb0b 100644
--- a/rotord/src/nodes_audio_analysis.h
+++ b/rotord/src/nodes_audio_analysis.h
@@ -14,26 +14,22 @@ namespace Rotor {
Audio_thumbnailer(){
height=128;
width=512; //fit
- vectordata =new float[width];
//trying to reduce valgrind errors
- column=0; //point thumbnail bitmap
out_sample=0; //sample in whole track
sample=0;
samples=0;
accum=0.0;
};
- ~Audio_thumbnailer(){
- delete[] vectordata;
- };
+ ~Audio_thumbnailer(){};
Audio_thumbnailer* clone(map<string,string> &_settings) { return new Audio_thumbnailer();};
bool init(int _channels,int _bits,int _samples,int _rate);
void cleanup(){};
int process_frame(uint8_t *data,int samples_in_frame);
void print_vector(xmlIO XML);
- float *vectordata;
+ vector<float> audiodata;
int height,width,samples_per_column;
- int column,out_sample,sample,samples;
+ int out_sample,sample,samples;
int offset;
float scale,accum;
};
diff --git a/rotord/src/nodes_filters.h b/rotord/src/nodes_filters.h
index b96c78e..13f7a3e 100644
--- a/rotord/src/nodes_filters.h
+++ b/rotord/src/nodes_filters.h
@@ -196,7 +196,7 @@ namespace Rotor {
if (images.find(absframe)==images.end()){
images[absframe]=new Image(frame.w,frame.h);
Frame_spec wanted=Frame_spec(absframe,frame.framerate,frame.duration,frame.w,frame.h);
- apply_LUT(*(((Image_node*)image_inputs[0]->connection)->get_output(wanted)),*(images[absframe]));
+ apply_LUT(*(((Image_node*)image_inputs[0]->connection)->get_image_output(wanted)),*(images[absframe]));
}
if (fless(1.0f,parameters["fadeto"]->value)){
float amount=(((parameters["number"]->value-i)/parameters["number"]->value)*(1.0f-parameters["fadeto"]->value))+(1.0f-parameters["fadeto"]->value);
diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp
index 39cd8d2..e0a962c 100644
--- a/rotord/src/rendercontext.cpp
+++ b/rotord/src/rendercontext.cpp
@@ -17,7 +17,7 @@ void Render_context::runTask() {
if(cmd.task==ANALYSE_AUDIO) {
state=ANALYSING_AUDIO;
vector<Audio_processor*> processors;
- processors.push_back(audio_thumb);
+ processors.push_back(graph.audio_thumb);
for (auto a: graph.nodes) {
if (dynamic_cast<Audio_processor*>(a.second)){
processors.push_back(dynamic_cast<Audio_processor*>(a.second));
@@ -174,7 +174,7 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H
//for now
status=HTTPResponse::HTTP_OK;
XML.addValue("status","Audio ready");
- audio_thumb->print_vector(XML);
+ graph.audio_thumb->print_vector(XML);
//XML.addValue("audio",audio_thumb->print());
}
else {
diff --git a/rotord/src/rendercontext.h b/rotord/src/rendercontext.h
index 2c88510..8656df4 100644
--- a/rotord/src/rendercontext.h
+++ b/rotord/src/rendercontext.h
@@ -59,7 +59,6 @@ namespace Rotor {
//and low level interface onto the graph
public:
Render_context(const std::string& name): Task(name) {
- audio_thumb=new Audio_thumbnailer();
state=IDLE;
output_framerate=25.0f;
@@ -73,7 +72,7 @@ namespace Rotor {
else cerr<<"Rotor: settings.xml not found, using defaults"<<endl;
output_filename=graph_filename=graph_body="";
};
- ~Render_context(){delete audio_thumb;};
+ ~Render_context(){};
void runTask();
void add_queue(Session_task item);
void session_command(const Session_command& command,xmlIO& XML,Poco::Net::HTTPResponse::HTTPStatus& status);
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index d75b9ed..6c1c61e 100644
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -69,7 +69,7 @@ bool Image_input::connect(Node* source) {
}
Image* Image_input::get(const Frame_spec& time){ //gets input and updates variable
if (connection){
- return (((Image_node*)connection)->get_output(time));
+ return (((Image_node*)connection)->get_image_output(time));
}
else return nullptr;
}
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index d7480c2..6ab6bce 100644
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -243,7 +243,7 @@ namespace Rotor {
void create_image_input(const string &_title,const string &_desc,Node* _connect=nullptr) {
image_inputs.push_back(new Image_input(_desc,_title,_connect));
};
- Image *get_output(const Frame_spec &frame) {
+ Image *get_image_output(const Frame_spec &frame) {
image.setup(frame.w,frame.h);
update((Time_spec)frame);
return output(frame);
@@ -943,9 +943,12 @@ namespace Rotor {
int lastframe;
};
class Video_output: public Image_node {
+ //Video_output 'presents' the output movie. Aspect ratio, bars, fadein/fadeout would happen here
public:
Video_output(){
create_image_input("image to output","Image input");
+ create_attribute("begin_mode","mode to begin movie","Begin mode","cut",{"cut","blank silence","fade peak"});
+ create_attribute("end_mode","mode to end movie","End mode","cut",{"cut","blank silence","fade peak"});
title="Video output";
description="Output to video";
};
@@ -953,6 +956,9 @@ namespace Rotor {
base_settings(settings);
};
~Video_output(){ };
+ void create_envelope(const vector<float> &audiodata){
+
+ }
Image *output(const Frame_spec &frame){
Image *in=image_inputs[0]->get(frame);
if (in){