| Crates.io | bbx_core |
| lib.rs | bbx_core |
| version | 0.4.3 |
| created_at | 2025-12-30 00:37:38.846056+00 |
| updated_at | 2026-01-15 17:28:44.936448+00 |
| description | Foundational utilities for audio DSP: lock-free SPSC, denormal handling, stack-allocated collections |
| homepage | |
| repository | https://github.com/blackboxaudio/bbx_audio |
| max_upload_size | |
| id | 2011768 |
| size | 82,764 |
Foundational utilities and data structures for the bbx_audio workspace.
ftz-dazEnables hardware-level denormal prevention on x86/x86_64 and AArch64 (Apple Silicon) processors. When enabled, the enable_ftz_daz() function becomes available:
use bbx_core::denormal::enable_ftz_daz;
// Call once at the start of each audio thread
enable_ftz_daz();
This sets CPU flags to automatically flush denormal floats to zero, avoiding the 10-100x slowdowns they can cause. On x86/x86_64, this enables both FTZ and DAZ modes. On AArch64, only FTZ is available—use flush_denormal_f64/f32 in feedback paths for full coverage. Recommended for production audio applications.
simdEnables SIMD-accelerated operations for common DSP tasks. Requires nightly Rust due to the unstable portable_simd feature.
[dependencies]
bbx_core = { version = "...", features = ["simd"] }
Provides the simd module with vectorized operations:
fill_f32/f64 - Fill buffers with a valueapply_gain_f32/f64 - Apply gain to samplesmultiply_add_f32/f64 - Element-wise multiplicationsin_f32/f64 - Vectorized sineAlso enables SIMD-accelerated flush_denormals_f32/f64_batch functions in the denormal module.
denormalUtilities for handling denormal (subnormal) floating-point values, preventing CPU slowdowns during quiet audio passages.
use bbx_core::{flush_denormal_f32, flush_denormal_f64};
let value = flush_denormal_f64(very_small_value);
spscA lock-free single-producer single-consumer ring buffer for inter-thread communication in audio applications.
use bbx_core::SpscRingBuffer;
let (producer, consumer) = SpscRingBuffer::new::<f32>(1024);
// Producer thread
producer.try_push(sample);
// Consumer thread
if let Some(sample) = consumer.try_pop() {
// Process sample
}
stack_vecA fixed-capacity vector that stores elements on the stack, avoiding heap allocations in performance-critical code.
use bbx_core::StackVec;
let mut vec: StackVec<f32, 8> = StackVec::new();
let _ = vec.push(1.0);
let _ = vec.push(2.0);
randomA fast XorShift64 random number generator suitable for audio applications (noise generation, etc.).
use bbx_core::random::XorShiftRng;
let mut rng = XorShiftRng::new(42);
let noise_sample = rng.next_noise_sample(); // Returns -1.0 to 1.0
errorUnified error types for the workspace.
use bbx_core::{BbxError, Result};
fn process() -> Result<()> {
// ...
Ok(())
}
MIT