From 515b45636a232da39e9cd9bbe1f451819b849b8f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 10:00:38 +0200 Subject: Start using C++-11. --- configure.ac | 4 ++++ plugingui/plugingui.cc | 4 ++-- vst/Makefile.mingw32.in | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 02027da..7dec472 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,10 @@ AM_INIT_AUTOMAKE AC_PROG_CXX AM_PROG_CC_C_O +dnl Compile with C++11 support. +#AX_CXX_COMPILE_STDCXX_11 +CXXFLAGS="$CXXFLAGS -std=c++11" + LT_INIT AC_CONFIG_HEADERS(config.h) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 5408334..60a75fc 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -311,7 +311,7 @@ void PluginGUI::init() (void*)&closing); window->setFixedSize(370, 330); - window->setCaption("DrumGizmo v"VERSION); + window->setCaption("DrumGizmo v" VERSION); GUI::Label *lbl_title = new GUI::Label(window); lbl_title->setText("DrumGizmo"); @@ -437,7 +437,7 @@ void PluginGUI::init() l2->resize(window->width() - 40, 2); GUI::Label *lbl_version = new GUI::Label(window); - lbl_version->setText(".::. v"VERSION" .::. http://www.drumgizmo.org .::. GPLv3 .::."); + lbl_version->setText(".::. v" VERSION " .::. http://www.drumgizmo.org .::. GPLv3 .::."); lbl_version->move(16, 300); lbl_version->resize(window->width(), 20); /* diff --git a/vst/Makefile.mingw32.in b/vst/Makefile.mingw32.in index 66e02ed..a5c8c31 100644 --- a/vst/Makefile.mingw32.in +++ b/vst/Makefile.mingw32.in @@ -137,7 +137,7 @@ SRC = \ all: gcc $(DBG_CFLAGS) @top_srcdir@/hugin/hugin.c -c gcc $(DBG_CFLAGS) @top_srcdir@/hugin/hugin_syslog.c -c - g++ -static -static-libgcc -O2 -g -Wall $(DBG_CFLAGS) $(DG_CFLAGS) $(DG_LIBS) $(VST_CFLAGS) hugin.o hugin_syslog.o $(DG_SRC) $(VST_SRC) ${SRC} ${GUI_SRC} ${GUI_CFLAGS} $(GUI_LIBS) $(EXPAT_CFLAGS) $(ZLIB_CFLAGS) $(SRC_CFLAGS) $(ZITA_CXXFLAGS) $(EXPAT_LIBS) $(ZLIB_LIBS) $(SNDFILE_CFLAGS) $(SNDFILE_LIBS) $(SRC_LIBS) $(ZITA_LIBS) -shared -o drumgizmo_vst.dll -Wl,--out-implib,libdrumgizmo_vst.a + g++ -std=c++11 -static -static-libgcc -O2 -g -Wall $(DBG_CFLAGS) $(DG_CFLAGS) $(DG_LIBS) $(VST_CFLAGS) hugin.o hugin_syslog.o $(DG_SRC) $(VST_SRC) ${SRC} ${GUI_SRC} ${GUI_CFLAGS} $(GUI_LIBS) $(EXPAT_CFLAGS) $(ZLIB_CFLAGS) $(SRC_CFLAGS) $(ZITA_CXXFLAGS) $(EXPAT_LIBS) $(ZLIB_LIBS) $(SNDFILE_CFLAGS) $(SNDFILE_LIBS) $(SRC_LIBS) $(ZITA_LIBS) -shared -o drumgizmo_vst.dll -Wl,--out-implib,libdrumgizmo_vst.a clean: del -f drumgizmo_vst.dll libdrumgizmo_vst.a -- cgit v1.2.3 From e3821e26ad868bdd78f999695cd70e6e132da4a8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 10:04:08 +0200 Subject: Only expect c++x0. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7dec472..17aae11 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ AM_PROG_CC_C_O dnl Compile with C++11 support. #AX_CXX_COMPILE_STDCXX_11 -CXXFLAGS="$CXXFLAGS -std=c++11" +CXXFLAGS="$CXXFLAGS -std=c++0x" LT_INIT -- cgit v1.2.3 From 53e66dbf4c17b4f823f57c974c77b6f7f02627bf Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 10:11:08 +0200 Subject: Make sure that M_PI is defined. --- src/powerlist.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/powerlist.cc b/src/powerlist.cc index 6fc77ad..6cff863 100644 --- a/src/powerlist.cc +++ b/src/powerlist.cc @@ -27,7 +27,11 @@ #include "powerlist.h" #include + +// Otherwise M_PI is not defined in math.h on some older platforms... +#define _USE_MATH_DEFINES #include + #include #include -- cgit v1.2.3 From eae90ebc9220ed26963e9f4b34268094ec629d4c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 10:18:00 +0200 Subject: Make sure that M_PI is defined. --- src/powerlist.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/powerlist.cc b/src/powerlist.cc index 6cff863..4248b30 100644 --- a/src/powerlist.cc +++ b/src/powerlist.cc @@ -28,14 +28,16 @@ #include -// Otherwise M_PI is not defined in math.h on some older platforms... -#define _USE_MATH_DEFINES -#include - #include #include +// M_PI is not defined in math.h if __STRICT_ANSI__ is defined. +#ifdef __STRICT_ANSI__ +#undef __STRICT_ANSI__ +#endif +#include + /** * Minimum sample set size. * Smaller means wider 'velocity groups'. -- cgit v1.2.3 From 6a19e8f182183ad88df91d4a46e418fb4d42f9bd Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 10:24:10 +0200 Subject: Make sure that M_PI is defined. --- plugingui/knob.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugingui/knob.cc b/plugingui/knob.cc index ca861b5..4cac180 100644 --- a/plugingui/knob.cc +++ b/plugingui/knob.cc @@ -30,6 +30,11 @@ #include #include + +// M_PI is not defined in math.h if __STRICT_ANSI__ is defined. +#ifdef __STRICT_ANSI__ +#undef __STRICT_ANSI__ +#endif #include GUI::Knob::Knob(Widget *parent) -- cgit v1.2.3 From 9555c6e2734977c82023907f82a3ae82f845720a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 11:53:17 +0200 Subject: New ConfigFile class for generic config file reading/writing in homedir .drumgizmo folder. Use said new class for PluginConfig class. --- plugingui/Makefile.am | 1 + plugingui/pluginconfig.cc | 122 ++------------------------ plugingui/pluginconfig.h | 22 ++--- src/Makefile.am.drumgizmo | 1 + src/configfile.cc | 215 ++++++++++++++++++++++++++++++++++++++++++++++ src/configfile.h | 56 ++++++++++++ vst/Makefile.mingw32.in | 1 + 7 files changed, 291 insertions(+), 127 deletions(-) create mode 100644 src/configfile.cc create mode 100644 src/configfile.h diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index bdb11cb..00b0881 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -14,6 +14,7 @@ plugingui_CFLAGS = $(plugingui_CXXFLAGS) plugingui_SOURCES = \ $(PLUGIN_GUI_SOURCES) \ + $(top_srcdir)/src/configfile.cc \ $(top_srcdir)/src/thread.cc \ $(top_srcdir)/src/semaphore.cc \ $(top_srcdir)/src/mutex.cc \ diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index d57d9df..0beef6e 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -26,140 +26,34 @@ */ #include "pluginconfig.h" -#include -#include -#include -#include - -#include "directory.h" - -#ifdef WIN32 -#include -#include -#include -#include -#else -#endif - #include #define CONFIGFILENAME "plugingui.conf" -#ifdef WIN32 - #define SEP "\\" - #define CONFIGDIRNAME ".drumgizmo" -#else - #define SEP "/" - #define CONFIGDIRNAME ".drumgizmo" -#endif - Config::Config() + : ConfigFile(CONFIGFILENAME) { - } Config::~Config() { - -} - -static std::string configPath() { - #ifdef WIN32 - std::string configpath; - TCHAR szPath[256]; - if(SUCCEEDED(SHGetFolderPath(NULL, - CSIDL_APPDATA | CSIDL_FLAG_CREATE, - NULL, - 0, - szPath))); { - configpath = szPath; - } -#else - std::string configpath = strdup(getenv("HOME")); -#endif - configpath += SEP; - configpath += CONFIGDIRNAME; - - return configpath; -} - -static bool createConfigPath() { - std::string configpath = configPath(); - - if(!Directory::exists(configpath)) { - DEBUG(pluginconfig, "No configuration exists, creating directory '%s'\n", configpath.c_str()); -#ifdef WIN32 - if( (mkdir(configpath.c_str())) < 0) { -#else - if( (mkdir(configpath.c_str(), 0755)) < 0) { -#endif - DEBUG(pluginconfig, "Could not create config directory\n"); - } - return false; - } - - return true; -} - -static FILE* openConfigFile(std::string mode) { - - std::string configpath = configPath(); - - FILE *fp; - std::string configfile = configpath; - configfile += SEP; - configfile += CONFIGFILENAME; - - DEBUG(pluginconfig, "Opening config file '%s'\n", configfile.c_str()); - if(! (fp = fopen(configfile.c_str(), mode.c_str())) ) { - return NULL; - } - - return fp; } void Config::load() { - DEBUG(pluginconfig, "Loading config file...\n"); - FILE *fp = openConfigFile("r"); - if(!fp) return; - lastkit.clear(); lastmidimap.clear(); - char buf[4096]; - while( fgets(buf, 4096, fp) ) { - if(!strncmp(buf, "lastkit:", 8)) { - DEBUG(pluginconfig, "Loading last kit path\n"); - // Dont copy newline - if(strlen(buf) > 8 + 1) { - lastkit.append(buf+8, strlen(buf+8) - 1); - DEBUG(pluginconfig, "\t path is %s\n", lastkit.c_str()); - } - } - if(!strncmp(buf, "lastmidimap:", 12)) { - DEBUG(pluginconfig, "Loading lastmidimap path\n"); - // Dont copy newline - if(strlen(buf) > 12+1) lastmidimap.append(buf+12, strlen(buf+12) - 1); - DEBUG(pluginconfig, "\t path is %s\n", lastmidimap.c_str()); - } - } + ConfigFile::load(); + + lastkit = getValue("lastkit"); + lastmidimap = getValue("lastmidimap"); } void Config::save() { - DEBUG(pluginconfig, "Saving configuration...\n"); - - createConfigPath(); - - FILE *fp = openConfigFile("w"); - if(!fp) return; - - std::string buf; - buf.append("lastkit:" + lastkit + '\n'); - buf.append("lastmidimap:" + lastmidimap + '\n'); - - fputs(buf.c_str(), fp); + setValue("lastkit", lastkit); + setValue("lastmidimap", lastmidimap); - fclose(fp); + ConfigFile::save(); } diff --git a/plugingui/pluginconfig.h b/plugingui/pluginconfig.h index d0e9bcd..29d2ef5 100644 --- a/plugingui/pluginconfig.h +++ b/plugingui/pluginconfig.h @@ -27,22 +27,18 @@ #ifndef __DRUMGIZMO_CONFIG_H__ #define __DRUMGIZMO_CONFIG_H__ -#include -#include +#include -#define DIRECTORY_HIDDEN 1 +class Config : public ConfigFile { +public: + Config(); + ~Config(); -class Config { + void load(); + void save(); - public: - Config(); - ~Config(); - - void load(); - void save(); - - std::string lastkit; - std::string lastmidimap; + std::string lastkit; + std::string lastmidimap; }; #endif/*__DRUMGIZMO_CONFIG_H__*/ diff --git a/src/Makefile.am.drumgizmo b/src/Makefile.am.drumgizmo index 26e2a30..1a3c857 100644 --- a/src/Makefile.am.drumgizmo +++ b/src/Makefile.am.drumgizmo @@ -4,6 +4,7 @@ DRUMGIZMO_SOURCES = \ $(top_srcdir)/src/channel.cc \ $(top_srcdir)/src/channelmixer.cc \ $(top_srcdir)/src/chresampler.cc \ + $(top_srcdir)/src/configfile.cc \ $(top_srcdir)/src/configuration.cc \ $(top_srcdir)/src/configparser.cc \ $(top_srcdir)/src/drumgizmo.cc \ diff --git a/src/configfile.cc b/src/configfile.cc new file mode 100644 index 0000000..bb7155f --- /dev/null +++ b/src/configfile.cc @@ -0,0 +1,215 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * configfile.cc + * + * Thu May 14 14:51:39 CEST 2015 + * Copyright 2015 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "configfile.h" + +#include +#include +#include +#include + +#include +#include + +#ifdef WIN32 +#include +#include +#include +#include +#else +#endif + +#include + +#ifdef WIN32 + #define SEP "\\" + #define CONFIGDIRNAME ".drumgizmo" +#else + #define SEP "/" + #define CONFIGDIRNAME ".drumgizmo" +#endif + +/** + * Return the path containing the config files. + */ +static std::string configPath() +{ +#ifdef WIN32 + std::string configpath; + TCHAR szPath[256]; + if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, + NULL, 0, szPath))) { + configpath = szPath; + } +#else + std::string configpath = strdup(getenv("HOME")); +#endif + configpath += SEP; + configpath += CONFIGDIRNAME; + + return configpath; +} + +/** + * Calling this makes sure that the config path exists + */ +static bool createConfigPath() +{ + std::string configpath = configPath(); + + struct stat st; + if(stat(configpath.c_str(), &st) == 0) { + DEBUG(configfile, "No configuration exists, creating directory '%s'\n", + configpath.c_str()); +#ifdef WIN32 + if(mkdir(configpath.c_str()) < 0) { +#else + if(mkdir(configpath.c_str(), 0755) < 0) { +#endif + DEBUG(pluginconfig, "Could not create config directory\n"); + } + + return false; + } + + return true; +} + +ConfigFile::ConfigFile(std::string filename) + : filename(filename) + , fp(NULL) +{ +} + +ConfigFile::~ConfigFile() +{ +} + +void ConfigFile::load() +{ + DEBUG(pluginconfig, "Loading config file...\n"); + if(!open("r")) return; + + values.clear(); + + std::string line; + while(true) { + line = readLine(); + + if(line == "") break; + + if(line[line.size() - 1] == '\n') { + line = line.substr(0, line.size() - 1); // strip ending newline. + } + + std::size_t colon = line.find(':'); + + if(colon == std::string::npos) break; // malformed line + + std::string key = line.substr(0, colon); + std::string value = line.substr(colon + 1); + + printf("key['%s'] value['%s']\n", key.c_str(), value.c_str()); + + if(key != "") { + values[key] = value; + } + } + + close(); +} + +void ConfigFile::save() +{ + DEBUG(pluginconfig, "Saving configuration...\n"); + + createConfigPath(); + + if(!open("w")) return; + + std::map::iterator v = values.begin(); + for(; v != values.end(); ++v) { + fprintf(fp, "%s:%s\n", v->first.c_str(), v->second.c_str()); + } + + close(); +} + +std::string ConfigFile::getValue(const std::string& key) +{ + if(values.find(key) != values.end()) { + return values[key]; + } + + return ""; +} + +void ConfigFile::setValue(const std::string& key, const std::string& value) +{ + values[key] = value; +} + +bool ConfigFile::open(std::string mode) +{ + if(fp) close(); + + std::string configpath = configPath(); + + std::string configfile = configpath; + configfile += SEP; + configfile += filename; + + DEBUG(pluginconfig, "Opening config file '%s'\n", configfile.c_str()); + fp = fopen(configfile.c_str(), mode.c_str()); + + if(!fp) return false; + + return true; +} + +void ConfigFile::close() +{ + fclose(fp); + fp = NULL; +} + +std::string ConfigFile::readLine() +{ + if(!fp) return ""; + + std::string line; + + char buf[1024]; + while(!feof(fp)) { + char *s = fgets(buf, sizeof(buf), fp); + if(s) { + line += buf; + if(buf[strlen(buf) - 1] == '\n') break; + } + } + + return line; +} diff --git a/src/configfile.h b/src/configfile.h new file mode 100644 index 0000000..21a6b88 --- /dev/null +++ b/src/configfile.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * configfile.h + * + * Thu May 14 14:51:38 CEST 2015 + * Copyright 2015 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef __DRUMGIZMO_CONFIGFILE_H__ +#define __DRUMGIZMO_CONFIGFILE_H__ + +#include +#include +#include + +class ConfigFile { +public: + ConfigFile(std::string filename); + virtual ~ConfigFile(); + + virtual void load(); + virtual void save(); + + virtual std::string getValue(const std::string& key); + virtual void setValue(const std::string& key, const std::string& value); + +protected: + std::map values; + std::string filename; + + bool open(std::string mode); + void close(); + std::string readLine(); + + FILE* fp; +}; + +#endif/*__DRUMGIZMO_CONFIGFILE_H__*/ diff --git a/vst/Makefile.mingw32.in b/vst/Makefile.mingw32.in index a5c8c31..54c42e0 100644 --- a/vst/Makefile.mingw32.in +++ b/vst/Makefile.mingw32.in @@ -12,6 +12,7 @@ DG_SRC = \ @top_srcdir@/src/channel.cc \ @top_srcdir@/src/channelmixer.cc \ @top_srcdir@/src/chresampler.cc \ + @top_srcdir@/src/configfile.cc \ @top_srcdir@/src/configuration.cc \ @top_srcdir@/src/configparser.cc \ @top_srcdir@/src/drumgizmo.cc \ -- cgit v1.2.3 From ceda77eb38f0b0824f03348f5291e3a42d8f7306 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 17:36:41 +0200 Subject: Add support for referenced files through refs.conf. --- plugingui/filebrowser.cc | 9 +++++++++ src/audioinputenginemidi.cc | 30 +++++++++++------------------- src/audioinputenginemidi.h | 4 ++++ src/drumgizmo.h | 6 +++--- src/drumkitparser.cc | 14 ++++++++++++-- src/drumkitparser.h | 3 +++ src/midimapparser.cc | 17 ----------------- 7 files changed, 42 insertions(+), 41 deletions(-) diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc index 6ecbc09..f025c25 100644 --- a/plugingui/filebrowser.cc +++ b/plugingui/filebrowser.cc @@ -160,6 +160,15 @@ static void handleKeyEvent(void *ptr) { lb->clearSelectedValue(); GUI::LineEdit *le = prv->lineedit; + std::string value = le->text(); + if(value.size() > 1 && value[0] == '@') { + DEBUG(filebrowser, "Selecting ref-file '%s'\n", value.c_str()); + if(prv->filesel_handler) { + prv->filesel_handler(prv->ptr, value); + } + return; + } + prv->dir->setPath(le->text()); changeDir(ptr); } diff --git a/src/audioinputenginemidi.cc b/src/audioinputenginemidi.cc index 82cafbf..5494462 100644 --- a/src/audioinputenginemidi.cc +++ b/src/audioinputenginemidi.cc @@ -28,15 +28,24 @@ #include "midimapparser.h" +#include "drumgizmo.h" + #include AudioInputEngineMidi::AudioInputEngineMidi() + : refs(REFSFILE) { + refs.load(); is_valid = false; } -bool AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments) +bool AudioInputEngineMidi::loadMidiMap(std::string _f, Instruments &instruments) { + std::string f = _f; + if(_f.size() > 1 && _f[0] == '@') { + f = refs.getValue(_f.substr(1)); + } + file = ""; is_valid = false; @@ -57,7 +66,7 @@ bool AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments) mmap.instrmap[instruments[i]->name()] = i; } - file = f; + file = _f; is_valid = true; return true; @@ -72,20 +81,3 @@ bool AudioInputEngineMidi::isValid() { return is_valid; } - -#ifdef TEST_AUDIOINPUTENGINEMIDI -//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; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_AUDIOINPUTENGINEMIDI*/ diff --git a/src/audioinputenginemidi.h b/src/audioinputenginemidi.h index b01fef0..0868730 100644 --- a/src/audioinputenginemidi.h +++ b/src/audioinputenginemidi.h @@ -34,6 +34,8 @@ #include "midimapper.h" #include "instrument.h" +#include "configfile.h" + class AudioInputEngineMidi : public AudioInputEngine { public: AudioInputEngineMidi(); @@ -62,6 +64,8 @@ protected: MidiMapper mmap; std::string file; bool is_valid; + + ConfigFile refs; }; #endif/*__DRUMGIZMO_AUDIOINPUTENGINEMIDI_H__*/ diff --git a/src/drumgizmo.h b/src/drumgizmo.h index f8d45f5..5e58ba5 100644 --- a/src/drumgizmo.h +++ b/src/drumgizmo.h @@ -47,7 +47,10 @@ #include "chresampler.h" +#include "configfile.h" + #define MAX_NUM_CHANNELS 64 +#define REFSFILE "refs.conf" class DrumGizmo : public MessageReceiver { public: @@ -92,9 +95,6 @@ private: std::map audiofiles; -#ifdef TEST_DRUMGIZMO -public: -#endif DrumKit kit; }; diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc index 2c21c52..00232b2 100644 --- a/src/drumkitparser.cc +++ b/src/drumkitparser.cc @@ -32,10 +32,20 @@ #include "instrumentparser.h" #include "path.h" +#include "drumgizmo.h" -DrumKitParser::DrumKitParser(const std::string &kitfile, DrumKit &k) +DrumKitParser::DrumKitParser(const std::string &file, DrumKit &k) : kit(k) + , refs(REFSFILE) { + refs.load(); + + std::string kitfile = file; + + if(file.size() > 1 && file[0] == '@') { + kitfile = refs.getValue(file.substr(1)); + } + // instr = NULL; path = getPath(kitfile); @@ -45,7 +55,7 @@ DrumKitParser::DrumKitParser(const std::string &kitfile, DrumKit &k) if(!fd) return; - kit._file = kitfile; + kit._file = file; } DrumKitParser::~DrumKitParser() diff --git a/src/drumkitparser.h b/src/drumkitparser.h index 907b09d..6311609 100644 --- a/src/drumkitparser.h +++ b/src/drumkitparser.h @@ -29,6 +29,7 @@ #include "saxparser.h" #include "drumkit.h" +#include "configfile.h" class DrumKitParser : public SAXParser { public: @@ -52,6 +53,8 @@ private: std::string instr_file; std::string instr_name; std::string instr_group; + + ConfigFile refs; }; #endif/*__DRUMGIZMO_DRUMKITPARSER_H__*/ diff --git a/src/midimapparser.cc b/src/midimapparser.cc index 07210a5..9d30a05 100644 --- a/src/midimapparser.cc +++ b/src/midimapparser.cc @@ -50,20 +50,3 @@ int MidiMapParser::readData(char *data, size_t size) if(!fd) return -1; return fread(data, 1, size, fd); } - -#ifdef TEST_MIDIMAPPARSER -//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; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_MIDIMAPPARSER*/ -- cgit v1.2.3