-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from orchetect/dev
API selection, fixes for packet iteration
- Loading branch information
Showing
56 changed files
with
543 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
Docs will be added in future. This is a placeholder file in the meantime. | ||
Docs will be added in future. | ||
|
||
In the meantime, check out the Examples folder for sample projects demonstrating usage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// APIVersion.swift | ||
// MIDIKit • https://github.com/orchetect/MIDIKit | ||
// | ||
|
||
import Darwin | ||
|
||
extension MIDI.IO { | ||
|
||
/// Enum describing which underlying Core MIDI API is being used internally. | ||
public enum APIVersion { | ||
|
||
/// Legacy Core MIDI API first introduced in early versions of OSX. | ||
/// | ||
/// Internally using `MIDIPacketList` / `MIDIPacket`. | ||
case legacyCoreMIDI | ||
|
||
/// New Core MIDI API introduced in macOS 11, iOS 14, macCatalyst 14, tvOS 14, and watchOS 7. | ||
/// | ||
/// Internally using `MIDIEventList` / `MIDIEventPacket`. | ||
case newCoreMIDI | ||
|
||
} | ||
|
||
} | ||
|
||
extension MIDI.IO.APIVersion { | ||
|
||
/// Returns the recommended API version for the current platform (operating system). | ||
public static func bestForPlatform() -> Self { | ||
|
||
if #available(macOS 11, iOS 14, macCatalyst 14, tvOS 14, watchOS 7, *) { | ||
// return legacy for now, since new API is buggy; | ||
// in future, this should return .newCoreMIDI when new API is more stable | ||
return .legacyCoreMIDI | ||
|
||
} else { | ||
return .legacyCoreMIDI | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
extension MIDI.IO.APIVersion { | ||
|
||
/// Returns true if API version can be used on the current platform (operating system). | ||
public var isValidOnCurrentPlatform: Bool { | ||
|
||
switch self { | ||
case .legacyCoreMIDI: | ||
#if os(macOS) | ||
if #available(macOS 12, *) { return false } | ||
return true | ||
#elseif os(iOS) | ||
if #available(iOS 15, *) { return false } | ||
return true | ||
#elseif os(tvOS) || os(watchOS) | ||
// only new API is supported on tvOS and watchOS | ||
return false | ||
#else | ||
// future or unknown/unsupported platform | ||
return false | ||
#endif | ||
|
||
case .newCoreMIDI: | ||
if #available(macOS 11, iOS 14, macCatalyst 14, tvOS 14, watchOS 7, *) { | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
extension MIDI.IO.APIVersion: CustomStringConvertible { | ||
|
||
public var description: String { | ||
|
||
switch self { | ||
case .legacyCoreMIDI: | ||
return "Legacy Core MIDI API" | ||
|
||
case .newCoreMIDI: | ||
return "New Core MIDI API" | ||
} | ||
|
||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...IDIKit/IO/CoreMIDI/CoreMIDI Devices.swift → ...IKit/IO/Core MIDI/Core MIDI Devices.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// CoreMIDI Devices.swift | ||
// Core MIDI Devices.swift | ||
// MIDIKit • https://github.com/orchetect/MIDIKit | ||
// | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...IKit/IO/CoreMIDI/CoreMIDI Endpoints.swift → ...it/IO/Core MIDI/Core MIDI Endpoints.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...DIKit/IO/CoreMIDI/CoreMIDI Entities.swift → ...Kit/IO/Core MIDI/Core MIDI Entities.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// CoreMIDI Entities.swift | ||
// Core MIDI Entities.swift | ||
// MIDIKit • https://github.com/orchetect/MIDIKit | ||
// | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...IO/CoreMIDI/CoreMIDI Properties Set.swift → .../Core MIDI/Core MIDI Properties Set.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.