diff options
| author | Comment <tim@gray.(none)> | 2013-09-22 00:22:30 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-09-22 00:22:30 +0100 |
| commit | 6fac9b5e406d7be3fbfd67cb5d21272727f6043a (patch) | |
| tree | 71d61ae4dcbfdd3f231876307b1bc141a93f7845 /rotord | |
| parent | 47a4f30fc852f4d49df6df7b4974c7c4751107f3 (diff) | |
fade top and tail
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/rotor.h | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 6ab6bce..d6cbbc6 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -951,20 +951,57 @@ namespace Rotor { create_attribute("end_mode","mode to end movie","End mode","cut",{"cut","blank silence","fade peak"}); title="Video output"; description="Output to video"; + start_silence=start_peak=end_silence=end_peak=-1.0f; + silence_threshold=0.01f; }; Video_output(map<string,string> &settings):Video_output() { base_settings(settings); }; ~Video_output(){ }; - void create_envelope(const vector<float> &audiodata){ - + void create_envelope(const vector<float> &audio){ + int i=0; + while (i<audio.size()&&audio[i]<silence_threshold) i++; + start_silence=((float)i)/audio.size(); + while (i<audio.size()&&audio[i]>audio[i-1]) i++; + start_peak=((float)i-1)/audio.size(); + i=audio.size(); + while (i>-1&&audio[i]<silence_threshold) i--; + end_silence=((float)i)/audio.size(); + while (i<audio.size()&&audio[i]>audio[i+1]) i--; + end_peak=((float)i+1)/audio.size(); + cerr<<"Video_output sound envelope: silence - "<<start_silence<<" : peak "<<start_peak<<" : peak "<<end_peak<<" silence - "<<end_silence<<endl; } Image *output(const Frame_spec &frame){ Image *in=image_inputs[0]->get(frame); if (in){ //make copy of the image, for feedback //optimise? + float amount=1.0f; + float track_time=frame.time/frame.duration; + if (attributes["begin_mode"]->value=="fade peak"||attributes["begin_mode"]->value=="blank silence"){ + if (track_time<start_silence){ + amount=0.0f; + } + else if (track_time<start_peak&&attributes["begin_mode"]->value=="fade peak"){ + amount = (track_time-start_silence)/(start_peak-start_silence); + } + } + if (attributes["end_mode"]->value=="fade peak"||attributes["end_mode"]->value=="blank silence"){ + if (track_time>end_silence){ + amount=0.0f; + } + else if (track_time>end_peak&&attributes["end_mode"]->value=="fade peak"){ + amount = 1.0f-((track_time-end_peak)/(end_silence-end_peak)); + } + } + if (amount<(1.0f/254.0f)){ + image.clear(); + } image=(*in); + if (amount<1.0f){ + image*=amount; + } + //seems to be outputting correctly but not saving frames return ℑ } return nullptr; @@ -972,7 +1009,11 @@ namespace Rotor { Video_output* clone(map<string,string> &_settings) { return new Video_output(_settings);}; private: - + float silence_threshold; + float start_silence; + float start_peak; + float end_silence; + float end_peak; }; class Video_feedback: public Image_node { public: |
