# FloatBuffer

    final class FloatBuffer: Equatable

A contiguous buffer of 32-bit floating-point audio samples.
- `
  ### [init(data:length:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC4data6lengthACSPySfGSg_Sitcfc)

  ` Creates a `FloatBuffer` by copying `length` elements from `data`, or zero-initializing when `data` is `nil`.

  #### Declaration

  Swift

      convenience init(data: UnsafePointer<Float>?, length: Int)

- `
  ### [init(elements:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC8elementsACSaySfG_tcfc)

  ` Creates a `FloatBuffer` copied from `elements`.

  #### Declaration

  Swift

      init(elements: [Float])

- `
  ### [init(length:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC6lengthACSi_tcfc)

  ` Creates a `FloatBuffer` of `length` elements initialized to zero.

  #### Declaration

  Swift

      convenience init(length: Int)

- `
  ### [elements](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC8elementsSaySfGvp)

  ` A copy of the buffer's elements.

  #### Declaration

  Swift

      final var elements: [Float] { get }

- `
  ### [length](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC6lengthSivp)

  ` The number of elements in the buffer.

  #### Declaration

  Swift

      final var length: Int { get }

- `
  ### [clear()](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC5clearyyF)

  ` Resets all elements in the buffer to `0.0`.

  #### Declaration

  Swift

      final func clear()

- `
  ### [copy()](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC4copyACyF)

  ` Returns an independent deep copy of this `FloatBuffer`.

  #### Declaration

  Swift

      final func copy() -> FloatBuffer

- `
  ### [withUnsafeBufferPointer(_:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC010withUnsafeF7PointeryxxSRySfGKXEKlF)

  ` Calls `body` with an immutable `UnsafeBufferPointer` to the buffer's elements.

  #### Declaration

  Swift

      final func withUnsafeBufferPointer<Result>(_ body: (UnsafeBufferPointer<Float>) throws -> Result) rethrows -> Result

- `
  ### [withUnsafeMutableBufferPointer(_:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/FloatBuffer.md.txt#/s:20MediaPipeTasksCommon11FloatBufferC017withUnsafeMutableF7PointeryxxSrySfGKXEKlF)

  ` Calls `body` with an `UnsafeMutableBufferPointer` to the buffer's elements.

  #### Declaration

  Swift

      final func withUnsafeMutableBufferPointer<Result>(_ body: (UnsafeMutableBufferPointer<Float>) throws -> Result) rethrows -> Result