Skip to content

Commit ac62ad8

Browse files
committed
Documentation: fix that default_midi_port now gives an optional
1 parent de5e4c2 commit ac62ad8

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

book/src/midi-1-in.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ libremidi::midi_in midi{
2424
// The argument is a libremidi::input_port gotten from a libremidi::observer.
2525
midi.open_port(/* a port */);
2626
// Alternatively, to get the default port for the system:
27-
midi.open_port(libremidi::midi1::in_default_port());
27+
if(auto port = libremidi::midi1::in_default_port())
28+
midi.open_port(*port);
2829

2930
// Note that only one port can be open at a given time on a midi_in or midi_out object.
3031

book/src/midi-1-out.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
libremidi::midi_out midi;
66

77
// Open a given midi port. Same as for input:
8-
midi.open_port(libremidi::midi2::out_default_port());
8+
if(auto port = libremidi::midi1::out_default_port())
9+
midi.open_port(*port);
910

1011
// Option A: send fixed amount of bytes for most basic cases
1112
midi.send_message(144, 110, 40); // Overloads exist for 1, 2, 3 bytes

book/src/midi-2-out.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
libremidi::midi_out midi;
66

77
// Open a given midi port. Same as for input:
8-
midi.open_port(libremidi::midi2::out_default_port());
8+
if(auto port = libremidi::midi2::out_default_port())
9+
midi.open_port(*port);
910

1011
// Option A: send fixed amount of bytes for most basic cases
1112
midi.send_ump(A, B, C, D); // Overloads exist for 1, 2, 3, 4 uint32_t

0 commit comments

Comments
 (0)