From cc0f25cd2b9fc5856f16b71a412ce8c17edc39a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Sat, 22 Apr 2017 13:09:42 +0200 Subject: Include new information into the status frame. --- plugingui/statusframecontent.cc | 52 +++++++++++++++++++++++++++++++++++++++++ plugingui/statusframecontent.h | 10 ++++++++ src/drumkit.cc | 5 ++++ src/drumkit.h | 1 + src/drumkitloader.cc | 8 ++++++- src/settings.h | 25 ++++++++++++++++++++ 6 files changed, 100 insertions(+), 1 deletion(-) diff --git a/plugingui/statusframecontent.cc b/plugingui/statusframecontent.cc index 196c0d3..928aeaa 100644 --- a/plugingui/statusframecontent.cc +++ b/plugingui/statusframecontent.cc @@ -35,12 +35,22 @@ StatusframeContent::StatusframeContent( { CONNECT(this, settings_notifier.drumkit_load_status, this, &StatusframeContent::updateDrumkitLoadStatus); + CONNECT(this, settings_notifier.drumkit_name, + this, &StatusframeContent::updateDrumkitName); + CONNECT(this, settings_notifier.drumkit_description, + 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.enable_resampling, this, &StatusframeContent::updateResamplingEnabled); + CONNECT(this, settings_notifier.resampling_active, + this, &StatusframeContent::updateResamplingActive); CONNECT(this, settings_notifier.number_of_underruns, this, &StatusframeContent::updateNumberOfUnderruns); @@ -62,8 +72,13 @@ void StatusframeContent::updateContent() text_field.setText( "Drumkit load status: " + drumkit_load_status + "\n" "Midimap load status: " + midimap_load_status + "\n" + "Drumkit name: " + drumkit_name + "\n" + "Drumkit description: " + drumkit_description + "\n" + "Drumkit version: " + drumkit_version + "\n" + "Drumkit samplerate: " + drumkit_samplerate + "\n" "Samplerate: " + samplerate + "\n" "Resampling enabled: " + resampling_enabled + "\n" + "Resampling active: " + resampling_active + "\n" "Number of underruns: " + number_of_underruns + "\n" ); } @@ -89,6 +104,36 @@ void StatusframeContent::updateDrumkitLoadStatus(LoadStatus load_status) updateContent(); } +void StatusframeContent::updateDrumkitName(std::string const& drumkit_name) +{ + this->drumkit_name = drumkit_name; + + updateContent(); +} + +void StatusframeContent::updateDrumkitDescription(std::string const& drumkit_description) +{ + this->drumkit_description = drumkit_description; + + updateContent(); +} + +void StatusframeContent::updateDrumkitVersion(std::string const& drumkit_version) +{ + this->drumkit_version = 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) @@ -124,6 +169,13 @@ void StatusframeContent::updateResamplingEnabled(bool enable_resampling) updateContent(); } +void StatusframeContent::updateResamplingActive(bool resampling_active) +{ + this->resampling_active = resampling_active ? "yes" : "no"; + + updateContent(); +} + void StatusframeContent::updateNumberOfUnderruns( std::size_t number_of_underruns) { diff --git a/plugingui/statusframecontent.h b/plugingui/statusframecontent.h index 0ca5bfe..20fbfd9 100644 --- a/plugingui/statusframecontent.h +++ b/plugingui/statusframecontent.h @@ -46,9 +46,14 @@ public: void updateContent(); void updateDrumkitLoadStatus(LoadStatus load_status); + 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 updateResamplingEnabled(bool enable_resampling); + void updateResamplingActive(bool resampling_active); void updateNumberOfUnderruns(std::size_t number_of_underruns); private: @@ -57,9 +62,14 @@ private: SettingsNotifier& settings_notifier; std::string drumkit_load_status; + 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 resampling_enabled; + std::string resampling_active; std::string number_of_underruns; }; diff --git a/src/drumkit.cc b/src/drumkit.cc index abef1b8..e557de1 100644 --- a/src/drumkit.cc +++ b/src/drumkit.cc @@ -68,6 +68,11 @@ std::string DrumKit::getDescription() const return _description; } +VersionStr DrumKit::getVersion() const +{ + return _version; +} + std::size_t DrumKit::getSamplerate() const { return _samplerate; diff --git a/src/drumkit.h b/src/drumkit.h index f646b22..682dbff 100644 --- a/src/drumkit.h +++ b/src/drumkit.h @@ -44,6 +44,7 @@ public: std::string getName() const; std::string getDescription() const; + VersionStr getVersion() const; Instruments instruments; Channels channels; diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc index e4d34f2..eed5a33 100644 --- a/src/drumkitloader.cc +++ b/src/drumkitloader.cc @@ -125,12 +125,18 @@ bool DrumKitLoader::loadkit(const std::string& file) "Trying to load it anyway...\n"); } + // Put some information about the kit into the settings + settings.drumkit_name = kit.getName(); + settings.drumkit_description = kit.getDescription(); + settings.drumkit_version = kit.getVersion(); + settings.drumkit_samplerate = kit.getSamplerate(); + loadKit(&kit); #ifdef WITH_RESAMPLER resamplers.setup(kit.getSamplerate(), settings.samplerate.load()); #endif/*WITH_RESAMPLER*/ - + settings.resampling_active.store(resamplers.isActive()); DEBUG(loadkit, "loadkit: Success\n"); diff --git a/src/settings.h b/src/settings.h index 3f9f9ae..61f92e7 100644 --- a/src/settings.h +++ b/src/settings.h @@ -48,6 +48,10 @@ struct Settings { Atomic drumkit_file{""}; Atomic drumkit_load_status{LoadStatus::Idle}; + Atomic drumkit_name{""}; + Atomic drumkit_description{""}; + Atomic drumkit_version{""}; + Atomic drumkit_samplerate{0}; //! The maximum amount of memory in bytes that the AudioCache //! is allowed to use for preloading. Default is 1GB. @@ -76,6 +80,7 @@ struct Settings Atomic samplerate{44100.0}; Atomic enable_resampling{true}; + Atomic resampling_active{false}; Atomic number_of_files{0}; Atomic number_of_files_loaded{0}; @@ -87,6 +92,10 @@ struct SettingsGetter { SettingRef drumkit_file; SettingRef drumkit_load_status; + SettingRef drumkit_name; + SettingRef drumkit_description; + SettingRef drumkit_version; + SettingRef drumkit_samplerate; SettingRef disk_cache_upper_limit; SettingRef disk_cache_chunk_size; @@ -107,6 +116,7 @@ struct SettingsGetter SettingRef samplerate; SettingRef enable_resampling; + SettingRef resampling_active; SettingRef number_of_files; SettingRef number_of_files_loaded; @@ -115,6 +125,10 @@ struct SettingsGetter SettingsGetter(Settings& settings) : drumkit_file(settings.drumkit_file) , drumkit_load_status(settings.drumkit_load_status) + , drumkit_name(settings.drumkit_name) + , drumkit_description(settings.drumkit_description) + , drumkit_version(settings.drumkit_version) + , drumkit_samplerate(settings.drumkit_samplerate) , disk_cache_upper_limit(settings.disk_cache_upper_limit) , disk_cache_chunk_size(settings.disk_cache_chunk_size) , disk_cache_enable(settings.disk_cache_enable) @@ -129,6 +143,7 @@ struct SettingsGetter , velocity_randomiser_weight{settings.velocity_randomiser_weight} , samplerate{settings.samplerate} , enable_resampling{settings.enable_resampling} + , resampling_active{settings.resampling_active} , number_of_files{settings.number_of_files} , number_of_files_loaded{settings.number_of_files_loaded} , current_file{settings.current_file} @@ -142,6 +157,10 @@ class SettingsNotifier public: Notifier drumkit_file; Notifier drumkit_load_status; + Notifier drumkit_name; + Notifier drumkit_description; + Notifier drumkit_version; + Notifier drumkit_samplerate; Notifier disk_cache_upper_limit; Notifier disk_cache_chunk_size; @@ -162,6 +181,7 @@ public: Notifier samplerate; Notifier enable_resampling; + Notifier resampling_active; Notifier number_of_files; Notifier number_of_files_loaded; @@ -173,6 +193,10 @@ public: EVAL(drumkit_file); EVAL(drumkit_load_status); + EVAL(drumkit_name); + EVAL(drumkit_description); + EVAL(drumkit_version); + EVAL(drumkit_samplerate); EVAL(disk_cache_upper_limit); EVAL(disk_cache_chunk_size); @@ -193,6 +217,7 @@ public: EVAL(samplerate); EVAL(enable_resampling); + EVAL(resampling_active); EVAL(number_of_files); EVAL(number_of_files_loaded); -- cgit v1.2.3