---
title: "AudioFileOptimize(_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/audiofileoptimize(_:)"
---

# AudioFileOptimize(_:)

Consolidates audio data and performs other internal optimizations of the file structure.

## Declaration

```swift
func AudioFileOptimize(_ inAudioFile: AudioFileID) -> OSStatus
```

## Parameters

- `inAudioFile`: The audio file you want to optimize.

## Return Value

Return Value A result code. See Result Codes.

## Discussion

Discussion This function optimizes the file so additional audio information can be appended to the existing data. Typically, this function consolidates the file’s audio data at the end of the file. This improves performance, such as when writing additional data to the file. Do not use this potentially expensive and time-consuming operation during time-critical operations. Instead, use the kAudioFilePropertyIsOptimized property to check the optimization state of a file. You can then optimize when it won’t adversely affect your application.
