1
0
Fork 0

Improve block splitting transport information

Don't do any recomputations at the start of the buffer, and also
recompute the bar positions and numbers.
This commit is contained in:
Robbert van der Helm 2022-04-08 23:10:38 +02:00
parent 8db35aaf9d
commit 52d7b47a24
2 changed files with 33 additions and 6 deletions

View file

@ -1349,8 +1349,11 @@ impl<P: ClapPlugin> Wrapper<P> {
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<P: ClapPlugin> Wrapper<P> {
// 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<P: ClapPlugin> Wrapper<P> {
}
}
// TODO: CLAP does not mention whether this is behind a flag or not
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

View file

@ -994,7 +994,10 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
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,8 +1011,17 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
if context.state & (1 << 11) != 0 {
// kBarPositionValid
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
transport.loop_range_beats =