Periodic access on the first sample & accurate for multi-channel sources

This commit is contained in:
Will Stott 2019-03-29 14:13:09 +00:00
parent 8dd11878ff
commit dba627a1b4

View file

@ -12,13 +12,14 @@ where
// TODO: handle the fact that the samples rate can change // TODO: handle the fact that the samples rate can change
// TODO: generally, just wrong // TODO: generally, just wrong
let update_ms = period.as_secs() as u32 * 1_000 + period.subsec_nanos() / 1_000_000; let update_ms = period.as_secs() as u32 * 1_000 + period.subsec_nanos() / 1_000_000;
let update_frequency = (update_ms * source.sample_rate()) / 1000; let sample_rate = source.sample_rate() * source.channels() as u32;
let update_frequency = (update_ms * sample_rate) / 1000;
PeriodicAccess { PeriodicAccess {
input: source, input: source,
modifier: modifier, modifier: modifier,
update_frequency: update_frequency, update_frequency: update_frequency,
samples_until_update: update_frequency, samples_until_update: 1,
} }
} }