Skip to content

Recorder

Structs

struct Recorder

A struct for storing a buffer and recording audio into it.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable

Recorder Parameters

Name Type Default Description
num_chans Int 1 The number of channels in the buffer. Default is 1 (mono).

Recorder Functions

struct Recorder . fn init

Initialize the Recorder struct.

fn init Signature

def __init__(out self, world: UnsafePointer[MMMWorld, MutUntrackedOrigin], num_frames: Int, sample_rate: Float64)

fn init Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] A pointer to the MMMWorld instance.
num_frames Int The number of frames in the empty buffer to be recorded to.
sample_rate Float64 The sample rate of the empty buffer.

fn init Returns : Self

Static Method

This is a static method.

struct Recorder . fn replace_buffer

Replace the internal buffer with a new buffer. The new buffer must have the same number of channels as the existing buffer. Write head is reset to 0.

fn replace_buffer Signature

def replace_buffer(mut self, new_buf: SIMDBuffer[num_chans])

fn replace_buffer Arguments

Name Type Default Description
new_buf SIMDBuffer[num_chans] The new buffer to replace the existing buffer with.

struct Recorder . fn zero_buffer

Utility function to set all samples in the buffer to zero. Can be useful to clear the buffer for a new recording without having to create a new Recorder instance.

fn zero_buffer Signature

def zero_buffer(mut self)

struct Recorder . fn write

Write SIMD input to buffer at specified index. Used internally by write_next and write_previous, which will be more appropriate for most use cases.

fn write Signature

def write(mut self, input: SIMD[DType.float64, num_chans], index: Int)

fn write Arguments

Name Type Default Description
input SIMD[DType.float64, num_chans] The SIMD input to write to the buffer.
index Int The index in the buffer to write the input to.

struct Recorder . fn write_next

Write SIMD input to buffer at current write head and advance write head forward. This is the correct option in most use cases.

fn write_next Signature

def write_next[loop: Bool = True](mut self, value: SIMD[DType.float64, num_chans])

fn write_next Parameters

Name Type Default Description
loop Bool True Whether to wrap the write head when it reaches the end of the buffer.

fn write_next Arguments

Name Type Default Description
value SIMD[DType.float64, num_chans] The SIMD input to write to the buffer.

struct Recorder . fn write_previous

Write SIMD input to buffer at current write head and move write head backward. This is useful for things like delay lines, which write backwards through a buffer so they can interpolate forwards.

fn write_previous Signature

def write_previous(mut self, value: SIMD[DType.float64, num_chans])

fn write_previous Arguments

Name Type Default Description
value SIMD[DType.float64, num_chans] The SIMD input to write to the buffer.

Documentation generated with mojo doc from Mojo version 1.0.0b2