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
Fields
CustomDefaultModulators
If the sound bank has custom default modulators (DMOD).
public bool CustomDefaultModulators
Field Value
DefaultModulators
Sound bank's default modulators.
public readonly List<Modulator> DefaultModulators
Field Value
Instruments
The sound bank's instruments.
public readonly List<BasicInstrument> Instruments
Field Value
Presets
The sound bank's presets.
public readonly List<BasicPreset> Presets
Field Value
Samples
The sound bank's samples.
public readonly List<BasicSample> Samples
Field Value
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
Properties
Info
public SoundBank.InfoData Info { get; set; }
Property Value
IsXGBank
Checks for XG drum sets and considers if this sound bank is XG.
public bool IsXGBank { get; }
Property Value
Methods
AddCompletePresets(List<BasicPreset>)
Adds complete presets along with their instruments and samples.
public void AddCompletePresets(List<BasicPreset> presets)
Parameters
presetsList<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
instrumentBasicInstrumentThe 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
presetBasicPresetThe 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
sampleBasicSampleThe 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
instrumentBasicInstrument
Delete(BasicPreset)
public void Delete(BasicPreset preset)
Parameters
presetBasicPreset
Delete(BasicSample)
public void Delete(BasicSample sample)
Parameters
sampleBasicSample
Destroy()
public void Destroy()
Flush()
public void Flush()
From(SoundBank)
Copies a given sound bank.
public static SoundBank From(SoundBank bank)
Parameters
bankSoundBankThe 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
bufferArraySegment<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
fileFileInfoThe 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
streamFileStreamThe 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
Returns
GetSampleSoundBankFile()
Creates a simple sound bank with one saw wave preset.
public static ArraySegment<byte> GetSampleSoundBankFile()
Returns
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
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
midMidiThe 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
presetDataPresetsWithKeyCombinationsA 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
fileFileInfoThe path to save the data. Use this for large (>2GB) soundbanks
optionsDLSWriteOptions?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
streamStreamThe stream to save the data. Use this for large (>2GB) soundbanks
optionsDLSWriteOptions?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
optionsDLSWriteOptions?Options for writing the file.
Returns
- ArraySegment<byte>
The DLS in binary form.
Remarks
If your soundbank is large (>2GB), use WriteDLS(FileInfo, DLSWriteOptions?) or WriteDLS(Stream, DLSWriteOptions?)
WriteSF2(FileInfo, SF2WriteOptions?)
Writes the sound bank as an SF2 file.
public void WriteSF2(FileInfo file, SF2WriteOptions? options = null)
Parameters
fileFileInfoThe path to save the data. Use this for large (>2GB) soundbanks
optionsSF2WriteOptions?The options for writing.
WriteSF2(Stream, SF2WriteOptions?)
Writes the sound bank as an SF2 file.
public void WriteSF2(Stream stream, SF2WriteOptions? options = null)
Parameters
streamStreamThe stream to save the data. Use this for large (>2GB) soundbanks
optionsSF2WriteOptions?The options for writing.
WriteSF2(SF2WriteOptions?)
Writes the sound bank as an SF2 file.
public ArraySegment<byte> WriteSF2(SF2WriteOptions? options = null)
Parameters
optionsSF2WriteOptions?The options for writing.
Returns
- ArraySegment<byte>
The binary file data.
Remarks
If your soundbank is large (>2GB), use WriteSF2(FileInfo, SF2WriteOptions?) or WriteSF2(Stream, SF2WriteOptions?)
WriteSFE(FileInfo, SFEWriteOptions?)
Writes the sound bank as an SFE file.
public void WriteSFE(FileInfo file, SFEWriteOptions? options = null)
Parameters
fileFileInfoThe path to save the data. Use this for large (>2GB) soundbanks
optionsSFEWriteOptions?The options for writing.
WriteSFE(Stream, SFEWriteOptions?)
Writes the sound bank as an SFE file.
public void WriteSFE(Stream stream, SFEWriteOptions? options = null)
Parameters
streamStreamThe stream to save the data. Use this for large (>2GB) soundbanks
optionsSFEWriteOptions?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
optionsSFEWriteOptions?The options for writing.
Returns
- ArraySegment<byte>
The binary file data.
Remarks
If your soundbank is large (>2GB), use WriteSFE(FileInfo, SFEWriteOptions?) or WriteSFE(Stream, SFEWriteOptions?)