class
TinySoundFont::SoundFont
- TinySoundFont::SoundFont
- Reference
- Object
Overview
High-level wrapper around LibTSF::TSF Note: Thread safety depends on the underlying C library.
Defined in:
tiny_sound_font/sound_font.crConstructors
-
.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
- .new(filename : String, sample_rate : Int32 = 44100, output_mode : LibTSF::OutputMode = LibTSF::OutputMode::StereoInterleaved, gain_db : Float32 = 0.0_f32)
Class Method Summary
-
.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
Instance Method Summary
- #active_voices : Int32
- #bank_note_off(bank : Int32, program : Int32, key : Int32) : Int32
-
#bank_note_on(bank : Int32, program : Int32, key : Int32, velocity : Float32 = 1.0_f32) : Int32
Notes using bank/program
-
#channel(index : Int32) : Channel
Channel access
- #close
- #closed? : Bool
-
#finalize
Rescue-only finalizer to avoid leaking native handle
- #handle : LibTSF::TSF
- #max_voices=(n : Int32)
- #note_off(preset_index : Int32, key : Int32)
- #note_off_all
-
#note_on(preset_index : Int32, key : Int32, velocity : Float32 = 1.0_f32) : Int32
Notes using preset index
-
#preset_count : Int32
Presets
- #preset_index(bank : Int32, program : Int32) : Int32
- #preset_name(index : Int32) : String
- #render_float(samples : Int32, mixing : Bool = false) : Slice(Float32)
- #render_float!(buffer : Slice(Float32), samples : Int32, mixing : Bool = false)
- #render_short(samples : Int32, mixing : Bool = false) : Slice(Int16)
-
#render_short!(buffer : Slice(Int16), samples : Int32, mixing : Bool = false)
Rendering API samples is the number of frames per channel
-
#reset
Global controls
- #sample_rate : Int32
-
#set_output(mode : LibTSF::OutputMode, sample_rate : Int32 = @sample_rate, gain_db : Float32 = 0.0_f32)
Configure output again if needed
- #volume=(v : Float32)
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
def self.new(filename : String, sample_rate : Int32 = 44100, output_mode : LibTSF::OutputMode = LibTSF::OutputMode::StereoInterleaved, gain_db : Float32 = 0.0_f32)
#
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
Instance Method Detail
def bank_note_on(bank : Int32, program : Int32, key : Int32, velocity : Float32 = 1.0_f32) : Int32
#
Notes using bank/program
def note_on(preset_index : Int32, key : Int32, velocity : Float32 = 1.0_f32) : Int32
#
Notes using preset index
def render_short!(buffer : Slice(Int16), samples : Int32, mixing : Bool = false)
#
Rendering API samples is the number of frames per channel
def set_output(mode : LibTSF::OutputMode, sample_rate : Int32 = @sample_rate, gain_db : Float32 = 0.0_f32)
#
Configure output again if needed