diff options
author | André Nusser <andre.nusser@googlemail.com> | 2017-05-05 23:54:29 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2017-05-06 20:26:40 +0200 |
commit | 17c4551a0a02df27cb907678a0509c1a63f6256c (patch) | |
tree | 5eed9407be2f20dd823521ebe8726139ec187a75 | |
parent | 286cddccfd9d69f4bc567fc9f00898f06315cd30 (diff) |
Introduce the new resampling frame.
-rw-r--r-- | plugin/Makefile.mingw32.in | 1 | ||||
-rw-r--r-- | plugingui/Makefile.am | 1 | ||||
-rw-r--r-- | plugingui/maintab.cc | 17 | ||||
-rw-r--r-- | plugingui/maintab.h | 4 | ||||
-rw-r--r-- | plugingui/resamplingframecontent.cc | 92 | ||||
-rw-r--r-- | plugingui/resamplingframecontent.h | 66 | ||||
-rw-r--r-- | plugingui/statusframecontent.cc | 42 | ||||
-rw-r--r-- | plugingui/statusframecontent.h | 8 | ||||
-rw-r--r-- | src/drumkitloader.cc | 2 | ||||
-rw-r--r-- | src/settings.h | 10 |
10 files changed, 187 insertions, 56 deletions
diff --git a/plugin/Makefile.mingw32.in b/plugin/Makefile.mingw32.in index 6ccfe48..77f43e1 100644 --- a/plugin/Makefile.mingw32.in +++ b/plugin/Makefile.mingw32.in @@ -79,6 +79,7 @@ GUI_SRC = \ @top_srcdir@/plugingui/pluginconfig.cc \ @top_srcdir@/plugingui/powerbutton.cc \ @top_srcdir@/plugingui/progressbar.cc \ + @top_srcdir@/plugingui/resamplingframecontent.cc \ @top_srcdir@/plugingui/resource.cc \ @top_srcdir@/plugingui/resource_data.cc \ @top_srcdir@/plugingui/scrollbar.cc \ diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index a7ee485..a9da1db 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -79,6 +79,7 @@ nodist_libdggui_la_SOURCES = \ pluginconfig.cc \ powerbutton.cc \ progressbar.cc \ + resamplingframecontent.cc \ resource.cc \ resource_data.cc \ scrollbar.cc \ diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index 3458a72..503a0a1 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -38,6 +38,7 @@ MainTab::MainTab(Widget* parent, , statusframe_content{this, settings_notifier} , humanizerframe_content{this, settings, settings_notifier} , diskstreamingframe_content{this, settings, settings_notifier} + , resamplingframe_content{this, settings, settings_notifier} , settings(settings) , settings_notifier(settings_notifier) { @@ -48,36 +49,47 @@ MainTab::MainTab(Widget* parent, layout.addItem(&status_frame); layout.addItem(&humanizer_frame); layout.addItem(&diskstreaming_frame); + layout.addItem(&resampling_frame); auto h1 = 20; auto h2 = 22; auto h3 = 13; auto h4 = 11; + auto h5 = 14; auto drumkit_range = GridLayout::GridRange{0, 1, 0, h1}; auto status_range = GridLayout::GridRange{0, 1, h1, h1 + h2}; auto humanizer_range = GridLayout::GridRange{1, 2, 0, h3}; auto diskstreaming_range = GridLayout::GridRange{1, 2, h3, h3 + h4}; + auto resampling_range = GridLayout::GridRange{1, 2, h3 + h4, h3 + h4 + h5}; layout.setPosition(&drumkit_frame, drumkit_range); layout.setPosition(&status_frame, status_range); layout.setPosition(&humanizer_frame, humanizer_range); layout.setPosition(&diskstreaming_frame, diskstreaming_range); + layout.setPosition(&resampling_frame, resampling_range); drumkit_frame.setTitle("Drumkit"); status_frame.setTitle("Status"); humanizer_frame.setTitle("Humanizer"); diskstreaming_frame.setTitle("Disk streaming"); + resampling_frame.setTitle("Resampling"); drumkit_frame.setContent(&drumkitframe_content); status_frame.setContent(&statusframe_content); humanizer_frame.setContent(&humanizerframe_content); diskstreaming_frame.setContent(&diskstreamingframe_content); + resampling_frame.setContent(&resamplingframe_content); humanizer_frame.setOnSwitch(settings.enable_velocity_modifier); + resampling_frame.setOnSwitch(settings.enable_resampling); CONNECT(this, settings_notifier.enable_velocity_modifier, &humanizer_frame, &FrameWidget::setOnSwitch); + CONNECT(this, settings_notifier.enable_resampling, + &resampling_frame, &FrameWidget::setOnSwitch); CONNECT(&humanizer_frame, onSwitchChangeNotifier, this, &MainTab::humanizerOnChange); + CONNECT(&resampling_frame, onSwitchChangeNotifier, + this, &MainTab::resamplingOnChange); } void MainTab::resize(std::size_t width, std::size_t height) @@ -95,4 +107,9 @@ void MainTab::humanizerOnChange(bool on) settings.enable_velocity_modifier.store(on); } +void MainTab::resamplingOnChange(bool on) +{ + settings.enable_resampling.store(on); +} + } // GUI:: diff --git a/plugingui/maintab.h b/plugingui/maintab.h index 62b3f82..ab7e760 100644 --- a/plugingui/maintab.h +++ b/plugingui/maintab.h @@ -33,6 +33,7 @@ #include "statusframecontent.h" #include "humanizerframecontent.h" #include "diskstreamingframecontent.h" +#include "resamplingframecontent.h" struct Settings; class SettingsNotifier; @@ -55,6 +56,7 @@ public: private: void humanizerOnChange(bool on); + void resamplingOnChange(bool on); Image logo{":resources/logo.png"}; @@ -64,11 +66,13 @@ private: FrameWidget status_frame{this, false}; FrameWidget humanizer_frame{this, true}; FrameWidget diskstreaming_frame{this, false}; + FrameWidget resampling_frame{this, true}; DrumkitframeContent drumkitframe_content; StatusframeContent statusframe_content; HumanizerframeContent humanizerframe_content; DiskstreamingframeContent diskstreamingframe_content; + ResamplingframeContent resamplingframe_content; Settings& settings; SettingsNotifier& settings_notifier; diff --git a/plugingui/resamplingframecontent.cc b/plugingui/resamplingframecontent.cc new file mode 100644 index 0000000..1f752d3 --- /dev/null +++ b/plugingui/resamplingframecontent.cc @@ -0,0 +1,92 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + * resamplingframecontent.cc + * + * Fri May 5 23:43:28 CEST 2017 + * Copyright 2017 André Nusser + * andre.nusser@googlemail.com + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DrumGizmo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "resamplingframecontent.h" + +#include <settings.h> + +namespace GUI +{ + +ResamplingframeContent::ResamplingframeContent( + Widget* parent, Settings& settings, SettingsNotifier& settings_notifier) + : Widget(parent) + , settings(settings) + , settings_notifier(settings_notifier) +{ + CONNECT(this, settings_notifier.drumkit_samplerate, + this, &ResamplingframeContent::updateDrumkitSamplerate); + CONNECT(this, settings_notifier.samplerate, + this, &ResamplingframeContent::updateSessionSamplerate); + CONNECT(this, settings_notifier.resamplig_recommended, + this, &ResamplingframeContent::updateResamplingRecommended); + + text_field.move(0, 0); + text_field.setReadOnly(true); + + updateContent(); + text_field.show(); +} + +void ResamplingframeContent::resize(std::size_t width, std::size_t height) +{ + Widget::resize(width, height); + text_field.resize(width, height); +} + +void ResamplingframeContent::updateContent() +{ + text_field.setText( + "Session samplerate: " + session_samplerate + "\n" + "Drumkit samplerate: " + drumkit_samplerate + "\n" + "Resampling recommended: " + resamplig_recommended + "\n" + ); +} + +void ResamplingframeContent::updateDrumkitSamplerate(std::size_t drumkit_samplerate) +{ + this->drumkit_samplerate = drumkit_samplerate == 0 + ? "" + : std::to_string(drumkit_samplerate); + + updateContent(); +} + +void ResamplingframeContent::updateSessionSamplerate(double samplerate) +{ + this->session_samplerate = std::to_string((std::size_t)samplerate); + + updateContent(); +} + +void ResamplingframeContent::updateResamplingRecommended(bool resamplig_recommended) +{ + this->resamplig_recommended = resamplig_recommended ? "Yes" : "No"; + + updateContent(); +} + +} // GUI:: diff --git a/plugingui/resamplingframecontent.h b/plugingui/resamplingframecontent.h new file mode 100644 index 0000000..e98e09b --- /dev/null +++ b/plugingui/resamplingframecontent.h @@ -0,0 +1,66 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + * resamplingframecontent.h + * + * Fri May 5 23:43:28 CEST 2017 + * Copyright 2017 André Nusser + * andre.nusser@googlemail.com + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DrumGizmo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#pragma once + +#include "widget.h" +#include "textedit.h" + +struct Settings; +class SettingsNotifier; + +namespace GUI +{ + +class ResamplingframeContent + : public Widget +{ +public: + ResamplingframeContent(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier); + + // From Widget + virtual void resize(std::size_t width, std::size_t height) override; + + void updateContent(); + + void updateDrumkitSamplerate(std::size_t drumkit_samplerate); + void updateSessionSamplerate(double samplerate); + void updateResamplingRecommended(bool resamplig_recommended); + +private: + TextEdit text_field{this}; + + Settings& settings; + SettingsNotifier& settings_notifier; + + std::string drumkit_samplerate; + std::string session_samplerate; + std::string resamplig_recommended; +}; + +} // GUI:: diff --git a/plugingui/statusframecontent.cc b/plugingui/statusframecontent.cc index e160da0..34903e8 100644 --- a/plugingui/statusframecontent.cc +++ b/plugingui/statusframecontent.cc @@ -41,18 +41,10 @@ StatusframeContent::StatusframeContent( this, &StatusframeContent::updateDrumkitDescription); CONNECT(this, settings_notifier.drumkit_version, this, &StatusframeContent::updateDrumkitVersion); - CONNECT(this, settings_notifier.drumkit_samplerate, - this, &StatusframeContent::updateDrumkitSamplerate); CONNECT(this, settings_notifier.midimap_load_status, this, &StatusframeContent::updateMidimapLoadStatus); - CONNECT(this, settings_notifier.samplerate, - this, &StatusframeContent::updateSamplerate); CONNECT(this, settings_notifier.buffer_size, this, &StatusframeContent::updateBufferSize); - CONNECT(this, settings_notifier.enable_resampling, - this, &StatusframeContent::updateResamplingEnabled); - CONNECT(this, settings_notifier.resampling_active, - this, &StatusframeContent::updateResamplingActive); CONNECT(this, settings_notifier.number_of_underruns, this, &StatusframeContent::updateNumberOfUnderruns); @@ -77,11 +69,7 @@ void StatusframeContent::updateContent() "Drumkit name: " + drumkit_name + "\n" "Drumkit description: " + drumkit_description + "\n" // "Drumkit version: " + drumkit_version + "\n" - "Drumkit samplerate: " + drumkit_samplerate + "\n" - "Session samplerate: " + samplerate + "\n" "Session buffer size: " + buffer_size + "\n" - // "Resampling enabled: " + resampling_enabled + "\n" - "Resampling active: " + resampling_active + "\n" "Number of underruns: " + number_of_underruns + "\n" ); } @@ -128,15 +116,6 @@ void StatusframeContent::updateDrumkitVersion(std::string const& drumkit_version updateContent(); } -void StatusframeContent::updateDrumkitSamplerate(std::size_t drumkit_samplerate) -{ - this->drumkit_samplerate = drumkit_samplerate == 0 - ? "" - : std::to_string(drumkit_samplerate); - - updateContent(); -} - void StatusframeContent::updateMidimapLoadStatus(LoadStatus load_status) { switch(load_status) @@ -158,13 +137,6 @@ void StatusframeContent::updateMidimapLoadStatus(LoadStatus load_status) updateContent(); } -void StatusframeContent::updateSamplerate(double samplerate) -{ - this->samplerate = std::to_string((std::size_t)samplerate); - - updateContent(); -} - void StatusframeContent::updateBufferSize(std::size_t buffer_size) { this->buffer_size = std::to_string(buffer_size); @@ -172,20 +144,6 @@ void StatusframeContent::updateBufferSize(std::size_t buffer_size) updateContent(); } -void StatusframeContent::updateResamplingEnabled(bool enable_resampling) -{ - this->resampling_enabled = enable_resampling ? "Yes" : "No"; - - updateContent(); -} - -void StatusframeContent::updateResamplingActive(bool resampling_active) -{ - this->resampling_active = resampling_active ? "Yes" : "No"; - - updateContent(); -} - void StatusframeContent::updateNumberOfUnderruns(std::size_t number_of_underruns) { this->number_of_underruns = std::to_string(number_of_underruns); diff --git a/plugingui/statusframecontent.h b/plugingui/statusframecontent.h index c5fb8c4..4ca4f63 100644 --- a/plugingui/statusframecontent.h +++ b/plugingui/statusframecontent.h @@ -49,12 +49,8 @@ public: void updateDrumkitName(std::string const& drumkit_name); void updateDrumkitDescription(std::string const& drumkit_description); void updateDrumkitVersion(std::string const& drumkit_version); - void updateDrumkitSamplerate(std::size_t drumkit_samplerate); void updateMidimapLoadStatus(LoadStatus load_status); - void updateSamplerate(double samplerate); void updateBufferSize(std::size_t buffer_size); - void updateResamplingEnabled(bool enable_resampling); - void updateResamplingActive(bool resampling_active); void updateNumberOfUnderruns(std::size_t number_of_underruns); private: @@ -66,12 +62,8 @@ private: std::string drumkit_name; std::string drumkit_description; std::string drumkit_version; - std::string drumkit_samplerate; std::string midimap_load_status; - std::string samplerate; std::string buffer_size; - std::string resampling_enabled; - std::string resampling_active; std::string number_of_underruns; }; diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc index eed5a33..a1a5bdf 100644 --- a/src/drumkitloader.cc +++ b/src/drumkitloader.cc @@ -136,7 +136,7 @@ bool DrumKitLoader::loadkit(const std::string& file) #ifdef WITH_RESAMPLER resamplers.setup(kit.getSamplerate(), settings.samplerate.load()); #endif/*WITH_RESAMPLER*/ - settings.resampling_active.store(resamplers.isActive()); + settings.resamplig_recommended.store(resamplers.isActive()); DEBUG(loadkit, "loadkit: Success\n"); diff --git a/src/settings.h b/src/settings.h index 76662c2..6d094ea 100644 --- a/src/settings.h +++ b/src/settings.h @@ -81,7 +81,7 @@ struct Settings Atomic<std::size_t> buffer_size{1024}; // Only used to show in the UI. Atomic<bool> enable_resampling{true}; - Atomic<bool> resampling_active{false}; + Atomic<bool> resamplig_recommended{false}; Atomic<std::size_t> number_of_files{0}; Atomic<std::size_t> number_of_files_loaded{0}; @@ -118,7 +118,7 @@ struct SettingsGetter SettingRef<std::size_t> buffer_size; SettingRef<bool> enable_resampling; - SettingRef<bool> resampling_active; + SettingRef<bool> resamplig_recommended; SettingRef<std::size_t> number_of_files; SettingRef<std::size_t> number_of_files_loaded; @@ -146,7 +146,7 @@ struct SettingsGetter , samplerate{settings.samplerate} , buffer_size(settings.buffer_size) , enable_resampling{settings.enable_resampling} - , resampling_active{settings.resampling_active} + , resamplig_recommended{settings.resamplig_recommended} , number_of_files{settings.number_of_files} , number_of_files_loaded{settings.number_of_files_loaded} , current_file{settings.current_file} @@ -185,7 +185,7 @@ public: Notifier<std::size_t> buffer_size; Notifier<bool> enable_resampling; - Notifier<bool> resampling_active; + Notifier<bool> resamplig_recommended; Notifier<std::size_t> number_of_files; Notifier<std::size_t> number_of_files_loaded; @@ -222,7 +222,7 @@ public: EVAL(buffer_size); EVAL(enable_resampling); - EVAL(resampling_active); + EVAL(resamplig_recommended); EVAL(number_of_files); EVAL(number_of_files_loaded); |