diff --git a/CMakeLists.txt b/CMakeLists.txt index 41b68076..6728bb27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,13 +112,15 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # setup compiler flags for debug vs release compiles add_option(-Wall) -if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - add_option(-O3) - add_option(-g) - add_definitions(-DNDEBUG) - add_option(-fomit-frame-pointer) - add_option(-funroll-loops) - add_option(-ffast-math) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + add_option(-g3) +else() + add_option(-O3) + add_option(-g) + add_definitions(-DNDEBUG) + add_option(-fomit-frame-pointer) + add_option(-funroll-loops) + add_option(-ffast-math) endif () if (RTAUDIO_USE_JACK OR RTMIDI_USE_JACK OR GO_USE_JACK) @@ -183,8 +185,6 @@ set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/license.txt) set(CPACK_PACKAGE_CONTACT "osamarin68@gmail.com") set(CPACK_PACKAGE_EXECUTABLES "GrandOrgue" "GrandOrgue") -set(CPACK_STRIP_FILES ON) - set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" "/build-for/") # components @@ -251,6 +251,12 @@ elseif (WIN32) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CPACK_STRIP_FILES OFF) + else() + set(CPACK_STRIP_FILES ON) + endif() + set(CPACK_SYSTEM_NAME "linux") set(CPACK_GENERATOR TGZ RPM DEB) diff --git a/build-scripts/for-osx/build-on-osx.sh b/build-scripts/for-osx/build-on-osx.sh index a2aaffff..d2366e3c 100755 --- a/build-scripts/for-osx/build-on-osx.sh +++ b/build-scripts/for-osx/build-on-osx.sh @@ -24,7 +24,7 @@ rm -rf * export LANG=C OS_PRMS="-DDOCBOOK_DIR=/usr/local/opt/docbook-xsl/docbook-xsl" -GO_PRMS="-DCMAKE_BUILD_TYPE=Release $CMAKE_VERSION_PRMS" +GO_PRMS="-DCMAKE_BUILD_TYPE=Debug $CMAKE_VERSION_PRMS" cmake -G "Unix Makefiles" $OS_PRMS $GO_PRMS . $SRC_DIR make -k $PARALLEL_PRMS VERBOSE=1 package diff --git a/src/core/GOrgueBitmap.cpp b/src/core/GOrgueBitmap.cpp index 989915bb..55db88a1 100644 --- a/src/core/GOrgueBitmap.cpp +++ b/src/core/GOrgueBitmap.cpp @@ -58,7 +58,8 @@ void GOrgueBitmap::ScaleBMP(wxImage& img, double scale, const wxRect& rect, GOrg dc.DrawBitmap(orig, 0, 0, true); bmp.SetMask(orig.GetMask()); wxImage img_result = bmp.ConvertToImage(); - img_result.InitAlpha(); + if (! img_result.HasAlpha()) + img_result.InitAlpha(); memcpy(img_result.GetAlpha(), img.GetAlpha(), img.GetWidth() * img.GetHeight()); m_bmp = (wxBitmap)img_result.Scale(img.GetWidth() * scale, img.GetHeight() * scale, wxIMAGE_QUALITY_BICUBIC); diff --git a/src/grandorgue/GOGUIHW1Background.cpp b/src/grandorgue/GOGUIHW1Background.cpp index d135d65a..5ceeb3c4 100644 --- a/src/grandorgue/GOGUIHW1Background.cpp +++ b/src/grandorgue/GOGUIHW1Background.cpp @@ -37,18 +37,25 @@ void GOGUIHW1Background::Init(GOrgueConfigReader& cfg, wxString group) GOGUIControl::Init(cfg, group); } +bool is_rect_valid(wxRect& rect) { + return rect.width > 0 && rect.height > 0; +} + void GOGUIHW1Background::Layout() { m_Images.clear(); wxRect rect; rect = wxRect(0, 0, m_layout->GetCenterX(), m_metrics->GetScreenHeight()); - m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopBackgroundImageNum()))); + if (is_rect_valid(rect)) + m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopBackgroundImageNum()))); rect = wxRect(m_layout->GetCenterX() + m_layout->GetCenterWidth(), 0, m_metrics->GetScreenWidth() - (m_layout->GetCenterX() + m_layout->GetCenterWidth()), m_metrics->GetScreenHeight()); - m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopBackgroundImageNum()))); + if (is_rect_valid(rect)) + m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopBackgroundImageNum()))); rect = wxRect(m_layout->GetCenterX(), 0, m_layout->GetCenterWidth(), m_metrics->GetScreenHeight()); - m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetConsoleBackgroundImageNum()))); + if (is_rect_valid(rect)) + m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetConsoleBackgroundImageNum()))); if (m_metrics->HasPairDrawstopCols()) { @@ -56,23 +63,27 @@ void GOGUIHW1Background::Layout() { rect = wxRect(i * (2 * m_metrics->GetDrawstopWidth() + 18) + m_layout->GetJambLeftX() - 5, m_layout->GetJambLeftRightY(), 2 * m_metrics->GetDrawstopWidth() + 10, m_layout->GetJambLeftRightHeight()); - m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopInsetBackgroundImageNum()))); + if (is_rect_valid(rect)) + m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopInsetBackgroundImageNum()))); rect = wxRect(i * (2 * m_metrics->GetDrawstopWidth() + 18) + m_layout->GetJambRightX() - 5, m_layout->GetJambLeftRightY(), 2 * m_metrics->GetDrawstopWidth() + 10, m_layout->GetJambLeftRightHeight()); - m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopInsetBackgroundImageNum()))); + if (is_rect_valid(rect)) + m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopInsetBackgroundImageNum()))); } } if (m_metrics->HasTrimAboveExtraRows()) { rect = wxRect(m_layout->GetCenterX(), m_layout->GetCenterY(), m_layout->GetCenterWidth(), 8); - m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetKeyVertBackgroundImageNum()))); + if (is_rect_valid(rect)) + m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetKeyVertBackgroundImageNum()))); } if (m_layout->GetJambTopHeight() + m_layout->GetPistonTopHeight()) { rect = wxRect(m_layout->GetCenterX(), m_layout->GetJambTopY(), m_layout->GetCenterWidth(), m_layout->GetJambTopHeight() + m_layout->GetPistonTopHeight()); - m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetKeyHorizBackgroundImageNum()))); + if (is_rect_valid(rect)) + m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetKeyHorizBackgroundImageNum()))); } } diff --git a/src/grandorgue/GOSoundEngine.cpp b/src/grandorgue/GOSoundEngine.cpp index 1ad7a82b..9e8c4b34 100644 --- a/src/grandorgue/GOSoundEngine.cpp +++ b/src/grandorgue/GOSoundEngine.cpp @@ -57,7 +57,8 @@ GOSoundEngine::GOSoundEngine() : m_AudioGroups(), m_AudioOutputs(), m_AudioRecorder(NULL), - m_TouchProcessor() + m_TouchProcessor(), + m_HasBeenSetup(false) { memset(&m_ResamplerCoefs, 0, sizeof(m_ResamplerCoefs)); m_SamplerPool.SetUsageLimit(2048); @@ -74,10 +75,16 @@ GOSoundEngine::~GOSoundEngine() void GOSoundEngine::Reset() { + if (m_HasBeenSetup) + { for (unsigned i = 0; i < m_Windchests.size(); i++) m_Windchests[i]->Init(m_Tremulants); + } - m_Scheduler.Clear(); + m_Scheduler.Clear(); + + if (m_HasBeenSetup) + { for (unsigned i = 0; i < m_Tremulants.size(); i++) m_Scheduler.Add(m_Tremulants[i]); for (unsigned i = 0; i < m_Windchests.size(); i++) @@ -90,7 +97,7 @@ void GOSoundEngine::Reset() m_Scheduler.Add(m_ReleaseProcessor); if (m_TouchProcessor) m_Scheduler.Add(m_TouchProcessor.get()); - + } m_UsedPolyphony = 0; m_SamplerPool.ReturnAll(); @@ -237,6 +244,7 @@ void GOSoundEngine::StartSampler(GO_SAMPLER* sampler, int sampler_group_id, unsi void GOSoundEngine::ClearSetup() { + m_HasBeenSetup = false; m_Scheduler.Clear(); m_Windchests.clear(); m_Tremulants.clear(); @@ -258,6 +266,7 @@ void GOSoundEngine::Setup(GrandOrgueFile* organ_file, unsigned release_count) for(unsigned i = 0; i < organ_file->GetWindchestGroupCount(); i++) m_Windchests.push_back(new GOSoundWindchestWorkItem(*this, organ_file->GetWindchest(i))); m_TouchProcessor = std::unique_ptr(new GOSoundTouchWorkItem(organ_file->GetMemoryPool())); + m_HasBeenSetup = true; Reset(); } diff --git a/src/grandorgue/GOSoundEngine.h b/src/grandorgue/GOSoundEngine.h index 0ed98398..3f24be46 100644 --- a/src/grandorgue/GOSoundEngine.h +++ b/src/grandorgue/GOSoundEngine.h @@ -79,6 +79,8 @@ class GOSoundEngine GOSoundScheduler m_Scheduler; struct resampler_coefs_s m_ResamplerCoefs; + + bool m_HasBeenSetup; /* samplerGroupID: -1 .. -n Tremulants diff --git a/src/grandorgue/GOrgueProgressDialog.cpp b/src/grandorgue/GOrgueProgressDialog.cpp index 071e8f02..19ec082b 100644 --- a/src/grandorgue/GOrgueProgressDialog.cpp +++ b/src/grandorgue/GOrgueProgressDialog.cpp @@ -24,6 +24,8 @@ #include #include +#define DLG_MAX_VALUE 0x10000 + GOrgueProgressDialog::GOrgueProgressDialog() : m_dlg(NULL), m_last(0), @@ -43,7 +45,7 @@ void GOrgueProgressDialog::Setup(long max, const wxString& title, const wxString { if (m_dlg) m_dlg->Destroy(); - m_dlg = new wxProgressDialog(title, msg, 0x10000, NULL, wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME); + m_dlg = new wxProgressDialog(title, msg, DLG_MAX_VALUE, NULL, wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME); m_last = 0; m_const = 0; m_value = 0; @@ -70,7 +72,10 @@ bool GOrgueProgressDialog::Update(unsigned value, const wxString& msg) if (m_last == wxGetUTCTime()) return true; m_last = wxGetUTCTime(); - if (!m_dlg->Update(0xffff * (m_value + m_const) / m_max, msg)) + + int newValue = (DLG_MAX_VALUE - 1) * (m_value + m_const) / m_max; + + if (newValue <= DLG_MAX_VALUE && !m_dlg->Update(newValue, msg)) return false; return true; } diff --git a/src/grandorgue/GOrgueSound.cpp b/src/grandorgue/GOrgueSound.cpp index 2b425cbb..25406589 100644 --- a/src/grandorgue/GOrgueSound.cpp +++ b/src/grandorgue/GOrgueSound.cpp @@ -230,9 +230,11 @@ void GOrgueSound::CloseSound() { if (m_AudioOutputs[i].port) { - m_AudioOutputs[i].port->Close(); - delete m_AudioOutputs[i].port; - m_AudioOutputs[i].port = 0; + GOrgueSoundPort* const port = m_AudioOutputs[i].port; + + m_AudioOutputs[i].port = NULL; + port->Close(); + delete port; } } diff --git a/src/grandorgue/GOrgueSoundRtPort.cpp b/src/grandorgue/GOrgueSoundRtPort.cpp index 1f2f20f7..d8e47bbb 100644 --- a/src/grandorgue/GOrgueSoundRtPort.cpp +++ b/src/grandorgue/GOrgueSoundRtPort.cpp @@ -47,8 +47,12 @@ GOrgueSoundRtPort::~GOrgueSoundRtPort() Close(); try { - if (m_port) - delete m_port; + if (m_port) { + const RtAudio* port = m_port; + + m_port = NULL; + delete port; + } } catch (RtAudioError &e) { diff --git a/src/grandorgue/GrandOrgueFrame.cpp b/src/grandorgue/GrandOrgueFrame.cpp index 801e7294..3f145581 100644 --- a/src/grandorgue/GrandOrgueFrame.cpp +++ b/src/grandorgue/GrandOrgueFrame.cpp @@ -275,11 +275,15 @@ GOrgueFrame::GOrgueFrame(wxFrame *frame, wxWindowID id, const wxString& title, c GOrgueFrame::~GOrgueFrame() { - if (m_doc) - delete m_doc; + if (m_doc) { + delete m_doc; + m_doc = NULL; + } m_listener.SetCallback(NULL); - if (m_Help) - delete m_Help; + if (m_Help) { + delete m_Help; + m_Help = NULL; + } } void GOrgueFrame::UpdateVolumeControl(unsigned count) diff --git a/src/grandorgue/SettingsAudioGroup.cpp b/src/grandorgue/SettingsAudioGroup.cpp index 3883c366..23666b03 100644 --- a/src/grandorgue/SettingsAudioGroup.cpp +++ b/src/grandorgue/SettingsAudioGroup.cpp @@ -53,9 +53,9 @@ SettingsAudioGroup::SettingsAudioGroup(GOrgueSettings& settings, wxWindow* paren m_Del = new wxButton(this, ID_AUDIOGROUP_DEL, _("&Delete")); m_Del->Disable(); - buttonSizer->Add(m_Add, 0, wxALIGN_LEFT | wxALL, 5); - buttonSizer->Add(m_Del, 0, wxALIGN_LEFT | wxALL, 5); - buttonSizer->Add(m_Change, 0, wxALIGN_RIGHT | wxALL, 5); + buttonSizer->Add(m_Add, 0, wxALL, 5); + buttonSizer->Add(m_Del, 0, wxALL, 5); + buttonSizer->Add(m_Change, 0, wxALL, 5); topSizer->Add(buttonSizer, 0, wxALL, 5); std::vector audio_groups = m_Settings.GetAudioGroups(); diff --git a/src/grandorgue/SettingsAudioOutput.cpp b/src/grandorgue/SettingsAudioOutput.cpp index f113a8b4..77b65781 100644 --- a/src/grandorgue/SettingsAudioOutput.cpp +++ b/src/grandorgue/SettingsAudioOutput.cpp @@ -114,11 +114,11 @@ SettingsAudioOutput::SettingsAudioOutput(GOrgueSound& sound, GOAudioGroupCallbac m_Properties = new wxButton(this, ID_OUTPUT_PROPERTIES, _("Properties")); m_Default = new wxButton(this, ID_OUTPUT_DEFAULT, _("Revert to Default")); - buttonSizer->Add(m_Add, 0, wxALIGN_LEFT | wxALL, 5); - buttonSizer->Add(m_Del, 0, wxALIGN_LEFT | wxALL, 5); - buttonSizer->Add(m_Change, 0, wxALIGN_RIGHT | wxALL, 5); - buttonSizer->Add(m_Properties, 0, wxALIGN_RIGHT | wxALL, 5); - buttonSizer->Add(m_Default, 0, wxALIGN_RIGHT | wxALL, 5); + buttonSizer->Add(m_Add, 0, wxALL, 5); + buttonSizer->Add(m_Del, 0, wxALL, 5); + buttonSizer->Add(m_Change, wxALL, 5); + buttonSizer->Add(m_Properties, 0, wxALL, 5); + buttonSizer->Add(m_Default, 0, wxALL, 5); topSizer->Add(buttonSizer, 0, wxALL, 5); m_AudioOutput->AddRoot(_("Audio Output"), -1, -1, new AudioItemData()); diff --git a/src/grandorgue/SettingsDefaults.cpp b/src/grandorgue/SettingsDefaults.cpp index bb523175..002fd22b 100644 --- a/src/grandorgue/SettingsDefaults.cpp +++ b/src/grandorgue/SettingsDefaults.cpp @@ -105,7 +105,7 @@ SettingsDefaults::SettingsDefaults(GOrgueSettings& settings, wxWindow* parent) : m_MidiRecorderPath->SetPath(m_Settings.MidiRecorderPath()); m_MidiPlayerPath->SetPath(m_Settings.MidiPlayerPath()); - topSizer->Add(item0, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5); + topSizer->Add(item0, 1, wxEXPAND | wxALL, 5); topSizer->AddSpacer(5); this->SetSizer(topSizer); topSizer->FitInside(this); diff --git a/src/grandorgue/SettingsMidiDevices.cpp b/src/grandorgue/SettingsMidiDevices.cpp index 250cbf63..cc745921 100644 --- a/src/grandorgue/SettingsMidiDevices.cpp +++ b/src/grandorgue/SettingsMidiDevices.cpp @@ -74,7 +74,7 @@ SettingsMidiDevices::SettingsMidiDevices(GOrgueSound& sound, wxWindow* parent) : m_InOutDevice->Disable(); item4->Add(m_InOutDevice, 0, wxALL, 5); item3->Add(item4, 0, wxALIGN_RIGHT | wxALL, 5); - topSizer->Add(item3, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5); + topSizer->Add(item3, 1, wxEXPAND | wxALL, 5); choices.clear(); std::vector out_state; @@ -94,7 +94,7 @@ SettingsMidiDevices::SettingsMidiDevices(GOrgueSound& sound, wxWindow* parent) : item3->Add(m_OutDevices, 1, wxEXPAND | wxALL, 5); wxBoxSizer* box = new wxBoxSizer(wxHORIZONTAL); item3->Add(box); - box->Add(new wxStaticText(this, wxID_ANY, _("Send MIDI Recorder Output Stream to ")), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + box->Add(new wxStaticText(this, wxID_ANY, _("Send MIDI Recorder Output Stream to ")), 0, wxALIGN_CENTER_VERTICAL); m_RecorderDevice = new wxChoice(this, ID_RECORDERDEVICE); box->Add(m_RecorderDevice, 0); m_RecorderDevice->Append(_("No device")); @@ -107,7 +107,7 @@ SettingsMidiDevices::SettingsMidiDevices(GOrgueSound& sound, wxWindow* parent) : m_RecorderDevice->SetSelection(m_RecorderDevice->GetCount() - 1); } - topSizer->Add(item3, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5); + topSizer->Add(item3, 1, wxEXPAND | wxALL, 5); topSizer->AddSpacer(5); this->SetSizer(topSizer); diff --git a/src/grandorgue/SettingsOption.cpp b/src/grandorgue/SettingsOption.cpp index 3a2c480c..b1589756 100644 --- a/src/grandorgue/SettingsOption.cpp +++ b/src/grandorgue/SettingsOption.cpp @@ -231,7 +231,7 @@ SettingsOption::SettingsOption(GOrgueSettings& settings, wxWindow* parent) : item9->Add(m_ODFCheck = new wxCheckBox(this, ID_ODF_CHECK, _("Perform strict ODF")), 0, wxEXPAND | wxALL, 5); m_ODFCheck->SetValue(m_Settings.ODFCheck()); - topSizer->Add(item0, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5); + topSizer->Add(item0, 1, wxEXPAND | wxALL, 5); topSizer->AddSpacer(5); this->SetScrollRate(5, 5); this->SetSizer(topSizer); diff --git a/src/grandorgue/SettingsOrgan.cpp b/src/grandorgue/SettingsOrgan.cpp index 0293c08e..e2f21004 100644 --- a/src/grandorgue/SettingsOrgan.cpp +++ b/src/grandorgue/SettingsOrgan.cpp @@ -66,7 +66,7 @@ SettingsOrgan::SettingsOrgan(GOrgueSettings& settings, GOrgueMidi& midi, wxWindo buttonSizer->Add(m_Up, 0, wxALIGN_LEFT | wxALL, 5); buttonSizer->Add(m_Top, 0, wxALIGN_LEFT | wxALL, 5); buttonSizer->Add(m_Del, 0, wxALIGN_LEFT | wxALL, 5); - buttonSizer->Add(m_Properties, 0, wxALIGN_RIGHT | wxALL, 5); + buttonSizer->Add(m_Properties, 0, wxALIGN_LEFT | wxALL, 5); topSizer->Add(buttonSizer, 0, wxALL, 5); for(unsigned i = 0; i < m_Settings.GetOrganList().size(); i++)