@@ -10,56 +10,7 @@ internal import SwiftMIDIInternals
1010
1111// MARK: - Init: Raw Data
1212
13- extension MIDI1File {
14- /// Initialize by loading the contents of a MIDI file's raw data.
15- ///
16- /// - Tip: Consider using the `async` overload of this initializer, as it is much more performant.
17- public init (
18- data: some DataProtocol & Sendable ,
19- options: MIDI1FileDecodeOptions = MIDI1FileDecodeOptions ( ) ,
20- predicate: DecodePredicate ? = nil
21- ) throws ( MIDIFileDecodeError) {
22- try decode (
23- data: data,
24- options: options,
25- predicate: predicate
26- )
27- }
28-
29- /// Initialize by loading the contents of a MIDI file's raw data, parsing chunks concurrently for improved performance.
30- @available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * )
31- public init (
32- data: some DataProtocol & Sendable ,
33- options: MIDI1FileDecodeOptions = MIDI1FileDecodeOptions ( ) ,
34- predicate: DecodePredicate ? = nil
35- ) async throws ( MIDIFileDecodeError) {
36- try await decode (
37- data: data,
38- options: options,
39- predicate: predicate
40- )
41- }
42-
43- /// Initialize by loading the contents of a MIDI file's raw data, parsing chunks concurrently for improved performance.
44- /// As each chunk completes parsing, a closure is called with the parsing results and the chunk's content.
45- ///
46- /// If the file header cannot be parsed or overall file structure is malformed, this method throws an error.
47- /// Errors encountered during individual chunk parsing are returned within the result closure and not thrown from this method.
48- @available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * )
49- public init (
50- data: some DataProtocol & Sendable ,
51- options: MIDI1FileDecodeOptions = MIDI1FileDecodeOptions ( ) ,
52- predicate: DecodePredicate ? = nil ,
53- parsedChunk: @escaping ChunkDecodeBlock
54- ) async throws ( MIDIFileDecodeError) {
55- try await decode (
56- data: data,
57- options: options,
58- predicate: predicate,
59- parsedChunk: parsedChunk
60- )
61- }
62- }
13+ // see MIDI1File+Decoding.swift
6314
6415// MARK: - Init: File Path
6516
@@ -116,7 +67,7 @@ extension MIDI1File {
11667 predicate: DecodePredicate ? = nil
11768 ) throws ( MIDIFileDecodeError) {
11869 let data = try AnyMIDI1File . data ( forFileURL: url)
119- try decode (
70+ try self . init (
12071 data: data,
12172 options: options,
12273 predicate: predicate
@@ -131,7 +82,7 @@ extension MIDI1File {
13182 predicate: DecodePredicate ? = nil
13283 ) async throws ( MIDIFileDecodeError) {
13384 let data = try AnyMIDI1File . data ( forFileURL: url)
134- try await decode (
85+ try await self . init (
13586 data: data,
13687 options: options,
13788 predicate: predicate
@@ -151,7 +102,7 @@ extension MIDI1File {
151102 parsedChunk: @escaping ChunkDecodeBlock
152103 ) async throws ( MIDIFileDecodeError) {
153104 let data = try AnyMIDI1File . data ( forFileURL: url)
154- try await decode (
105+ try await self . init (
155106 data: data,
156107 options: options,
157108 predicate: predicate,
0 commit comments