enum SunVox::Slot

Overview

The slots SunVox can use. MAX: 16

Defined in:

slot.cr

Enum Members

Zero = 0
One = 1
Two = 2
Three = 3
Four = 4
Five = 5
Six = 6
Seven = 7
Eight = 8
Nine = 9
Ten = 10
Eleven = 11
Twelve = 12
Thirteen = 13
Fourteen = 14
Fifteen = 15

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from_int(in_int : Int) : Slot #

Converts an integer index (0..15) into a Slot, raising if out of range.


[View source]
def self.open(slot : Slot | Int = Slot::Zero) : Slot #

Opens a slot (defaults to Slot::Zero) and returns it.


[View source]

Class Method Detail

def self.open(slot : Slot | Int = Slot::Zero, & : Slot -> ) #

Opens a slot, yields it to the block, and ensures it is closed afterwards.


[View source]

Instance Method Detail

def add_module(type : ModuleType | String, name : String = "", x : Int32 = 512, y : Int32 = 512, z : Int32 = 0) : Module #

Creates a new module in this slot and returns its SunVox::Module wrapper.


[View source]
def add_pattern(lines : Int32 = 32, tracks : Int32 = 4, x : Int32 = 0, y : Int32 = 0, name : String = "", clone : Pattern | Int32 = -1, icon_seed : Int32 = 0) : Pattern #

Alias for #new_pattern.


[View source]
def autostop=(enabled : Bool) : Bool #

Enables or disables autostop on this slot.


[View source]
def autostop? : Bool #

Returns true if autostop is enabled (song stops at end instead of looping).


[View source]
def base_version : Int32 #

Gets the SunVox version used to create the project.


[View source]
def bpm : Int32 #

Gets the project BPM (Beats Per Minute).


[View source]
def close : Nil #

Closes this slot in the SunVox engine.


[View source]
def current_line : Int32 #

Gets the current line number on the timeline.


[View source]
def current_line2 : Int32 #

Gets the current line number in fixed-point 27.5 format.


[View source]
def current_line_float : Float64 #

Gets the current line number as a floating-point value.


[View source]
def duration : Time::Span #

Gets the approximate duration of the project.


[View source]
def eight? #

Returns true if this enum value equals Eight


[View source]
def eleven? #

Returns true if this enum value equals Eleven


[View source]
def end_of_song? : Bool #

Returns true if the song has stopped / finished playing.


[View source]
def export_to_wav(out_filename : String | Path, song_len_frames : Int = length_frames) : self #

Exports the project in this slot to a WAV file (requires engine started with offline: true).


[View source]
def fifteen? #

Returns true if this enum value equals Fifteen


[View source]
def find_module(name : String) : Module | Nil #

Finds a module by name and returns it, or nil if not found.


[View source]
def find_pattern(name : String) : Pattern | Nil #

Finds a pattern by name and returns it, or nil if not found.


[View source]
def five? #

Returns true if this enum value equals Five


[View source]
def four? #

Returns true if this enum value equals Four


[View source]
def fourteen? #

Returns true if this enum value equals Fourteen


[View source]
def from_int(in_int : Int) : Slot #

Instance-level helper preserved for backwards compatibility.


[View source]
def length_frames : UInt32 #

Gets the project length in audio frames.


[View source]
def length_lines : UInt32 #

Gets the project length in tracker lines.


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

Loads a project file (.sunvox, .mod, .xm) from disk into this slot.


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

Loads a project from a memory buffer (Bytes) into this slot.


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

Alias for #load(data : Bytes).


[View source]
def load_module(filename : String | Path, x : Int32 = 512, y : Int32 = 512, z : Int32 = 0) : Module #

Loads a module or sample from a file (sunsynth, xi, wav, aiff, ogg, mp3, flac) and returns a SunVox::Module.


[View source]
def load_module(data : Bytes, x : Int32 = 512, y : Int32 = 512, z : Int32 = 0) : Module #

Loads a module or sample from memory (Bytes) and returns a SunVox::Module.


[View source]
def load_module_from_memory(data : Bytes, x : Int32 = 512, y : Int32 = 512, z : Int32 = 0) : Module #

Alias for #load_module(data : Bytes, ...).


[View source]
def lock : Nil #

Locks this slot for thread-safe access/modification.


[View source]
def module(id : Int32) : Module #

Returns a SunVox::Module handle for id.


[View source]
def module(name : String) : Module #

Finds a module by name and returns its SunVox::Module, raising if not found.


[View source]
def module?(id : Int32) : Module | Nil #

Returns a SunVox::Module for id if it exists in this slot, or nil.


[View source]
def module?(name : String) : Module | Nil #

Finds a module by name and returns it, or nil if not found.


[View source]
def module_slots_count : Int32 #

Returns the number of module slots in the project (some slots may be empty).


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

Returns all active modules currently existing in this slot.


[View source]
def name : String #

Gets the project/song name.


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

Sets the project/song name.


[View source]
def new_module(type : ModuleType | String, name : String = "", x : Int32 = 512, y : Int32 = 512, z : Int32 = 0) : Module #

Alias for #add_module.


[View source]
def new_pattern(lines : Int32 = 32, tracks : Int32 = 4, x : Int32 = 0, y : Int32 = 0, name : String = "", clone : Pattern | Int32 = -1, icon_seed : Int32 = 0) : Pattern #

Creates a new pattern in this slot and returns its SunVox::Pattern wrapper.


[View source]
def nine? #

Returns true if this enum value equals Nine


[View source]
def one? #

Returns true if this enum value equals One


[View source]
def open : self #

Opens this slot in the SunVox engine.


[View source]
def open? : Bool #

Returns true if this slot is currently open.


[View source]
def output : Module #

Returns the built-in Output module (module 0) for this slot.


[View source]
def pattern(id : Int32) : Pattern #

Returns a SunVox::Pattern handle for id.


[View source]
def pattern(name : String) : Pattern #

Finds a pattern by name and returns its SunVox::Pattern, raising if not found.


[View source]
def pattern?(id : Int32) : Pattern | Nil #

Returns a SunVox::Pattern for id if it exists in this slot, or nil.


[View source]
def pattern?(name : String) : Pattern | Nil #

Finds a pattern by name and returns it, or nil if not found.


[View source]
def pattern_slots_count : Int32 #

Returns the number of pattern slots in the project (some slots may be empty).


[View source]
def patterns : Array(Pattern) #

Returns all active patterns currently existing in this slot.


[View source]
def pause : self #

Pauses the audio stream on this slot.


[View source]
def play : self #

Plays the current project from the current playhead position.


[View source]
def play_from_beginning : self #

Plays the current project from the beginning (line 0).


[View source]
def playing? : Bool #

Returns true if the song is currently playing.


[View source]
def repeats=(repeat : Bool) : Bool #

Sets whether the song repeats when the end is reached.


[View source]
def repeats? : Bool #

Returns whether the song repeats (i.e. autostop is disabled).


[View source]
def reset_event_time : self #

Resets event timing on this slot back to automatic mode.


[View source]
def resume : self #

Resumes the audio stream on this slot.


[View source]
def rewind(line_num : Int32) : self #

Jumps the playhead to line_num.


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

Saves the current project in this slot to a file on disk.


[View source]
def save_to_bytes : Bytes #

Saves the current project in this slot to a Bytes buffer in memory.


[View source]
def save_to_memory : Bytes #

Alias for #save_to_bytes.


[View source]
def send_event(track_num : Int32, note : Note | Int32 = Note::None, velocity : Int32 = 0, mod : Module | Int32 = -1, ctl : Int32 = 0, effect : Int32 = 0, ctl_value : Int32 = 0) : self #

Sends a real-time event to this slot.


[View source]
def send_event(track_num : Int32, event : Event) : self #

Sends a SunVox::Event record to track_num on this slot.


[View source]
def set_event_time(timestamp : UInt32 = 0_u32, set : Bool = true) : self #

Sets the timestamp for subsequent events sent to this slot.


[View source]
def seven? #

Returns true if this enum value equals Seven


[View source]
def signal_level(channel : Int32 = 0) : Int32 #

Gets the current real-time output signal level (0..255) for channel (0 = left, 1 = right).


[View source]
def six? #

Returns true if this enum value equals Six


[View source]
def skip_to_line(line_num : Int32) : self #

Alias for #rewind.


[View source]
def song_name : String #

Alias for #name.


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

Alias for #name=.


[View source]
def stop : self #

Stops playback (second call puts all modules into standby mode).


[View source]
def sync_resume : self #

Waits for sync (pattern effect 0x33) and resumes the audio stream on this slot.


[View source]
def synchronize(&) #

Locks this slot, yields self, and unlocks in an ensure block.


[View source]
def ten? #

Returns true if this enum value equals Ten


[View source]
def thirteen? #

Returns true if this enum value equals Thirteen


[View source]
def three? #

Returns true if this enum value equals Three


[View source]
def time_map(start_line : Int32 = 0, len : Int32 = length_lines.to_i, flags : TimeMapFlags | Int32 = TimeMapFlags::Speed) : Slice(UInt32) #

Gets the project time map for len lines starting at start_line.


[View source]
def tpl : Int32 #

Gets the project TPL (Ticks Per Line).


[View source]
def twelve? #

Returns true if this enum value equals Twelve


[View source]
def two? #

Returns true if this enum value equals Two


[View source]
def unlock : Nil #

Unlocks this slot.


[View source]
def volume(vol : Int) : Int32 #

Sets the volume of this slot (0..256) and returns the previous volume.


[View source]
def volume : Int32 #

Gets the current volume of this slot (0..256).


[View source]
def volume=(vol : Int) #

Sets the volume of this slot (0..256).


[View source]
def zero? #

Returns true if this enum value equals Zero


[View source]