diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 2e10abf9..91742b35 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -1349,8 +1349,11 @@ impl Wrapper

{ if context.flags & CLAP_TRANSPORT_HAS_BEATS_TIMELINE != 0 { let beats = context.song_pos_beats as f64 / CLAP_BEATTIME_FACTOR as f64; - // This is a bit messy, but we'll try to compensate for the block splitting + // This is a bit messy, but we'll try to compensate for the block splitting. + // We can't use the functions on the transport information object for this + // because we don't have any sample information. if P::SAMPLE_ACCURATE_AUTOMATION + && block_start > 0 && (context.flags & CLAP_TRANSPORT_HAS_TEMPO != 0) { transport.pos_beats = Some( @@ -1367,6 +1370,7 @@ impl Wrapper

{ // Same here if P::SAMPLE_ACCURATE_AUTOMATION + && block_start > 0 && (context.flags & CLAP_TRANSPORT_HAS_TEMPO != 0) { transport.pos_seconds = @@ -1376,9 +1380,20 @@ impl Wrapper

{ } } // TODO: CLAP does not mention whether this is behind a flag or not - transport.bar_start_pos_beats = - Some(context.bar_start as f64 / CLAP_BEATTIME_FACTOR as f64); - transport.bar_number = Some(context.bar_number); + if P::SAMPLE_ACCURATE_AUTOMATION && block_start > 0 { + transport.bar_start_pos_beats = match transport.bar_start_pos_beats() { + Some(updated) => Some(updated), + None => Some(context.bar_start as f64 / CLAP_BEATTIME_FACTOR as f64), + }; + transport.bar_number = match transport.bar_number() { + Some(updated) => Some(updated), + None => Some(context.bar_number), + }; + } else { + transport.bar_start_pos_beats = + Some(context.bar_start as f64 / CLAP_BEATTIME_FACTOR as f64); + transport.bar_number = Some(context.bar_number); + } // TODO: They also aren't very clear about this, but presumably if the loop is // active and the corresponding song transport information is available then // this is also available diff --git a/src/wrapper/vst3/wrapper.rs b/src/wrapper/vst3/wrapper.rs index 04cab378..d44dedd5 100644 --- a/src/wrapper/vst3/wrapper.rs +++ b/src/wrapper/vst3/wrapper.rs @@ -994,7 +994,10 @@ impl IAudioProcessor for Wrapper

{ Some(context.project_time_samples + block_start as i64); if context.state & (1 << 9) != 0 { // kProjectTimeMusicValid - if P::SAMPLE_ACCURATE_AUTOMATION && (context.state & (1 << 10) != 0) { + if P::SAMPLE_ACCURATE_AUTOMATION + && block_start > 0 + && (context.state & (1 << 10) != 0) + { // kTempoValid transport.pos_beats = Some( context.project_time_music @@ -1008,7 +1011,16 @@ impl IAudioProcessor for Wrapper

{ if context.state & (1 << 11) != 0 { // kBarPositionValid - transport.bar_start_pos_beats = Some(context.bar_position_music); + if P::SAMPLE_ACCURATE_AUTOMATION && block_start > 0 { + // The transport object knows how to recompute this from the other information + transport.bar_start_pos_beats = + match transport.bar_start_pos_beats() { + Some(updated) => Some(updated), + None => Some(context.bar_position_music), + }; + } else { + transport.bar_start_pos_beats = Some(context.bar_position_music); + } } if context.state & (1 << 2) != 0 && context.state & (1 << 12) != 0 { // kCycleActive && kCycleValid