diff options
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/rotor.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index be6ecee..b95a7b0 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -983,17 +983,20 @@ namespace Rotor { }; ~Video_output(){ }; 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; + if (audio.size()){ + 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; + } + else cerr<<"Video_output sound envelope: no data"<<endl; } Image *output(const Frame_spec &frame){ Image *in=image_inputs[0]->get(frame); |
