AVAudioPCMBuffer

class AVAudioPCMBuffer : AVAudioBuffer
  • Declaration

    Swift

    public struct Peak
  • Copies data from another PCM buffer. Will copy to the end of the buffer (frameLength), and increment frameLength. Will not exceed frameCapacity.

    Declaration

    Swift

    @discardableResult
    open func copy(from buffer: AVAudioPCMBuffer,
                   readOffset: AVAudioFrameCount = 0,
                   frames: AVAudioFrameCount = 0) -> AVAudioFrameCount

    Parameters

    buffer

    The source buffer that data will be copied from.

    readOffset

    The offset into the source buffer to read from.

    frames

    The number of frames to copy from the source buffer.

    Return Value

    The number of frames copied.

  • Returns an AVAudioPCMBuffer copied from a sample offset to the end of the buffer.

    Declaration

    Swift

    open func copyFrom(startSample: AVAudioFrameCount) -> AVAudioPCMBuffer?
  • Returns an AVAudioPCMBuffer copied from the start of the buffer to the specified endSample.

    Declaration

    Swift

    open func copyTo(count: AVAudioFrameCount) -> AVAudioPCMBuffer?
  • Declaration

    Swift

    open func peakTime() -> Double

    Return Value

    The time in seconds of the peak of the buffer or 0 if it failed

  • Declaration

    Swift

    open func peak() -> Peak?

    Return Value

    A Peak struct containing the time, frame position and peak amplitude

  • Returns a normalized buffer

    Declaration

    Swift

    open func normalize() -> AVAudioPCMBuffer?
  • Returns a reversed buffer

    Declaration

    Swift

    open func reverse() -> AVAudioPCMBuffer?
  • Creates a new buffer from this one that has fades applied to it. Pass 0 for either parameter if you only want one of them

    Declaration

    Swift

    open func fade(inTime: Double,
                   outTime: Double,
                   inRampType: AKSettings.RampType = .exponential,
                   outRampType: AKSettings.RampType = .exponential) -> AVAudioPCMBuffer?