<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureSpatialAudioMetadataSampleGenerator/newTimedMetadataSampleBufferAndResetAnalyzer()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureSpatialAudioMetadataSampleGenerator(im)newTimedMetadataSampleBufferAndResetAnalyzer"
  },
  "title" : "newTimedMetadataSampleBufferAndResetAnalyzer()"
}
-->

# newTimedMetadataSampleBufferAndResetAnalyzer()

Creates a sample buffer containing a spatial audio timed metadata sample computed from all analyzed audio buffers, and resets the analyzer to its initial state.

```
func newTimedMetadataSampleBufferAndResetAnalyzer() -> Unmanaged<CMSampleBuffer>?
```

## Return Value

a `CMSampleBufferRef` containing the spatial audio timed metadata sample, or `NULL` if no value can be computed.

## Discussion

Call this method after you pass the last audio sample buffer of your recording to [`analyzeAudioSample(_:)`](/documentation/AVFoundation/AVCaptureSpatialAudioMetadataSampleGenerator/analyzeAudioSample(_:)). Then pass the returned `CMSampleBufferRef` directly to your [`AVAssetWriterInput`](/documentation/AVFoundation/AVAssetWriterInput) to add the sample to your recording’s audio timed metadata track. Note that [`AVAssetWriter`](/documentation/AVFoundation/AVAssetWriter) expects one and only one spatial audio metadata sample buffer to be present in the timed metadata track.

> Note: Calling this method also resets the analyzer, making it ready for another run of audio sample buffers. Thus one generator can be re-used for multiple recordings.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)