Skip to content

Commit 419a143

Browse files
authored
Merge pull request #51 from orchetect/dev
Dev merge
2 parents d84d0ea + 74f4c37 commit 419a143

28 files changed

+352
-25
lines changed

Sources/MIDIKit/Events/Event/Channel Voice/CC/CC.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,30 @@ extension MIDI.Event {
2222
/// UMP Group (0x0...0xF)
2323
public var group: MIDI.UInt4 = 0x0
2424

25+
public init(controller: Controller,
26+
value: Value,
27+
channel: MIDI.UInt4,
28+
group: MIDI.UInt4 = 0x0) {
29+
30+
self.controller = controller
31+
self.value = value
32+
self.channel = channel
33+
self.group = group
34+
35+
}
36+
37+
public init(controller: MIDI.UInt7,
38+
value: Value,
39+
channel: MIDI.UInt4,
40+
group: MIDI.UInt4 = 0x0) {
41+
42+
self.controller = .init(number: controller)
43+
self.value = value
44+
self.channel = channel
45+
self.group = group
46+
47+
}
48+
2549
}
2650

2751
}
@@ -64,7 +88,7 @@ extension MIDI.Event {
6488
group: MIDI.UInt4 = 0x0) -> Self {
6589

6690
.cc(
67-
.init(controller: .init(number: controller),
91+
.init(controller: controller,
6892
value: value,
6993
channel: channel,
7094
group: group)

Sources/MIDIKit/Events/Event/Channel Voice/Note/CC/Note CC.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,34 @@ extension MIDI.Event.Note {
2626
/// UMP Group (0x0...0xF)
2727
public var group: MIDI.UInt4 = 0x0
2828

29+
public init(note: MIDI.UInt7,
30+
controller: CC.Controller,
31+
value: UInt32,
32+
channel: MIDI.UInt4,
33+
group: MIDI.UInt4 = 0x0) {
34+
35+
self.note = note
36+
self.controller = controller
37+
self.value = value
38+
self.channel = channel
39+
self.group = group
40+
41+
}
42+
43+
public init(note: MIDI.Note,
44+
controller: CC.Controller,
45+
value: UInt32,
46+
channel: MIDI.UInt4,
47+
group: MIDI.UInt4 = 0x0) {
48+
49+
self.note = note.number
50+
self.controller = controller
51+
self.value = value
52+
self.channel = channel
53+
self.group = group
54+
55+
}
56+
2957
}
3058

3159
}

Sources/MIDIKit/Events/Event/Channel Voice/Note/Management/Note Management.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,30 @@ extension MIDI.Event.Note {
2525
/// UMP Group (0x0...0xF)
2626
public var group: MIDI.UInt4 = 0x0
2727

28+
public init(note: MIDI.UInt7,
29+
optionFlags: Set<OptionFlag> = [],
30+
channel: MIDI.UInt4,
31+
group: MIDI.UInt4 = 0x0) {
32+
33+
self.note = note
34+
self.optionFlags = optionFlags
35+
self.channel = channel
36+
self.group = group
37+
38+
}
39+
40+
public init(note: MIDI.Note,
41+
optionFlags: Set<OptionFlag> = [],
42+
channel: MIDI.UInt4,
43+
group: MIDI.UInt4 = 0x0) {
44+
45+
self.note = note.number
46+
self.optionFlags = optionFlags
47+
self.channel = channel
48+
self.group = group
49+
50+
}
51+
2852
}
2953

3054
}

Sources/MIDIKit/Events/Event/Channel Voice/Note/Note Attribute Pitch7_9.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ extension MIDI.Event.Note.Attribute {
2020
/// 9-Bit fractional pitch above Note Number (i.e., fraction of one semitone).
2121
public var fine: MIDI.UInt9
2222

23+
public init(coarse: MIDI.UInt7,
24+
fine: MIDI.UInt9) {
25+
26+
self.coarse = coarse
27+
self.fine = fine
28+
29+
}
30+
2331
}
2432

2533
}

Sources/MIDIKit/Events/Event/Channel Voice/Note/Off/Note Off.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@ extension MIDI.Event.Note {
2727
/// UMP Group (0x0...0xF)
2828
public var group: MIDI.UInt4 = 0x0
2929

30+
public init(note: MIDI.UInt7,
31+
velocity: MIDI.Event.Note.Velocity,
32+
channel: MIDI.UInt4,
33+
attribute: MIDI.Event.Note.Attribute = .none,
34+
group: MIDI.UInt4 = 0x0) {
35+
36+
self.note = note
37+
self.velocity = velocity
38+
self.channel = channel
39+
self.attribute = attribute
40+
self.group = group
41+
42+
}
43+
44+
public init(note: MIDI.Note,
45+
velocity: MIDI.Event.Note.Velocity,
46+
channel: MIDI.UInt4,
47+
attribute: MIDI.Event.Note.Attribute = .none,
48+
group: MIDI.UInt4 = 0x0) {
49+
50+
self.note = note.number
51+
self.velocity = velocity
52+
self.channel = channel
53+
self.attribute = attribute
54+
self.group = group
55+
56+
}
57+
3058
}
3159

3260
}

Sources/MIDIKit/Events/Event/Channel Voice/Note/On/Note On.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,38 @@ extension MIDI.Event.Note {
3030
/// For MIDI 1.0, transmit velocity of 0 as a Note Off event.
3131
public var midi1ZeroVelocityAsNoteOff: Bool = true
3232

33+
public init(note: MIDI.UInt7,
34+
velocity: MIDI.Event.Note.Velocity,
35+
channel: MIDI.UInt4,
36+
attribute: MIDI.Event.Note.Attribute = .none,
37+
group: MIDI.UInt4 = 0x0,
38+
midi1ZeroVelocityAsNoteOff: Bool = true) {
39+
40+
self.note = note
41+
self.velocity = velocity
42+
self.channel = channel
43+
self.attribute = attribute
44+
self.group = group
45+
self.midi1ZeroVelocityAsNoteOff = midi1ZeroVelocityAsNoteOff
46+
47+
}
48+
49+
public init(note: MIDI.Note,
50+
velocity: MIDI.Event.Note.Velocity,
51+
channel: MIDI.UInt4,
52+
attribute: MIDI.Event.Note.Attribute = .none,
53+
group: MIDI.UInt4 = 0x0,
54+
midi1ZeroVelocityAsNoteOff: Bool = true) {
55+
56+
self.note = note.number
57+
self.velocity = velocity
58+
self.channel = channel
59+
self.attribute = attribute
60+
self.group = group
61+
self.midi1ZeroVelocityAsNoteOff = midi1ZeroVelocityAsNoteOff
62+
63+
}
64+
3365
}
3466

3567
}

Sources/MIDIKit/Events/Event/Channel Voice/Note/PitchBend/Note PitchBend.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,30 @@ extension MIDI.Event.Note {
2424
/// UMP Group (0x0...0xF)
2525
public var group: MIDI.UInt4 = 0x0
2626

27+
public init(note: MIDI.UInt7,
28+
value: Value,
29+
channel: MIDI.UInt4,
30+
group: MIDI.UInt4 = 0x0) {
31+
32+
self.note = note
33+
self.value = value
34+
self.channel = channel
35+
self.group = group
36+
37+
}
38+
39+
public init(note: MIDI.Note,
40+
value: Value,
41+
channel: MIDI.UInt4,
42+
group: MIDI.UInt4 = 0x0) {
43+
44+
self.note = note.number
45+
self.value = value
46+
self.channel = channel
47+
self.group = group
48+
49+
}
50+
2751
}
2852

2953
}

Sources/MIDIKit/Events/Event/Channel Voice/Note/Pressure/Note Pressure.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ extension MIDI.Event.Note {
2727
/// UMP Group (0x0...0xF)
2828
public var group: MIDI.UInt4 = 0x0
2929

30+
public init(note: MIDI.UInt7,
31+
amount: Amount,
32+
channel: MIDI.UInt4,
33+
group: MIDI.UInt4 = 0x0) {
34+
35+
self.note = note
36+
self.amount = amount
37+
self.channel = channel
38+
self.group = group
39+
40+
}
41+
42+
public init(note: MIDI.Note,
43+
amount: Amount,
44+
channel: MIDI.UInt4,
45+
group: MIDI.UInt4 = 0x0) {
46+
47+
self.note = note.number
48+
self.amount = amount
49+
self.channel = channel
50+
self.group = group
51+
52+
}
53+
3054
}
3155

3256
}

Sources/MIDIKit/Events/Event/Channel Voice/PitchBend/PitchBend.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ extension MIDI.Event {
1818
/// UMP Group (0x0...0xF)
1919
public var group: MIDI.UInt4 = 0x0
2020

21+
public init(value: Value,
22+
channel: MIDI.UInt4,
23+
group: MIDI.UInt4 = 0x0) {
24+
25+
self.value = value
26+
self.channel = channel
27+
self.group = group
28+
29+
}
30+
2131
}
2232

2333
/// Channel Voice Message: Pitch Bend

Sources/MIDIKit/Events/Event/Channel Voice/Pressure/Pressure.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ extension MIDI.Event {
2424
/// UMP Group (0x0...0xF)
2525
public var group: MIDI.UInt4 = 0x0
2626

27+
public init(amount: Amount,
28+
channel: MIDI.UInt4,
29+
group: MIDI.UInt4 = 0x0) {
30+
31+
self.amount = amount
32+
self.channel = channel
33+
self.group = group
34+
35+
}
36+
2737
}
2838

2939
/// Channel Voice Message: Channel Pressure

Sources/MIDIKit/Events/Event/Channel Voice/ProgramChange/ProgramChange.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ extension MIDI.Event {
4545
/// UMP Group (0x0...0xF)
4646
public var group: MIDI.UInt4 = 0x0
4747

48+
public init(program: MIDI.UInt7,
49+
bank: Bank,
50+
channel: MIDI.UInt4,
51+
group: MIDI.UInt4 = 0x0) {
52+
53+
self.program = program
54+
self.bank = bank
55+
self.channel = channel
56+
self.group = group
57+
58+
}
59+
4860
}
4961

5062
/// Channel Voice Message: Program Change

Sources/MIDIKit/Events/Event/System Common/SongPositionPointer.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ extension MIDI.Event {
1919
/// UMP Group (0x0...0xF)
2020
public var group: MIDI.UInt4 = 0x0
2121

22+
public init(midiBeat: MIDI.UInt14,
23+
group: MIDI.UInt4 = 0x0) {
24+
25+
self.midiBeat = midiBeat
26+
self.group = group
27+
28+
}
29+
2230
}
2331

2432
/// System Common: Song Position Pointer

Sources/MIDIKit/Events/Event/System Common/SongSelect.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ extension MIDI.Event {
1919
/// UMP Group (0x0...0xF)
2020
public var group: MIDI.UInt4 = 0x0
2121

22+
public init(number: MIDI.UInt7,
23+
group: MIDI.UInt4 = 0x0) {
24+
25+
self.number = number
26+
self.group = group
27+
28+
}
29+
2230
}
2331

2432
/// System Common: Song Select

Sources/MIDIKit/Events/Event/System Common/TimecodeQuarterFrame.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ extension MIDI.Event {
1919
/// UMP Group (0x0...0xF)
2020
public var group: MIDI.UInt4 = 0x0
2121

22+
public init(dataByte: MIDI.UInt7,
23+
group: MIDI.UInt4 = 0x0) {
24+
25+
self.dataByte = dataByte
26+
self.group = group
27+
28+
}
29+
2230
}
2331

2432
/// System Common: Timecode Quarter-Frame

Sources/MIDIKit/Events/Event/System Common/TuneRequest.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ extension MIDI.Event {
1616
/// UMP Group (0x0...0xF)
1717
public var group: MIDI.UInt4 = 0x0
1818

19+
public init(group: MIDI.UInt4 = 0x0) {
20+
21+
self.group = group
22+
23+
}
24+
1925
}
2026

2127
/// System Common: Tune Request

Sources/MIDIKit/Events/Event/System Common/UnofficialBusSelect.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ extension MIDI.Event {
1616
/// UMP Group (0x0...0xF)
1717
public var group: MIDI.UInt4 = 0x0
1818

19+
public init(bus: MIDI.UInt7 = 0,
20+
group: MIDI.UInt4 = 0x0) {
21+
22+
self.bus = bus
23+
self.group = group
24+
25+
}
26+
1927
}
2028

2129
/// Unofficial Bus Select (Status `0xF5`)

Sources/MIDIKit/Events/Event/System Exclusive/SysEx Parser.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import Foundation
77

88
extension MIDI.Event {
99

10+
/// Parse a raw System Exclusive message and return a `.sysEx()` or `.universalSysEx()` case if successful.
11+
///
12+
/// - Throws: `MIDI.Event.ParseError` if message is malformed.
1013
@inline(__always)
11-
internal static func sysEx(
12-
from rawBytes: [MIDI.Byte],
14+
public static func sysEx(
15+
rawBytes: [MIDI.Byte],
1316
group: MIDI.UInt4 = 0
1417
) throws -> Self {
1518

0 commit comments

Comments
 (0)