Polyphony
trait PolyObject¶
PolyObject Required Methods¶
trait PolyObject . fn check_active¶
A required, user defind function to check if the voice is active. This is usually done by checking if the envelope is active or if a Play object is still playing. This function is used internally by Poly to keep track of which voices are active and which are not.
Signature
Returns
Type: Bool
trait PolyObject . fn set_trigger¶
Necessary for triggered PolyObjects. This function is used internally by Poly to set the PolyObject to triggered. That way, the PolyObject can open its own envelope or trigger other parameters in the subsequent next call.
Signature
Arguments
- trigger:
Bool
Default Implementation
This method has a default implementation.
trait PolyObject . fn set_gate¶
Necessary for gated PolyObjects. This function is used internally by PolyGate and PolyGateSig to open and close the gate of the PolyObject.
Signature
Arguments
- gate:
Bool
Default Implementation
This method has a default implementation.
trait PolyObject . fn reset_env¶
Necessary for gated PolyObjects that use gated envelopes. This is needed because Poly will internally copy a living PolyObject to create a new voice, and this can result in a hung voice if the env is already active when it's copied.
Signature
Default Implementation
This method has a default implementation.
struct PolyTrigger¶
A Poly implementation that has an internal Messenger for handling messages from Python. The next function is designed to be used with messages that simply trigger a voice. Use PolyGate for messages that open and close gates.
PolyTrigger is designed to be paired with the PolyPal class in Python. Give them the same name_space and num_messages arguments, and the messages sent from Python with PolyPal will be correctly received by the PolyTrigger object.
Traits: AnyType, Copyable, ImplicitlyDestructible, Movable
PolyTrigger Functions¶
struct PolyTrigger . fn init¶
fn init Signature
__init__(out self, initial_num_voices: Int, max_voices: Int, world: UnsafePointer[MMMWorld, MutExternalOrigin], name_space: String, num_messages: Int = 10)
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| initial_num_voices | Int |
— | — |
| max_voices | Int |
— | — |
| world | UnsafePointer |
— | — |
| name_space | String |
— | — |
| num_messages | Int |
10 |
— |
fn init Returns
: Self
Static Method
This is a static method.
struct PolyTrigger . fn next¶
This convenience function acheives all functionality of a Triggered PolyObject synth in one function. It resets the Poly at the beginning of each block, looks for triggers from Python, and triggers PolyObjects as needed. The optional call_back function is called whenever a new trigger is received from Python. next has to be paired with messages sent from Python as a List[Int] or a List[Float64] or an Int or a Float64. The call_back function receives the List or value as the second argument, so the PolyObject can be controlled by the message from Python.
fn next Signature
next[T: PolyObject](mut self, mut poly_objects: List[T], call_back: fn(mut poly_object: T, mut vals: List[Int]) -> None)
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| call_back | fn(mut poly_object: T, mut vals: List[Int]) -> None |
— | — |
struct PolyTrigger . fn next¶
fn next Signature
next[T: PolyObject](mut self, mut poly_objects: List[T], call_back: fn(mut poly_object: T, mut vals: List[Float64]) -> None)
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| call_back | fn(mut poly_object: T, mut vals: List[Float64]) -> None |
— | — |
struct PolyTrigger . fn next¶
fn next Signature
next[T: PolyObject](mut self, mut poly_objects: List[T], call_back: fn(mut poly_object: T, mut val: Int) -> None)
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| call_back | fn(mut poly_object: T, mut val: Int) -> None |
— | — |
struct PolyTrigger . fn next¶
fn next Signature
next[T: PolyObject](mut self, mut poly_objects: List[T], call_back: fn(mut poly_object: T, mut val: Float64) -> None)
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| call_back | fn(mut poly_object: T, mut val: Float64) -> None |
— | — |
struct PolyGate¶
A Poly implementation that has an internal Messenger for handling messages from Python. The next function is designed to be used with list messages where the second value opens and closes the voice's gate.
PolyGate is designed to be paired with the PolyPal class in Python. Give them the same name_space and num_messages arguments, and the messages sent from Python with PolyPal will be correctly received by the PolyGate object.
Traits: AnyType, Copyable, ImplicitlyDestructible, Movable
PolyGate Functions¶
struct PolyGate . fn init¶
fn init Signature
__init__(out self, initial_num_voices: Int, max_voices: Int, world: UnsafePointer[MMMWorld, MutExternalOrigin], name_space: String, num_messages: Int = 10)
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| initial_num_voices | Int |
— | — |
| max_voices | Int |
— | — |
| world | UnsafePointer |
— | — |
| name_space | String |
— | — |
| num_messages | Int |
10 |
— |
fn init Returns
: Self
Static Method
This is a static method.
struct PolyGate . fn next¶
This convenience function acheives all functionality of a Gated PolyObject synth in one function. It resets the Poly at the beginning of each block, looks for triggers from Python, and opens and closes gates for PolyObjects as needed. The call_back function is called whenever a new trigger is received from Python. next has to be paired with messages sent from Python as a List[Int] or a List[Float64], where the first value is the note or key to trigger and the second value is the velocity or gate of the note. A 0 in the second value will close the gate. The call_back function receives the List or value as the second argument, so the PolyObject can be controlled by the message from Python.
fn next Signature
next[T: PolyObject](mut self, mut poly_objects: List[T], call_back: fn(mut poly_object: T, mut vals: List[Int]) -> None)
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| call_back | fn(mut poly_object: T, mut vals: List[Int]) -> None |
— | — |
struct PolyGate . fn next¶
fn next Signature
next[T: PolyObject](mut self, mut poly_objects: List[T], call_back: fn(mut poly_object: T, mut vals: List[Float64]) -> None)
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| call_back | fn(mut poly_object: T, mut vals: List[Float64]) -> None |
— | — |
struct PolyGateSig¶
A Poly object designed for managing polyphonic synths with gated controls that are signals.
Traits: AnyType, Copyable, ImplicitlyDestructible, Movable
PolyGateSig Functions¶
struct PolyGateSig . fn init¶
fn init Signature
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| initial_num_voices | Int |
— | — |
| max_voices | Int |
— | — |
| num_gates | Int |
— | — |
fn init Returns
: Self
Static Method
This is a static method.
struct PolyGateSig . fn next¶
This function is designed to be used with polyphonic synths that have gated controls that are signals.
fn next Signature
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | A list of structs conforming to the PolyObject trait. This function calls the set_gate function for each PolyObject to open and close the gates as needed. |
| gate_sigs | List |
— | A list of boolean signals that control the gates of the voices. Each signal corresponds to a different gate, so the length of the gate_sigs list should be the same as the number of gates in the synth. When a signal goes from False to True, the corresponding gate will be opened for a new voice. When a signal goes from True to False, the corresponding gate will be closed for the voice that is currently playing with that gate. |
struct PolyTriggerSig¶
A Poly implementation for synths triggered by signals, like TGrains and PitchShift.
Traits: AnyType, Copyable, ImplicitlyDestructible, Movable
PolyTriggerSig Functions¶
struct PolyTriggerSig . fn init¶
Args: initial_num_voices (Int): the number of voices to start with. This can be changed later by the Poly object itself if more voices need to be added. max_voices (Int): the maximum number of voices that can be allocated. Poly will not allocate more than this number of voices.
fn init Signature
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| initial_num_voices | Int |
— | — |
| max_voices | Int |
— | — |
fn init Returns
: Self
Static Method
This is a static method.
struct PolyTriggerSig . fn next¶
Looks at the value of trig. If trig is True, looks for a free voice and triggers it. Returns the index of the voice that was triggered, or -1 if no voice was triggered.
fn next Signature
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| trig | Bool |
— | — |
fn next Returns
: Int
struct PolyTriggerSig . fn next¶
fn next Signature
next[T: PolyObject](mut self, mut poly_objects: List[T], trig: Bool, call_back: fn(mut poly_object: T, trig: Bool) -> None) -> Int
fn next Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| trig | Bool |
— | — |
| call_back | fn(mut poly_object: T, trig: Bool) -> None |
— | — |
fn next Returns
: Int
struct PolyTriggerSig . fn find_voice_and_trigger¶
fn find_voice_and_trigger Signature
fn find_voice_and_trigger Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| T | PolyObject |
— | — |
fn find_voice_and_trigger Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| poly_objects | List |
— | — |
| trig | Bool |
— | — |
fn find_voice_and_trigger Returns
: Int
Documentation generated with mojo doc from Mojo version 0.26.1.0