Files
bass-foundry/plugins/crucible/core/src/player.rs
T
nvrl f36ff0780c
Check and Windows preview / check (anvil) (push) Successful in 2m41s
Check and Windows preview / check (crucible) (push) Successful in 2m7s
Check and Windows preview / check (patina) (push) Successful in 2m5s
Check and Windows preview / check (rivet) (push) Successful in 1m33s
Check and Windows preview / previews (push) Successful in 1m10s
Check and Windows preview / windows (push) Successful in 2m2s
Independent plugin release / publish (push) Successful in 8s
Independent plugin release / plan (push) Successful in 7s
Independent plugin release / build (push) Successful in 3m3s
feat: add Anvil sub anchor and Crucible resampler
Two new CLAP effects aimed at riddim and dubstep production, plus shared
crates so all four plugins keep one look and reuse DSP.

Anvil 0.1.0 (io.storyboard.sub-anchor):
- Replaces the band below Split with a clean mono sine. Every note gets
  the same peak level and restarts at the same phase, so switch-ups keep
  their weight and kick hits line up.
- Pitch and note starts come from the audio (YIN, 80 ms lookahead
  reported to the host) or from MIDI notes sent to the effect.
- Dynamics, Drive, Octave, Glide, Phase, Gate and Keep; Solo sub monitor,
  note readout, level meters and a low-band oscilloscope.

Crucible 0.1.0 (io.storyboard.resampler):
- Records its input continuously in a lock-free ring with host transport
  markers. Capture takes the newest 1-16 complete bars on the bar grid,
  following tempo changes, or the newest audio when stopped.
- Grid (straight and triplet) or transient slicing, manual cuts, slice
  audition without audio-thread allocation.
- Export writes the loop, trimmed, declicked and normalised slices named
  and tagged with their root note, and an optional 2048-sample wavetable
  for Serum and Vital.

Shared:
- common-ui holds the palette, fonts, knobs and panels taken from Patina;
  Patina renders identically. Rotary knobs at their minimum no longer
  tessellate a zero-length arc into NaN vertices.
- common-dsp holds biquads, a Linkwitz-Riley crossover, YIN, note helpers
  and a float WAV writer with sampler root and Serum frame chunks.
- Catalog, CI matrix, release tags, editor previews and docs cover both
  plugins; a script test keeps the catalog and workflows in step.
2026-11-06 03:22:00 +01:00

74 lines
2.0 KiB
Rust

//! Audition of slices on the audio thread without allocating or freeing there.
use crossbeam_queue::ArrayQueue;
use std::sync::Arc;
pub type Clip = Arc<[f32]>;
/// Shared queues. The GUI sends clips and drains finished ones, so all frees happen there.
pub struct Queues {
incoming: ArrayQueue<Option<Clip>>,
finished: ArrayQueue<Clip>,
}
impl Default for Queues {
fn default() -> Self {
Self {
incoming: ArrayQueue::new(4),
finished: ArrayQueue::new(16),
}
}
}
impl Queues {
/// Plays an interleaved stereo clip, replacing the current one.
pub fn play(&self, clip: Clip) {
self.drain();
let _ = self.incoming.force_push(Some(clip));
}
pub fn stop(&self) {
let _ = self.incoming.force_push(None);
}
/// Frees finished clips. Call regularly from the GUI thread.
pub fn drain(&self) {
while self.finished.pop().is_some() {}
}
}
#[derive(Default)]
pub struct Player {
clip: Option<Clip>,
at: usize,
}
impl Player {
fn retire(&mut self, queues: &Queues) {
if let Some(old) = self.clip.take() {
// The GUI drains this queue every frame; a full queue only happens with no editor.
if let Err(old) = queues.finished.push(old) {
std::mem::forget(old);
}
}
}
/// Call once per block.
pub fn block(&mut self, queues: &Queues) {
while let Some(next) = queues.incoming.pop() {
self.retire(queues);
self.clip = next;
self.at = 0;
}
}
#[inline]
pub fn next(&mut self, queues: &Queues) -> [f32; 2] {
let Some(clip) = &self.clip else {
return [0.; 2];
};
if self.at + 1 >= clip.len() {
self.retire(queues);
return [0.; 2];
}
let out = [clip[self.at], clip[self.at + 1]];
self.at += 2;
out
}
pub fn playing(&self) -> bool {
self.clip.is_some()
}
}