AKSamplePlayer

open class AKSamplePlayer: AKNode, AKComponent

Audio player that loads a sample into memory

  • Four letter unique description of the node

    Declaration

    Swift

    public static let ComponentDescription = AudioComponentDescription(generator: "smpl")
  • Ramp Time represents the speed at which parameters are allowed to change

    Declaration

    Swift

    open dynamic var rampTime: Double = AKSettings.rampTime
  • startPoint in samples - where to start playing the sample from

    Declaration

    Swift

    open dynamic var startPoint: Sample = 0
  • endPoint - this is where the sample will play to before stopping. A value less than the start point will play the sample backwards.

    Declaration

    Swift

    open dynamic var endPoint: Sample = 0
  • playback rate - A value of 1 is normal, 2 is double speed, 0.5 is halfspeed, etc.

    Declaration

    Swift

    open dynamic var rate: Double = 1
  • Volume - amplitude adjustment

    Declaration

    Swift

    open dynamic var volume: Double = 1
  • Loop Enabled - if enabled, the sample will loop back to the startpoint when the endpoint is reached. When disabled, the sample will play through once from startPoint to endPoint

    Declaration

    Swift

    open dynamic var loopEnabled: Bool = false
  • Number of sample in the audio stored in memory

    Declaration

    Swift

    open var size: Sample
  • Position in the audio file from 0 - 1

    Declaration

    Swift

    open var normalizedPosition: Double
  • Position in the audio in samples, but represented as a double since you could conceivably be at a non-integer sample

    Declaration

    Swift

    open var position: Double
  • Tells whether the node is processing (ie. started, playing, or active)

    Declaration

    Swift

    open dynamic var isStarted: Bool
  • Function to start, play, or activate the node, all do the same thing

    Declaration

    Swift

    open func start()
  • Function to stop or bypass the node, both are equivalent

    Declaration

    Swift

    open func stop()
  • Play from a certain sample

    Declaration

    Swift

    open func play(from: Sample = 0)
  • Play from a certain sample for a certain number of samples

    Declaration

    Swift

    open func play(from: Sample = 0, length: Sample = 0)
  • Play from a certain sample to an end sample

    Declaration

    Swift

    open func play(from: Sample = 0, to: Sample = 0)
  • Load a new audio file into memory

    Declaration

    Swift

    open func loadSound(file: AVAudioFile)