X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fvirtualaconsole.C;h=fab1b6a7599338b00aad8e2664947b2fdab2c680;hp=4afc12f7f7b1d822b445a5be7984f2ce37ce2ed4;hb=HEAD;hpb=120f82197b4bdfdad9a5a666d773b45a8064d049 diff --git a/cinelerra-5.1/cinelerra/virtualaconsole.C b/cinelerra-5.1/cinelerra/virtualaconsole.C index 4afc12f7..fab1b6a7 100644 --- a/cinelerra-5.1/cinelerra/virtualaconsole.C +++ b/cinelerra-5.1/cinelerra/virtualaconsole.C @@ -205,31 +205,30 @@ if(debug) printf("VirtualAConsole::process_buffer %d\n", __LINE__); for( int i=0; iaudio_out[i]->get_data(); +// Time stretch the fragment to the real_output size for( int i=0; i 1 ) { - int out = 0; - for( int in=0; in len ) end = len; - int k = end - in; - double sample = 0; - while( in < end ) sample += current_buffer[in++]; - if( k > 0 ) sample /= k; + if( speed > 1 ) { // buffer gets shorter + int in = 0, out = 0; + while( in < len ) { + int next = (out+1) * speed; + if( next > len) next = len; + double sample = current_buffer[in]; + for( int i=in; ++i 1 ) sample /= l; current_buffer[out++] = sample; + in = next; } real_output_len = out; } - else if( speed < 1 ) { - int end = len / speed; - real_output_len = end; - for( int in=len, out=end; --in>=0; ) { -// samples rendered in real output buffer sample. - int start = in / speed; - double v = current_buffer[in]; - while( --out >= start ) current_buffer[out] = v; + else if( speed < 1 ) { // buffer gets longer + real_output_len = len / speed; + int in = len, out = real_output_len; + while( in > 0 && out > 0 ) { + double sample = current_buffer[--in]; + int next = in / speed; + while( out > next ) current_buffer[--out] = sample; } } else