Skip to main content

Module buffer

Module buffer 

Source
Expand description

Lock-free, real-time safe signal buffers

§Signal Buffers for single-threaded signal processing

This module provides real-time safe buffers used by graph nodes inside the signal thread. All buffers are single-threaded — they contain no atomics or locks. Cross-thread communication goes through rill_core::queues.

§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
TapeLoopHeap-allocated circular bufferTape delay with large capacity

§Features

  • Real-time safe - No allocations, no blocking, no system calls
  • Single-threaded - No atomics, no locks, minimal overhead
  • Cache-line aligned - Prevents false sharing
  • Statistically monitored - Track performance metrics
  • Type-safe - Generic over Transcendental (f32/f64)

Modules§

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

Structs§

AtomicCell
Atomic cell with a fully safe API.
AtomicStats
Atomic statistics for safe concurrent access
BufferRegistry
Registry of named buffers.
BufferStats
Buffer statistics snapshot for monitoring and debugging
DelayLine
Delay line for audio effects — single-threaded circular buffer.
FanInBuffer
Buffer for mixing multiple producers to one consumer. Single-threaded — use rill_core::queues for cross-thread.
FanOutBuffer
Buffer for broadcasting from one producer to multiple consumers. Single-threaded — use rill_core::queues for cross-thread.
FixedBuffer
Fixed-size buffer on the stack — default per-port buffer.
HeapBuffer
Heap-allocated buffer with runtime-determined size.
PipeBuffer
Single-producer, single-consumer buffer for intra-graph node connections.
RingBuffer
Fixed-size ring buffer (power-of-two size). Single-threaded.
TapeLoop
Heap-allocated ring buffer for tape delay — single-threaded.

Enums§

AtomicCellError
Errors that can occur when creating an AtomicCell.
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§

Buffer
Common interface for audio buffers of arbitrary size.
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