trait BufferedProcessable¶
Trait that user structs must implement to be used with a BufferedProcess.
Requires two functions:
- next_window(buffer: List[Float64]) -> None: This function is called when enough samples have been buffered.
The user can process the input buffer in place meaning that the samples you want to return to the output need
to replace the samples that you receive in the input list.
- get_messages() -> None: This function is called at the top of each audio block to allow the user to retrieve any messages
they may have sent to this process. Put your message retrieval code here. (e.g. self.messenger.update(self.param, "param_name"))
BufferedProcessable Required Methods¶
trait BufferedProcessable . fn next_window¶
Signature¶
Arguments¶
- buffer:
List
Default Implementation
This method has a default implementation.
trait BufferedProcessable . fn next_stereo_window¶
Signature¶
Arguments¶
- buffer:
List
Default Implementation
This method has a default implementation.
trait BufferedProcessable . fn get_messages¶
Signature¶
Default Implementation
This method has a default implementation.
struct BufferedInput¶
Buffers input samples and hands them over to be processed in 'windows'.
BufferedInput struct handles buffering of input samples and handing them as "windows"
to a user defined struct for processing (The user defined struct must implement the
BufferedProcessable trait). The user defined struct's next_window() function is called every
hop_size samples. BufferedInput passes the user defined struct a List of window_size samples.
The user can process can do whatever they want with the samples in the List and then must replace the
values in the List with the values.
Traits: AnyType, Copyable, Movable, UnknownDestructibility
BufferedInput Parameters
| Name | Type | Description |
|---|---|---|
| T | BufferedProcessable |
A user defined struct that implements the BufferedProcessable trait. |
| window_size | Int |
The size of the window that is passed to the user defined struct for processing. The default is 1024 samples. |
| hop_size | Int |
The number of samples between each call to the user defined struct's next_window() function. The default is 512 samples. |
| input_window_shape | Optional |
Optional window shape to apply to the input samples before passing them to the user defined struct. Use alias variables from WindowTypes struct (e.g. WindowTypes.hann) found in mmm_utils.Windows. If None, no window is applied. The default is None. |
BufferedInput Functions¶
struct BufferedInput . fn init¶
Initializes a BufferedInput struct.
fn init Signature
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| world | UnsafePointer |
— | A pointer to the MMMWorld. |
| process | T |
— | A user defined struct that implements the BufferedProcessable trait. |
| hop_start | Int |
0 |
The initial value of the hop counter. Default is 0. This can be used to offset the processing start time, if for example, you need to offset the start time of the first frame. This can be useful when separating windows into separate BufferedProcesses, and therefore separate audio streams, so that each window could be routed or processed with different FX chains. |
fn init Returns
: Self
An initialized BufferedInput struct.
Static Method
This is a static method.
struct BufferedInput . fn next¶
Process the next input sample and return the next output sample.
This function is called in the audio processing loop for each input sample. It buffers the input samples,
and internally here calls the user defined struct's .next_window() method every hop_size samples.
fn next Signature
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| input | Float64 |
— | The next input sample to process. |
struct BufferedProcess¶
Buffers input samples and hands them over to be processed in 'windows'.
BufferedProcess struct handles buffering of input samples and handing them as "windows"
to a user defined struct for processing (The user defined struct must implement the
BufferedProcessable trait). The user defined struct's next_window() function is called every
hop_size samples. BufferedProcess passes the user defined struct a List of window_size samples.
The user can process can do whatever they want with the samples in the List and then must replace the
values in the List with the values.
Traits: AnyType, Copyable, Movable, UnknownDestructibility
BufferedProcess Parameters
| Name | Type | Description |
|---|---|---|
| T | BufferedProcessable |
A user defined struct that implements the BufferedProcessable trait. |
| window_size | Int |
The size of the window that is passed to the user defined struct for processing. The default is 1024 samples. |
| hop_size | Int |
The number of samples between each call to the user defined struct's next_window() function. The default is 512 samples. |
| input_window_shape | Optional |
Optional window shape to apply to the input samples before passing them to the user defined struct. Use alias variables from WindowTypes struct (e.g. WindowTypes.hann) found in mmm_utils.Windows. If None, no window is applied. The default is None. |
| output_window_shape | Optional |
Optional window shape to apply to the output samples after processing by the user defined struct. Use alias variables from WindowTypes struct (e.g. WindowTypes.hann) found in mmm_utils.Windows. If None, no window is applied. The default is None. |
BufferedProcess Functions¶
struct BufferedProcess . fn init¶
Initializes a BufferedProcess struct.
fn init Signature
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| world | UnsafePointer |
— | A pointer to the MMMWorld. |
| process | T |
— | A user defined struct that implements the BufferedProcessable trait. |
| hop_start | Int |
0 |
The initial value of the hop counter. Default is 0. This can be used to offset the processing start time, if for example, you need to offset the start time of the first frame. This can be useful when separating windows into separate BufferedProcesses, and therefore separate audio streams, so that each window could be routed or processed with different FX chains. |
fn init Returns
: Self
An initialized BufferedProcess struct.
Static Method
This is a static method.
struct BufferedProcess . fn next¶
Process the next input sample and return the next output sample.
This function is called in the audio processing loop for each input sample. It buffers the input samples,
and internally here calls the user defined struct's .next_window() method every hop_size samples.
fn next Signature
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| input | Float64 |
— | The next input sample to process. |
fn next Returns
: Float64
The next output sample.
struct BufferedProcess . fn next_stereo¶
Process the next input sample and return the next output sample.
This function is called in the audio processing loop for each input sample. It buffers the input samples,
and internally here calls the user defined struct's .next_window() method every hop_size samples.
fn next_stereo Signature
fn next_stereo Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| input | SIMD |
— | The next input sample to process. |
fn next_stereo Returns
: SIMD
The next output sample.
struct BufferedProcess . fn next_from_buffer¶
Used for non-real-time, buffer-based, processing. At the onset of the next window, reads a block of window_size samples from the provided buffer, starting at the given phase and channel. Phase values between zero and one will read samples within the provided buffer. If the provided phase tries to read samples with an index below zero or above the duration of the buffer, zeros will be returned.
fn next_from_buffer Signature
fn next_from_buffer Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| buffer | Buffer |
— | The input buffer to read samples from. |
| phase | Float64 |
— | The current phase to start reading from the buffer. |
| start_chan | Int |
0 |
The first channel to read from the buffer. |
fn next_from_buffer Returns
: Float64
The next output sample.
struct BufferedProcess . fn next_from_stereo_buffer¶
Used for non-real-time, buffer-based, processing of stereo files. At the onset of the next window, reads a window_size block of samples from the provided buffer, starting at the given phase and channel. Phase values between zero and one will read samples within the provided buffer. If the provided phase results in reading samples with an index below zero or above the duration of the buffer, zeros will be returned.
fn next_from_stereo_buffer Signature
next_from_stereo_buffer(mut self, ref buffer: Buffer, phase: Float64, start_chan: Int = 0) -> SIMD[DType.float64, 2]
fn next_from_stereo_buffer Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| buffer | Buffer |
— | The input buffer to read samples from. |
| phase | Float64 |
— | The current phase to read from the buffer. |
| start_chan | Int |
0 |
The firstchannel to read from the buffer. |
fn next_from_stereo_buffer Returns
: SIMD
The next output sample.
Documentation generated with mojo doc from Mojo version 0.25.6.1