Class SoundBank

Namespace
SpessaSharp.SoundBank
Assembly
SpessaSharp.dll

Represents a single sound bank, be it DLS or SF2.

public sealed class SoundBank : IPresetGetter
Inheritance
SoundBank
Implements
Inherited Members

Constructors

SoundBank(BankType)

Represents a single sound bank, be it DLS or SF2.

public SoundBank(SoundBank.BankType type = BankType.SF2)

Parameters

type SoundBank.BankType

Fields

CustomDefaultModulators

If the sound bank has custom default modulators (DMOD).

public bool CustomDefaultModulators

Field Value

bool

DefaultModulators

Sound bank's default modulators.

public readonly List<Modulator> DefaultModulators

Field Value

List<Modulator>

Instruments

The sound bank's instruments.

public readonly List<BasicInstrument> Instruments

Field Value

List<BasicInstrument>

Presets

The sound bank's presets.

public readonly List<BasicPreset> Presets

Field Value

List<BasicPreset>

Samples

The sound bank's samples.

public readonly List<BasicSample> Samples

Field Value

List<BasicSample>

Type

The type of the sound bank that was loaded. Either sf2 for SoundFont2/SoundFont3 or dls for DownLoadable Sounds or sfe for SF-Enhanced..

Please note that SF3 or SFOGG files are parsed as sf2 files, but with compressed samples. The type is still sf2.

public readonly SoundBank.BankType Type

Field Value

SoundBank.BankType

Properties

Info

public SoundBank.InfoData Info { get; set; }

Property Value

SoundBank.InfoData

IsXGBank

Checks for XG drum sets and considers if this sound bank is XG.

public bool IsXGBank { get; }

Property Value

bool

Methods

AddCompletePresets(List<BasicPreset>)

Adds complete presets along with their instruments and samples.

public void AddCompletePresets(List<BasicPreset> presets)

Parameters

presets List<BasicPreset>

The presets to add.

Clone(BasicInstrument)

Recursively clones an instrument into this sound bank, as well as its samples.

public BasicInstrument Clone(BasicInstrument instrument)

Parameters

instrument BasicInstrument

The copied instrument, if an instrument exists with that name, it is returned instead.

Returns

BasicInstrument

The cloned instrument

Clone(BasicPreset)

Recursively clones a preset into this sound bank, as well as its instruments and samples.

public BasicPreset Clone(BasicPreset preset)

Parameters

preset BasicPreset

The copied preset, if a preset exists with that name, it is returned instead.

Returns

BasicPreset

The cloned preset

Clone(BasicSample)

Clones a sample into this bank.

public BasicSample Clone(BasicSample sample)

Parameters

sample BasicSample

The sample to copy.

Returns

BasicSample

The copied sample, if a sample exists with that name, it is returned instead

Delete(BasicInstrument)

public void Delete(BasicInstrument instrument)

Parameters

instrument BasicInstrument

Delete(BasicPreset)

public void Delete(BasicPreset preset)

Parameters

preset BasicPreset

Delete(BasicSample)

public void Delete(BasicSample sample)

Parameters

sample BasicSample

Destroy()

public void Destroy()

Flush()

public void Flush()

From(SoundBank)

Copies a given sound bank.

public static SoundBank From(SoundBank bank)

Parameters

bank SoundBank

The sound bank to copy.

Returns

SoundBank

The new copy

From(ArraySegment<byte>)

Loads a sound bank from a file buffer.

public static SoundBank From(ArraySegment<byte> buffer)

Parameters

buffer ArraySegment<byte>

The binary file buffer to load.

Returns

SoundBank

The loaded sound bank, a BasicSoundBank instance.

Remarks

If your soundbank is large (>2GB), use From(FileInfo) or From(FileStream)

From(FileInfo)

Loads a sound bank from a file buffer.

public static SoundBank From(FileInfo file)

Parameters

file FileInfo

The file to load. Use this for large (>2GB) soundbanks

Returns

SoundBank

The loaded sound bank, a BasicSoundBank instance.

From(FileStream)

Loads a sound bank from a file buffer.

public static SoundBank From(FileStream stream)

Parameters

stream FileStream

The file stream to load. Use this for large (>2GB) soundbanks

Returns

SoundBank

The loaded sound bank, a BasicSoundBank instance.

GetPreset(MidiPatch, System)

Get the appropriate preset.

public BasicPreset GetPreset(MidiPatch patch, Midi.System system)

Parameters

patch MidiPatch
system Midi.System

Returns

BasicPreset

GetSampleSoundBankFile()

Creates a simple sound bank with one saw wave preset.

public static ArraySegment<byte> GetSampleSoundBankFile()

Returns

ArraySegment<byte>

Merge(List<SoundBank>)

Merges sound banks with the given order. Keep in mind that the info read is copied from the first one

public static SoundBank Merge(List<SoundBank> soundBanks)

Parameters

soundBanks List<SoundBank>

The sound banks to merge, the first overwrites the last

Returns

SoundBank

The new merged soundbank

Exceptions

ArgumentOutOfRangeException

Empty Soundbank list

RemoveUnusedElements()

public void RemoveUnusedElements()

Trim(Midi)

Trims the sound bank in-place to only contain samples in a given MIDI file. Absent presets will be removed from the sound bank, and samples that don't get activated in the remaining presets will be removed as well.

public void Trim(Midi mid)

Parameters

mid Midi

The MIDI file

Trim(PresetsWithKeyCombinations)

Trims the sound bank in-place to only contain samples in a given MIDI file. Absent presets will be removed from the sound bank, and samples that don't get activated in the remaining presets will be removed as well.

public void Trim(PresetsWithKeyCombinations presetData)

Parameters

presetData PresetsWithKeyCombinations

A Map: BasicPreset -> (key-velocity).

WriteDLS(FileInfo, DLSWriteOptions?)

Write the sound bank as a .dls file. This may not be 100% accurate. Note that samples are always written in the s16le PCM encoding.

public void WriteDLS(FileInfo file, DLSWriteOptions? options = null)

Parameters

file FileInfo

The path to save the data. Use this for large (>2GB) soundbanks

options DLSWriteOptions?

Options for writing the file.

WriteDLS(Stream, DLSWriteOptions?)

Write the sound bank as a .dls file. This may not be 100% accurate. Note that samples are always written in the s16le PCM encoding.

public void WriteDLS(Stream stream, DLSWriteOptions? options = null)

Parameters

stream Stream

The stream to save the data. Use this for large (>2GB) soundbanks

options DLSWriteOptions?

Options for writing the file.

WriteDLS(DLSWriteOptions?)

Write the sound bank as a .dls file. This may not be 100% accurate. Note that samples are always written in the s16le PCM encoding.

public ArraySegment<byte> WriteDLS(DLSWriteOptions? options = null)

Parameters

options DLSWriteOptions?

Options for writing the file.

Returns

ArraySegment<byte>

The DLS in binary form.

Remarks

WriteSF2(FileInfo, SF2WriteOptions?)

Writes the sound bank as an SF2 file.

public void WriteSF2(FileInfo file, SF2WriteOptions? options = null)

Parameters

file FileInfo

The path to save the data. Use this for large (>2GB) soundbanks

options SF2WriteOptions?

The options for writing.

WriteSF2(Stream, SF2WriteOptions?)

Writes the sound bank as an SF2 file.

public void WriteSF2(Stream stream, SF2WriteOptions? options = null)

Parameters

stream Stream

The stream to save the data. Use this for large (>2GB) soundbanks

options SF2WriteOptions?

The options for writing.

WriteSF2(SF2WriteOptions?)

Writes the sound bank as an SF2 file.

public ArraySegment<byte> WriteSF2(SF2WriteOptions? options = null)

Parameters

options SF2WriteOptions?

The options for writing.

Returns

ArraySegment<byte>

The binary file data.

Remarks

WriteSFE(FileInfo, SFEWriteOptions?)

Writes the sound bank as an SFE file.

public void WriteSFE(FileInfo file, SFEWriteOptions? options = null)

Parameters

file FileInfo

The path to save the data. Use this for large (>2GB) soundbanks

options SFEWriteOptions?

The options for writing.

WriteSFE(Stream, SFEWriteOptions?)

Writes the sound bank as an SFE file.

public void WriteSFE(Stream stream, SFEWriteOptions? options = null)

Parameters

stream Stream

The stream to save the data. Use this for large (>2GB) soundbanks

options SFEWriteOptions?

The options for writing.

WriteSFE(SFEWriteOptions?)

Writes the sound bank as an SFE 4 file. This enables features such as bank LSB and RIFF64. Note that spessasynth is currently the only software that can read these files.

public ArraySegment<byte> WriteSFE(SFEWriteOptions? options = null)

Parameters

options SFEWriteOptions?

The options for writing.

Returns

ArraySegment<byte>

The binary file data.

Remarks