Play
struct Play¶
The principle buffer playback object for MMMAudio.
Plays back audio from a Buffer with variable rate, interpolation, looping, and triggering capabilities.
Traits: AnyType, Copyable, ImplicitlyDeletable, Movable
Play Functions¶
struct Play . fn init¶
Initialize the buffer playback object.
fn init Signature
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| world | UnsafePointer[MMMWorld, MutUntrackedOrigin] |
— | Pointer to the MMMWorld instance. |
fn init Returns
: Self
Static Method
This is a static method.
struct Play . fn next¶
Get the next sample from a SIMD audio buf (SIMDBuffer). The internal phasor is advanced according to the specified rate. If a trigger is received, playback starts at the specified start_frame. If looping is enabled, playback will loop back to the start when reaching the end of the specified num_frames. A key difference between SIMDBuffer and Buffer is that calling next on a SIMDBuffer always returns the entire SIMD vector of samples for the current phase, whereas with Buffer, you can specify the number of channels to read.
fn next Signature
def next[num_chans: Int = 1, interp: Interp = Interp.linear, bWrap: Bool = False](mut self, buf: SIMDBuffer[num_chans], rate: Float64 = Float64("1"), loop: Bool = True, trig: Bool = True, start_frame: Int = 0, var num_frames: Int = -1) -> SIMD[DType.float64, num_chans]
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| num_chans | Int |
1 |
Number of output channels to read from the buffer and also the size of the output SIMD vector. |
| interp | Interp |
Interp.linear |
Interpolation method to use when reading from the buffer (see the Interp struct for available options - default: Interp.linear). |
| bWrap | Bool |
False |
Whether to interpolate between the end and start of the buffer when reading (default: False). This is necessary when reading from a wavetable or other oscillating buffer, for instance, where the ending samples of the buffer connect seamlessly to the first. If this is false, reading beyond the end of the buffer will return 0. When True, the index into the buffer will wrap around to the beginning using a modulus. |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| buf | SIMDBuffer[num_chans] |
— | The audio buf to read from (List[MFloat[num_chans]]). |
| rate | Float64 |
Float64("1") |
The playback rate. 1 is the normal speed of the buf. |
| loop | Bool |
True |
Whether to loop the buf (default: True). |
| trig | Bool |
True |
Trigger starts the synth at start_frame (default: 1.0). |
| start_frame | Int |
0 |
The start frame for playback (default: 0) upon receiving a trigger. |
| num_frames | Int |
-1 |
The end frame for playback (default: -1 means to the end of the buf). |
fn next Returns
: SIMD[DType.float64, num_chans]
The next sample(s) from the buf as a SIMD vector.
struct Play . fn next¶
Get the next sample from an audio buf (Buffer). The internal phasor is advanced according to the specified rate. If a trigger is received, playback starts at the specified start_frame. If looping is enabled, playback will loop back to the start when reaching the end of the specified num_frames.
fn next Signature
def next[num_chans: Int = 1, interp: Interp = Interp.linear, bWrap: Bool = False](mut self, buf: Buffer, rate: Float64 = Float64("1"), loop: Bool = True, trig: Bool = True, start_frame: Int = 0, var num_frames: Int = -1, start_chan: Int = 0) -> SIMD[DType.float64, num_chans]
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| num_chans | Int |
1 |
Number of output channels to read from the buffer and also the size of the output SIMD vector. |
| interp | Interp |
Interp.linear |
Interpolation method to use when reading from the buffer (see the Interp struct for available options - default: Interp.linear). |
| bWrap | Bool |
False |
Whether to interpolate between the end and start of the buffer when reading (default: False). This is necessary when reading from a wavetable or other oscillating buffer, for instance, where the ending samples of the buffer connect seamlessly to the first. If this is false, reading beyond the end of the buffer will return 0. When True, the index into the buffer will wrap around to the beginning using a modulus. |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| buf | Buffer |
— | The audio buf to read from (List[Float64]). |
| rate | Float64 |
Float64("1") |
The playback rate. 1 is the normal speed of the buf. |
| loop | Bool |
True |
Whether to loop the buf (default: True). |
| trig | Bool |
True |
Trigger starts the synth at start_frame (default: 1.0). |
| start_frame | Int |
0 |
The start frame for playback (default: 0) upon receiving a trigger. |
| num_frames | Int |
-1 |
The end frame for playback (default: -1 means to the end of the buf). |
| start_chan | Int |
0 |
The start channel for multi-channel bufs (default: 0). |
fn next Returns
: SIMD[DType.float64, num_chans]
The next sample(s) from the buf as a SIMD vector.
struct Play . fn get_relative_phase¶
fn get_relative_phase Signature
fn get_relative_phase Returns
: Float64
struct Play . fn reset_phase¶
Documentation generated with mojo doc from Mojo version 1.0.0b2