X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fvirtualaconsole.C;h=4afc12f7f7b1d822b445a5be7984f2ce37ce2ed4;hb=120f82197b4bdfdad9a5a666d773b45a8064d049;hp=02a86dcf8b2f972ea23ed8111d512d0aeb31c5de;hpb=03fa86e6dc495f9444ae14dad401b1ad6de793fe;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/virtualaconsole.C b/cinelerra-5.1/cinelerra/virtualaconsole.C index 02a86dcf..4afc12f7 100644 --- a/cinelerra-5.1/cinelerra/virtualaconsole.C +++ b/cinelerra-5.1/cinelerra/virtualaconsole.C @@ -196,60 +196,40 @@ if(debug) printf("VirtualAConsole::process_buffer %d\n", __LINE__); !interrupt) { // speed parameters + float speed = renderengine->command->get_speed(); // length compensated for speed int real_output_len = 0; -// output sample - double sample; - int k; double *audio_out_packed[MAX_CHANNELS]; int audio_channels = renderengine->get_edl()->session->audio_channels; - for(int i = 0, j = 0; - i < audio_channels; - i++) - { - audio_out_packed[j++] = arender->audio_out[i]->get_data(); - } - for(int i = 0; - i < audio_channels; - i++) - { - int in, out; + for( int i=0; iaudio_out[i]->get_data(); + for( int i=0; icommand->get_speed() > 1) - { -// Number of samples in real output buffer for each to sample rendered. - int interpolate_len = (int)renderengine->command->get_speed(); - for(in = 0, out = 0; in < len; ) - { - sample = 0; - for(k = 0; k < interpolate_len; k++) - { - sample += current_buffer[in++]; - } - - sample /= renderengine->command->get_speed(); + if( speed > 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; current_buffer[out++] = sample; } real_output_len = out; } - else - if(renderengine->command->get_speed() < 1) - { -// number of samples to skip - int interpolate_len = (int)(1.0 / renderengine->command->get_speed()); - real_output_len = len * interpolate_len; - - for(in = len - 1, out = real_output_len - 1; in >= 0; ) - { - for(k = 0; k < interpolate_len; k++) - { - current_buffer[out--] = current_buffer[in]; - } - in--; + 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 @@ -257,53 +237,23 @@ if(debug) printf("VirtualAConsole::process_buffer %d\n", __LINE__); } // Wait until video is ready - if(arender->first_buffer) - { + if( arender->first_buffer ) { renderengine->first_frame_lock->lock("VirtualAConsole::process_buffer"); arender->first_buffer = 0; } - if(!renderengine->audio->get_interrupted()) - { + if( !renderengine->audio->get_interrupted() ) { renderengine->audio->write_buffer(audio_out_packed, audio_channels, real_output_len); } - if(renderengine->audio->get_interrupted()) interrupt = 1; + if( renderengine->audio->get_interrupted() ) + interrupt = 1; } -if(debug) printf("VirtualAConsole::process_buffer %d\n", __LINE__); - - - - - return result; } - - - - - - - - - - - - - - - - - - - - - - - int VirtualAConsole::init_rendering(int duplicate) { return 0;