Buffer
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
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
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
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
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
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
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
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
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
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