From b4c3e9e452c44650faedd4547076d8a1ce57aa74 Mon Sep 17 00:00:00 2001 From: Steffan Andrews Date: Fri, 5 Nov 2021 00:25:03 -0700 Subject: [PATCH 1/2] Made `MIDI.Event.sysEx(rawBytes:group:)` public access level --- .../Event/System Exclusive/SysEx Parser.swift | 7 +++- Sources/MIDIKit/Parser/MIDI1Parser.swift | 2 +- Sources/MIDIKit/Parser/MIDI2Parser.swift | 2 +- .../Events/Event/SysEx/SysEx Tests.swift | 40 +++++++++---------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Sources/MIDIKit/Events/Event/System Exclusive/SysEx Parser.swift b/Sources/MIDIKit/Events/Event/System Exclusive/SysEx Parser.swift index 07bbd34c1c..1579de77af 100644 --- a/Sources/MIDIKit/Events/Event/System Exclusive/SysEx Parser.swift +++ b/Sources/MIDIKit/Events/Event/System Exclusive/SysEx Parser.swift @@ -7,9 +7,12 @@ import Foundation extension MIDI.Event { + /// Parse a raw System Exclusive message and return a `.sysEx()` or `.universalSysEx()` case if successful. + /// + /// - Throws: `MIDI.Event.ParseError` if message is malformed. @inline(__always) - internal static func sysEx( - from rawBytes: [MIDI.Byte], + public static func sysEx( + rawBytes: [MIDI.Byte], group: MIDI.UInt4 = 0 ) throws -> Self { diff --git a/Sources/MIDIKit/Parser/MIDI1Parser.swift b/Sources/MIDIKit/Parser/MIDI1Parser.swift index 974ad15510..fbc5db19a0 100644 --- a/Sources/MIDIKit/Parser/MIDI1Parser.swift +++ b/Sources/MIDIKit/Parser/MIDI1Parser.swift @@ -489,7 +489,7 @@ extension MIDI { case 0xF: // system message switch statusByte.nibbles.low { case 0x0: // System Common - SysEx Start - guard let parsedSysEx = try? MIDI.Event.sysEx(from: bytes) + guard let parsedSysEx = try? MIDI.Event.sysEx(rawBytes: bytes) else { return events } events.append(parsedSysEx) diff --git a/Sources/MIDIKit/Parser/MIDI2Parser.swift b/Sources/MIDIKit/Parser/MIDI2Parser.swift index f776105bc2..510145a61f 100644 --- a/Sources/MIDIKit/Parser/MIDI2Parser.swift +++ b/Sources/MIDIKit/Parser/MIDI2Parser.swift @@ -356,7 +356,7 @@ extension MIDI { ] guard let parsedSysEx = try? MIDI.Event.sysEx( - from: [0xF0] + payloadBytes + [0xF7], + rawBytes: [0xF0] + payloadBytes + [0xF7], group: group ) else { return nil } diff --git a/Tests/MIDIKitTests/Events/Event/SysEx/SysEx Tests.swift b/Tests/MIDIKitTests/Events/Event/SysEx/SysEx Tests.swift index e61a684748..a30de32f03 100644 --- a/Tests/MIDIKitTests/Events/Event/SysEx/SysEx Tests.swift +++ b/Tests/MIDIKitTests/Events/Event/SysEx/SysEx Tests.swift @@ -17,10 +17,10 @@ class SysExTests: XCTestCase { let sourceRawBytes: [MIDI.Byte] = [0xF0, 0x41, 0x01, 0x34, 0xF7] XCTAssertNoThrow( - try MIDI.Event.sysEx(from: sourceRawBytes) + try MIDI.Event.sysEx(rawBytes: sourceRawBytes) ) - let event = try! MIDI.Event.sysEx(from: sourceRawBytes) + let event = try! MIDI.Event.sysEx(rawBytes: sourceRawBytes) guard case .sysEx(let innerEvent) = event else { XCTFail() ; return } @@ -38,10 +38,10 @@ class SysExTests: XCTestCase { let sourceRawBytes: [MIDI.Byte] = [0xF0, 0x41, 0xF7] XCTAssertNoThrow( - try MIDI.Event.sysEx(from: sourceRawBytes) + try MIDI.Event.sysEx(rawBytes: sourceRawBytes) ) - let event = try! MIDI.Event.sysEx(from: sourceRawBytes) + let event = try! MIDI.Event.sysEx(rawBytes: sourceRawBytes) guard case .sysEx(let innerEvent) = event else { XCTFail() ; return } @@ -59,10 +59,10 @@ class SysExTests: XCTestCase { let sourceRawBytes: [MIDI.Byte] = [0xF0, 0x41] XCTAssertNoThrow( - try MIDI.Event.sysEx(from: sourceRawBytes) + try MIDI.Event.sysEx(rawBytes: sourceRawBytes) ) - let event = try! MIDI.Event.sysEx(from: sourceRawBytes) + let event = try! MIDI.Event.sysEx(rawBytes: sourceRawBytes) guard case .sysEx(let innerEvent) = event else { XCTFail() ; return } @@ -80,7 +80,7 @@ class SysExTests: XCTestCase { let sourceRawBytes: [MIDI.Byte] = [0xF0, 0xF7] XCTAssertThrowsError( - try MIDI.Event.sysEx(from: sourceRawBytes) + try MIDI.Event.sysEx(rawBytes: sourceRawBytes) ) } @@ -90,7 +90,7 @@ class SysExTests: XCTestCase { // valid - maximum byte length (256 bytes) XCTAssertNoThrow( try MIDI.Event.sysEx( - from: [0xF0, 0x41] + rawBytes: [0xF0, 0x41] + [MIDI.Byte](repeating: 0x20, count: 256-3) + [0xF7]) ) @@ -98,7 +98,7 @@ class SysExTests: XCTestCase { // valid - length is larger than default 256 bytes (257 bytes) XCTAssertNoThrow( try MIDI.Event.sysEx( - from: [0xF0, 0x41] + rawBytes: [0xF0, 0x41] + [MIDI.Byte](repeating: 0x20, count: 256-2) + [0xF7]) ) @@ -109,27 +109,27 @@ class SysExTests: XCTestCase { // empty raw bytes - invalid XCTAssertThrowsError( - try MIDI.Event.sysEx(from: []) + try MIDI.Event.sysEx(rawBytes: []) ) // start byte only - invalid XCTAssertThrowsError( - try MIDI.Event.sysEx(from: [0xF0]) + try MIDI.Event.sysEx(rawBytes: [0xF0]) ) // end byte only - invalid XCTAssertThrowsError( - try MIDI.Event.sysEx(from: [0xF7]) + try MIDI.Event.sysEx(rawBytes: [0xF7]) ) // start and end bytes only - invalid XCTAssertThrowsError( - try MIDI.Event.sysEx(from: [0xF0, 0xF7]) + try MIDI.Event.sysEx(rawBytes: [0xF0, 0xF7]) ) // correct start byte, valid length, but incorrect end byte XCTAssertThrowsError( - try MIDI.Event.sysEx(from: [0xF0, 0x41, 0x01, 0x34, 0xF6]) + try MIDI.Event.sysEx(rawBytes: [0xF0, 0x41, 0x01, 0x34, 0xF6]) ) } @@ -138,10 +138,10 @@ class SysExTests: XCTestCase { // ensure instances equate correctly - let event1A = try! MIDI.Event.sysEx(from: [0xF0, 0x41, 0x01, 0x34, 0xF7]) - let event1B = try! MIDI.Event.sysEx(from: [0xF0, 0x41, 0x01, 0x34, 0xF7]) + let event1A = try! MIDI.Event.sysEx(rawBytes: [0xF0, 0x41, 0x01, 0x34, 0xF7]) + let event1B = try! MIDI.Event.sysEx(rawBytes: [0xF0, 0x41, 0x01, 0x34, 0xF7]) - let event2 = try! MIDI.Event.sysEx(from: [0xF0, 0x41, 0x01, 0x64, 0xF7]) + let event2 = try! MIDI.Event.sysEx(rawBytes: [0xF0, 0x41, 0x01, 0x64, 0xF7]) XCTAssert(event1A == event1B) @@ -153,10 +153,10 @@ class SysExTests: XCTestCase { // ensure instances hash correctly - let event1A = try! MIDI.Event.sysEx(from: [0xF0, 0x41, 0x01, 0x34, 0xF7]) - let event1B = try! MIDI.Event.sysEx(from: [0xF0, 0x41, 0x01, 0x34, 0xF7]) + let event1A = try! MIDI.Event.sysEx(rawBytes: [0xF0, 0x41, 0x01, 0x34, 0xF7]) + let event1B = try! MIDI.Event.sysEx(rawBytes: [0xF0, 0x41, 0x01, 0x34, 0xF7]) - let event2 = try! MIDI.Event.sysEx(from: [0xF0, 0x41, 0x01, 0x64, 0xF7]) + let event2 = try! MIDI.Event.sysEx(rawBytes: [0xF0, 0x41, 0x01, 0x64, 0xF7]) let set1: Set = [event1A, event1B] From 74f4c37031788d4c1f3475e36d500a173986bbfe Mon Sep 17 00:00:00 2001 From: Steffan Andrews Date: Fri, 5 Nov 2021 00:25:35 -0700 Subject: [PATCH 2/2] Added public inits to all `MIDI.Event.*` concrete types --- .../Events/Event/Channel Voice/CC/CC.swift | 26 ++++++++++++++- .../Event/Channel Voice/Note/CC/Note CC.swift | 28 ++++++++++++++++ .../Note/Management/Note Management.swift | 24 ++++++++++++++ .../Note/Note Attribute Pitch7_9.swift | 8 +++++ .../Channel Voice/Note/Off/Note Off.swift | 28 ++++++++++++++++ .../Event/Channel Voice/Note/On/Note On.swift | 32 +++++++++++++++++++ .../Note/PitchBend/Note PitchBend.swift | 24 ++++++++++++++ .../Note/Pressure/Note Pressure.swift | 24 ++++++++++++++ .../Channel Voice/PitchBend/PitchBend.swift | 10 ++++++ .../Channel Voice/Pressure/Pressure.swift | 10 ++++++ .../ProgramChange/ProgramChange.swift | 12 +++++++ .../System Common/SongPositionPointer.swift | 8 +++++ .../Event/System Common/SongSelect.swift | 8 +++++ .../System Common/TimecodeQuarterFrame.swift | 8 +++++ .../Event/System Common/TuneRequest.swift | 6 ++++ .../System Common/UnofficialBusSelect.swift | 8 +++++ .../Event/System Exclusive/SysEx/SysEx.swift | 10 ++++++ .../UniversalSysEx/UniversalSysEx.swift | 16 ++++++++++ .../System Real Time/ActiveSensing.swift | 6 ++++ .../Event/System Real Time/Continue.swift | 6 ++++ .../Events/Event/System Real Time/Start.swift | 6 ++++ .../Events/Event/System Real Time/Stop.swift | 6 ++++ .../Event/System Real Time/SystemReset.swift | 6 ++++ .../Event/System Real Time/TimingClock.swift | 6 ++++ 24 files changed, 325 insertions(+), 1 deletion(-) diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/CC/CC.swift b/Sources/MIDIKit/Events/Event/Channel Voice/CC/CC.swift index fa9bdb8f3e..254aee6e27 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/CC/CC.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/CC/CC.swift @@ -22,6 +22,30 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(controller: Controller, + value: Value, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.controller = controller + self.value = value + self.channel = channel + self.group = group + + } + + public init(controller: MIDI.UInt7, + value: Value, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.controller = .init(number: controller) + self.value = value + self.channel = channel + self.group = group + + } + } } @@ -64,7 +88,7 @@ extension MIDI.Event { group: MIDI.UInt4 = 0x0) -> Self { .cc( - .init(controller: .init(number: controller), + .init(controller: controller, value: value, channel: channel, group: group) diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/Note/CC/Note CC.swift b/Sources/MIDIKit/Events/Event/Channel Voice/Note/CC/Note CC.swift index 657e2bb9f6..7345bb2862 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/Note/CC/Note CC.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/Note/CC/Note CC.swift @@ -26,6 +26,34 @@ extension MIDI.Event.Note { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(note: MIDI.UInt7, + controller: CC.Controller, + value: UInt32, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.note = note + self.controller = controller + self.value = value + self.channel = channel + self.group = group + + } + + public init(note: MIDI.Note, + controller: CC.Controller, + value: UInt32, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.note = note.number + self.controller = controller + self.value = value + self.channel = channel + self.group = group + + } + } } diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/Note/Management/Note Management.swift b/Sources/MIDIKit/Events/Event/Channel Voice/Note/Management/Note Management.swift index 1a86ebcb8b..62a5dc949d 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/Note/Management/Note Management.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/Note/Management/Note Management.swift @@ -25,6 +25,30 @@ extension MIDI.Event.Note { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(note: MIDI.UInt7, + optionFlags: Set = [], + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.note = note + self.optionFlags = optionFlags + self.channel = channel + self.group = group + + } + + public init(note: MIDI.Note, + optionFlags: Set = [], + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.note = note.number + self.optionFlags = optionFlags + self.channel = channel + self.group = group + + } + } } diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/Note/Note Attribute Pitch7_9.swift b/Sources/MIDIKit/Events/Event/Channel Voice/Note/Note Attribute Pitch7_9.swift index 589093eb27..bfc1bb9589 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/Note/Note Attribute Pitch7_9.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/Note/Note Attribute Pitch7_9.swift @@ -20,6 +20,14 @@ extension MIDI.Event.Note.Attribute { /// 9-Bit fractional pitch above Note Number (i.e., fraction of one semitone). public var fine: MIDI.UInt9 + public init(coarse: MIDI.UInt7, + fine: MIDI.UInt9) { + + self.coarse = coarse + self.fine = fine + + } + } } diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/Note/Off/Note Off.swift b/Sources/MIDIKit/Events/Event/Channel Voice/Note/Off/Note Off.swift index 8b24624f37..0550a85928 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/Note/Off/Note Off.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/Note/Off/Note Off.swift @@ -27,6 +27,34 @@ extension MIDI.Event.Note { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(note: MIDI.UInt7, + velocity: MIDI.Event.Note.Velocity, + channel: MIDI.UInt4, + attribute: MIDI.Event.Note.Attribute = .none, + group: MIDI.UInt4 = 0x0) { + + self.note = note + self.velocity = velocity + self.channel = channel + self.attribute = attribute + self.group = group + + } + + public init(note: MIDI.Note, + velocity: MIDI.Event.Note.Velocity, + channel: MIDI.UInt4, + attribute: MIDI.Event.Note.Attribute = .none, + group: MIDI.UInt4 = 0x0) { + + self.note = note.number + self.velocity = velocity + self.channel = channel + self.attribute = attribute + self.group = group + + } + } } diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/Note/On/Note On.swift b/Sources/MIDIKit/Events/Event/Channel Voice/Note/On/Note On.swift index c2e2fcb89d..3d9518d34c 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/Note/On/Note On.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/Note/On/Note On.swift @@ -30,6 +30,38 @@ extension MIDI.Event.Note { /// For MIDI 1.0, transmit velocity of 0 as a Note Off event. public var midi1ZeroVelocityAsNoteOff: Bool = true + public init(note: MIDI.UInt7, + velocity: MIDI.Event.Note.Velocity, + channel: MIDI.UInt4, + attribute: MIDI.Event.Note.Attribute = .none, + group: MIDI.UInt4 = 0x0, + midi1ZeroVelocityAsNoteOff: Bool = true) { + + self.note = note + self.velocity = velocity + self.channel = channel + self.attribute = attribute + self.group = group + self.midi1ZeroVelocityAsNoteOff = midi1ZeroVelocityAsNoteOff + + } + + public init(note: MIDI.Note, + velocity: MIDI.Event.Note.Velocity, + channel: MIDI.UInt4, + attribute: MIDI.Event.Note.Attribute = .none, + group: MIDI.UInt4 = 0x0, + midi1ZeroVelocityAsNoteOff: Bool = true) { + + self.note = note.number + self.velocity = velocity + self.channel = channel + self.attribute = attribute + self.group = group + self.midi1ZeroVelocityAsNoteOff = midi1ZeroVelocityAsNoteOff + + } + } } diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/Note/PitchBend/Note PitchBend.swift b/Sources/MIDIKit/Events/Event/Channel Voice/Note/PitchBend/Note PitchBend.swift index ff084e8fd6..0d033d5f95 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/Note/PitchBend/Note PitchBend.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/Note/PitchBend/Note PitchBend.swift @@ -24,6 +24,30 @@ extension MIDI.Event.Note { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(note: MIDI.UInt7, + value: Value, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.note = note + self.value = value + self.channel = channel + self.group = group + + } + + public init(note: MIDI.Note, + value: Value, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.note = note.number + self.value = value + self.channel = channel + self.group = group + + } + } } diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/Note/Pressure/Note Pressure.swift b/Sources/MIDIKit/Events/Event/Channel Voice/Note/Pressure/Note Pressure.swift index c8aec7fdc0..cba40dc398 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/Note/Pressure/Note Pressure.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/Note/Pressure/Note Pressure.swift @@ -27,6 +27,30 @@ extension MIDI.Event.Note { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(note: MIDI.UInt7, + amount: Amount, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.note = note + self.amount = amount + self.channel = channel + self.group = group + + } + + public init(note: MIDI.Note, + amount: Amount, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.note = note.number + self.amount = amount + self.channel = channel + self.group = group + + } + } } diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/PitchBend/PitchBend.swift b/Sources/MIDIKit/Events/Event/Channel Voice/PitchBend/PitchBend.swift index 79677b7cec..58b172293d 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/PitchBend/PitchBend.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/PitchBend/PitchBend.swift @@ -18,6 +18,16 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(value: Value, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.value = value + self.channel = channel + self.group = group + + } + } /// Channel Voice Message: Pitch Bend diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/Pressure/Pressure.swift b/Sources/MIDIKit/Events/Event/Channel Voice/Pressure/Pressure.swift index 48f71e3172..689926ffac 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/Pressure/Pressure.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/Pressure/Pressure.swift @@ -24,6 +24,16 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(amount: Amount, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.amount = amount + self.channel = channel + self.group = group + + } + } /// Channel Voice Message: Channel Pressure diff --git a/Sources/MIDIKit/Events/Event/Channel Voice/ProgramChange/ProgramChange.swift b/Sources/MIDIKit/Events/Event/Channel Voice/ProgramChange/ProgramChange.swift index 4e3e4a8f61..b9dd1eb9c2 100644 --- a/Sources/MIDIKit/Events/Event/Channel Voice/ProgramChange/ProgramChange.swift +++ b/Sources/MIDIKit/Events/Event/Channel Voice/ProgramChange/ProgramChange.swift @@ -45,6 +45,18 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(program: MIDI.UInt7, + bank: Bank, + channel: MIDI.UInt4, + group: MIDI.UInt4 = 0x0) { + + self.program = program + self.bank = bank + self.channel = channel + self.group = group + + } + } /// Channel Voice Message: Program Change diff --git a/Sources/MIDIKit/Events/Event/System Common/SongPositionPointer.swift b/Sources/MIDIKit/Events/Event/System Common/SongPositionPointer.swift index edb90c9214..2080a5e1e3 100644 --- a/Sources/MIDIKit/Events/Event/System Common/SongPositionPointer.swift +++ b/Sources/MIDIKit/Events/Event/System Common/SongPositionPointer.swift @@ -19,6 +19,14 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(midiBeat: MIDI.UInt14, + group: MIDI.UInt4 = 0x0) { + + self.midiBeat = midiBeat + self.group = group + + } + } /// System Common: Song Position Pointer diff --git a/Sources/MIDIKit/Events/Event/System Common/SongSelect.swift b/Sources/MIDIKit/Events/Event/System Common/SongSelect.swift index ea6bffd7b2..2b296ddc13 100644 --- a/Sources/MIDIKit/Events/Event/System Common/SongSelect.swift +++ b/Sources/MIDIKit/Events/Event/System Common/SongSelect.swift @@ -19,6 +19,14 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(number: MIDI.UInt7, + group: MIDI.UInt4 = 0x0) { + + self.number = number + self.group = group + + } + } /// System Common: Song Select diff --git a/Sources/MIDIKit/Events/Event/System Common/TimecodeQuarterFrame.swift b/Sources/MIDIKit/Events/Event/System Common/TimecodeQuarterFrame.swift index 27340420de..2eeff7cf20 100644 --- a/Sources/MIDIKit/Events/Event/System Common/TimecodeQuarterFrame.swift +++ b/Sources/MIDIKit/Events/Event/System Common/TimecodeQuarterFrame.swift @@ -19,6 +19,14 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(dataByte: MIDI.UInt7, + group: MIDI.UInt4 = 0x0) { + + self.dataByte = dataByte + self.group = group + + } + } /// System Common: Timecode Quarter-Frame diff --git a/Sources/MIDIKit/Events/Event/System Common/TuneRequest.swift b/Sources/MIDIKit/Events/Event/System Common/TuneRequest.swift index e3108b6701..87d728f94b 100644 --- a/Sources/MIDIKit/Events/Event/System Common/TuneRequest.swift +++ b/Sources/MIDIKit/Events/Event/System Common/TuneRequest.swift @@ -16,6 +16,12 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(group: MIDI.UInt4 = 0x0) { + + self.group = group + + } + } /// System Common: Tune Request diff --git a/Sources/MIDIKit/Events/Event/System Common/UnofficialBusSelect.swift b/Sources/MIDIKit/Events/Event/System Common/UnofficialBusSelect.swift index 59c7ff23bd..7632c9d455 100644 --- a/Sources/MIDIKit/Events/Event/System Common/UnofficialBusSelect.swift +++ b/Sources/MIDIKit/Events/Event/System Common/UnofficialBusSelect.swift @@ -16,6 +16,14 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(bus: MIDI.UInt7 = 0, + group: MIDI.UInt4 = 0x0) { + + self.bus = bus + self.group = group + + } + } /// Unofficial Bus Select (Status `0xF5`) diff --git a/Sources/MIDIKit/Events/Event/System Exclusive/SysEx/SysEx.swift b/Sources/MIDIKit/Events/Event/System Exclusive/SysEx/SysEx.swift index acd08ef526..003e407216 100644 --- a/Sources/MIDIKit/Events/Event/System Exclusive/SysEx/SysEx.swift +++ b/Sources/MIDIKit/Events/Event/System Exclusive/SysEx/SysEx.swift @@ -24,6 +24,16 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(manufacturer: MIDI.Event.SysExManufacturer, + data: [MIDI.Byte], + group: MIDI.UInt4 = 0x0) { + + self.manufacturer = manufacturer + self.data = data + self.group = group + + } + } /// System Exclusive: Manufacturer-specific diff --git a/Sources/MIDIKit/Events/Event/System Exclusive/UniversalSysEx/UniversalSysEx.swift b/Sources/MIDIKit/Events/Event/System Exclusive/UniversalSysEx/UniversalSysEx.swift index 161fc930f0..31e77fa6a1 100644 --- a/Sources/MIDIKit/Events/Event/System Exclusive/UniversalSysEx/UniversalSysEx.swift +++ b/Sources/MIDIKit/Events/Event/System Exclusive/UniversalSysEx/UniversalSysEx.swift @@ -33,6 +33,22 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(universalType: MIDI.Event.UniversalSysExType, + deviceID: MIDI.UInt7, + subID1: MIDI.UInt7, + subID2: MIDI.UInt7, + data: [MIDI.Byte], + group: MIDI.UInt4 = 0x0) { + + self.universalType = universalType + self.deviceID = deviceID + self.subID1 = subID1 + self.subID2 = subID2 + self.data = data + self.group = group + + } + } /// System Exclusive: Universal SysEx diff --git a/Sources/MIDIKit/Events/Event/System Real Time/ActiveSensing.swift b/Sources/MIDIKit/Events/Event/System Real Time/ActiveSensing.swift index 3342a43ccd..e169ea2060 100644 --- a/Sources/MIDIKit/Events/Event/System Real Time/ActiveSensing.swift +++ b/Sources/MIDIKit/Events/Event/System Real Time/ActiveSensing.swift @@ -18,6 +18,12 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(group: MIDI.UInt4 = 0x0) { + + self.group = group + + } + } /// System Real Time: Active Sensing diff --git a/Sources/MIDIKit/Events/Event/System Real Time/Continue.swift b/Sources/MIDIKit/Events/Event/System Real Time/Continue.swift index 7e9e1f437b..dd588c792c 100644 --- a/Sources/MIDIKit/Events/Event/System Real Time/Continue.swift +++ b/Sources/MIDIKit/Events/Event/System Real Time/Continue.swift @@ -16,6 +16,12 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(group: MIDI.UInt4 = 0x0) { + + self.group = group + + } + } /// System Real Time: Continue diff --git a/Sources/MIDIKit/Events/Event/System Real Time/Start.swift b/Sources/MIDIKit/Events/Event/System Real Time/Start.swift index 0ed75d9e8d..aed9565d74 100644 --- a/Sources/MIDIKit/Events/Event/System Real Time/Start.swift +++ b/Sources/MIDIKit/Events/Event/System Real Time/Start.swift @@ -16,6 +16,12 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(group: MIDI.UInt4 = 0x0) { + + self.group = group + + } + } /// System Real Time: Start diff --git a/Sources/MIDIKit/Events/Event/System Real Time/Stop.swift b/Sources/MIDIKit/Events/Event/System Real Time/Stop.swift index 9c3dcbb8c5..cbe27d11eb 100644 --- a/Sources/MIDIKit/Events/Event/System Real Time/Stop.swift +++ b/Sources/MIDIKit/Events/Event/System Real Time/Stop.swift @@ -16,6 +16,12 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(group: MIDI.UInt4 = 0x0) { + + self.group = group + + } + } /// System Real Time: Stop diff --git a/Sources/MIDIKit/Events/Event/System Real Time/SystemReset.swift b/Sources/MIDIKit/Events/Event/System Real Time/SystemReset.swift index 296c245a2d..1b8808925e 100644 --- a/Sources/MIDIKit/Events/Event/System Real Time/SystemReset.swift +++ b/Sources/MIDIKit/Events/Event/System Real Time/SystemReset.swift @@ -16,6 +16,12 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(group: MIDI.UInt4 = 0x0) { + + self.group = group + + } + } /// System Real Time: System Reset diff --git a/Sources/MIDIKit/Events/Event/System Real Time/TimingClock.swift b/Sources/MIDIKit/Events/Event/System Real Time/TimingClock.swift index 46c5264fb4..863da025ae 100644 --- a/Sources/MIDIKit/Events/Event/System Real Time/TimingClock.swift +++ b/Sources/MIDIKit/Events/Event/System Real Time/TimingClock.swift @@ -16,6 +16,12 @@ extension MIDI.Event { /// UMP Group (0x0...0xF) public var group: MIDI.UInt4 = 0x0 + public init(group: MIDI.UInt4 = 0x0) { + + self.group = group + + } + } /// System Real Time: Timing Clock