No matching definitions.

signal/buffer

src/signal/buffer.tur
defopaque

Buffer

(Buffer)

a fixed-length array of samples, shared by handle.

defn

buffer-new

(buffer-new [n :int] :)

a buffer of `n` silent samples.

nlength in samples, clamped to [1, 16777216]

A Buffer of n zeros.

(buffer-len (buffer-new 64))  ; => 64
defn

buffer-len

(buffer-len [buf : Buffer] :)

number of samples in a buffer.

bufthe buffer

The length in samples.

(buffer-len (buffer-new 64))  ; => 64
defn

buffer-get

(buffer-get [buf : Buffer i :int] :)

the sample at index `i`, wrapping out-of-range indices.

bufthe buffer
iindex; taken modulo the length, so -1 is the last sample

The stored sample.

(buffer-get buf 0)
defn

buffer-set!

(buffer-set! [buf : Buffer i :int x :float] :)

store sample `x` at index `i`, wrapping like `buffer-get`.

bufthe buffer
iindex; taken modulo the length
xthe sample to store
(buffer-set! buf 0 1.0)
defn

buffer-read

(buffer-read [buf : Buffer pos :float] :)

linearly interpolated read at a position in buffer lengths.

bufthe buffer
posread position; wraps, so any float is valid

The interpolated sample.

(buffer-read buf 0.5)   ;; the middle of the buffer
defn

buffer-read-nearest

(buffer-read-nearest [buf : Buffer pos :float] :)

the sample nearest a position in buffer lengths.

bufthe buffer
posread position; wraps, so any float is valid

The nearest stored sample.

;; a 4-sample buffer: 0.3 * 4 = 1.2 rounds to sample 1
  (buffer-read-nearest buf 0.3)

Since: signal v0.1.0

defn

buffer-read-cubic

(buffer-read-cubic [buf : Buffer pos :float] :)

cubic-interpolated read at a position in buffer lengths.

bufthe buffer
posread position; wraps, so any float is valid

The interpolated sample.

(buffer-read-cubic buf 0.5)   ;; the middle of the buffer

Since: signal v0.1.0

defn

buffer-read-sinc

(buffer-read-sinc [buf : Buffer pos :float] :)

band-limited read at a position in buffer lengths.

bufthe buffer
posread position; wraps, so any float is valid

The interpolated sample.

(buffer-read-sinc buf 0.5)    ;; the middle of the buffer

Since: signal v0.1.0

defn

buffer-render

(buffer-render [sample-rate :float n :int ^fat sig : (fn [float])

record `n` samples of a signal into a new buffer.

sample-ratethe rate to sample `sig` at, in Hz
nlength in samples, clamped to [1, 16777216]
sigthe signal to record

A new Buffer.

;; one cycle of a 1 Hz sine over 2048 samples: a wavetable
  (buffer-render 2048.0 2048 ((sine 1.0 0.0) (constant 0.0)))
defn

scan

(scan [buf : Buffer])

read a buffer at the position given by the input signal.

bufthe buffer to scan

SF Sample Sample: position -> sample. Stateless.

((scan table) ((sawtooth 220.0) (constant 0.0)))
defn

scan-nearest

(scan-nearest [buf : Buffer])

`scan` with no interpolation: each position reads the

bufthe buffer to scan

SF Sample Sample: position -> nearest sample. Stateless.

((scan-nearest steps) ((sawtooth 2.0) (constant 0.0)))

Since: signal v0.1.0

defn

scan-cubic

(scan-cubic [buf : Buffer])

`scan` with 4-point cubic Hermite interpolation

bufthe buffer to scan

SF Sample Sample: position -> interpolated sample. Stateless.

((scan-cubic table) ((sawtooth 220.0) (constant 0.0)))

Since: signal v0.1.0

defn

scan-sinc

(scan-sinc [buf : Buffer])

`scan` with 32-tap windowed-sinc interpolation

bufthe buffer to scan

SF Sample Sample: position -> interpolated sample. Stateless.

((scan-sinc recording) ((sawtooth 1.0) (constant 0.0)))

Since: signal v0.1.0

Internal definitions
__buffer_alloc-- allocate a zeroed buffer of `n` samples (clamped).
__buffer_fill-- write sig(k / sample-rate) into every slot, in order.