class TinySoundFont::SoundFont

Overview

High-level wrapper around LibTSF::TSF Note: Thread safety depends on the underlying C library.

Defined in:

tiny_sound_font/sound_font.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from_memory(data : Bytes, sample_rate : Int32 = 44100, output_mode : LibTSF::OutputMode = LibTSF::OutputMode::StereoInterleaved, gain_db : Float32 = 0.0_f32) : self #

Load from memory buffer


[View source]
def self.new(filename : String, sample_rate : Int32 = 44100, output_mode : LibTSF::OutputMode = LibTSF::OutputMode::StereoInterleaved, gain_db : Float32 = 0.0_f32) #

[View source]

Class Method Detail

def self.open(filename : String, sample_rate : Int32 = 44100, output_mode : LibTSF::OutputMode = LibTSF::OutputMode::StereoInterleaved, gain_db : Float32 = 0.0_f32, &) #

RAII helper that ensures close is called


[View source]

Instance Method Detail

def active_voices : Int32 #

[View source]
def bank_note_off(bank : Int32, program : Int32, key : Int32) : Int32 #

[View source]
def bank_note_on(bank : Int32, program : Int32, key : Int32, velocity : Float32 = 1.0_f32) : Int32 #

Notes using bank/program


[View source]
def channel(index : Int32) : Channel #

Channel access


[View source]
def close #

[View source]
def closed? : Bool #

[View source]
def finalize #

Rescue-only finalizer to avoid leaking native handle


[View source]
def handle : LibTSF::TSF #

[View source]
def max_voices=(n : Int32) #

[View source]
def note_off(preset_index : Int32, key : Int32) #

[View source]
def note_off_all #

[View source]
def note_on(preset_index : Int32, key : Int32, velocity : Float32 = 1.0_f32) : Int32 #

Notes using preset index


[View source]
def preset_count : Int32 #

Presets


[View source]
def preset_index(bank : Int32, program : Int32) : Int32 #

[View source]
def preset_name(index : Int32) : String #

[View source]
def render_float(samples : Int32, mixing : Bool = false) : Slice(Float32) #

[View source]
def render_float!(buffer : Slice(Float32), samples : Int32, mixing : Bool = false) #

[View source]
def render_short(samples : Int32, mixing : Bool = false) : Slice(Int16) #

[View source]
def render_short!(buffer : Slice(Int16), samples : Int32, mixing : Bool = false) #

Rendering API samples is the number of frames per channel


[View source]
def reset #

Global controls


[View source]
def sample_rate : Int32 #

[View source]
def set_output(mode : LibTSF::OutputMode, sample_rate : Int32 = @sample_rate, gain_db : Float32 = 0.0_f32) #

Configure output again if needed


[View source]
def volume=(v : Float32) #

[View source]