diff options
| author | Comment <tim@gray.(none)> | 2013-10-01 02:28:24 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-10-01 02:28:24 +0100 |
| commit | 58222a5ad27e41c02b9700e16b6e31fa9b5be09c (patch) | |
| tree | ab55fc9e8cdc0fb488a8a89279cc1638e2953382 /rotord | |
| parent | 6bbe71d21f9ddf1af84d9a9e7d2dbf989ec921ce (diff) | |
sound envelope catch no data
Diffstat (limited to 'rotord')
| -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); |
