MCPcopy Create free account
hub / github.com/BillyDM/Firewheel / process

Method process

crates/firewheel-nodes/src/triple_buffer.rs:364–463  ·  view source on GitHub ↗
(
        &mut self,
        info: &ProcInfo,
        buffers: ProcBuffers,
        _extra: &mut ProcExtra,
    )

Source from the content-addressed store, hash-verified

362 }
363
364 fn process(
365 &mut self,
366 info: &ProcInfo,
367 buffers: ProcBuffers,
368 _extra: &mut ProcExtra,
369 ) -> ProcessStatus {
370 let input_is_silent = info.in_silence_mask.all_channels_silent(self.num_inputs);
371 if input_is_silent {
372 self.num_silent_frames_in_tmp =
373 (self.num_silent_frames_in_tmp + info.frames).min(self.window_size_frames);
374 } else {
375 self.num_silent_frames_in_tmp = 0;
376 }
377
378 if self.num_silent_frames_in_tmp == self.window_size_frames
379 && self.prev_publish_was_silent
380 && !self.did_resize
381 {
382 // The previous publish already contained silence, so no need to publish again.
383 self.tmp_buffer_needs_cleared = true;
384 return ProcessStatus::ClearAllOutputs;
385 }
386 self.did_resize = false;
387
388 if info.frames >= self.window_size_frames {
389 // Just copy all the new data.
390 for (tmp_ch, in_ch) in self
391 .tmp_ring_buffer
392 .iter_channels_mut()
393 .zip(buffers.inputs.iter())
394 {
395 tmp_ch[..self.window_size_frames]
396 .copy_from_slice(&in_ch[info.frames - self.window_size_frames..info.frames]);
397 }
398 self.ring_buf_ptr = 0;
399 self.tmp_buffer_needs_cleared = false;
400 } else {
401 if self.tmp_buffer_needs_cleared {
402 self.tmp_buffer_needs_cleared = false;
403
404 for tmp_ch in self.tmp_ring_buffer.iter_channels_mut() {
405 tmp_ch[..self.window_size_frames].fill(0.0);
406 }
407 self.ring_buf_ptr = 0;
408
409 self.num_silent_frames_in_tmp = self.window_size_frames;
410 }
411
412 let first_copy_frames = info.frames.min(self.window_size_frames - self.ring_buf_ptr);
413 let second_copy_frames = info.frames - first_copy_frames;
414
415 for (tmp_ch, in_ch) in self
416 .tmp_ring_buffer
417 .iter_channels_mut()
418 .zip(buffers.inputs.iter())
419 {
420 if first_copy_frames > 0 {
421 tmp_ch[self.ring_buf_ptr..self.ring_buf_ptr + first_copy_frames]

Callers

nothing calls this directly

Calls 5

all_channels_silentMethod · 0.80
minMethod · 0.80
iter_channels_mutMethod · 0.80
as_mutMethod · 0.80
iter_channelsMethod · 0.80

Tested by

no test coverage detected