class

TinySoundFont::SoundFont

Inherits Reference < Object

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

Constructors

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

Source
new(filename : String, sample_rate : Int32 = 44100, output_mode : LibTSF::OutputMode = LibTSF::OutputMode::StereoInterleaved, gain_db : Float32 = 0.0_f32)
Source

Class methods

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

Source

Instance methods

active_voices
Source
bank_note_off(bank : Int32, program : Int32, key : Int32) : Int32
Source
bank_note_on(bank : Int32, program : Int32, key : Int32, velocity : Float32 = 1.0_f32) : Int32

Notes using bank/program

Source
channel(index : Int32) : Channel

Channel access

Source
close
Source
closed?
Source
finalize

Rescue-only finalizer to avoid leaking native handle

Source
handle
Source
max_voices=(n : Int32)
Source
note_off(preset_index : Int32, key : Int32)
Source
note_off_all
Source
note_on(preset_index : Int32, key : Int32, velocity : Float32 = 1.0_f32) : Int32

Notes using preset index

Source
preset_count

Presets

Source
preset_index(bank : Int32, program : Int32) : Int32
Source
preset_name(index : Int32) : String
Source
render_float(samples : Int32, mixing : Bool = false) : Slice(Float32)
Source
render_float!(buffer : Slice(Float32), samples : Int32, mixing : Bool = false)
Source
render_short(samples : Int32, mixing : Bool = false) : Slice(Int16)
Source
render_short!(buffer : Slice(Int16), samples : Int32, mixing : Bool = false)

Rendering API samples is the number of frames per channel

Source
reset

Global controls

Source
sample_rate
Source
set_output(mode : LibTSF::OutputMode, sample_rate : Int32 = @sample_rate, gain_db : Float32 = 0.0_f32)

Configure output again if needed

Source
volume=(v : Float32)
Source