struct

SunVox::Module

Inherits Struct < Value < Object

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

Constructors

new(slot : Slot, id : Int32)
Source

Instance methods

>>(destination : Module | Int32) : Module

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

Source
[](index_or_name : Int32 | String, scaled : CtlScale = CtlScale::Real) : Int32

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

Source
[]=(index_or_name : Int32 | String, val : Int32) : Int32

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

Source
bypass?

Returns true if this module is bypassed.

Source
clean!(track : Int32 = 0) : self

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

Source
color

Gets the module's color in 0xBBGGRR format.

Source
color=(new_color : Int32) : Int32

Sets the module's color in 0xBBGGRR format.

Source
connect(destination : Module) : Module

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

Source
connect(destination_id : Int32) : Module

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

Source
connect_to_output

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

Source
controllers

Returns all controllers on this module.

Source
ctl(index : Int32) : Controller

Returns the Controller at index (0-based).

Source
ctl(name : String) : Controller

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

Source
ctl?(index : Int32) : Controller | Nil

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

Source
ctl?(name : String) : Controller | Nil

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

Source
ctl_count

Number of controllers on this module.

Source
curve(curve_num : Int32 = 0, length : Int32 = 257) : Slice(Float32)

Reads curve values (Float32) from this module.

Source
disconnect(destination : Module | Int32) : self

Disconnects this module from destination.

Source
effect?

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

Source
exists?

Returns true if this module exists in the slot.

Source
finetune

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

Source
finetune=(val : Int32) : Int32

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

Source
finetune_info

Gets both {finetune, relative_note} for this module.

Source
flags

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

Source
generator?

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

Source
input_ids

Active input module IDs connected to this module.

Source
inputs

Active input modules connected to this module.

Source
metamodule_load(filename : String | Path) : self

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

Source
metamodule_load(data : Bytes) : self

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

Source
muted?

Returns true if this module is muted.

Source
name

Gets the module's name.

Source
name=(new_name : String) : String

Sets the module's name.

Source
note_off(track : Int32 = 0) : self

Sends a Note Off command on track for this module.

Source
output_ids

Active output module IDs connected from this module.

Source
output_module?

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

Source
outputs

Active output modules connected from this module.

Source
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.

Source
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.

Source
raw_inputs

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

Source
raw_outputs

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

Source
relative_note

Gets the module's relative note (transposition).

Source
relative_note=(val : Int32) : Int32

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

Source
relnote

Alias for #relative_note.

Source
relnote=(val : Int32) : Int32

Alias for #relative_note=.

Source
remove!

Removes this module from its slot.

Source
rgb

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

Source
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).

Source
sampler_load(data : Bytes, sample_slot : Int32 = -1) : self

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

Source
sampler_par(par : SamplerParam | Int32, sample_slot : Int32 = 0) : Int32

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

Source
scope(channel : Int32 = 0, samples_to_read : Int32 = 1024) : Slice(Int16)

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

Source
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.

Source
set_curve(curve_num : Int32, data : Slice(Float32)) : Int32

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

Source
set_curve(curve_num : Int32, data : Array(Float32)) : Int32

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

Source
set_rgb(r : Int, g : Int, b : Int) : self

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

Source
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.

Source
set_xy(x : Int32, y : Int32) : self

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

Source
slot
Source
solo?

Returns true if this module is soloed.

Source
to_i

Returns the integer module ID.

Source
type

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

Source
vplayer_load(filename : String | Path) : self

Loads an OGG Vorbis file into this Vorbis Player module.

Source
vplayer_load(data : Bytes) : self

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

Source
x

Gets the module's X coordinate.

Source
x=(new_x : Int32) : Int32

Sets the module's X coordinate.

Source
xy

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

Source
y

Gets the module's Y coordinate.

Source
y=(new_y : Int32) : Int32

Sets the module's Y coordinate.

Source