Skip to content

Buffer

Structs

struct Buffer

A multi-channel audio buffer for storing audio data.

Audio data is stored in the data variable as a List[List[Float64]], where each inner List represents a channel of audio samples.

Traits: AnyType, Copyable, Movable, UnknownDestructibility


Buffer Functions

struct Buffer . fn init

Initialize a Buffer with the given audio data and sample rate.

fn init Signature

__init__(out self, data: List[List[Float64]], sample_rate: Float64)

fn init Arguments

Name Type Default Description
data List A List of Lists of Float64 representing the audio data for each channel.
sample_rate Float64 The sample rate of the audio data.

fn init Returns : Self

Static Method

This is a static method.

struct Buffer . fn zeros

Initialize a Buffer with zeros.

fn zeros Signature

zeros(num_frames: Int64, num_chans: Int64 = 1, sample_rate: Float64 = 48000) -> Self

fn zeros Arguments

Name Type Default Description
num_frames Int64 Number of frames in the buffer.
num_chans Int64 1 Number of channels in the buffer.
sample_rate Float64 48000 Sample rate of the buffer.

fn zeros Returns : Self

Static Method

This is a static method.

struct Buffer . fn load

Initialize a Buffer by loading data from a WAV file using SciPy and NumPy.

fn load Signature

load(filename: String, num_wavetables: Int64 = 1) -> Self

fn load Arguments

Name Type Default Description
filename String Path to the WAV file to load.
num_wavetables Int64 1 Number of wavetables per channel. This is only used if the sound file being loaded contains multiple wavetables concatenated in a single channel.

fn load Returns : Self

Static Method

This is a static method.

struct ListInterpolator

A collection of static methods for interpolating values from a List[Float64].

ListInterpolator supports various interpolation methods including

  • no interpolation (none)
  • linear interpolation
  • quadratic interpolation
  • cubic interpolation
  • lagrange interpolation (4th order)
  • sinc interpolation

The available interpolation methods are defined in the struct Interp.

Traits: AnyType, Copyable, Movable, UnknownDestructibility


ListInterpolator Functions

struct ListInterpolator . fn idx_in_range

fn idx_in_range Signature

idx_in_range(data: List[Float64], idx: Int64) -> Bool

fn idx_in_range Arguments

Name Type Default Description
data List
idx Int64

fn idx_in_range Returns : Bool

Static Method

This is a static method.

struct ListInterpolator . fn read

Read a value from a List[Float64] using provided index and interpolation method, which is determined at compile time.

fn read Signature

read[interp: Int = 0, bWrap: Bool = True, mask: Int = 0](world: UnsafePointer[MMMWorld], data: List[Float64], f_idx: Float64, prev_f_idx: Float64 = 0) -> Float64

fn read Parameters

Name Type Default Description
interp Int 0 Interpolation method to use (from Interp enum).
bWrap Bool True Whether to wrap indices that go out of bounds.
mask Int 0 Bitmask for wrapping indices (if applicable). If 0, standard modulo wrapping is used. If non-zero, bitwise AND wrapping is used (only valid for power-of-two lengths).

fn read Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld instance.
data List The List[Float64] to read from.
f_idx Float64 The floating-point index to read at.
prev_f_idx Float64 0 The previous floating-point index (used for SincInterpolation).

fn read Returns : Float64

Static Method

This is a static method.

struct ListInterpolator . fn read_none

Read a value from a List[Float64] using provided index with no interpolation.

fn read_none Signature

read_none[bWrap: Bool = True, mask: Int = 0](data: List[Float64], f_idx: Float64) -> Float64

fn read_none Parameters

Name Type Default Description
bWrap Bool True Whether to wrap indices that go out of bounds.
mask Int 0 Bitmask for wrapping indices (if applicable). If 0, standard modulo wrapping is used. If non-zero, bitwise AND wrapping is used (only valid for power-of-two lengths).

fn read_none Arguments

Name Type Default Description
data List The List[Float64] to read from.
f_idx Float64 The floating-point index to read at.

fn read_none Returns : Float64

Static Method

This is a static method.

struct ListInterpolator . fn read_linear

Read a value from a List[Float64] using provided index with linear interpolation.

fn read_linear Signature

read_linear[bWrap: Bool = True, mask: Int = 0](data: List[Float64], f_idx: Float64) -> Float64

fn read_linear Parameters

Name Type Default Description
bWrap Bool True Whether to wrap indices that go out of bounds.
mask Int 0 Bitmask for wrapping indices (if applicable). If 0, standard modulo wrapping is used. If non-zero, bitwise AND wrapping is used (only valid for power-of-two lengths).

fn read_linear Arguments

Name Type Default Description
data List The List[Float64] to read from.
f_idx Float64 The floating-point index to read at.

fn read_linear Returns : Float64

Static Method

This is a static method.

struct ListInterpolator . fn read_quad

Read a value from a List[Float64] using provided index with quadratic interpolation.

fn read_quad Signature

read_quad[bWrap: Bool = True, mask: Int = 0](data: List[Float64], f_idx: Float64) -> Float64

fn read_quad Parameters

Name Type Default Description
bWrap Bool True Whether to wrap indices that go out of bounds.
mask Int 0 Bitmask for wrapping indices (if applicable). If 0, standard modulo wrapping is used. If non-zero, bitwise AND wrapping is used (only valid for power-of-two lengths).

fn read_quad Arguments

Name Type Default Description
data List The List[Float64] to read from.
f_idx Float64 The floating-point index to read at.

fn read_quad Returns : Float64

Static Method

This is a static method.

struct ListInterpolator . fn read_cubic

Read a value from a List[Float64] using provided index with cubic interpolation.

fn read_cubic Signature

read_cubic[bWrap: Bool = True, mask: Int = 0](data: List[Float64], f_idx: Float64) -> Float64

fn read_cubic Parameters

Name Type Default Description
bWrap Bool True Whether to wrap indices that go out of bounds.
mask Int 0 Bitmask for wrapping indices (if applicable). If 0, standard modulo wrapping is used. If non-zero, bitwise AND wrapping is used. (only valid for power-of-two lengths).

fn read_cubic Arguments

Name Type Default Description
data List The List[Float64] to read from.
f_idx Float64 The floating-point index to read at.

fn read_cubic Returns : Float64

Static Method

This is a static method.

struct ListInterpolator . fn read_lagrange4

Read a value from a List[Float64] using provided index with lagrange4 interpolation.

fn read_lagrange4 Signature

read_lagrange4[bWrap: Bool = True, mask: Int = 0](data: List[Float64], f_idx: Float64) -> Float64

fn read_lagrange4 Parameters

Name Type Default Description
bWrap Bool True Whether to wrap indices that go out of bounds.
mask Int 0 Bitmask for wrapping indices (if applicable). If 0, standard modulo wrapping is used. If non-zero, bitwise AND wrapping is used (only valid for power-of-two lengths).

fn read_lagrange4 Arguments

Name Type Default Description
data List The List[Float64] to read from.
f_idx Float64 The floating-point index to read at.

fn read_lagrange4 Returns : Float64

Static Method

This is a static method.

struct ListInterpolator . fn read_sinc

Read a value from a List[Float64] using provided index with SincInterpolation.

fn read_sinc Signature

read_sinc[bWrap: Bool = True, mask: Int = 0](world: UnsafePointer[MMMWorld], data: List[Float64], f_idx: Float64, prev_f_idx: Float64) -> Float64

fn read_sinc Parameters

Name Type Default Description
bWrap Bool True Whether to wrap indices that go out of bounds.
mask Int 0 Bitmask for wrapping indices (if applicable). If 0, standard modulo wrapping is used. If non-zero, bitwise AND wrapping is used (only valid for power-of-two lengths).

fn read_sinc Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld instance.
data List The List[Float64] to read from.
f_idx Float64 The floating-point index to read at.
prev_f_idx Float64 The previous floating-point index.

fn read_sinc Returns : Float64

Static Method

This is a static method.


Documentation generated with mojo doc from Mojo version 0.25.6.1