module SunVox

Defined in:

note.cr
sunvox.cr

Constant Summary

BUFFER_SIZE = 1024
CURRENT_VERSION_MAJOR = 2
CURRENT_VERSION_MINOR = 1
CURRENT_VERSION_MINOR2 = 0
DEFAULT_CHANNELS = 2
DEFAULT_CONFIG = ""
DEFAULT_FREQ = 44100
MAX_SLOTS = 16
NO_MODULE = -1
OUTPUT_MODULE = 0

Class Method Summary

Class Method Detail

def self.close_slot(slot : Slot) #

Closes a slot. Raises exception if the slot is closed or something goes wrong.


[View source]
def self.connect_module(slot : Slot, src, dest) #

Connect a module src to a module dest.


[View source]
def self.disconnect_module(slot : Slot, src, dest) #

Disconnect a module src from a module dest.


[View source]
def self.end_of_song?(slot : Slot) : Bool #

Is the song over and the end has been reached?


[View source]
def self.export_to_wav(slot, song_len_frames, out_filename) #

[View source]
def self.find_module(slot : Slot, name) #

Find a module in a slot by name


[View source]
def self.find_pattern(slot : Slot, name) #

Finds the pattern in slot by name


[View source]
def self.frequency_to_pitch(in_freq) #

[View source]
def self.get_current_line(slot : Slot) #

The current line the playhead is at


[View source]
def self.get_current_line2(slot : Slot) #

THe current line the play head is at in a fractional form (not sure how this works) https://warmplace.ru/soft/sunvox/sunvox_lib.php#sv_get_current_line2


[View source]
def self.get_current_signal_level(slot : Slot, channel) #

Gets the current output signal level


[View source]
def self.get_log(bytes : Int32) #

Gets the debug log messages


[View source]
def self.get_module_color(slot : Slot, module_num) #

TODO Parse the color Get the color of a module in 0xBBGGRR format.


[View source]
def self.get_module_ctl_name(slot : Slot, module_num, ctl_num) #

Get the name of a module's controller.


[View source]
def self.get_module_ctl_value(slot : Slot, module_num, ctl_num, scaled = false) #

Get the value of a modules controller.


[View source]
def self.get_module_curve(slot : Slot, module_num, curve_num, length) #

Get the curve from a module


[View source]
def self.get_module_finetune(slot : Slot, module_num) #

Get module's finetune values.


[View source]
def self.get_module_flags(slot : Slot, module_num) #

TODO Parse the flags Get the flags set on a module


[View source]
def self.get_module_inputs(slot : Slot, module_num) #

A list of all the inputs a module has.


[View source]
def self.get_module_inputs_number(slot : Slot, module_num) #

The number of module inputs.


[View source]
def self.get_module_name(slot : Slot, name) #

Gets the name of a module.


[View source]
def self.get_module_outputs(slot : Slot, module_num) #

A list of all the outputs a module has.


[View source]
def self.get_module_outputs_number(slot : Slot, module_num) #

The number of module outputs.


[View source]
def self.get_module_scope(slot : Slot, module_num, channel, samples_to_read) #

TODO Not sure if this works right, and not sure how to check if it does.... Maybe try to output to WAV or something.... Get the raw audio output values for a module.


[View source]
def self.get_module_xy(slot : Slot, module_num) #

Get the x, y positon of a module.


[View source]
def self.get_number_of_module_ctls(slot : Slot, module_num) #

Get the number of controllers a module has.


[View source]
def self.get_number_of_modules(slot : Slot) #

The number of modules in slot


[View source]
def self.get_number_of_patterns(slot : Slot) #

Gets the number of patterns in a slot


[View source]
def self.get_pattern_data(slot : Slot, pattern_num) #

Get the event data, seperated by tracks.


[View source]
def self.get_pattern_lines(slot : Slot, pattern_num) #

Gets the number of lines in a pattern


[View source]
def self.get_pattern_name(slot : Slot, pattern_num) #

Gets the pattern's name


[View source]
def self.get_pattern_tracks(slot : Slot, pattern_num) #

Get the number of track in the pattern.


[View source]
def self.get_pattern_x(slot : Slot, pat_num) #

Gets the pattern's starting line.


[View source]
def self.get_pattern_y(slot : Slot, pat_num) #

Gets the pattern's height.


[View source]
def self.get_song_bpm(slot : Slot) #

Gets the BPM of the song in slot


[View source]
def self.get_song_length(slot : Slot) #

Get the length of the song in seconds


[View source]
def self.get_song_length_frames(slot : Slot) #

The total length in ticks of the song in slots.


[View source]
def self.get_song_length_lines(slot : Slot) #

The total song length in lines of slot.


[View source]
def self.get_song_name(slot : Slot) #

Gets the name of the song in slot


[View source]
def self.get_song_tpl(slot : Slot) #

Number of lines executed in a second in the song.


[View source]
def self.load(slot : Slot, filename) #

Loads a filename into a slot.


[View source]
def self.load_module(slot : Slot, filename, x = 0, y = 0, z = 0) #

Load a module from a file. File can be sunsynth, xi, wav, or aiff.


[View source]
def self.module_bypass?(slot : Slot, module_num) #

[View source]
def self.module_effect?(slot : Slot, module_num) #

[View source]
def self.module_exists?(slot : Slot, module_num) #

[View source]
def self.module_mute?(slot : Slot, module_num) #

[View source]
def self.module_solo?(slot : Slot, module_num) #

[View source]
def self.new_module(slot : Slot, type : ModuleType, name = "", x = 0, y = 0, z = 0) #

Create a new module in slot. Returns the number of the new module.


[View source]
def self.offline? #

[View source]
def self.open_slot(slot : Slot) #

Opens a slot


[View source]
def self.pattern_mute(slot : Slot, pattern_num, mute = true) #

Mute/Unmute the pattern.


[View source]
def self.pause(slot : Slot) #

Pauses the playback at the current line.


[View source]
def self.pitch_to_frequency(in_pitch) #

[View source]
def self.play(slot : Slot) #

Plays the current song from the current line.


[View source]
def self.play_from_beginning(slot : Slot) #

Plays the current song from the beginning.


[View source]
def self.remove_module(slot : Slot, module_num) #

Remove the module module_num in slot.


[View source]
def self.repeats?(slot : Slot) : Bool #

Returns whether or not a song will repeat when the end is reached.


[View source]
def self.resume(slot : Slot) #

Resumes playback from a paused state.


[View source]
def self.sample_rate #

[View source]
def self.sample_size #

[View source]
def self.sampler_load(slot : Slot, sampler_module_num, filename, sample_slot = -1) #

Loads a file into a sampler. File must be xi, wav, or aiff.


[View source]
def self.send_event(slot : Slot, track_num, note : Note, velocity, module_num = -1, ctl = 0, effect = 0, ctl_value = 0) #

Sends an event to SunVox. Can be used to send notes, change ctl values, or set note effects. A module_num of 0 causes no effect, so any module you would like to actually use must have 1 added to it


[View source]
def self.send_event(slot : Slot, track_num, note : Int32, velocity, module_num = -1, ctl = 0, effect = 0, ctl_value = 0) #

Sends an event to SunVox. Can be used to send notes, change ctl values, or set note effects. A module_num of 0 causes no effect, so any module you would like to actually use must have 1 added to it


[View source]
def self.send_event(slot : Slot, track_num, event : Event) #

Sends an event to SunVox. Can be used to send notes, change ctl values, or set note effects. A module_num of 0 causes no effect, so any module you would like to actually use must have 1 added to it


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

Changes how SunVox processes .send_event. Instead of playing the event as soon as it's called, this allows .send_event to be delayed by a number of ticks. When setting set to false it will reset the timing method back to immediate. When used timestamp should generally be SunVox.ticks + (SunVox.ticks_per_second/1000 * delay_milliseconds)


[View source]
def self.set_module_curve(slot : Slot, module_num, curve_num, curve_data : Slice(Float32)) #

TODO Do I need to Pointer.malloc here? Set the curve data of a module


[View source]
def self.set_repeat(slot : Slot, bool) : Nil #

Sets whether or not a song will repeat when the end is reached.


[View source]
def self.skip_to_line(slot : Slot, line_num : Int32) #

Jumps the current position of the playhead to a line number.


[View source]
def self.start_engine(config = DEFAULT_CONFIG, freq = DEFAULT_FREQ, channels = DEFAULT_CHANNELS, no_debug_output = false, offline = false, sample_type = SampleType::Int16, one_thread = false) #

Starts up the SunVox Engine. Hooks at_exit to ensure .stop_engine is run on close


[View source]
def self.started? #

[View source]
def self.stop(slot : Slot) #

Stops the current song from playing. 2 calls will stop all the synths and sounds.


[View source]
def self.stop_engine #

Shuts down the engine.


[View source]
def self.ticks : UInt32 #

The current tick


[View source]
def self.ticks_per_second : UInt32 #

How many ticks happen per second


[View source]
def self.time_map(slot : Slot, start_line, len, flags = 0) #

Honestly, no idea how this one works. Seems like it should be useful if someone who isn't me wants to figure it out lol: https://warmplace.ru/soft/sunvox/sunvox_lib.php#sv_get_time_map Good Luck!


[View source]
def self.update_input #

[View source]
def self.volume(slot : Slot, volume : UInt8) #

Sets the output volume of the slot.


[View source]