From 20c5726e9442ebaf3711043cc0f317a600fb9c75 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 12 Apr 2020 14:50:24 +0200 Subject: Make sure that drumkit::clear clear all metadata. --- src/domloader.cc | 8 ++++---- src/drumkit.cc | 16 +++++++++------- src/drumkit.h | 14 ++++++++------ 3 files changed, 21 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/domloader.cc b/src/domloader.cc index 97c1d6b..c78ed75 100644 --- a/src/domloader.cc +++ b/src/domloader.cc @@ -56,10 +56,10 @@ bool DOMLoader::loadDom(const std::string& basepath, { settings.has_bleed_control.store(false); - drumkit._name = dom.metadata.title; - drumkit._version = dom.version; - drumkit._description = dom.metadata.description; - drumkit._samplerate = dom.samplerate; + drumkit.metadata._name = dom.metadata.title; + drumkit.metadata._version = dom.version; + drumkit.metadata._description = dom.metadata.description; + drumkit.metadata._samplerate = dom.samplerate; for(const auto& channel: dom.channels) { diff --git a/src/drumkit.cc b/src/drumkit.cc index 61fabf6..9df9a33 100644 --- a/src/drumkit.cc +++ b/src/drumkit.cc @@ -43,9 +43,11 @@ void DrumKit::clear() channels.clear(); - _name = ""; - _description = ""; - _samplerate = 44100.0f; + // Set all metadata fields to empty values. + metadata = {}; + + // Explicitly set the samplerate default value, since this cannot be 0 + metadata._samplerate = 44100.0f; } bool DrumKit::isValid() const @@ -60,22 +62,22 @@ std::string DrumKit::getFile() const std::string DrumKit::getName() const { - return _name; + return metadata._name; } std::string DrumKit::getDescription() const { - return _description; + return metadata._description; } VersionStr DrumKit::getVersion() const { - return _version; + return metadata._version; } float DrumKit::getSamplerate() const { - return _samplerate; + return metadata._samplerate; } std::size_t DrumKit::getNumberOfFiles() const diff --git a/src/drumkit.h b/src/drumkit.h index 4cee6be..aee5d19 100644 --- a/src/drumkit.h +++ b/src/drumkit.h @@ -18,7 +18,7 @@ * 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. + * 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 @@ -68,9 +68,11 @@ private: std::string _file; - std::string _name; - std::string _description; - float _samplerate{44100.0f}; - - VersionStr _version; + struct MetaData + { + std::string _name; + std::string _description; + float _samplerate{44100.0f}; + VersionStr _version; + } metadata; }; -- cgit v1.2.3