summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rotord/src/nodes_drawing.h38
-rwxr-xr-xrotord/src/rotor.cpp7
2 files changed, 38 insertions, 7 deletions
diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h
index d6b7abe..3c26c9f 100644
--- a/rotord/src/nodes_drawing.h
+++ b/rotord/src/nodes_drawing.h
@@ -113,7 +113,31 @@ namespace Rotor {
private:
Colour colour;
};
- class Waves: public Draw_node {
+ class Audio_viz: public Draw_node {
+ public:
+ Audio_viz(){}
+ Audio_viz(map<string,string> &settings):Audio_viz() {
+ base_settings(settings);
+ };
+ ~Audio_viz(){};
+ Audio_viz* clone(map<string,string> &_settings) { return new Audio_viz(_settings);};
+ void vector_output(cairo_t * cr,const Frame_spec &frame){
+ if (audioactive){
+ if (!frame.audio){
+ cerr<<"Audio_viz: audio not found"<<endl;
+ audioactive=false;
+ }
+ }
+ if (frame.audio){
+ vector_audio_output(cr,frame);
+ audioactive=true;
+ }
+ }
+ virtual void vector_audio_output(cairo_t * cr,const Frame_spec &frame){};
+ private:
+ bool audioactive;
+ };
+ class Waves: public Audio_viz {
public:
Waves(){
title="Waves";
@@ -124,11 +148,15 @@ namespace Rotor {
};
~Waves(){};
Waves* clone(map<string,string> &_settings) { return new Waves(_settings);};
- void vector_output(cairo_t * cr,const Frame_spec &frame){
- if (frame.audio){
-
+ void vector_audio_output(cairo_t * cr,const Frame_spec &frame){
+ cairo_set_source_rgb(cr, 1.0,1.0,1.0);
+ cairo_save(cr); //not really even necessary?
+ cairo_translate(cr, 0, frame.h/2);
+ for (int i=0;i<frame.w;i++){
+ cairo_line_to(cr,i,(((int16_t)frame.audio->samples[i*frame.audio->channels])*frame.h)>>16);
}
- else cerr<<"error: visualisation audio not found"<<endl;
+ cairo_restore (cr); //not really even necessary?
+ cairo_stroke(cr);
}
private:
};
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index 6e0c790..0a1207b 100755
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -230,6 +230,7 @@ bool Video_output::render(const float duration, const float framerate,const stri
float af=0.0f;
int aoffs=0;
int audioend=0;
+ Audio_frame *a;
while (vf<duration){ //-vstep) {
uint16_t *audio=nullptr;
if (usingaudio) {
@@ -261,6 +262,7 @@ bool Video_output::render(const float duration, const float framerate,const stri
af+=exporter.get_audio_step();
aoffs+=exporter.get_audio_framesize();
}
+ a=new Audio_frame(audio,audioloader.codecContext->channels,samples_in_frame);
}
@@ -273,17 +275,18 @@ bool Video_output::render(const float duration, const float framerate,const stri
//Assertion ff_avcodec_locked failed at libavcodec/utils.c:2967
//cerr<<"videoloader: "<<vf<<" seconds, vstep "<<vstep<<" ,asking for frame "<<((int)((vf*framerate)+0.5))<<endl
+
Image* i;
if (usingaudio) {
- i=get_output(Frame_spec(vf,framerate,duration,outW,outH,&Audio_frame(audio,audioloader.codecContext->channels,samples_in_frame)));
+ i=get_output(Frame_spec(vf,framerate,duration,outW,outH,a));
}
else i=get_output(Frame_spec(vf,framerate,duration,outW,outH));
if (i) {
exporter.encodeFrame(i->RGBdata);
-
}
vf+=vstep;
progress=vf/duration;
+ if (usingaudio) {delete a;};
}
exporter.finishRecord();