Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MIDI file writing #1

Merged
merged 2 commits into from
Apr 1, 2016
Merged

Conversation

aidangomez
Copy link
Contributor

Given a MusicSequence we should be able to write the corresponding MIDI
file and return the MIDIFile representation of it.

@@ -11,6 +11,15 @@ public class MIDIFile {
public private(set) var sequence: MusicSequence = nil
public private(set) var tracks = [MusicTrack]()

public func create(outFilePath: String, inout sequence: MusicSequence) -> MIDIFile? {
let url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, outFilePath, .CFURLPOSIXPathStyle, false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use NSURL

Given a MusicSequence we should be able to write the corresponding MIDI
file and return the MIDIFile representation of it.
@@ -11,6 +11,15 @@ public class MIDIFile {
public private(set) var sequence: MusicSequence = nil
public private(set) var tracks = [MusicTrack]()

public static func create(outFilePath: String, sequence: MusicSequence) -> MIDIFile? {
let url = NSURL.fileURLWithPath(outFilePath)
guard MusicSequenceFileCreate(sequence, url, MusicSequenceFileTypeID.MIDIType, MusicSequenceFileFlags.EraseFile, 0) == noErr else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could drop the enum names if you like MusicSequenceFileCreate(sequence, url, .MIDIType, .EraseFile, 0)

@aidangomez
Copy link
Contributor Author

@hoseking @Aleph7 Everything good now? <3

@alejandro-isaza alejandro-isaza merged commit bf98e06 into hoseking:master Apr 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants