AKAppleSampler

open class AKAppleSampler : AKNode

Sampler audio generation.

  1. init the audio unit like this: var sampler = AKAppleSampler()
  2. load a sound a file: sampler.loadWav(path/to/your/sound/file/in/app/bundle) (without wav extension)
  3. connect to the engine: AudioKit.output = sampler
  4. start the engine AudioKit.start()
  • Sampler AV Audio Unit

    Declaration

    Swift

    @objc
    open dynamic var samplerUnit: AVAudioUnitSampler
  • Tuning amount in semitones, from -24.0 to 24.0, Default: 0.0 Doesn’t transpose by playing another note (and the accoring zone and layer) but bends the sound up and down like tuning.

    Declaration

    Swift

    @objc
    open dynamic var tuning: Double { get set }
  • Initialize the sampler node

    Declaration

    Swift

    override public init()
  • Load a wav file

    Declaration

    Swift

    @objc
    open func loadWav(_ file: String) throws

    Parameters

    file

    Name of the file without an extension (assumed to be accessible from the bundle)

  • Load an EXS24 sample data file

    Declaration

    Swift

    @objc
    open func loadEXS24(_ file: String) throws

    Parameters

    file

    Name of the EXS24 file without the .exs extension

  • Load an AKAudioFile

    Declaration

    Swift

    @objc
    open func loadAudioFile(_ file: AKAudioFile) throws

    Parameters

    file

    an AKAudioFile

  • Load an array of AKAudioFiles

    If a file name ends with a note name (ex: violinC3.wav) The file will be set to this note Handy to set multi-sampled instruments or a drum kit…

    Declaration

    Swift

    @objc
    open func loadAudioFiles(_ files: [AKAudioFile]) throws

    Parameters

    files

    An array of AKAudioFiles

  • Load a file path. The sampler can be configured by loading instruments from different types of files such as an aupreset, a DLS or SF2 sound bank, an EXS24 instrument, a single audio file, or an array of audio files.

    Declaration

    Swift

    @objc
    open func loadPath(_ filePath: String) throws

    Parameters

    filePath

    Name of the file with the extension

  • Output Amplitude. Range: -90.0 -> +12 db, Default: 0 db

    Declaration

    Swift

    @objc
    open dynamic var amplitude: Double { get set }
  • Normalized Output Volume. Range: 0 -> 1, Default: 1

    Declaration

    Swift

    @objc
    open dynamic var volume: Double { get set }
  • pan

    Pan. Range: -1 -> 1, Default: 0

    Declaration

    Swift

    @objc
    open dynamic var pan: Double { get set }
  • Load a Bank from a SoundFont SF2 sample data file

    Declaration

    Swift

    @objc
    public func loadSoundFont(_ file: String, preset: Int, bank: Int) throws

    Parameters

    file

    Name of the SoundFont SF2 file without the .sf2 extension

    preset

    Number of the program to use

    bank

    Number of the bank to use

  • Load a Melodic SoundFont SF2 sample data file

    Declaration

    Swift

    @objc
    public func loadMelodicSoundFont(_ file: String, preset: Int) throws

    Parameters

    file

    Name of the SoundFont SF2 file without the .sf2 extension

    preset

    Number of the program to use

  • Load a Percussive SoundFont SF2 sample data file

    Declaration

    Swift

    @objc
    public func loadPercussiveSoundFont(_ file: String, preset: Int = 0) throws

    Parameters

    file

    Name of the SoundFont SF2 file without the .sf2 extension

    preset

    Number of the program to use