Table of Contents

Class SoundFont

Namespace
NAudio.SoundFont
Assembly
NAudio.Core.dll

Represents a SoundFont

public class SoundFont
Inheritance
SoundFont
Inherited Members

Constructors

SoundFont(Stream)

Loads a SoundFont from a stream

public SoundFont(Stream sfFile)

Parameters

sfFile Stream

stream

SoundFont(string)

Loads a SoundFont from a file

public SoundFont(string fileName)

Parameters

fileName string

Filename of the SoundFont

Properties

FileInfo

The File Info Chunk

public InfoChunk FileInfo { get; }

Property Value

InfoChunk

Has24BitSamples

Whether this SoundFont carries 24-bit sample data (an sm24 sub-chunk).

public bool Has24BitSamples { get; }

Property Value

bool

Instruments

The Instruments

public Instrument[] Instruments { get; }

Property Value

Instrument[]

Presets

The Presets

public Preset[] Presets { get; }

Property Value

Preset[]

SampleData

The raw Sample Data exactly as stored in the file's smpl chunk: the high 16 bits of each sample, little-endian. For 24-bit SoundFonts the least-significant 8 bits are stored separately in SampleData24 (the file keeps them in a parallel sm24 chunk so 16-bit players can ignore them). To get decoded samples at the font's full precision use ReadSampleDataFloat().

public byte[] SampleData { get; }

Property Value

byte[]

SampleData24

The raw optional 24-bit extension data (the file's sm24 chunk: one byte per sample, the low 8 bits of each sample), or null if the SoundFont contains only 16-bit samples. Pairs one byte with each 16-bit sample in SampleData; combine as (smpl16 << 8) | sm24, or use ReadSampleDataFloat().

public byte[] SampleData24 { get; }

Property Value

byte[]

SampleHeaders

The Sample Headers

public SampleHeader[] SampleHeaders { get; }

Property Value

SampleHeader[]

Methods

ReadSampleDataFloat()

Decodes the sample pool to normalised 32-bit float at the font's full available precision: 16-bit samples from SampleData, extended with the low bytes from SampleData24 when the font is 24-bit (each sample is (smpl16 << 8) | sm24, scaled by 2^23). SampleHeader start/end/loop addresses index the result directly (one float per sample point). Allocates a new array on every call.

public float[] ReadSampleDataFloat()

Returns

float[]

ToString()

public override string ToString()

Returns

string