struct SunVox::Module

Overview

High-level wrapper around a synth, effect, or misc module inside a SunVox::Slot.

Defined in:

module.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(slot : Slot, id : Int32) #

[View source]

Instance Method Detail

def >>(destination : Module | Int32) : Module #

Chainable connection operator: gen >> filter >> reverb >> slot.output.


[View source]
def [](index_or_name : Int32 | String, scaled : CtlScale = CtlScale::Real) : Int32 #

Reads a controller value by 0-based index or name.


[View source]
def []=(index_or_name : Int32 | String, val : Int32) : Int32 #

Sets a controller value by 0-based index or name.


[View source]
def bypass? : Bool #

Returns true if this module is bypassed.


[View source]
def clean!(track : Int32 = 0) : self #

Stops this module and clears its internal buffers (NOTECMD_CLEAN_MODULE).


[View source]
def color : Int32 #

Gets the module's color in 0xBBGGRR format.


[View source]
def color=(new_color : Int32) : Int32 #

Sets the module's color in 0xBBGGRR format.


[View source]
def connect(destination : Module) : Module #

Connects this module (source) to destination and returns destination for chaining.


[View source]
def connect(destination_id : Int32) : Module #

Connects this module (source) to destination_id and returns the destination Module.


[View source]
def connect_to_output : Module #

Connects this module directly to the slot's master Output module (module 0).


[View source]
def controllers : Array(Controller) #

Returns all controllers on this module.


[View source]
def ctl(index : Int32) : Controller #

Returns the Controller at index (0-based).


[View source]
def ctl(name : String) : Controller #

Finds a Controller by name (case-insensitive), raising if not found.


[View source]
def ctl?(index : Int32) : Controller | Nil #

Returns the Controller at index if in range, or nil.


[View source]
def ctl?(name : String) : Controller | Nil #

Finds a Controller by name (case-insensitive), or nil if not found.


[View source]
def ctl_count : Int32 #

Number of controllers on this module.


[View source]
def curve(curve_num : Int32 = 0, length : Int32 = 257) : Slice(Float32) #

Reads curve values (Float32) from this module.


[View source]
def disconnect(destination : Module | Int32) : self #

Disconnects this module from destination.


[View source]
def effect? : Bool #

Returns true if this module is an effect (Sound input + Sound output).


[View source]
def exists? : Bool #

Returns true if this module exists in the slot.


[View source]
def finetune : Int32 #

Gets the module's finetune (-256..256).


[View source]
def finetune=(val : Int32) : Int32 #

Sets the module's finetune (-256..256) immediately.


[View source]
def finetune_info : NamedTuple(finetune: Int32, relative_note: Int32) #

Gets both {finetune, relative_note} for this module.


[View source]
def flags : UInt32 #

Raw bitflags for this module (LibSunVox::MODULE_FLAG_*).


[View source]
def generator? : Bool #

Returns true if this module is a generator (Note input + Sound output).


[View source]
def id : Int32 #

[View source]
def input_ids : Array(Int32) #

Active input module IDs connected to this module.


[View source]
def inputs : Array(Module) #

Active input modules connected to this module.


[View source]
def metamodule_load(filename : String | Path) : self #

Loads a file (sunvox, mod, xm, midi) into this MetaModule.


[View source]
def metamodule_load(data : Bytes) : self #

Loads a project from memory (Bytes) into this MetaModule.


[View source]
def muted? : Bool #

Returns true if this module is muted.


[View source]
def name : String #

Gets the module's name.


[View source]
def name=(new_name : String) : String #

Sets the module's name.


[View source]
def note_off(track : Int32 = 0) : self #

Sends a Note Off command on track for this module.


[View source]
def output_ids : Array(Int32) #

Active output module IDs connected from this module.


[View source]
def output_module? : Bool #

Returns true if this is the master Output module (ID 0).


[View source]
def outputs : Array(Module) #

Active output modules connected from this module.


[View source]
def play_frequency(freq_hz : Number, track : Int32 = 0, velocity : Int32 = 129) : self #

Triggers a specific frequency (in Hz) on this module using NOTECMD_SET_PITCH.


[View source]
def play_note(note : Note | Int32, track : Int32 = 0, velocity : Int32 = 129, ctl : Int32 = 0, effect : Int32 = 0, ctl_value : Int32 = 0) : self #

Triggers a note on this module.


[View source]
def raw_inputs : Slice(Int32) #

Raw input link slot array (may contain -1 for empty link slots).


[View source]
def raw_outputs : Slice(Int32) #

Raw output link slot array (may contain -1 for empty link slots).


[View source]
def relative_note : Int32 #

Gets the module's relative note (transposition).


[View source]
def relative_note=(val : Int32) : Int32 #

Sets the module's relative note (transposition) immediately.


[View source]
def relnote : Int32 #

Alias for #relative_note.


[View source]
def relnote=(val : Int32) : Int32 #

Alias for #relative_note=.


[View source]
def remove! : Nil #

Removes this module from its slot.


[View source]
def rgb : NamedTuple(r: UInt8, g: UInt8, b: UInt8) #

Gets the module's color unpacked into {r, g, b} bytes (0..255).


[View source]
def sampler_load(filename : String | Path, sample_slot : Int32 = -1) : self #

Loads a sample file into this Sampler module (sample_slot = -1 replaces the whole sampler).


[View source]
def sampler_load(data : Bytes, sample_slot : Int32 = -1) : self #

Loads a sample from memory (Bytes) into this Sampler module.


[View source]
def sampler_par(par : SamplerParam | Int32, sample_slot : Int32 = 0) : Int32 #

Gets a sample parameter from this Sampler module (sv_sampler_par).


[View source]
def scope(channel : Int32 = 0, samples_to_read : Int32 = 1024) : Slice(Int16) #

Reads oscilloscope samples (Int16) from this module's output.


[View source]
def send_event(track : Int32 = 0, note : Note | Int32 = Note::None, velocity : Int32 = 0, ctl : Int32 = 0, effect : Int32 = 0, ctl_value : Int32 = 0) : self #

Sends an event targeting this module.


[View source]
def set_curve(curve_num : Int32, data : Slice(Float32)) : Int32 #

Writes curve values (Slice(Float32)) to this module.


[View source]
def set_curve(curve_num : Int32, data : Array(Float32)) : Int32 #

Writes curve values (Array(Float32)) to this module.


[View source]
def set_rgb(r : Int, g : Int, b : Int) : self #

Sets the module's color from RGB components (0..255).


[View source]
def set_sampler_par(par : SamplerParam | Int32, val : Int32, sample_slot : Int32 = 0) : Int32 #

Sets a sample parameter on this Sampler module (sv_sampler_par) and returns the previous value.


[View source]
def set_xy(x : Int32, y : Int32) : self #

Sets the module's (x, y) coordinates.


[View source]
def slot : Slot #

[View source]
def solo? : Bool #

Returns true if this module is soloed.


[View source]
def to_i : Int32 #

Returns the integer module ID.


[View source]
def type : String #

Gets the module's type string (e.g., "Generator", "Filter Pro", "Output").


[View source]
def vplayer_load(filename : String | Path) : self #

Loads an OGG Vorbis file into this Vorbis Player module.


[View source]
def vplayer_load(data : Bytes) : self #

Loads an OGG Vorbis stream from memory (Bytes) into this Vorbis Player module.


[View source]
def x : Int32 #

Gets the module's X coordinate.


[View source]
def x=(new_x : Int32) : Int32 #

Sets the module's X coordinate.


[View source]
def xy : NamedTuple(x: Int32, y: Int32) #

Gets the module's {x, y} coordinates.


[View source]
def y : Int32 #

Gets the module's Y coordinate.


[View source]
def y=(new_y : Int32) : Int32 #

Sets the module's Y coordinate.


[View source]