diff options
-rw-r--r-- | src/domloader.cc | 8 | ||||
-rw-r--r-- | src/drumkit.cc | 16 | ||||
-rw-r--r-- | src/drumkit.h | 14 | ||||
-rw-r--r-- | test/domloadertest.cc | 4 |
4 files changed, 23 insertions, 19 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; }; diff --git a/test/domloadertest.cc b/test/domloadertest.cc index 2cd6aa8..093bcde 100644 --- a/test/domloadertest.cc +++ b/test/domloadertest.cc @@ -153,9 +153,9 @@ public: DGUNIT_ASSERT_EQUAL(std::string("SnareTop"), drumkit.channels[2].name); DGUNIT_ASSERT_EQUAL(std::string("SnareBottom"), drumkit.channels[3].name); - DGUNIT_ASSERT_EQUAL(std::size_t(48000), drumkit._samplerate); + DGUNIT_ASSERT_EQUAL(48000.0f, drumkit.metadata._samplerate); - DGUNIT_ASSERT(VersionStr("2.0.0") == drumkit._version); + DGUNIT_ASSERT(VersionStr("2.0.0") == drumkit.metadata._version); // // Instrument1 'Snare1': |