UNPKG

ringbuf.js

Version:

Wait-free thread-safe single-consumer single-producer ring buffer using SharedArrayBuffer.

68 lines 2.37 kB
/** * Send parameter changes, lock free, no gc, between a UI thread (browser * main thread or worker) and a real-time thread (in an AudioWorkletProcessor). * Write and Reader cannot change role after setup, unless externally * synchronized. * * GC _can_ happen during the initial construction of this object when hopefully * no audio is being output. This depends on the implementation. * * Parameter changes are like in the VST framework: an index and a float value * (no restriction on the value). * * This class supports up to 256 parameters, but this is easy to extend if * needed. * * An element is an index, that is an unsigned byte, and a float32, which is 4 * bytes. */ export class ParameterWriter { /** * From a RingBuffer, build an object that can enqueue a parameter change in * the queue. * @param {RingBuffer} ringbuf A RingBuffer object of Uint8Array. * @constructor */ constructor(ringbuf: RingBuffer); ringbuf: RingBuffer; mem: ArrayBuffer; array: Uint8Array; view: DataView; enqueue_change(index: any, value: any): boolean; } /** * Receive parameter changes, lock free, no gc, between a UI thread (browser * main thread or worker) and a real-time thread (in an AudioWorkletProcessor). * Write and Reader cannot change role after setup, unless externally * synchronized. * * GC _can_ happen during the initial construction of this object when hopefully * no audio is being output. This depends on the implementation. * * Parameter changes are like in the VST framework: an index and a float value * (no restriction on the value). * * This class supports up to 256 parameters, but this is easy to extend if * needed. * * An element is an index, that is an unsigned byte, and a float32, which is 4 * bytes. */ export class ParameterReader { /** * @constructor * @param {RingBuffer} ringbuf A RingBuffer setup to hold Uint8. */ constructor(ringbuf: RingBuffer); ringbuf: RingBuffer; mem: ArrayBuffer; array: Uint8Array; view: DataView; /** * Attempt to dequeue a single parameter change. * @param {Object} o An object with two attributes: `index` and `value`. * @return true if a parameter change has been dequeued, false otherwise. */ dequeue_change(o: any): boolean; } //# sourceMappingURL=param.d.ts.map