---
title: newTimedMetadataSampleBufferAndResetAnalyzer()
framework: avfoundation
role: symbol
role_heading: Instance Method
path: avfoundation/avcapturespatialaudiometadatasamplegenerator/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.

## Declaration

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

## Return Value

Return Value A CMSampleBufferRef containing the spatial audio timed metadata sample, or NULL if no value can be computed.

## Discussion

Discussion Call this method after you pass the last audio sample buffer of your recording to analyzeAudioSample(_:). Then pass the returned CMSampleBufferRef directly to your AVAssetWriterInput to add the sample to your recording’s audio timed metadata track. Note that 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.

## See Also

### Analyzing audio samples

- [analyzeAudioSample(_:)](avfoundation/avcapturespatialaudiometadatasamplegenerator/analyzeaudiosample(_:).md)
- [timedMetadataSampleBufferFormatDescription](avfoundation/avcapturespatialaudiometadatasamplegenerator/timedmetadatasamplebufferformatdescription.md)
- [resetAnalyzer()](avfoundation/avcapturespatialaudiometadatasamplegenerator/resetanalyzer().md)
