Skip to main content

Module buffer

Module buffer 

Source
Expand description

Lock-free, real-time safe signal buffers

§Audio Buffers with Transcendental Support

This module provides lock-free, real-time safe buffers for signal processing with full Transcendental support for both f32 and f64 sample types.

§Buffer Types

BufferDescriptionUse Case
PipeBufferSingle-producer, single-consumerPoint-to-point node connections
FanOutBufferOne producer, multiple consumersBroadcast signals to multiple nodes
FanInBufferMultiple producers, one consumerMix multiple signals
DelayLineCircular buffer with delayEffects like echo, reverb
RingBufferMulti-producer, multi-consumerGeneric queue for any scenario

§Features

  • Lock-free - All buffers use atomic operations, no mutexes
  • Wait-free - Bounded number of steps per operation
  • Cache-line aligned - Prevents false sharing between threads
  • Real-time safe - No allocations, no blocking, no system calls
  • Statistically monitored - Track performance metrics
  • Type-safe - Generic over Transcendental (f32/f64)
  • Const generics - Sizes checked at compile time

Modules§

prelude
Prelude for convenient imports
utils
Utility functions for common buffer operations

Structs§

AtomicCell
Атомарная ячейка с полностью безопасным API
AtomicStats
Atomic statistics for safe concurrent access
Buffer
Fixed-size audio buffer owned by a port.
BufferStats
Buffer statistics snapshot for monitoring and debugging
DelayLine
Delay line for audio effects
FanInBuffer
Buffer for mixing multiple producers to one consumer
FanOutBuffer
Buffer for broadcasting from one producer to multiple consumers
PipeBuffer
Single-producer, single-consumer buffer for node connections
ReadGuard
Cache-line aligned storage for lock-free buffers
RingBuffer
Кольцевой буфер с фиксированным размером
WriteGuard
Write guard for buffer access

Enums§

AtomicCellError
Ошибки создания атомарной ячейки
BufferError
Buffer error types

Constants§

CACHE_LINE_SIZE
Cache line size for alignment (64 bytes on x86_64)
DEFAULT_BUFFER_SIZE
Default buffer size for most use cases
MAX_BUFFER_SIZE
Maximum buffer size (2^16 = 65536 samples)
MIN_BUFFER_SIZE
Minimum buffer size (must be at least 16 for most algorithms)

Traits§

SignalBuffer
Common trait for all signal buffers

Functions§

array_from_fn
Helper function to create arrays without requiring Copy

Type Aliases§

BufferResult
Result type for buffer operations