Skip to content

Commit de5e4c2

Browse files
committed
core: clang-format
1 parent 8e0a615 commit de5e4c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+436
-460
lines changed
Lines changed: 80 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,95 @@
1-
#include <jni.h>
2-
#include <string>
3-
#include <vector>
4-
#include <sstream>
51
#include <libremidi/libremidi.hpp>
62

73
#include <android/log.h>
4+
5+
#include <jni.h>
6+
7+
#include <sstream>
8+
#include <string>
9+
#include <vector>
810
extern "C" JNIEXPORT jstring JNICALL
9-
Java_com_libremidi_example_MainActivity_getMidiDevices(JNIEnv* env, jobject /* this */) {
10-
std::stringstream result;
11-
__android_log_print(ANDROID_LOG_WARN, "libremidi", "Java_com_libremidi_example_MainActivity_getMidiDevices!!");
12-
13-
try {
14-
auto api = libremidi::API::ANDROID_AMIDI;
15-
libremidi::observer obs{{.track_any = true}, libremidi::observer_configuration_for(api)};
16-
17-
result << "=== MIDI Input Devices ===\n";
18-
auto inputs = obs.get_input_ports();
19-
if (inputs.empty()) {
20-
result << "No input devices found\n";
21-
} else {
22-
for (const auto& port : inputs) {
23-
result << "Port " << port.port << ": " << port.port_name;
24-
if (!port.device_name.empty() && port.device_name != port.port_name) {
25-
result << " (Device: " << port.device_name << ")";
26-
}
27-
if (!port.display_name.empty() && port.display_name != port.port_name) {
28-
result << " [" << port.display_name << "]";
29-
}
30-
result << "\n";
11+
Java_com_libremidi_example_MainActivity_getMidiDevices(JNIEnv* env, jobject /* this */)
12+
{
13+
std::stringstream result;
14+
__android_log_print(
15+
ANDROID_LOG_WARN, "libremidi", "Java_com_libremidi_example_MainActivity_getMidiDevices!!");
16+
17+
try
18+
{
19+
auto api = libremidi::API::ANDROID_AMIDI;
20+
libremidi::observer obs{{.track_any = true}, libremidi::observer_configuration_for(api)};
3121

32-
__android_log_print(ANDROID_LOG_WARN, "libremidi", "opening: %s", port.port_name.c_str());
33-
auto midi_in = new libremidi::midi_in{{.on_message{[](const libremidi::message& m) {
34-
__android_log_print(ANDROID_LOG_WARN, "libremidi", "ayy!!");
35-
}}}, libremidi::midi_in_configuration_for(api)};
22+
result << "=== MIDI Input Devices ===\n";
23+
auto inputs = obs.get_input_ports();
24+
if (inputs.empty())
25+
{
26+
result << "No input devices found\n";
27+
}
28+
else
29+
{
30+
for (const auto& port : inputs)
31+
{
32+
result << "Port " << port.port << ": " << port.port_name;
33+
if (!port.device_name.empty() && port.device_name != port.port_name)
34+
{
35+
result << " (Device: " << port.device_name << ")";
36+
}
37+
if (!port.display_name.empty() && port.display_name != port.port_name)
38+
{
39+
result << " [" << port.display_name << "]";
40+
}
41+
result << "\n";
3642

37-
auto p = midi_in->get_current_api();
43+
__android_log_print(ANDROID_LOG_WARN, "libremidi", "opening: %s", port.port_name.c_str());
44+
auto midi_in = new libremidi::midi_in{
45+
{.on_message{[](const libremidi::message& m) {
46+
__android_log_print(ANDROID_LOG_WARN, "libremidi", "ayy!!");
47+
}}},
48+
libremidi::midi_in_configuration_for(api)};
3849

39-
__android_log_print(ANDROID_LOG_WARN, "libremidi", ">> ??! %s", libremidi::get_api_name(p).data());
40-
__android_log_print(ANDROID_LOG_WARN, "libremidi", ">> open port?!");
41-
midi_in->open_port(port);
42-
}
50+
auto p = midi_in->get_current_api();
51+
52+
__android_log_print(
53+
ANDROID_LOG_WARN, "libremidi", ">> ??! %s", libremidi::get_api_name(p).data());
54+
__android_log_print(ANDROID_LOG_WARN, "libremidi", ">> open port?!");
55+
midi_in->open_port(port);
56+
}
57+
}
58+
59+
result << "\n=== MIDI Output Devices ===\n";
60+
auto outputs = obs.get_output_ports();
61+
if (outputs.empty())
62+
{
63+
result << "No output devices found\n";
64+
}
65+
else
66+
{
67+
for (const auto& port : outputs)
68+
{
69+
result << "Port " << port.port << ": " << port.port_name;
70+
if (!port.device_name.empty() && port.device_name != port.port_name)
71+
{
72+
result << " (Device: " << port.device_name << ")";
4373
}
44-
45-
result << "\n=== MIDI Output Devices ===\n";
46-
auto outputs = obs.get_output_ports();
47-
if (outputs.empty()) {
48-
result << "No output devices found\n";
49-
} else {
50-
for (const auto& port : outputs) {
51-
result << "Port " << port.port << ": " << port.port_name;
52-
if (!port.device_name.empty() && port.device_name != port.port_name) {
53-
result << " (Device: " << port.device_name << ")";
54-
}
55-
if (!port.display_name.empty() && port.display_name != port.port_name) {
56-
result << " [" << port.display_name << "]";
57-
}
58-
result << "\n";
59-
}
74+
if (!port.display_name.empty() && port.display_name != port.port_name)
75+
{
76+
result << " [" << port.display_name << "]";
6077
}
61-
62-
} catch (const std::exception& e) {
63-
result << "Error: " << e.what() << "\n";
78+
result << "\n";
79+
}
6480
}
81+
}
82+
catch (const std::exception& e)
83+
{
84+
result << "Error: " << e.what() << "\n";
85+
}
6586

66-
__android_log_print(ANDROID_LOG_WARN, "libremidi", "FINITO!!");
67-
return env->NewStringUTF(result.str().c_str());
87+
__android_log_print(ANDROID_LOG_WARN, "libremidi", "FINITO!!");
88+
return env->NewStringUTF(result.str().c_str());
6889
}
6990

7091
extern "C" JNIEXPORT jstring JNICALL
71-
Java_com_libremidi_example_MainActivity_getLibremidiVersion(JNIEnv* env, jobject /* this */) {
72-
return env->NewStringUTF("libremidi Android example");
92+
Java_com_libremidi_example_MainActivity_getLibremidiVersion(JNIEnv* env, jobject /* this */)
93+
{
94+
return env->NewStringUTF("libremidi Android example");
7395
}

examples/backends/midi2_out_winmidi.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "backend_test_utils.hpp"
2+
23
#include <libremidi/backends/winmidi.hpp>
34
#include <libremidi/libremidi.hpp>
45
using api = libremidi::winmidi::backend;

examples/client.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ int main()
1818
std::cerr << port.display_name << ": " << mess.bytes.size() << std::endl;
1919

2020
client.send_message(mess.bytes.data(), mess.bytes.size());
21-
},
21+
},
2222
.input_added =
2323
[&](const libremidi::input_port& port) {
2424
std::cerr << "Input added: " << port.display_name << " | " << port.port_name << std::endl;
2525
client.add_input(port, "input_" + std::to_string(input_k++));
26-
},
27-
.input_removed
28-
= [&](const libremidi::input_port& port) {
26+
},
27+
.input_removed =
28+
[&](const libremidi::input_port& port) {
2929
std::cerr << "Input removed: " << port.display_name << std::endl;
3030
client.remove_input(port);
31-
},
32-
.output_added
33-
= [&](const libremidi::output_port& port) {
31+
},
32+
.output_added =
33+
[&](const libremidi::output_port& port) {
3434
std::cerr << "Output added: " << port.display_name << std::endl;
3535
client.add_output(port, "output_" + std::to_string(output_k++));
36-
},
37-
.output_removed = [&](const libremidi::output_port& port) {
38-
std::cerr << "Output removed: " << port.display_name << std::endl;
39-
client.remove_output(port);
40-
}}};
36+
},
37+
.output_removed = [&](const libremidi::output_port& port) {
38+
std::cerr << "Output removed: " << port.display_name << std::endl;
39+
client.remove_output(port);
40+
}}};
4141

4242
auto inputs = client.get_input_ports();
4343
auto outputs = client.get_output_ports();

examples/coremidi_share.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#include "utils.hpp"
2+
13
#include <libremidi/configurations.hpp>
24
#include <libremidi/libremidi.hpp>
3-
#include "utils.hpp"
45

56
#include <CoreMIDI/CoreMIDI.h>
67

examples/echo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ int main()
3030
libremidi::midi_in midiin{
3131
{
3232
// Set our callback function.
33-
.on_message
34-
= [&](const libremidi::message& message) {
33+
.on_message =
34+
[&](const libremidi::message& message) {
3535
std::cout << message << std::endl;
36-
auto _ = midiout.send_message(message);
37-
},
36+
auto _ = midiout.send_message(message);
37+
},
3838
},
3939
libremidi::midi_in_configuration_for(obs)};
4040

examples/emscripten_midiin.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#include "utils.hpp"
2+
13
#include <libremidi/configurations.hpp>
24
#include <libremidi/libremidi.hpp>
3-
#include "utils.hpp"
5+
46
#include <emscripten.h>
57

68
#include <array>
@@ -25,31 +27,29 @@ int main(int argc, char**)
2527
.on_message = [](const libremidi::message& msg) { std::cout << msg << std::endl; }};
2628
auto& input = inputs.emplace_back(conf, libremidi::emscripten_input_configuration{});
2729
input.open_port(id);
28-
},
30+
},
2931

3032
.input_removed =
3133
[&](const libremidi::input_port& id) {
3234
std::cout << "MIDI Input removed: " << id.port_name << std::endl;
33-
},
35+
},
3436

35-
.output_added
36-
= [&](const libremidi::output_port& id) {
37+
.output_added =
38+
[&](const libremidi::output_port& id) {
3739
std::cout << "MIDI Output connected: " << id.port_name << std::endl;
3840

3941
libremidi::midi_out output{};
4042
output.open_port(id);
4143
output.send_message(0x90, 64, 100);
4244
output.send_message(0x80, 64, 100);
43-
},
45+
},
4446

4547
.output_removed = [&](const libremidi::output_port& id) {
46-
std::cout << "MIDI Output removed: " << id.port_name << std::endl;
47-
}};
48+
std::cout << "MIDI Output removed: " << id.port_name << std::endl;
49+
}};
4850

4951
libremidi::observer obs{
50-
std::move(callbacks)
51-
, libremidi::observer_configuration_for(libremidi::API::WEBMIDI)
52-
};
52+
std::move(callbacks), libremidi::observer_configuration_for(libremidi::API::WEBMIDI)};
5353

54-
emscripten_set_main_loop([] {}, 60, 1);
54+
emscripten_set_main_loop([] { }, 60, 1);
5555
}

examples/gui/main.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,24 @@ int main(int argc, char** argv)
9292
// Connect gui changes to port changes
9393
QObject::connect(
9494
&inputs, &QListWidget::currentItemChanged, [&](QListWidgetItem* selected, QListWidgetItem*) {
95-
in.close_port();
96-
for (auto& [port, item] : input_items)
95+
in.close_port();
96+
for (auto& [port, item] : input_items)
97+
{
98+
if (item == selected)
99+
{
100+
in.open_port(port);
101+
if (!in.is_port_open())
97102
{
98-
if (item == selected)
99-
{
100-
in.open_port(port);
101-
if (!in.is_port_open())
102-
{
103-
QMessageBox::warning(
104-
&main, QString("Error !"),
105-
QString("Could not connect to input:\n%1\n%2")
106-
.arg(port.display_name.c_str())
107-
.arg(port.port_name.c_str()));
108-
}
109-
return;
110-
}
103+
QMessageBox::warning(
104+
&main, QString("Error !"),
105+
QString("Could not connect to input:\n%1\n%2")
106+
.arg(port.display_name.c_str())
107+
.arg(port.port_name.c_str()));
111108
}
112-
});
109+
return;
110+
}
111+
}
112+
});
113113

114114
QObject::connect(
115115
&outputs, &QListWidget::currentItemChanged,
@@ -131,6 +131,6 @@ int main(int argc, char** argv)
131131
return;
132132
}
133133
}
134-
});
134+
});
135135
return app.exec();
136136
}

examples/jack_share.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ struct my_app
4646
// Create our configuration
4747
auto api_input_config = libremidi::jack_input_configuration{
4848
.context = handle.get(), .set_process_func = [this](libremidi::jack_callback cb) {
49-
midiin_callbacks.push_back(std::move(cb));
50-
}};
49+
midiin_callbacks.push_back(std::move(cb));
50+
}};
5151
auto api_output_config = libremidi::jack_output_configuration{
5252
.context = handle.get(), .set_process_func = [this](libremidi::jack_callback cb) {
53-
midiout_callbacks.push_back(std::move(cb));
54-
}};
53+
midiout_callbacks.push_back(std::move(cb));
54+
}};
5555

5656
// Create 16 inputs and 16 outputs
5757
for (int i = 0; i < 16; i++)

examples/midifile_dump.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <libremidi/reader.hpp>
22

33
#include <cmath>
4+
45
#include <fstream>
56
#include <iomanip>
67
#include <iostream>

include/libremidi/backends/alsa_raw/helpers.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ struct enumerator
9898
: handler{self}
9999
, configuration{self.configuration}
100100
{
101-
102101
}
103102

104103
// 1: is an input / output

0 commit comments

Comments
 (0)