Rename Buffer::len() to Buffer::samples()
To reduce ambiguity.
This commit is contained in:
parent
9e1a888b38
commit
cb827d18dd
|
@ -6,6 +6,11 @@ new and what's changed, this document lists all breaking changes in reverse
|
|||
chronological order. If a new feature did not require any changes to existing
|
||||
code then it will not be listed here.
|
||||
|
||||
## [2023-01-05]
|
||||
|
||||
- `Buffer::len()` has been renamed to `Buffer::samples()` to make this less
|
||||
ambiguous.
|
||||
|
||||
## [2022-11-17]
|
||||
|
||||
- The `Params` derive macro now also properly supports persistent fields in
|
||||
|
|
|
@ -311,7 +311,7 @@ impl Crossover {
|
|||
fn process_fir(&mut self, buffer: &mut Buffer, aux: &mut AuxiliaryBuffers) {
|
||||
// In theory we could do smoothing in between processed blocks, but this hsould be fine
|
||||
if self.should_update_filters() {
|
||||
self.update_filters(buffer.len() as u32);
|
||||
self.update_filters(buffer.samples() as u32);
|
||||
}
|
||||
|
||||
let aux_outputs = &mut aux.outputs;
|
||||
|
|
|
@ -183,7 +183,7 @@ impl Plugin for PolyModSynth {
|
|||
// num_remaining_samples, next_event_idx - block_start_idx)`. Because blocks also need to be
|
||||
// split on note events, it's easier to work with raw audio here and to do the splitting by
|
||||
// hand.
|
||||
let num_samples = buffer.len();
|
||||
let num_samples = buffer.samples();
|
||||
let sample_rate = context.transport().sample_rate;
|
||||
let output = buffer.as_slice();
|
||||
|
||||
|
|
|
@ -84,10 +84,12 @@ impl DryWetMixer {
|
|||
|
||||
assert_eq!(buffer.channels(), self.delay_line.len());
|
||||
let delay_line_len = self.delay_line[0].len();
|
||||
assert!(buffer.len() <= delay_line_len);
|
||||
assert!(buffer.samples() <= delay_line_len);
|
||||
|
||||
let num_samples_before_wrap = buffer.len().min(delay_line_len - self.next_write_position);
|
||||
let num_samples_after_wrap = buffer.len() - num_samples_before_wrap;
|
||||
let num_samples_before_wrap = buffer
|
||||
.samples()
|
||||
.min(delay_line_len - self.next_write_position);
|
||||
let num_samples_after_wrap = buffer.samples() - num_samples_before_wrap;
|
||||
|
||||
for (buffer_channel, delay_line) in buffer
|
||||
.as_slice_immutable()
|
||||
|
@ -101,7 +103,7 @@ impl DryWetMixer {
|
|||
.copy_from_slice(&buffer_channel[num_samples_before_wrap..]);
|
||||
}
|
||||
|
||||
self.next_write_position = (self.next_write_position + buffer.len()) % delay_line_len;
|
||||
self.next_write_position = (self.next_write_position + buffer.samples()) % delay_line_len;
|
||||
}
|
||||
|
||||
/// Mix the dry signal into the buffer. The ratio is a `[0, 1]` integer where 0 results in an
|
||||
|
@ -134,12 +136,13 @@ impl DryWetMixer {
|
|||
|
||||
assert_eq!(buffer.channels(), self.delay_line.len());
|
||||
let delay_line_len = self.delay_line[0].len();
|
||||
assert!(buffer.len() + latency <= delay_line_len);
|
||||
assert!(buffer.samples() + latency <= delay_line_len);
|
||||
|
||||
let read_position =
|
||||
(self.next_write_position + delay_line_len - buffer.len() - latency) % delay_line_len;
|
||||
let num_samples_before_wrap = buffer.len().min(delay_line_len - read_position);
|
||||
let num_samples_after_wrap = buffer.len() - num_samples_before_wrap;
|
||||
(self.next_write_position + delay_line_len - buffer.samples() - latency)
|
||||
% delay_line_len;
|
||||
let num_samples_before_wrap = buffer.samples().min(delay_line_len - read_position);
|
||||
let num_samples_after_wrap = buffer.samples() - num_samples_before_wrap;
|
||||
|
||||
for (buffer_channel, delay_line) in buffer.as_slice().iter_mut().zip(self.delay_line.iter())
|
||||
{
|
||||
|
|
|
@ -449,7 +449,7 @@ impl Plugin for SpectralCompressor {
|
|||
.global
|
||||
.dry_wet_ratio
|
||||
.smoothed
|
||||
.next_step(buffer.len() as u32),
|
||||
.next_step(buffer.samples() as u32),
|
||||
// The dry and wet signals are in phase, so we can do a linear mix
|
||||
dry_wet_mixer::MixingStyle::Linear,
|
||||
self.stft.latency_samples() as usize,
|
||||
|
|
|
@ -34,7 +34,7 @@ pub struct Buffer<'a> {
|
|||
impl<'a> Buffer<'a> {
|
||||
/// Returns the number of samples per channel in this buffer.
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
pub fn samples(&self) -> usize {
|
||||
self.num_samples
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ impl<'a> Buffer<'a> {
|
|||
SamplesIter {
|
||||
buffers: self.output_slices.as_mut_slice(),
|
||||
current_sample: 0,
|
||||
samples_end: self.len(),
|
||||
samples_end: self.samples(),
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ struct NoSidechain;
|
|||
impl StftInput for Buffer<'_> {
|
||||
#[inline]
|
||||
fn num_samples(&self) -> usize {
|
||||
self.len()
|
||||
self.samples()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -407,7 +407,7 @@ impl Cpal {
|
|||
|
||||
// TODO: Handle MIDI output events
|
||||
|
||||
num_processed_samples += buffer.len() as i64;
|
||||
num_processed_samples += buffer.samples() as i64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ impl Backend for Dummy {
|
|||
break;
|
||||
}
|
||||
|
||||
num_processed_samples += buffer.len() as i64;
|
||||
num_processed_samples += buffer.samples() as i64;
|
||||
|
||||
let period_end = Instant::now();
|
||||
std::thread::sleep((period_start + interval).saturating_duration_since(period_end));
|
||||
|
|
Loading…
Reference in a new issue