SoundFonts
public protocol SoundFonts : AnyObject
Actions available on a collection of SoundFont instances. Supports subscribing to changes.
-
True if the collection of sound fonts has been restored
Declaration
Swift
var restored: Bool { get } -
Collection of all of the sound fount names
Declaration
Swift
var soundFontNames: [String] { get } -
The default preset to use if there is not one
Declaration
Swift
var defaultPreset: SoundFontAndPatch? { get } -
Obtain the index in the collection of a SoundFont with the given Key.
Declaration
Swift
func firstIndex(of: LegacySoundFont.Key) -> Int?Parameters
ofthe key to look for
Return Value
the index of the matching entry or nil if not found
-
Obtain the SoundFont in the collection by its unique key
Declaration
Swift
func getBy(key: LegacySoundFont.Key) -> LegacySoundFont?Parameters
keythe key to look for
Return Value
the index of the matching entry or nil if not found
-
Obtain an actual preset object from the given SoundFontAndPatch value.
Declaration
Swift
func resolve(soundFontAndPatch: SoundFontAndPatch) -> LegacyPatch?Parameters
soundFontAndPatchreference to a preset in a sound font
Return Value
LegacyPatch object that corresponds to the given value
-
Obtain the collection of sound fonts that contains the given tag.
Declaration
Swift
func filtered(by tag: LegacyTag.Key) -> [LegacySoundFont.Key]Parameters
tagthe tag to filter on
Return Value
collection of sound font instances that have the given tag
-
Get the names of the given sound fonts.
Declaration
Swift
func names(of keys: [LegacySoundFont.Key]) -> [String]Parameters
keysthe sound font keys to look for
Return Value
list of sound font names
-
Add a new SoundFont.
Declaration
Swift
func add(url: URL) -> Result<(Int, LegacySoundFont), SoundFontFileLoadFailure>Parameters
urlthe URL of the file containing SoundFont (SF2) data
Return Value
2-tuple containing the index in the collection where the new SoundFont was inserted, and the SoundFont instance created from the raw data
-
Remove the SoundFont at the given index
Declaration
Swift
func remove(key: LegacySoundFont.Key)Parameters
indexthe location to remove
-
Change the name of a SoundFont
Declaration
Swift
func rename(key: LegacySoundFont.Key, name: String)Parameters
indexlocation of the SoundFont to edit
namenew name to use
-
Create a new favorite for a sound font preset.
Declaration
Swift
func createFavorite(soundFontAndPatch: SoundFontAndPatch, keyboardLowestNote: Note?) -> LegacyFavorite?Parameters
soundFontAndPatchthe preset to make a favorite
keyboardLowestNotethe lowest note to use for the preset
Return Value
new Favorite
-
Remove an existing favorite.
Declaration
Swift
func deleteFavorite(soundFontAndPatch: SoundFontAndPatch, key: LegacyFavorite.Key)Parameters
soundFontAndPatchthe preset that was used to create the favorite
keythe unique key of the favorite to remove
-
Update the configuration of a preset.
Declaration
Swift
func updatePreset(soundFontAndPatch: SoundFontAndPatch, config: PresetConfig)Parameters
soundFontAndPatchthe preset to update
configthe configuration to use
-
Set the preset visibility.
Declaration
Swift
func setVisibility(soundFontAndPatch: SoundFontAndPatch, state: Bool)Parameters
soundFontAndPatchthe preset to change
statethe new visibility state for the preset
-
Make all presets of a given SoundFont visible.
Declaration
Swift
func makeAllVisible(key: LegacySoundFont.Key)Parameters
keythe unique key of the SoundFont to change
-
Attach effect configurations to a preset.
Declaration
Swift
func setEffects(soundFontAndPatch: SoundFontAndPatch, delay: DelayConfig?, reverb: ReverbConfig?)Parameters
soundFontAndPatchthe preset to change
delaythe configuration for the delay
reverbthe configuration for the reverb
-
Reload the embedded contents of the sound font
Declaration
Swift
func reloadEmbeddedInfo(key: LegacySoundFont.Key)Parameters
keythe sound font to reload
-
Determine if there are any bundled fonts in the collection
Declaration
Swift
var hasAnyBundled: Bool { get } -
Determine if all bundled fonts are in the collection
Declaration
Swift
var hasAllBundled: Bool { get } -
Remove all built-in SoundFont entries.
Declaration
Swift
func removeBundled() -
Restore built-in SoundFonts.
Declaration
Swift
func restoreBundled() -
Export all sound fonts in the collection to a local documents directory that the user can access.
Declaration
Swift
func exportToLocalDocumentsDirectory() -> (good: Int, total: Int)Return Value
2-tuple containing a counter of the number of successful exports and the total number that was attempted
-
Import sound fonts found in the local documents directory for the app.
Declaration
Swift
func importFromLocalDocumentsDirectory() -> (good: Int, total: Int)Return Value
2-tuple containing a counter of the number of successful exports and the total number that was attempted
-
Subscribe to notifications when the collection changes. The types of changes are defined in SoundFontsEvent enum.
Declaration
Swift
@discardableResult func subscribe<O: AnyObject>(_ subscriber: O, notifier: @escaping (SoundFontsEvent) -> Void) -> SubscriberTokenParameters
subscriberthe object doing the monitoring
notifierthe closure to invoke when a change takes place
Return Value
token that can be used to unsubscribe
View on GitHub
SoundFonts Protocol Reference