Skip to content

World

Structs

struct Environment

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable


Environment Functions

struct Environment . fn init

fn init Signature

def __init__(out self, block_size: Int = 64, num_in_chans: Int = 2, num_out_chans: Int = 2)

fn init Arguments

Name Type Default Description
block_size Int 64
num_in_chans Int 2
num_out_chans Int 2

fn init Returns : Self

Static Method

This is a static method.

struct MMMWorld

The MMMWorld struct holds global audio processing parameters and state.

In pretty much all usage, don't edit this struct.

Traits: AnyType, Copyable, ImplicitlyDeletable, Movable


MMMWorld Functions

struct MMMWorld . fn init

Initializes the MMMWorld struct.

fn init Signature

def __init__(out self, sample_rate: Float64, environment_ptr: Optional[UnsafePointer[Environment, MutUntrackedOrigin]] = None)

fn init Arguments

Name Type Default Description
sample_rate Float64 The audio sample rate.
environment_ptr Optional[UnsafePointer[Environment, MutUntrackedOrigin]] None A pointer to the Environment struct, which holds information about the current audio block and input buffers.

fn init Returns : Self

Static Method

This is a static method.

struct MMMWorld . fn windows

Returns a reference to the Windows struct for accessing predefined windows.

fn windows Signature

def windows(self) -> refWindows

fn windows Returns : refWindows A reference to the Windows struct.

struct MMMWorld . fn sinc_interpolator

Returns a reference to the SincInterpolator struct for performing sinc interpolation.

fn sinc_interpolator Signature

def sinc_interpolator(self) -> refSincInterpolator

fn sinc_interpolator Returns : refSincInterpolator A reference to the SincInterpolator struct.

struct MMMWorld . fn osc_buffers

Returns a reference to the OscBuffers struct for accessing oscillator buffers.

fn osc_buffers Signature

def osc_buffers(self) -> refOscBuffers

fn osc_buffers Returns : refOscBuffers A reference to the OscBuffers struct.

struct MMMWorld . fn messenger_manager

Returns a reference to the MessengerManager struct for managing messages.

fn messenger_manager Signature

def messenger_manager(self) -> refMessengerManager

fn messenger_manager Returns : refMessengerManager A reference to the MessengerManager struct.

struct MMMWorld . fn mouse_x

Returns the current mouse x position as a value between 0.0 and 1.0.

fn mouse_x Signature

def mouse_x(self) -> Float64

fn mouse_x Returns : Float64 The current mouse x position as a value between 0.0 and 1.0.

struct MMMWorld . fn mouse_y

Returns the current mouse y position as a value between 0.0 and 1.0.

fn mouse_y Signature

def mouse_y(self) -> Float64

fn mouse_y Returns : Float64 The current mouse y position as a value between 0.0 and 1.0.

struct MMMWorld . fn top_of_block

Returns true if the current sample is the first sample of the audio block.

fn top_of_block Signature

def top_of_block(self) -> Bool

fn top_of_block Returns : Bool True if the current sample is the first sample of the audio block, false otherwise.

struct MMMWorld . fn block_state

Returns the block state.

fn block_state Signature

def block_state(self) -> Int

fn block_state Returns : Int An integer that increments by 1 at the start of each audio block. Resets to 0 after reaching 2^31 - 1.

struct MMMWorld . fn num_in_chans

Returns the number of input channels.

fn num_in_chans Signature

def num_in_chans(self) -> Int

fn num_in_chans Returns : Int The number of input channels.

struct MMMWorld . fn num_out_chans

Returns the number of output channels.

fn num_out_chans Signature

def num_out_chans(self) -> Int

fn num_out_chans Returns : Int The number of output channels.

struct MMMWorld . fn sound_in

Returns the input sample value for a given channel.

fn sound_in Signature

def sound_in(self, chan: Int) -> Float64

fn sound_in Arguments

Name Type Default Description
chan Int The input channel to read from. Must be less than num_in_chans.

fn sound_in Returns : Float64 The input sample value for the given channel.

struct MMMWorld . fn print

Print values to the console at the top of the audio block every n_blocks.

fn print Signature

def print[*Ts: Writable](self, *values: *Ts.values, *, n_blocks: UInt16 = UInt16(10), sep: StringSlice[StaticConstantOrigin] = StringSlice(" "), end: StringSlice[StaticConstantOrigin] = StringSlice("\n"))

fn print Parameters

Name Type Default Description
*Ts Writable Types of the values to print. Can be of any type that implements Mojo's Writable trait. This parameter is inferred by the values passed to the function. The user doesn't need to specify it.

fn print Arguments

Name Type Default Description
*values *Ts.values Values to print. Can be of any type that implements Mojo's Writable trait. This is a "variadic" argument meaning that the user can pass in any number of values (not as a list, just as comma separated arguments).
n_blocks UInt16 UInt16(10) Number of audio blocks between prints. Must be specified using the keyword argument.
sep StringSlice[StaticConstantOrigin] StringSlice(" ") Separator string between values. Must be specified using the keyword argument.
end StringSlice[StaticConstantOrigin] StringSlice("\n") End string to print after all values. Must be specified using the keyword argument.

struct MMMWorld . fn create_subworld

Create another MMMWorld instance using a different TimesOversampling. This is mostly used to create an oversampled subworld with a higher sample rate based on the main world.

fn create_subworld Signature

def create_subworld(self, times_ov_samp: TimesOversampling = TimesOversampling.none) -> UnsafePointer[Self, MutUntrackedOrigin]

fn create_subworld Arguments

Name Type Default Description
times_ov_samp TimesOversampling TimesOversampling.none A TimesOversampling struct to indicate times oversampling.

fn create_subworld Returns : UnsafePointer[Self, MutUntrackedOrigin] A pointer to the newly created MMMWorld struct.

struct Interp

Interpolation types for use in various UGens.

Specify an interpolation type by typing it explicitly.

Interpolation Type Notes
Interp.none
Interp.linear
Interp.quad
Interp.cubic
Interp.lagrange4
Interp.sinc Should only be used with oscillators

Traits: AnyType, Copyable, Equatable, ImplicitlyCopyable, ImplicitlyDeletable, Movable


struct WindowType

Window types for predefined windows found in world[].windows.

Specify a window type by typing it explicitly.

Window Type
WindowType.none
WindowType.rect
WindowType.hann
WindowType.hamming
WindowType.blackman
WindowType.kaiser
WindowType.sine
WindowType.tri
WindowType.pan2
WindowType.gaussian
WindowType.user_defined

Traits: AnyType, Copyable, Equatable, ImplicitlyCopyable, ImplicitlyDeletable, Movable


struct OscType

Oscillator types for selecting waveform types.

Specify an oscillator type by typing it explicitly. For example, to specify a sine, one could use the number 0, but it is clearer to type OscType.sine.

Oscillator Type Value
OscType.sine 0
OscType.triangle 1
OscType.saw 2
OscType.square 3

Traits: AnyType, Copyable, Equatable, ImplicitlyCopyable, ImplicitlyDeletable, Intable, Movable


struct TimesOversampling

Traits: AnyType, Copyable, Equatable, ImplicitlyCopyable, ImplicitlyDeletable, Movable


TimesOversampling Functions

struct TimesOversampling . fn get_freq_mul

Get the frequency multiplier for a given oversampling setting.

fn get_freq_mul Signature

def get_freq_mul(world: UnsafePointer[MMMWorld, MutUntrackedOrigin], ov_samp: Self) -> Float64

fn get_freq_mul Arguments

Name Type Default Description
world UnsafePointer[MMMWorld, MutUntrackedOrigin] A pointer to the MMMWorld instance, used to access the sample rate.
ov_samp Self A TimesOversampling struct to use for computing the frequency multiplier.

fn get_freq_mul Returns : Float64 The frequency multiplier corresponding to the oversampling setting.

Static Method

This is a static method.


Documentation generated with mojo doc from Mojo version 1.0.0b2