Ctrl+K

TinySoundFontBackend

اعلان

public sealed class Strawberry.Sound.Midi.TinySoundFontBackend

backend سنتز MIDI باکیفیت با استفاده از TinySoundFont v0.9 از طریق P/Invoke. نیازمند یک کتابخانه‌ی native کامپایل‌شده‌ی libtsf در مسیر کتابخانه‌ی سیستم.

نکات: این backend از API مبتنی بر کانال TSF (tsf_channel_note_on, tsf_channel_note_off, tsf_channel_set_presetnumber و غیره) استفاده می‌کند که نت‌ها را به‌درستی به preset های هر کانال مسیریابی می‌کند — مطابق با نحوه‌ی کار پخش MIDI. توابع سطح‌پایین tsf_note_on/tsf_note_off یک preset_index می‌گیرند، نه شماره‌ی کانال. استفاده از آن‌ها باعث سازهای اشتباه و crash می‌شود.

پیاده‌سازی: Strawberry.Sound.Midi.ISynthBackend

سازنده‌ها

TinySoundFontBackend

یک SoundFont را از مسیر فایل بارگذاری کرده و synth را مقداردهی اولیه می‌کند.

void TinySoundFontBackend(string soundFontPath, int sampleRate = 44100, int channels = 2, float globalGainDB = -6)

پارامترها:

نام نوع توضیحات
soundFontPath System.String مسیر به یک فایل SoundFont با پسوند .sf2.
sampleRate System.Int32 = 44100 نرخ نمونه‌برداری خروجی (پیش‌فرض 44100).
channels System.Int32 = 2 کانال‌های خروجی: 1 = مونو، 2 = استریو (پیش‌فرض 2).
globalGainDB System.Single = -6 gain سراسری به dB (پیش‌فرض -6 برای جلوگیری از clipping).

TinySoundFontBackend

یک SoundFont را از یک stream بارگذاری کرده و synth را مقداردهی اولیه می‌کند.

void TinySoundFontBackend(Stream soundFontStream, int sampleRate = 44100, int channels = 2, float globalGainDB = -6)

پارامترها:

نام نوع توضیحات
soundFontStream System.IO.Stream
sampleRate System.Int32 = 44100
channels System.Int32 = 2
globalGainDB System.Single = -6

ویژگی‌ها

SampleRate

int SampleRate { get }

Channels

int Channels { get }

متدها

NoteOn

void NoteOn(int channel, int key, float velocity)

پارامترها:

نام نوع توضیحات
channel System.Int32
key System.Int32
velocity System.Single

NoteOff

void NoteOff(int channel, int key)

پارامترها:

نام نوع توضیحات
channel System.Int32
key System.Int32

NoteOffAll

void NoteOffAll()

ProgramChange

void ProgramChange(int channel, int program)

پارامترها:

نام نوع توضیحات
channel System.Int32
program System.Int32

ControlChange

void ControlChange(int channel, int controller, int value)

پارامترها:

نام نوع توضیحات
channel System.Int32
controller System.Int32
value System.Int32

PitchWheel

void PitchWheel(int channel, int value)

پارامترها:

نام نوع توضیحات
channel System.Int32
value System.Int32

Reset

void Reset()

RenderShort

int RenderShort(short[] buffer, int offset, int sampleFrames)

پارامترها:

نام نوع توضیحات
buffer System.Int16[]
offset System.Int32
sampleFrames System.Int32

Dispose

void Dispose()