Fix [#36351] Changing the Frame Rate value doesnt adjust audio strip length.

Simply recalc sequence len for audio (and meta!) strips when modifying fps value. Note start, startofs and endofs are also updated, to try to keep final pos and length as consistent as possible.
This commit is contained in:
Bastien Montagne 2013-08-20 19:50:31 +00:00
parent e2534eac8e
commit aa10489a0d
3 changed files with 48 additions and 0 deletions

@ -318,6 +318,8 @@ void BKE_sequencer_update_sound_bounds(struct Scene *scene, struct Sequence *seq
void BKE_sequencer_update_muting(struct Editing *ed);
void BKE_sequencer_update_sound(struct Scene *scene, struct bSound *sound);
void BKE_sequencer_refresh_sound_length(struct Scene *scene);
void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
void BKE_sequence_base_dupli_recursive(struct Scene *scene, struct Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag);
bool BKE_sequence_is_valid_check(struct Sequence *seq);

@ -3677,6 +3677,50 @@ bool BKE_sequence_base_shuffle_time(ListBase *seqbasep, Scene *evil_scene)
return offset ? false : true;
}
/* Unlike _update_sound_ funcs, these ones take info from audaspace to update sequence length! */
#ifdef WITH_AUDASPACE
static bool sequencer_refresh_sound_length_recursive(Scene *scene, ListBase *seqbase) {
Sequence *seq;
bool changed = false;
for (seq = seqbase->first; seq; seq = seq->next) {
if (seq->type == SEQ_TYPE_META) {
if (sequencer_refresh_sound_length_recursive(scene, &seq->seqbase)) {
BKE_sequence_calc(scene, seq);
changed = true;
}
}
else if (seq->type == SEQ_TYPE_SOUND_RAM) {
AUD_SoundInfo info = AUD_getInfo(seq->sound->playback_handle);
int old = seq->len;
float fac;
seq->len = (int)ceil((double)info.length * FPS);
fac = (float)seq->len / (float)old;
old = seq->startofs;
seq->startofs *= fac;
seq->endofs *= fac;
seq->start += (old - seq->startofs); /* So that visual/"real" start frame does not change! */
BKE_sequence_calc(scene, seq);
changed = true;
}
}
return changed;
}
#endif
void BKE_sequencer_refresh_sound_length(Scene *scene)
{
#ifdef WITH_AUDASPACE
if (scene->ed) {
sequencer_refresh_sound_length_recursive(scene, &scene->ed->seqbase);
}
#else
(void)scene;
#endif
}
void BKE_sequencer_update_sound_bounds_all(Scene *scene)
{
Editing *ed = scene->ed;

@ -427,6 +427,8 @@ void sound_update_fps(struct Scene *scene)
{
if (scene->sound_scene)
AUD_setSequencerFPS(scene->sound_scene, FPS);
BKE_sequencer_refresh_sound_length(scene);
}
void sound_update_scene_listener(struct Scene *scene)