<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioSequencer/write(to:smpteResolution:replaceExisting:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioSequencer(im)writeToURL:SMPTEResolution:replaceExisting:error:"
  },
  "title" : "write(to:smpteResolution:replaceExisting:)"
}
-->

# write(to:smpteResolution:replaceExisting:)

Creates and writes a MIDI file from the events in the sequence.

```
func write(to fileURL: URL, smpteResolution resolution: Int, replaceExisting replace: Bool) throws
```

## Parameters

`fileURL`

The URL of the file you want to write to.

`resolution`

The relationship between tick and quarter note for saving to a Standard MIDI File. Passing zero uses the default value set using the tempo track.

`replace`

When `true`, the framework overwrites an existing file at `fileURL`. Otherwise, the call fails with a permission error if a file at the specified path exists.

## Discussion

The framework writes only MIDI events when writing to the MIDI file. MIDI files are normally beat-based, but can also have an SMPTE (or real-time, rather than beat time) representation. The relationship between tick and quarter note for saving to a Standard MIDI File is the current value for the tempo track.

---

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)