Playback Nodes

  • 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()
    See more

    Declaration

    Swift

    open class AKAppleSampler : AKNode
  • A protocol containing timing information for scheduling audio clips in a timeline. All properties are time values in seconds, relative to a zero based timeline.

    See more

    Declaration

    Swift

    @objc
    public protocol AKClip : AnyObject
  • A FileClip implementation, used by AKClipPlayer.

    See more

    Declaration

    Swift

    open class AKFileClip : NSObject, FileClip
  • A file based AKClip

    See more

    Declaration

    Swift

    @objc
    public protocol FileClip : AKClip
  • AKClipMerger merges new clips into an existing array of validated clips and returns a new array of validated clips including the new clip.

    Validation rules:

    • The clip itself must be valid as defined by the clip’s isValid function.
    • The clips in the array must not overlap each other (clip.time + clip.duration <= nextClip.time).

    The strategy used when a new clip overlaps an existing clip is last-in precedence. Existing clips will shortened, split, or removed in order to make room for the new clip. Since clips can be split or removed, merging a clip may result in the clip count decreasing when a clip is merged, or increasing by more than 1. This behavior requires that the clip merger create clips, so to facilitate this need it uses a delegate. When a clip is to be shortened, it is removed from the existing clips, and a new clip is created using the delegate’s newClip function. When a clip is to be split, the original is removed and newClip will be called twice. When a clip is removed, the delegate’s clipWillBeRemoved function will be called (if implemented).

    See more

    Declaration

    Swift

    open class AKClipMerger : NSObject
  • A class that manages the merging of AKFileClips.

    See more

    Declaration

    Swift

    open class AKFileClipSequence : NSObject, ClipMergeDelegate
  • The protocol for the AKClipMerger’s delegate It is the responsibility of the delegate to create a new clip when a an existing clip has been altered or split.

    See more

    Declaration

    Swift

    @objc
    public protocol ClipMergeDelegate : AnyObject
  • Schedules multiple audio files to be played in a sequence.

    See more

    Declaration

    Swift

    open class AKClipPlayer : AKNode
  • This is a phase locked vocoder. It has the ability to play back an audio file loaded into an ftable like a sampler would. Unlike a typical sampler, mincer allows time and pitch to be controlled separately.

    See more

    Declaration

    Swift

    open class AKPhaseLockedVocoder : AKNode, AKComponent
  • AKPlayer is meant to be a simple yet powerful audio player that just works. It supports scheduling of sounds, looping, fading, time-stretching, pitch-shifting and reversing. Players can be locked to a common clock as well as video by using hostTime in the various play functions. By default the player will buffer audio if needed, otherwise stream from disk. Reversing the audio will cause the file to buffer. For seamless looping use buffered playback.

    There are a few options for syncing to external objects.

    A locked video function would resemble:

    func videoPlay(at time: TimeInterval = 0, hostTime: UInt64 = 0 ) {
    let cmHostTime = CMClockMakeHostTimeFromSystemUnits(hostTime)
    let cmVTime = CMTimeMakeWithSeconds(time, 1000000)
    let futureTime = CMTimeAdd(cmHostTime, cmVTime)
    videoPlayer.setRate(1, time: kCMTimeInvalid, atHostTime: futureTime)
    }
    

    Basic usage looks like:

    guard let player = AKPlayer(url: url) else { return }
    player.completionHandler = { AKLog("Done") }
    
    // Loop Options
    player.loop.start = 1
    player.loop.end = 3
    player.isLooping = true
    player.buffer = true // if seamless is desired
    
    player.play()
    

    Please note that pre macOS 10.13 / iOS 11 the completionHandler isn’t sample accurate. It’s pretty close though.

    See more

    Declaration

    Swift

    public class AKPlayer : AKNode
  • Audio player that loads a sample into memory

    See more

    Declaration

    Swift

    @available(*, deprecated, message: "AKSamplePlayer is now AKWaveTable")
    open class AKSamplePlayer : AKNode, AKComponent
  • A Sample type, just a UInt32

    Declaration

    Swift

    public typealias Sample = UInt32