summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Glöckner <cgloeckner@freenet.de>2016-03-29 15:36:53 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2016-03-31 17:35:47 +0200
commitbc4e506e48785ce448f18098b96c0d7333abb801 (patch)
tree1f282fe53493fe0292ef51a791c8f61283e44542
parent1a8361a1f6a1bf442d474cf5baf2e9a09f511777 (diff)
API Refactoring for class Drumkit
-rw-r--r--src/drumgizmo.cc10
-rw-r--r--src/drumkit.cc65
-rw-r--r--src/drumkit.h45
3 files changed, 60 insertions, 60 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index 4ce45ba..0570114 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -101,7 +101,7 @@ bool DrumGizmo::loadkit(std::string file)
#ifdef WITH_RESAMPLER
for(int i = 0; i < MAX_NUM_CHANNELS; ++i)
{
- resampler[i].setup(kit.samplerate(), Conf::samplerate);
+ resampler[i].setup(kit.getSamplerate(), Conf::samplerate);
}
#endif/*WITH_RESAMPLER*/
@@ -167,7 +167,7 @@ void DrumGizmo::handleMessage(Message *msg)
EngineSettingsMessage *msg = new EngineSettingsMessage();
msg->midimapfile = mmapfile;
msg->midimap_loaded = mmap_loaded;
- msg->drumkitfile = kit.file();
+ msg->drumkitfile = kit.getFile();
msg->drumkit_loaded = loader.isDone();
msg->enable_velocity_modifier = Conf::enable_velocity_modifier;
msg->velocity_modifier_falloff = Conf::velocity_modifier_falloff;
@@ -646,7 +646,7 @@ void DrumGizmo::setSamplerate(int samplerate)
#ifdef WITH_RESAMPLER
for(int i = 0; i < MAX_NUM_CHANNELS; ++i)
{
- resampler[i].setup(kit.samplerate(), Conf::samplerate);
+ resampler[i].setup(kit.getSamplerate(), Conf::samplerate);
}
if(resampler[0].getRatio() != 1)
{
@@ -688,7 +688,7 @@ std::string DrumGizmo::configString()
return
"<config>\n"
- " <value name=\"drumkitfile\">" + kit.file() + "</value>\n"
+ " <value name=\"drumkitfile\">" + kit.getFile() + "</value>\n"
" <value name=\"midimapfile\">" + mmapfile + "</value>\n"
" <value name=\"enable_velocity_modifier\">" +
bool2str(Conf::enable_velocity_modifier) + "</value>\n"
@@ -752,7 +752,7 @@ bool DrumGizmo::setConfigString(std::string cfg)
}
std::string newkit = p.value("drumkitfile");
- if(newkit != "" && kit.file() != newkit)
+ if(newkit != "" && kit.getFile() != newkit)
{
/*
if(!loadkit(p.values["drumkitfile"]))
diff --git a/src/drumkit.cc b/src/drumkit.cc
index d8596c7..1b95c87 100644
--- a/src/drumkit.cc
+++ b/src/drumkit.cc
@@ -28,63 +28,64 @@
DrumKit::DrumKit()
{
- magic = this;
+ magic = this;
}
DrumKit::~DrumKit()
{
- magic = NULL;
- clear();
+ magic = NULL;
+ clear();
}
void DrumKit::clear()
{
- Instruments::iterator i = instruments.begin();
- while(i != instruments.end()) {
- delete *i;
- i++;
- }
- instruments.clear();
-
- channels.clear();
-
- _name = "";
- _description = "";
- _samplerate = 44100;
+ Instruments::iterator i = instruments.begin();
+ while(i != instruments.end())
+ {
+ delete *i;
+ i++;
+ }
+ instruments.clear();
+
+ channels.clear();
+
+ _name = "";
+ _description = "";
+ _samplerate = 44100;
}
-bool DrumKit::isValid()
+bool DrumKit::isValid() const
{
- return this == magic;
+ return this == magic;
}
-std::string DrumKit::file()
+std::string DrumKit::getFile() const
{
- return _file;
+ return _file;
}
-std::string DrumKit::name()
+std::string DrumKit::getName() const
{
- return _name;
+ return _name;
}
-std::string DrumKit::description()
+std::string DrumKit::getDescription() const
{
- return _description;
+ return _description;
}
-size_t DrumKit::samplerate()
+size_t DrumKit::getSamplerate() const
{
- return _samplerate;
+ return _samplerate;
}
#ifdef TEST_DRUMKIT
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
+// Additional dependency files
+// deps:
+// Required cflags (autoconf vars may be used)
+// cflags:
+// Required link options (autoconf vars may be used)
+// libs:
#include "test.h"
TEST_BEGIN;
@@ -93,4 +94,4 @@ TEST_BEGIN;
TEST_END;
-#endif/*TEST_DRUMKIT*/
+#endif /*TEST_DRUMKIT*/
diff --git a/src/drumkit.h b/src/drumkit.h
index 24fce99..1ceef3e 100644
--- a/src/drumkit.h
+++ b/src/drumkit.h
@@ -24,8 +24,7 @@
* along with DrumGizmo; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#ifndef __DRUMGIZMO_DRUMKIT_H__
-#define __DRUMGIZMO_DRUMKIT_H__
+#pragma once
#include <map>
#include <string>
@@ -35,36 +34,36 @@
#include "versionstr.h"
class DrumKitParser;
-class DrumKit {
- friend class DrumKitParser;
+class DrumKit
+{
+ friend class DrumKitParser;
+
public:
- DrumKit();
- ~DrumKit();
+ DrumKit();
+ ~DrumKit();
+
+ std::string getFile() const;
- std::string file();
+ std::string getName() const;
+ std::string getDescription() const;
- std::string name();
- std::string description();
-
- Instruments instruments;
- Channels channels;
-
- void clear();
+ Instruments instruments;
+ Channels channels;
- bool isValid();
+ void clear();
- size_t samplerate();
+ bool isValid() const;
+
+ size_t getSamplerate() const;
private:
- void *magic{nullptr};
+ void* magic{nullptr};
- std::string _file;
+ std::string _file;
- std::string _name;
- std::string _description;
+ std::string _name;
+ std::string _description;
size_t _samplerate{0};
- VersionStr _version;
+ VersionStr _version;
};
-
-#endif/*__DRUMGIZMO_DRUMKIT_H__*/