summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-04-12 14:50:24 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2020-04-12 14:50:24 +0200
commit20c5726e9442ebaf3711043cc0f317a600fb9c75 (patch)
tree43bf21f5ebb987bb2c0af957a959458bf99c42d1 /src
parente61e6df43ab0b9014f524abf76ea033086b7dcdf (diff)
Make sure that drumkit::clear clear all metadata.
Diffstat (limited to 'src')
-rw-r--r--src/domloader.cc8
-rw-r--r--src/drumkit.cc16
-rw-r--r--src/drumkit.h14
3 files changed, 21 insertions, 17 deletions
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;
};