Skip to content

Commit 41829b0

Browse files
committed
docs
1 parent 1061440 commit 41829b0

File tree

5 files changed

+63
-59
lines changed

5 files changed

+63
-59
lines changed

.github/workflows/workflow.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ jobs:
2424
cmake
2525
fluidsynth
2626
libfluidsynth-dev
27-
libtinyxml2-dev
27+
libxml2-dev
2828
qt6-base-dev
29-
qt6-wayland
3029
3130
- name: Install gcovr on Ubuntu
3231
if: matrix.os == 'ubuntu-24.04'
3332
run: pipx install gcovr
3433

3534
- name: Install dependencies on MacOS
3635
if: matrix.os == 'macos-latest'
37-
run: brew install fluid-synth ninja qt tinyxml2
36+
run: brew install fluid-synth ninja qt libxml2
3837

3938
- name: Add MSVC to path on Windows
4039
if: matrix.os == 'windows-latest'

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ if (WIN32)
100100
iconv
101101
intl
102102
fluidsynth
103+
lzma
103104
mp3lame
104105
mpg123
105106
ogg
@@ -109,6 +110,7 @@ if (WIN32)
109110
xml2
110111
vorbis
111112
vorbisenc
113+
zlib
112114
PRE_EXCLUDE_REGEXES .
113115
DIRECTORIES
114116
${_VCPKG_INSTALLED_DIR}/{VCPKG_TARGET_TRIPLET}/lib
@@ -121,7 +123,7 @@ qt_add_executable(Justly)
121123
target_sources(Justly PRIVATE bin/main.cpp)
122124
target_link_libraries(Justly PRIVATE JustlyLibrary Qt6::Core Qt6::Widgets)
123125
if (WIN32)
124-
set_target_properties(Justly PROPERTIES WIN32_EXECUTABLE ON)
126+
# set_target_properties(Justly PROPERTIES WIN32_EXECUTABLE ON)
125127
endif()
126128
install_executable(Justly)
127129

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
[![codecov](https://codecov.io/github/bramtayl/Justly/branch/master/graph/badge.svg?token=MUNbRKjHpZ)](https://codecov.io/github/bramtayl/Justly/tree/master)
44

55
> [!IMPORTANT]
6-
> Requires dependencies on Linux. To install, run `sudo apt install fluidsynth qt6-base-dev qt6-gtk-platformtheme qt6-wayland`.
6+
> Requires dependencies on Linux. To install, run `sudo apt install fluidsynth libfluidsynth-dev qt6-base-dev qt6-gtk-platformtheme libxml2-dev`.
77
88
> [!IMPORTANT]
9-
> Requires dependencies on MacOS. To install, run `brew install fluid-synth qt`.
9+
> Requires dependencies on MacOS. To install, run `brew install fluid-synth qt libxml2`.
1010
1111
## Installation
1212

@@ -145,7 +145,7 @@ To go back to the chords, select "Back to chords" from the "Edit" menu (see belo
145145
In the "File" menu, you can choose among the following options:
146146

147147
- "Open" to open a previously saved song.
148-
- "Import MusicXML" to import an uncompressed MusicXML file using [5-limit tuning](https://en.wikipedia.org/wiki/Five-limit_tuning#The_just_ratios)
148+
- "Import MusicXML" to import an uncompressed MusicXML file using [5-limit tuning](https://en.wikipedia.org/wiki/Five-limit_tuning#The_just_ratios) based on the key signature.
149149
- "Save" to save the song in the previous location.
150150
- "Save As" to save the song in a new location.
151151
- "Export recording" to export a recording of the song as a wav file.

src/justly.cpp

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include <libxml/xmlschemas.h>
6565
#include <libxml/xmlstring.h>
6666
#include <libxml/xmlversion.h>
67+
#include <array>
6768
#include <limits>
6869
#include <numeric>
6970
#include <optional>
@@ -1847,16 +1848,16 @@ struct Player {
18471848
double final_time = 0;
18481849

18491850
fluid_settings_t &settings = []() -> fluid_settings_t & {
1850-
fluid_settings_t &settings = get_reference(new_fluid_settings());
1851+
fluid_settings_t &result = get_reference(new_fluid_settings());
18511852
const auto cores = std::thread::hardware_concurrency();
1852-
set_fluid_int(settings, "synth.midi-channels", NUMBER_OF_MIDI_CHANNELS);
1853+
set_fluid_int(result, "synth.midi-channels", NUMBER_OF_MIDI_CHANNELS);
18531854
if (cores > 0) {
1854-
set_fluid_int(settings, "synth.cpu-cores", static_cast<int>(cores));
1855+
set_fluid_int(result, "synth.cpu-cores", static_cast<int>(cores));
18551856
}
18561857
#ifdef __linux__
1857-
fluid_settings_setstr(&settings, "audio.driver", "pulseaudio");
1858+
fluid_settings_setstr(&result, "audio.driver", "pulseaudio");
18581859
#endif
1859-
return settings;
1860+
return result;
18601861
}();
18611862
fluid_event_t &event = get_reference(new_fluid_event());
18621863
fluid_sequencer_t &sequencer = get_reference(new_fluid_sequencer2(0));
@@ -2350,7 +2351,7 @@ parse_clipboard(QWidget &parent,
23502351

23512352
const auto &copied_text = mime_data.data(mime_type).toStdString();
23522353
auto *document_pointer = xmlReadMemory(
2353-
copied_text.c_str(), copied_text.size(), nullptr, nullptr, 0);
2354+
copied_text.c_str(), static_cast<int>(copied_text.size()), nullptr, nullptr, 0);
23542355
if (document_pointer == nullptr) {
23552356
QMessageBox::warning(&parent, QObject::tr("Paste error"),
23562357
QObject::tr("Invalid XML"));
@@ -2369,8 +2370,8 @@ parse_clipboard(QWidget &parent,
23692370

23702371
auto &root = get_root(document);
23712372
QList<SubRow> new_rows;
2372-
int left_column = 0;
2373-
int right_column = 0;
2373+
auto left_column = 0;
2374+
auto right_column = 0;
23742375

23752376
auto *field_pointer = xmlFirstElementChild(&root);
23762377
while (field_pointer != nullptr) {
@@ -2381,7 +2382,7 @@ parse_clipboard(QWidget &parent,
23812382
} else if (name == "right_column") {
23822383
right_column = to_xml_int(field_node);
23832384
} else if (name == "rows") {
2384-
int counter = 1;
2385+
auto counter = 1;
23852386
auto *xml_row_pointer = xmlFirstElementChild(&field_node);
23862387
while (xml_row_pointer != nullptr && counter <= max_rows) {
23872388
SubRow child_row;
@@ -2873,10 +2874,10 @@ struct SpinBoxes : public QWidget {
28732874
QFormLayout &spin_boxes_form = *(new QFormLayout(this));
28742875

28752876
explicit SpinBoxes(Song &song, fluid_synth_t &synth, QUndoStack &undo_stack) {
2876-
auto &gain_editor = this->gain_editor;
2877-
auto &starting_key_editor = this->starting_key_editor;
2878-
auto &starting_velocity_editor = this->starting_velocity_editor;
2879-
auto &starting_tempo_editor = this->starting_tempo_editor;
2877+
auto &gain_editor_ref = this->gain_editor;
2878+
auto &starting_key_editor_ref = this->starting_key_editor;
2879+
auto &starting_velocity_editor_ref = this->starting_velocity_editor;
2880+
auto &starting_tempo_editor_ref = this->starting_tempo_editor;
28802881

28812882
add_control(spin_boxes_form, SpinBoxes::tr("&Gain:"), gain_editor, 0,
28822883
MAX_GAIN, SpinBoxes::tr("/10"), GAIN_STEP, 1);
@@ -2892,28 +2893,28 @@ struct SpinBoxes : public QWidget {
28922893

28932894
QObject::connect(
28942895
&gain_editor, &QDoubleSpinBox::valueChanged, this,
2895-
[&undo_stack, &song, &synth, &gain_editor](double new_value) {
2896-
add_set_double(undo_stack, song, synth, gain_editor, gain_id,
2896+
[&undo_stack, &song, &synth, &gain_editor_ref](double new_value) {
2897+
add_set_double(undo_stack, song, synth, gain_editor_ref, gain_id,
28972898
fluid_synth_get_gain(&synth), new_value);
28982899
});
28992900
QObject::connect(
29002901
&starting_key_editor, &QDoubleSpinBox::valueChanged, this,
2901-
[&undo_stack, &song, &synth, &starting_key_editor](double new_value) {
2902-
add_set_double(undo_stack, song, synth, starting_key_editor,
2902+
[&undo_stack, &song, &synth, &starting_key_editor_ref](double new_value) {
2903+
add_set_double(undo_stack, song, synth, starting_key_editor_ref,
29032904
starting_key_id, song.starting_key, new_value);
29042905
});
29052906
QObject::connect(
29062907
&starting_velocity_editor, &QDoubleSpinBox::valueChanged, this,
29072908
[&undo_stack, &song, &synth,
2908-
&starting_velocity_editor](double new_value) {
2909-
add_set_double(undo_stack, song, synth, starting_velocity_editor,
2909+
&starting_velocity_editor_ref](double new_value) {
2910+
add_set_double(undo_stack, song, synth, starting_velocity_editor_ref,
29102911
starting_velocity_id, song.starting_velocity,
29112912
new_value);
29122913
});
29132914
QObject::connect(
29142915
&starting_tempo_editor, &QDoubleSpinBox::valueChanged, this,
2915-
[&undo_stack, &song, &synth, &starting_tempo_editor](double new_value) {
2916-
add_set_double(undo_stack, song, synth, starting_tempo_editor,
2916+
[&undo_stack, &song, &synth, &starting_tempo_editor_ref](double new_value) {
2917+
add_set_double(undo_stack, song, synth, starting_tempo_editor_ref,
29172918
starting_tempo_id, song.starting_tempo, new_value);
29182919
});
29192920

@@ -3026,19 +3027,19 @@ struct IntervalRow : public QWidget {
30263027
row_layout.addWidget(&text);
30273028
row_layout.addWidget(&plus_button);
30283029

3029-
auto &switch_column = this->switch_column;
3030-
auto &undo_stack = this->undo_stack;
3031-
const auto &interval = this->interval;
3030+
auto &switch_column_ref = this->switch_column;
3031+
auto &undo_stack_ref = this->undo_stack;
3032+
const auto &interval_ref = this->interval;
30323033

30333034
QObject::connect(&minus_button, &QPushButton::released, this,
3034-
[&undo_stack, &switch_column, &interval]() {
3035-
update_interval(undo_stack, switch_column,
3036-
Interval() / interval);
3035+
[&undo_stack_ref, &switch_column_ref, &interval_ref]() {
3036+
update_interval(undo_stack_ref, switch_column_ref,
3037+
Interval() / interval_ref);
30373038
});
30383039

30393040
QObject::connect(&plus_button, &QPushButton::released, this,
3040-
[&undo_stack, &switch_column, &interval]() {
3041-
update_interval(undo_stack, switch_column, interval);
3041+
[&undo_stack_ref, &switch_column_ref, &interval_ref]() {
3042+
update_interval(undo_stack_ref, switch_column_ref, interval_ref);
30423043
});
30433044
}
30443045
};
@@ -3337,7 +3338,6 @@ static void add_delete_cells(SongWidget &song_widget) {
33373338
void save_as_file(SongWidget &song_widget, const QString &filename) {
33383339
Q_ASSERT(filename.isValidUtf16());
33393340
const auto &song = song_widget.song;
3340-
std::ofstream file_io(filename.toStdString().c_str());
33413341

33423342
auto &document = make_tree();
33433343
auto &song_node = make_root(document, "song");
@@ -3847,12 +3847,12 @@ void import_musicxml(SongWidget &song_widget, const QString &filename) {
38473847
auto *pitch_field_pointer = xmlFirstElementChild(&note_field);
38483848
while (pitch_field_pointer != nullptr) {
38493849
auto &pitch_field = get_reference(pitch_field_pointer);
3850-
const auto &name = get_xml_name(pitch_field);
3851-
if (name == "step") {
3850+
const auto &pitch_field_name = get_xml_name(pitch_field);
3851+
if (pitch_field_name == "step") {
38523852
midi_degree = note_to_midi[get_content(pitch_field)];
3853-
} else if (name == "octave") {
3853+
} else if (pitch_field_name == "octave") {
38543854
octave_number = to_xml_int(pitch_field);
3855-
} else if (name == "alter") {
3855+
} else if (pitch_field_name == "alter") {
38563856
alter = to_xml_int(pitch_field);
38573857
}
38583858
pitch_field_pointer =
@@ -4017,7 +4017,7 @@ struct FileMenu : public QMenu {
40174017
QAction export_action = QAction(FileMenu::tr("&Export recording"));
40184018

40194019
explicit FileMenu(SongWidget &song_widget) : QMenu(FileMenu::tr("&File")) {
4020-
auto &save_action = this->save_action;
4020+
auto &save_action_ref = this->save_action;
40214021
add_menu_action(*this, open_action, QKeySequence::Open);
40224022
add_menu_action(*this, import_action, QKeySequence::StandardKey(), true);
40234023
addSeparator();
@@ -4026,8 +4026,8 @@ struct FileMenu : public QMenu {
40264026
add_menu_action(*this, export_action);
40274027

40284028
QObject::connect(&song_widget.undo_stack, &QUndoStack::cleanChanged, this,
4029-
[&save_action, &song_widget]() {
4030-
save_action.setEnabled(
4029+
[&save_action_ref, &song_widget]() {
4030+
save_action_ref.setEnabled(
40314031
!song_widget.undo_stack.isClean() &&
40324032
!song_widget.current_file.isEmpty());
40334033
});
@@ -4562,8 +4562,8 @@ static void connect_selection_model(SongMenuBar &song_menu_bar,
45624562
SongEditor::SongEditor()
45634563
: song_widget(*(new SongWidget)),
45644564
song_menu_bar(*(new SongMenuBar(song_widget))) {
4565-
auto &song_menu_bar = this->song_menu_bar;
4566-
auto &song_widget = this->song_widget;
4565+
auto &song_menu_bar_ref = this->song_menu_bar;
4566+
auto &song_widget_ref = this->song_widget;
45674567

45684568
auto &switch_column = song_widget.switch_column;
45694569
auto &undo_stack = song_widget.undo_stack;
@@ -4587,36 +4587,36 @@ SongEditor::SongEditor()
45874587
switch_column.unpitched_notes_table);
45884588

45894589
QObject::connect(&song_menu_bar.view_menu.back_to_chords_action,
4590-
&QAction::triggered, this, [&song_menu_bar, &song_widget]() {
4591-
add_replace_table(song_menu_bar, song_widget, chord_type,
4590+
&QAction::triggered, this, [&song_menu_bar_ref, &song_widget_ref]() {
4591+
add_replace_table(song_menu_bar_ref, song_widget_ref, chord_type,
45924592
-1);
45934593
});
45944594

45954595
QObject::connect(
45964596
&switch_column.chords_table, &QAbstractItemView::doubleClicked, this,
4597-
[&song_menu_bar, &song_widget](const QModelIndex &index) {
4597+
[&song_menu_bar_ref, &song_widget_ref](const QModelIndex &index) {
45984598
const auto column = index.column();
45994599
const auto is_pitched = column == chord_pitched_notes_column;
46004600
if (is_pitched || (column == chord_unpitched_notes_column)) {
46014601
add_replace_table(
4602-
song_menu_bar, song_widget,
4602+
song_menu_bar_ref, song_widget_ref,
46034603
(is_pitched ? pitched_note_type : unpitched_note_type),
46044604
index.row());
46054605
}
46064606
});
46074607

46084608
QObject::connect(&song_menu_bar.view_menu.previous_chord_action,
4609-
&QAction::triggered, this, [&song_menu_bar, &song_widget]() {
4610-
const auto &switch_column = song_widget.switch_column;
4611-
add_replace_table(song_menu_bar, song_widget,
4609+
&QAction::triggered, this, [&song_menu_bar_ref, &song_widget_ref]() {
4610+
const auto &switch_column = song_widget_ref.switch_column;
4611+
add_replace_table(song_menu_bar_ref, song_widget_ref,
46124612
switch_column.current_row_type,
46134613
get_parent_chord_number(switch_column) -
46144614
1);
46154615
});
46164616
QObject::connect(&song_menu_bar.view_menu.next_chord_action,
4617-
&QAction::triggered, this, [&song_menu_bar, &song_widget]() {
4618-
const auto &switch_column = song_widget.switch_column;
4619-
add_replace_table(song_menu_bar, song_widget,
4617+
&QAction::triggered, this, [&song_menu_bar_ref, &song_widget_ref]() {
4618+
const auto &switch_column = song_widget_ref.switch_column;
4619+
add_replace_table(song_menu_bar_ref, song_widget_ref,
46204620
switch_column.current_row_type,
46214621
get_parent_chord_number(switch_column) +
46224622
1);

tests/test.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ static void test_model(Tester &tester, SongEditor &song_editor,
254254
const auto editable_flags = uneditable_flags | Qt::ItemIsEditable;
255255

256256
for (const auto &row : flag_rows) {
257-
const auto uneditable_flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
258257
QCOMPARE(model.index(0, row.column_number).flags(),
259258
row.is_editable ? editable_flags : uneditable_flags);
260259
}
@@ -865,15 +864,19 @@ void Tester::run_tests() {
865864
QCOMPARE(get_current_file(song_widget), file_name);
866865

867866
QVERIFY(temp_json_file.open());
868-
const auto written = QString(temp_json_file.readAll());
867+
QString written(temp_json_file.readAll());
869868
temp_json_file.close();
870869

870+
written.replace("\r\n", "\n");
871+
871872
QFile test_song_qfile(test_song_file);
872873

873874
QVERIFY(test_song_qfile.open(QIODevice::ReadOnly));
874-
const auto original = QString(test_song_qfile.readAll());
875+
QString original(test_song_qfile.readAll());
875876
test_song_qfile.close();
876877

878+
original.replace("\r\n", "\n");
879+
877880
QCOMPARE(original, written);
878881
trigger_save(song_menu_bar);
879882

0 commit comments

Comments
 (0)