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 }
  • Validate the sound font collection, making sure that everything is in order. Removes any stray tags or favorites.

    Declaration

    Swift

    func validateCollections(favorites: Favorites, tags: Tags)

    Parameters

    favorites

    collection of favorites

    tags

    collection of tags

  • Obtain the index in the collection of a SoundFont with the given Key.

    Declaration

    Swift

    func firstIndex(of: LegacySoundFont.Key) -> Int?

    Parameters

    of

    the 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

    key

    the 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

    soundFontAndPatch

    reference 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

    tag

    the tag to filter on

    Return Value

    collection of sound font instances that have the given tag

  • Undocumented

    Declaration

    Swift

    func filteredIndex(index: Int, tag: LegacyTag.Key) -> Int
  • Get the names of the given sound fonts.

    Declaration

    Swift

    func names(of keys: [LegacySoundFont.Key]) -> [String]

    Parameters

    keys

    the 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

    url

    the 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

    index

    the location to remove

  • Change the name of a SoundFont

    Declaration

    Swift

    func rename(key: LegacySoundFont.Key, name: String)

    Parameters

    index

    location of the SoundFont to edit

    name

    new name to use

  • Remove an association between a sound font and a tag

    Declaration

    Swift

    func removeTag(_ tag: LegacyTag.Key)

    Parameters

    tag

    the tag to remove

  • Create a new favorite for a sound font preset.

    Declaration

    Swift

    func createFavorite(soundFontAndPatch: SoundFontAndPatch, keyboardLowestNote: Note?)
      -> LegacyFavorite?

    Parameters

    soundFontAndPatch

    the preset to make a favorite

    keyboardLowestNote

    the 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

    soundFontAndPatch

    the preset that was used to create the favorite

    key

    the unique key of the favorite to remove

  • Update the configuration of a preset.

    Declaration

    Swift

    func updatePreset(soundFontAndPatch: SoundFontAndPatch, config: PresetConfig)

    Parameters

    soundFontAndPatch

    the preset to update

    config

    the configuration to use

  • Set the preset visibility.

    Declaration

    Swift

    func setVisibility(soundFontAndPatch: SoundFontAndPatch, state: Bool)

    Parameters

    soundFontAndPatch

    the preset to change

    state

    the new visibility state for the preset

  • Make all presets of a given SoundFont visible.

    Declaration

    Swift

    func makeAllVisible(key: LegacySoundFont.Key)

    Parameters

    key

    the unique key of the SoundFont to change

  • Attach effect configurations to a preset.

    Declaration

    Swift

    func setEffects(soundFontAndPatch: SoundFontAndPatch, delay: DelayConfig?, reverb: ReverbConfig?)

    Parameters

    soundFontAndPatch

    the preset to change

    delay

    the configuration for the delay

    reverb

    the configuration for the reverb

  • Reload the embedded contents of the sound font

    Declaration

    Swift

    func reloadEmbeddedInfo(key: LegacySoundFont.Key)

    Parameters

    key

    the 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)
      -> SubscriberToken

    Parameters

    subscriber

    the object doing the monitoring

    notifier

    the closure to invoke when a change takes place

    Return Value

    token that can be used to unsubscribe