- double asset_over_session = (double)source_samplerate /
- mwindow->edl->session->sample_rate;
- int64_t startsource = (int64_t)(((pixmap->pixmap_x - virtual_edit_x + x) *
- mwindow->edl->local_session->zoom_sample +
- edit->startsource) *
- asset_over_session);
-// just in case we get a numerical error
- if (startsource < 0) startsource = 0;
- int64_t length = (int64_t)(w *
- mwindow->edl->local_session->zoom_sample *
- asset_over_session);
- int64_t lengthindex = length / index_state->index_zoom * 2;
- int64_t startindex = startsource / index_state->index_zoom * 2;
-// length of index to read in floats
+ FloatAutos *speed_autos = !edit->track->has_speed() ? 0 :
+ (FloatAutos *)edit->track->automation->autos[AUTOMATION_SPEED];
+ double project_zoom = mwindow->edl->local_session->zoom_sample;
+ int64_t edit_position = (x + pixmap->pixmap_x - virtual_edit_x) * project_zoom;
+ int64_t start_position = edit->startsource;
+ start_position += !speed_autos ? edit_position :
+ speed_autos->automation_integral(edit->startproject, edit_position, PLAY_FORWARD);
+ int64_t end_position = edit->startsource;
+ edit_position = (x + w + pixmap->pixmap_x - virtual_edit_x) * project_zoom;
+ end_position += !speed_autos ? edit_position :
+ speed_autos->automation_integral(edit->startproject, edit_position, PLAY_FORWARD);
+ double session_sample_rate = mwindow->edl->session->sample_rate;
+ double asset_over_session = (double)indexable->get_sample_rate() / session_sample_rate;
+ int64_t start_source = start_position * asset_over_session;
+ if( start_source < 0 ) start_source = 0;
+ int64_t start_index = start_source / index_state->index_zoom;
+ int64_t end_source = end_position * asset_over_session;
+ if( end_source < 0 ) end_source = 0;
+ int64_t end_index = end_source / index_state->index_zoom;
+// start/length of index to read in floats
+ start_index *= 2; end_index *= 2;