Skip to content
Snippets Groups Projects
Unverified Commit 1fc9a1c6 authored by Erwin Ried's avatar Erwin Ried Committed by GitHub
Browse files

Merge pull request #120 from eried/WAV-viewer-bug-when-wav-file-format-is-wrong

Update ui_view_wav.cpp
parents 4b02a1c4 b49ad91d
No related branches found
No related tags found
No related merge requests found
...@@ -81,15 +81,6 @@ void ViewWavView::load_wav(std::filesystem::path file_path) { ...@@ -81,15 +81,6 @@ void ViewWavView::load_wav(std::filesystem::path file_path) {
int16_t sample; int16_t sample;
uint32_t average; uint32_t average;
if (!wav_reader->open(file_path)) {
nav_.display_modal("Error", "Couldn't open file.", INFO, nullptr);
return;
}
if ((wav_reader->channels() != 1) || (wav_reader->bits_per_sample() != 16)) {
nav_.display_modal("Error", "Wrong format.\nWav viewer only accepts\n16-bit mono files.", INFO, nullptr);
return;
}
text_filename.set(file_path.filename().string()); text_filename.set(file_path.filename().string());
auto ms_duration = wav_reader->ms_duration(); auto ms_duration = wav_reader->ms_duration();
...@@ -148,10 +139,18 @@ ViewWavView::ViewWavView( ...@@ -148,10 +139,18 @@ ViewWavView::ViewWavView(
&field_cursor_b, &field_cursor_b,
&text_delta &text_delta
}); });
reset_controls();
button_open.on_select = [this, &nav](Button&) { button_open.on_select = [this, &nav](Button&) {
auto open_view = nav.push<FileLoadView>(".WAV"); auto open_view = nav.push<FileLoadView>(".WAV");
open_view->on_changed = [this](std::filesystem::path file_path) { open_view->on_changed = [this](std::filesystem::path file_path) {
if (!wav_reader->open(file_path)) {
nav_.display_modal("Error", "Couldn't open file.", INFO, nullptr);
return;
}
if ((wav_reader->channels() != 1) || (wav_reader->bits_per_sample() != 16)) {
nav_.display_modal("Error", "Wrong format.\nWav viewer only accepts\n16-bit mono files.", INFO, nullptr);
return;
}
load_wav(file_path); load_wav(file_path);
field_pos_seconds.focus(); field_pos_seconds.focus();
}; };
...@@ -176,7 +175,6 @@ ViewWavView::ViewWavView( ...@@ -176,7 +175,6 @@ ViewWavView::ViewWavView(
refresh_measurements(); refresh_measurements();
}; };
reset_controls();
} }
void ViewWavView::focus() { void ViewWavView::focus() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment