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=02a86dcf8b2f972ea23ed8111d512d0aeb31c5de;hb=HEAD;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/cinelerra/virtualaconsole.C b/cinelerra-5.1/cinelerra/virtualaconsole.C index 02a86dcf..fab1b6a7 100644 --- a/cinelerra-5.1/cinelerra/virtualaconsole.C +++ b/cinelerra-5.1/cinelerra/virtualaconsole.C @@ -196,60 +196,39 @@ 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; - - double *current_buffer = audio_out_packed[i]; + for( int i=0; iaudio_out[i]->get_data(); // Time stretch the fragment to the real_output size - if(renderengine->command->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(); + for( int i=0; i 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(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 ) { // 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 @@ -257,53 +236,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;