!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; i<audio_channels; ++i )
+ audio_out_packed[i] = arender->audio_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<audio_channels; ++i ) {
+ double *current_buffer = audio_out_packed[i];
+ 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<next; ) sample += current_buffer[i];
+ int l = next - in;
+ if( l > 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
}
// 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;