---
title: "MusicSequenceFileCreate(_:_:_:_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/musicsequencefilecreate(_:_:_:_:_:)"
---

# MusicSequenceFileCreate(_:_:_:_:_:)

Creates a MIDI file from the events in a music sequence.

## Declaration

```swift
func MusicSequenceFileCreate(_ inSequence: MusicSequence, _ inFileRef: CFURL, _ inFileType: MusicSequenceFileTypeID, _ inFlags: MusicSequenceFileFlags, _ inResolution: Int16) -> OSStatus
```

## Parameters

- `inSequence`: The music sequence that you want to create a MIDI file from.
- `inFileRef`: The URL to the MIDI file to be created.
- `inFileType`: The type of file to create.
- `inFlags`: Flags that configure the file creation process.
- `inResolution`: The resolution, which depends on the file type and the music sequence type.

## Return Value

Return Value A result code.

## Discussion

Discussion This function can be (and is most commonly) used to create a MIDI file from the events in a sequence. Only MIDI based events are used when creating the MIDI file. MIDI files are normally beat based, but can also have a SMPTE (or real-time rather than beat time) representation. The inResolution parameter specifies the relationship between “tick” and quarter note for saving to a standard MIDI file. Pass 0 to this parameter to use the default value; namely, the value that is currently set on the tempo track. The various sequence types determine the kinds of files that can be created, as follows: Beats—When saving a MIDI file, it saves a beats (PPQ) based axis. Seconds—When saving a MIDI file, it will save it as a SMPTE resolution - so you should specify this resolution when creating the MIDI file. If zero is specified, 25 fps and 40 ticks/frame is used (a time scale of a millisecond) Samples—You cannot save to a MIDI file with this sequence type. The complete meaning of the 16-bit “division” field in a MIDI File’s MThd chunk. If it is positive, then a tick represents 1/D quarter notes.  If it negative, the following pertains: Bits 14-8 are a signed 7-bit number representing the SMPTE format: 24, -25, -29 (drop), -30. Bits 7-0 represents the number of ticks per SMPTE frame. Typical values are 4, 10, 80, 100. You can obtain millisecond resolution by specifying 25 frames/sec and 40 divisions/frame:   30 fps with 80 bits (ticks) per frame: 0xE250  ((char)0xE2 == -30)

## See Also

### Managing Music Sequences

- [NewMusicSequence(_:)](audiotoolbox/newmusicsequence(_:).md)
- [DisposeMusicSequence(_:)](audiotoolbox/disposemusicsequence(_:).md)
- [MusicSequenceBarBeatTimeToBeats(_:_:_:)](audiotoolbox/musicsequencebarbeattimetobeats(_:_:_:).md)
- [MusicSequenceBeatsToBarBeatTime(_:_:_:_:)](audiotoolbox/musicsequencebeatstobarbeattime(_:_:_:_:).md)
- [MusicSequenceDisposeTrack(_:_:)](audiotoolbox/musicsequencedisposetrack(_:_:).md)
- [MusicSequenceFileCreateData(_:_:_:_:_:)](audiotoolbox/musicsequencefilecreatedata(_:_:_:_:_:).md)
- [MusicSequenceFileLoad(_:_:_:_:)](audiotoolbox/musicsequencefileload(_:_:_:_:).md)
- [MusicSequenceFileLoadData(_:_:_:_:)](audiotoolbox/musicsequencefileloaddata(_:_:_:_:).md)
- [MusicSequenceGetAUGraph(_:_:)](audiotoolbox/musicsequencegetaugraph(_:_:).md)
- [MusicSequenceGetBeatsForSeconds(_:_:_:)](audiotoolbox/musicsequencegetbeatsforseconds(_:_:_:).md)
- [MusicSequenceGetIndTrack(_:_:_:)](audiotoolbox/musicsequencegetindtrack(_:_:_:).md)
- [MusicSequenceGetInfoDictionary(_:)](audiotoolbox/musicsequencegetinfodictionary(_:).md)
- [MusicSequenceGetSMPTEResolution(_:_:_:)](audiotoolbox/musicsequencegetsmpteresolution(_:_:_:).md)
- [MusicSequenceGetSecondsForBeats(_:_:_:)](audiotoolbox/musicsequencegetsecondsforbeats(_:_:_:).md)
- [MusicSequenceGetSequenceType(_:_:)](audiotoolbox/musicsequencegetsequencetype(_:_:).md)
