From 0e048dee411cc20beb2a8667e5bb339f9b7fb939 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 17 May 2014 21:27:52 +0200 Subject: New resample feature on output channels. --- configure.ac | 31 ++++++++++++- drumgizmo/audiooutputenginedl.cc | 12 +++++ drumgizmo/audiooutputenginedl.h | 3 ++ drumgizmo/output/jackaudio/jackaudio.cc | 12 +++++ lv2/Makefile.am | 12 ++--- src/Makefile.am.drumgizmo | 2 +- src/audiofile.cc | 36 --------------- src/audiooutputengine.h | 7 +++ src/drumgizmo.cc | 82 ++++++++++++++++++++++++++++----- src/drumkit.cc | 6 +++ src/drumkit.h | 3 ++ src/drumkitparser.cc | 8 ++++ 12 files changed, 158 insertions(+), 56 deletions(-) diff --git a/configure.ac b/configure.ac index c3fc352..d8d45d4 100644 --- a/configure.ac +++ b/configure.ac @@ -355,7 +355,36 @@ if test x$with_resample == xyes; then dnl Check for libsamplerate dnl ====================== PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.1.7) -fi + +# dnl ====================== +# dnl Check for the zitaresampler library +# dnl ====================== +# AC_LANG_PUSH([C++]) +# tmp_CXXFLAGS="$CXXFLAGS" +# tmp_CPPFLAGS="$CPPFLAGS" +# tmp_CFLAGS="$CFLAGS" +# tmp_LDFLAGS="$LDFLAGS" +# tmp_LIBS="$LIBS" +# CXXFLAGS="" +# CPPFLAGS="$ZITA_CPPFLAGS" +# CFLAGS="" +# LDFLAGS="$ZITA_LDFLAGS" +# LIBS="" +# AC_CHECK_HEADER(zita-resampler/resampler.h, , +# AC_MSG_ERROR([*** zita-resampler header files not found! Set ZITA_CPPFLAGS to add searchpath.])) +# AC_CHECK_LIB(zita-resampler, _Z28zita_resampler_major_versionv, , +# AC_MSG_ERROR([*** zita-resampler library not found! Set ZITA_LDFLAGS to add searchpath.])) +# ZITA_CPPFLAGS="$CXXFLAGS $CPPFLAGS $CFLAGS" +# ZITA_LIBS="$LDFLAGS $LIBS" +# CXXFLAGS="$tmp_CXXFLAGS" +# CPPFLAGS="$tmp_CPPFLAGS" +# CFLAGS="$tmp_CFLAGS" +# LDFLAGS="$tmp_LDFLAGS" +# LIBS="$tmp_LIBS" +# AC_SUBST(ZITA_CPPFLAGS) +# AC_SUBST(ZITA_LIBS) +# AC_LANG_POP([C++]) +fi #dnl ====================== #dnl Check for zlib diff --git a/drumgizmo/audiooutputenginedl.cc b/drumgizmo/audiooutputenginedl.cc index 513d21b..fcedd9d 100644 --- a/drumgizmo/audiooutputenginedl.cc +++ b/drumgizmo/audiooutputenginedl.cc @@ -111,6 +111,12 @@ AudioOutputEngineDL::AudioOutputEngineDL(std::string name) o_bufsize = NULL; } + o_samplerate = (output_samplerate_func_t) dlsym(lib, "samplerate"); + dlsym_error = dlerror(); + if(dlsym_error) { + o_samplerate = NULL; + } + ptr = o_create(); if(is_jack_plugin) { @@ -181,6 +187,12 @@ size_t AudioOutputEngineDL::getBufferSize() return 1024; } +size_t AudioOutputEngineDL::samplerate() +{ + if(o_samplerate) return o_samplerate(ptr); + return UNKNOWN_SAMPLERATE; +} + #ifdef TEST_AUDIOOUTPUTENGINEDL //Additional dependency files //deps: diff --git a/drumgizmo/audiooutputenginedl.h b/drumgizmo/audiooutputenginedl.h index 471247e..75460f3 100644 --- a/drumgizmo/audiooutputenginedl.h +++ b/drumgizmo/audiooutputenginedl.h @@ -46,6 +46,7 @@ typedef void (*output_pre_func_t)(void*, size_t); typedef void (*output_run_func_t)(void*,int,sample_t*,size_t); typedef void (*output_post_func_t)(void*, size_t); typedef size_t (*output_bufsize_func_t)(void*); +typedef size_t (*output_samplerate_func_t)(void*); class AudioOutputEngineDL : public AudioOutputEngine { public: @@ -64,6 +65,7 @@ public: void post(size_t nsamples); size_t getBufferSize(); + size_t samplerate(); private: void *ptr; @@ -77,6 +79,7 @@ private: output_run_func_t o_run; output_post_func_t o_post; output_bufsize_func_t o_bufsize; + output_samplerate_func_t o_samplerate; bool is_jack_plugin; JackClient *jackclient; diff --git a/drumgizmo/output/jackaudio/jackaudio.cc b/drumgizmo/output/jackaudio/jackaudio.cc index 2afe1ea..b7fa4f9 100644 --- a/drumgizmo/output/jackaudio/jackaudio.cc +++ b/drumgizmo/output/jackaudio/jackaudio.cc @@ -54,6 +54,7 @@ public: void jack_process(jack_nframes_t nframes); size_t bufsize(); + size_t samplerate(); private: JackClient *jackclient; @@ -146,6 +147,11 @@ size_t JackAudio::bufsize() return jack_get_buffer_size(jackclient->jack_client); } +size_t JackAudio::samplerate() +{ + return jack_get_sample_rate(jackclient->jack_client); +} + extern "C" { void *create() { @@ -205,6 +211,12 @@ extern "C" { JackAudio *jack = (JackAudio*)h; return jack->bufsize(); } + + size_t samplerate(void *h) + { + JackAudio *jack = (JackAudio*)h; + return jack->samplerate(); + } } #ifdef TEST_AUDIOINPUTENGINEJACKAUDIO diff --git a/lv2/Makefile.am b/lv2/Makefile.am index a714dce..9939131 100644 --- a/lv2/Makefile.am +++ b/lv2/Makefile.am @@ -3,12 +3,6 @@ if ENABLE_LV2 include $(top_srcdir)/plugingui/Makefile.am.plugingui include $(top_srcdir)/src/Makefile.am.drumgizmo -AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/plugingui \ - -I$(top_srcdir)/include $(SNDFILE_CXXFLAGS) \ - $(PTHREAD_CFLAGS) $(EXPAT_CFLAGS) $(LV2_CFLAGS) \ - $(PLUGIN_GUI_CFLAGS) $(SSEFLAGS)\ - -DUSE_THREAD $(SAMPLERATE_CFLAGS) - plugindir = $(prefix)/lib/lv2/drumgizmo.lv2 plugin_LTLIBRARIES = drumgizmo.la plugin_DATA = manifest.ttl drumgizmo.ttl @@ -21,6 +15,12 @@ EXTRA_DIST = \ lv2_gui.h \ lv2_instance.h +drumgizmo_la_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/plugingui \ + -I$(top_srcdir)/include $(SNDFILE_CXXFLAGS) \ + $(PTHREAD_CFLAGS) $(EXPAT_CFLAGS) $(LV2_CFLAGS) \ + $(PLUGIN_GUI_CFLAGS) $(SSEFLAGS) $(ZITA_CPPFLAGS) \ + -DUSE_THREAD $(SAMPLERATE_CFLAGS) + drumgizmo_la_SOURCES = \ $(DRUMGIZMO_SOURCES) \ $(PLUGIN_GUI_SOURCES) \ diff --git a/src/Makefile.am.drumgizmo b/src/Makefile.am.drumgizmo index c48c478..da5d839 100644 --- a/src/Makefile.am.drumgizmo +++ b/src/Makefile.am.drumgizmo @@ -26,4 +26,4 @@ DRUMGIZMO_SOURCES = \ $(top_srcdir)/src/velocity.cc \ $(top_srcdir)/src/versionstr.cc -DRUMGIZMO_LIBS = $(SNDFILE_LIBS) $(EXPAT_LIBS) $(SAMPLERATE_LIBS) \ No newline at end of file +DRUMGIZMO_LIBS = $(ZITA_LIBS) $(SNDFILE_LIBS) $(EXPAT_LIBS) $(SAMPLERATE_LIBS) \ No newline at end of file diff --git a/src/audiofile.cc b/src/audiofile.cc index 874b9c5..59e0c14 100644 --- a/src/audiofile.cc +++ b/src/audiofile.cc @@ -34,9 +34,6 @@ #include #include #include -#ifdef WITH_RESAMPLE -#include -#endif/*WITH_RESAMPLE*/ #include #include "configuration.h" @@ -154,39 +151,6 @@ void AudioFile::load(int num_samples) sf_close(fh); -#ifdef WITH_RESAMPLE - - // Check environment to see if resample should be disabled. - // Defaults to "1" which is 'enable'. All other values are 'disabled'. - const char *env_res = getenv("DRUMGIZMO_RESAMPLE"); - if(env_res == NULL) env_res = "1"; - - if( (strcmp(env_res, "1") == 0) && - Conf::samplerate != sf_info.samplerate) { - // Resample data... - size_t osize = size * ratio; - sample_t *odata = new sample_t[osize]; - - SRC_DATA src; - src.data_in = data; - src.input_frames = size; - - src.data_out = odata; - src.output_frames = osize; - - src.src_ratio = ratio; - - // Do the conversion - src_simple(&src, SRC_SINC_BEST_QUALITY, 1); - - delete[] data; - data = odata; - size = src.output_frames; - - DEBUG(audiofile,"Converted into %d samples %p\n", (int)size, this); - } -#endif/*WITH_RESAMPLE*/ - this->data = data; is_loaded = true; diff --git a/src/audiooutputengine.h b/src/audiooutputengine.h index 7f15e49..25b6ea0 100644 --- a/src/audiooutputengine.h +++ b/src/audiooutputengine.h @@ -33,6 +33,8 @@ #include "channel.h" +#define UNKNOWN_SAMPLERATE 0 + class AudioOutputEngine { public: virtual ~AudioOutputEngine() {} @@ -55,6 +57,11 @@ public: * Overload this method to force engine to use different buffer size. */ virtual size_t getBufferSize() { return 1024; } + + /** + * Overload this method to report output engine samplerate. + */ + virtual size_t samplerate() { return UNKNOWN_SAMPLERATE; } }; #endif/*__DRUMGIZMO_AUDIOOUTPUTENGINE_H__*/ diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 5d67c86..3ffcba5 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -36,6 +36,19 @@ #include +#include + +// +// Warning: Zita currently not working... +// +#ifdef WITH_RESAMPLE +#ifdef ZITA +#include +#else +#include +#endif/*ZITA*/ +#endif/*WITH_RESAMPLE*/ + #include "drumkitparser.h" #include "audioinputenginemidi.h" #include "configuration.h" @@ -158,6 +171,13 @@ void DrumGizmo::handleMessage(Message *msg) bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) { + double samplerate_scale = 1.0; +#ifndef WITH_RESAMPLE + if(oe->samplerate() != UNKNOWN_SAMPLERATE) { + samplerate_scale = (double)kit.samplerate() / (double)oe->samplerate(); + } +#endif/*WITH_RESAMPLE*/ + // Handle engine messages, at most one in each iteration: handleMessages(1); @@ -240,7 +260,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) } else { //DEBUG(drumgizmo, "Adding event %d.\n", evs[e].offset); Event *evt = new EventSample(ch.num, 1.0, af, i->group(), i); - evt->offset = evs[e].offset + pos; + evt->offset = (evs[e].offset + pos) * samplerate_scale; activeevents[ch.num].push_back(evt); } j++; @@ -255,22 +275,60 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) free(evs); - // // Write audio // for(size_t c = 0; c < kit.channels.size(); c++) { - sample_t *buf = samples; - bool internal = false; - if(oe->getBuffer(c)) { - buf = oe->getBuffer(c); - internal = true; - } - if(buf) { - memset(buf, 0, nsamples * sizeof(sample_t)); + if(samplerate_scale == 1.0) { + // No resampling needed + sample_t *buf = samples; + bool internal = false; + if(oe->getBuffer(c)) { + buf = oe->getBuffer(c); + internal = true; + } + if(buf) { + memset(buf, 0, nsamples * sizeof(sample_t)); - getSamples(c, pos, buf, nsamples); - if(!internal) oe->run(c, samples, nsamples); + getSamples(c, pos, buf, nsamples); + + if(!internal) oe->run(c, samples, nsamples); + } + } else { +#ifdef WITH_RESAMPLE + // Resampling needed + size_t nkitsamples = nsamples * samplerate_scale; + sample_t kitsamples[nkitsamples]; + + memset(rs, 0, nkitsamples * sizeof(sample_t)); + getSamples(c, pos * samplerate_scale, rs, nkitsamples); + +#ifdef ZITA + Resampler resampler; + resampler.setup(kit.samplerate(), oe->samplerate(), 1, 96); + + resampler.inp_data = kitsamples; + resampler.inp_count = nkitsamples; + + resampler.out_data = samples; + resampler.out_count = nsamples; + + resampler.process(); +#else + SRC_DATA src; + src.data_in = kitsamples; + src.input_frames = nkitsamples; + + src.data_out = samples; + src.output_frames = nsamples; + + src.src_ratio = 1.0 / samplerate_scale; + + src_simple(&src, SRC_SINC_BEST_QUALITY, 1); +#endif/*ZITA*/ + + oe->run(c, samples, nsamples); +#endif/*WITH_RESAMPLE*/ } } diff --git a/src/drumkit.cc b/src/drumkit.cc index c2aa221..4d75f3b 100644 --- a/src/drumkit.cc +++ b/src/drumkit.cc @@ -50,6 +50,7 @@ void DrumKit::clear() _name = ""; _description = ""; + _samplerate = 44100; } bool DrumKit::isValid() @@ -72,6 +73,11 @@ std::string DrumKit::description() return _description; } +size_t DrumKit::samplerate() +{ + return _samplerate; +} + #ifdef TEST_DRUMKIT //Additional dependency files //deps: diff --git a/src/drumkit.h b/src/drumkit.h index 82fe69b..04b2c56 100644 --- a/src/drumkit.h +++ b/src/drumkit.h @@ -53,6 +53,8 @@ public: bool isValid(); + size_t samplerate(); + private: void *magic; @@ -60,6 +62,7 @@ private: std::string _name; std::string _description; + size_t _samplerate; VersionStr _version; }; diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc index 1b7ecaf..2c21c52 100644 --- a/src/drumkitparser.cc +++ b/src/drumkitparser.cc @@ -60,6 +60,14 @@ void DrumKitParser::startTag(std::string name, if(attr.find("name") != attr.end()) kit._name = attr["name"]; + if(attr.find("samplerate") != attr.end()) { + kit._samplerate = atoi(attr["samplerate"].c_str()); + } else { + // If 'samplerate' attribute is missing, assume 44k1Hz + // TODO: Ask instrument what samplerate is in the audiofiles... + kit._samplerate = 44100; + } + if(attr.find("description") != attr.end()) kit._description = attr["description"]; -- cgit v1.2.3 From e73d3463d3114db2f5db5a453d30fe642e6024f3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 17 May 2014 21:53:01 +0200 Subject: Fix resampler... --- src/drumgizmo.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 3ffcba5..8fb449a 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -172,7 +172,7 @@ void DrumGizmo::handleMessage(Message *msg) bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) { double samplerate_scale = 1.0; -#ifndef WITH_RESAMPLE +#ifdef WITH_RESAMPLE if(oe->samplerate() != UNKNOWN_SAMPLERATE) { samplerate_scale = (double)kit.samplerate() / (double)oe->samplerate(); } @@ -300,8 +300,8 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) size_t nkitsamples = nsamples * samplerate_scale; sample_t kitsamples[nkitsamples]; - memset(rs, 0, nkitsamples * sizeof(sample_t)); - getSamples(c, pos * samplerate_scale, rs, nkitsamples); + memset(kitsamples, 0, nkitsamples * sizeof(sample_t)); + getSamples(c, pos * samplerate_scale, kitsamples, nkitsamples); #ifdef ZITA Resampler resampler; -- cgit v1.2.3 From fcac65c66436faa23b8ea10ec8465ac6221e10d2 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:08:15 +0200 Subject: Removed PUGL code --- plugingui/Makefile.am.plugingui | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plugingui/Makefile.am.plugingui b/plugingui/Makefile.am.plugingui index 0b4f2d2..075ff3f 100644 --- a/plugingui/Makefile.am.plugingui +++ b/plugingui/Makefile.am.plugingui @@ -1,10 +1,4 @@ -if ENABLE_PUGL -puglsources = $(top_srcdir)/pugl/pugl/pugl_x11.c $(top_srcdir)/plugingui/nativewindow_pugl.cc -else -puglsources = -endif - PLUGIN_GUI_SOURCES = \ $(top_srcdir)/hugin/hugin.c \ $(top_srcdir)/hugin/hugin_syslog.c \ @@ -36,6 +30,7 @@ PLUGIN_GUI_SOURCES = \ $(top_srcdir)/plugingui/combobox.cc \ $(top_srcdir)/plugingui/progressbar.cc \ $(top_srcdir)/plugingui/verticalline.cc \ + $(top_srcdir)/plugingui/config.cc \ $(top_srcdir)/plugingui/resource.cc \ $(top_srcdir)/plugingui/resource_data.cc \ $(top_srcdir)/plugingui/lodepng/lodepng.cpp -- cgit v1.2.3 From e46c013eff23e85d41b04d05663a692143e2977d Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:09:58 +0200 Subject: Added missing semicolon. --- plugingui/directory.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index d481d24..61b1441 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -320,7 +320,7 @@ bool Directory::isHidden(std::string path) { // TODO: Handle hidden and system files in windows #ifdef WIN32 - return false + return false; #else unsigned pos = path.find_last_of("/\\"); std::string entry = path.substr(pos+1); -- cgit v1.2.3 From c35e6f3ae438fb63c571f807037417d9d71b2afd Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:15:41 +0200 Subject: Added global configfile/history file. --- plugingui/Makefile.am | 1 + plugingui/pluginconfig.cc | 130 ++++++++++++++++++++++++++++++++++++++++++++++ plugingui/pluginconfig.h | 48 +++++++++++++++++ plugingui/plugingui.cc | 28 ++++++++++ plugingui/plugingui.h | 3 ++ 5 files changed, 210 insertions(+) create mode 100644 plugingui/pluginconfig.cc create mode 100644 plugingui/pluginconfig.h diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index 3cf60a5..79e25e4 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -26,6 +26,7 @@ EXTRA_DIST = \ button.h \ checkbox.h \ colour.h \ + config.h \ combobox.h \ directory.h \ eventhandler.h \ diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc new file mode 100644 index 0000000..57a4e08 --- /dev/null +++ b/plugingui/pluginconfig.cc @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * config.cc + * + * Tue Jun 3 13:54:05 CEST 2014 + * Copyright 2014 Jonas Suhr Christensen + * jsc@umbraculum.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 "config.h" + +#include +#include +#include +#include + +#include "directory.h" + +#ifdef WIN32 +#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() +{ + +} + +Config::~Config() +{ + +} + +FILE* openFilePtr(std::string mode) { +#ifdef WIN32 + TCHAR szPath[256]; + if(SUCCEEDED(SHGetFolderPath(NULL, + CSIDL_APPDATA | CSIDL_FLAG_CREATE, + NULL, + 0, + szPath))); { + DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); +// PathAppend(szPath, TEXT( +// PathAppend(szPath, TEXT(CONFIGFILENAME)); +// HANDLE hFile = CreateFile(szPath, GENERIC_READ | GENERIC_WRITE, 0, NULL); + } +#else + std::string configpath = strdup(getenv("HOME")); + configpath += SEP; + configpath += CONFIGDIRNAME; + if(!Directory::exists(configpath)) { + if( (mkdir(configpath.c_str(), 0755)) < 0) return NULL; + } +#endif + + FILE *fp; + std::string configfile = configpath; + configfile += SEP; + configfile += CONFIGFILENAME; + if(! (fp = fopen(configfile.c_str(), mode.c_str())) ) { + return NULL; + } + + return fp; +} + +void Config::load() +{ + FILE *fp = openFilePtr("r"); + if(!fp) return; + + lastkit.clear(); + lastmidimap.clear(); + + char buf[4096]; + while( fgets(buf, 4096, fp) ) { + if(!strncmp(buf, "lastkit:", 8)) { + // Dont copy newline + if(strlen(buf) > 8 + 1) lastkit.append(buf+8, strlen(buf+8) - 1); + } + if(!strncmp(buf, "lastmidimap:", 12)) { + // Dont copy newline + if(strlen(buf) > 12+1) lastmidimap.append(buf+12, strlen(buf+12) - 1); + } + } +} + +void Config::save() +{ + FILE *fp = openFilePtr("w"); + if(!fp) return; + + std::string buf; + buf.append("lastkit:" + lastkit + '\n'); + buf.append("lastmidimap:" + lastmidimap + '\n'); + + fputs(buf.c_str(), fp); + + fclose(fp); +} diff --git a/plugingui/pluginconfig.h b/plugingui/pluginconfig.h new file mode 100644 index 0000000..d0e9bcd --- /dev/null +++ b/plugingui/pluginconfig.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * config.h + * + * Tue Jun 3 13:51:29 CEST 2014 + * Copyright 2014 Jonas Suhr Christensen + * jsc@umbraculum.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_CONFIG_H__ +#define __DRUMGIZMO_CONFIG_H__ + +#include +#include + +#define DIRECTORY_HIDDEN 1 + +class Config { + + public: + Config(); + ~Config(); + + void load(); + void save(); + + std::string lastkit; + std::string lastmidimap; +}; + +#endif/*__DRUMGIZMO_CONFIG_H__*/ diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 6601be7..86f3758 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -33,6 +33,7 @@ #include "verticalline.h" #include "../version.h" +#include "config.h" #include "messagehandler.h" static void checkClick(void *ptr) @@ -81,6 +82,12 @@ static void knobChange2(void *ptr) #endif } +static void quit(void *ptr) { + PluginGUI *gui = (PluginGUI*)ptr; + + gui->stopThread(); +} + GUI::FileBrowser *fb; static void selectKitFile(void *ptr, std::string filename) { @@ -91,6 +98,8 @@ static void selectKitFile(void *ptr, std::string filename) std::string drumkit = gui->lineedit->text(); + gui->config->lastkit = drumkit; + gui->progress->setProgress(0); gui->progress->setState(GUI::ProgressBar::blue); @@ -105,6 +114,7 @@ static void kitBrowseClick(void *ptr) PluginGUI *gui = (PluginGUI*)ptr; std::string path = gui->lineedit->text(); + if(path == "") path = gui->config->lastkit; if(path == "") path = gui->lineedit2->text(); fb->setPath(path); @@ -121,6 +131,8 @@ static void selectMapFile(void *ptr, std::string filename) std::string midimap = gui->lineedit2->text(); + gui->config->lastmidimap = midimap; + LoadMidimapMessage *msg = new LoadMidimapMessage(); msg->midimapfile = midimap; msghandler.sendMessage(MSGRCV_ENGINE, msg); @@ -137,6 +149,7 @@ static void midimapBrowseClick(void *ptr) PluginGUI *gui = (PluginGUI*)ptr; std::string path = gui->lineedit2->text(); + if(path == "") path = gui->config->lastmidimap; if(path == "") path = gui->lineedit->text(); fb->setPath(path); @@ -269,6 +282,10 @@ void PluginGUI::thread_main() void PluginGUI::deinit() { if(window) delete window; + if(config) { + config->save(); + delete config; + } } void closeEventHandler(void *ptr) @@ -280,6 +297,10 @@ void closeEventHandler(void *ptr) void PluginGUI::init() { DEBUG(gui, "init"); + + config = new Config(); + config->load(); + window = new GUI::Window(); window->eventHandler()->registerCloseHandler(closeEventHandler, (void*)&closing); @@ -428,6 +449,13 @@ void PluginGUI::init() filebrowser->hide(); fb = filebrowser; + // Enable quit button + GUI::Button *btn_quit = new GUI::Button(window); + btn_quit->setText("Quit"); + btn_quit->move(50,280); + btn_quit->resize(80,80); + btn_quit->registerClickHandler(quit, this); + window->show(); sem.post(); diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h index 7ec5e77..9fb8d6a 100644 --- a/plugingui/plugingui.h +++ b/plugingui/plugingui.h @@ -36,6 +36,7 @@ #include "button.h" #include "knob.h" #include "progressbar.h" +#include "config.h" #include "filebrowser.h" @@ -80,6 +81,8 @@ public: GUI::LineEdit *lineedit2; GUI::ProgressBar *progress2; + Config *config; + void (*windowClosedHandler)(void *); void *windowClosedPtr; -- cgit v1.2.3 From d1717aedda6ed9dbe0996ebcc6f781497b8ef932 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:16:54 +0200 Subject: . --- plugingui/Makefile.am | 2 +- plugingui/plugingui.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index 79e25e4..32228f4 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = \ button.h \ checkbox.h \ colour.h \ - config.h \ + pluginconfig.h \ combobox.h \ directory.h \ eventhandler.h \ diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h index 9fb8d6a..f94a062 100644 --- a/plugingui/plugingui.h +++ b/plugingui/plugingui.h @@ -36,7 +36,7 @@ #include "button.h" #include "knob.h" #include "progressbar.h" -#include "config.h" +#include "pluginconfig.h" #include "filebrowser.h" -- cgit v1.2.3 From 2821c2da5d69e63ec916dcf618140ab0dd3694da Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:17:36 +0200 Subject: . --- plugingui/plugingui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 86f3758..7dd2ba6 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -33,7 +33,7 @@ #include "verticalline.h" #include "../version.h" -#include "config.h" +#include "pluginconfig.h" #include "messagehandler.h" static void checkClick(void *ptr) -- cgit v1.2.3 From 98d924b7b28b33f460925402623a25fd06a80b02 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:18:14 +0200 Subject: . --- plugingui/Makefile.am.plugingui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/Makefile.am.plugingui b/plugingui/Makefile.am.plugingui index 075ff3f..bd703b2 100644 --- a/plugingui/Makefile.am.plugingui +++ b/plugingui/Makefile.am.plugingui @@ -30,7 +30,7 @@ PLUGIN_GUI_SOURCES = \ $(top_srcdir)/plugingui/combobox.cc \ $(top_srcdir)/plugingui/progressbar.cc \ $(top_srcdir)/plugingui/verticalline.cc \ - $(top_srcdir)/plugingui/config.cc \ + $(top_srcdir)/plugingui/pluginconfig.cc \ $(top_srcdir)/plugingui/resource.cc \ $(top_srcdir)/plugingui/resource_data.cc \ $(top_srcdir)/plugingui/lodepng/lodepng.cpp -- cgit v1.2.3 From b1ee499b55f9226c94a94668b5416fc7a83c541c Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:18:46 +0200 Subject: . --- plugingui/pluginconfig.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 57a4e08..7c0bd9c 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -24,7 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include "config.h" +#include "pluginconfig.h" #include #include -- cgit v1.2.3 From 4a8ca1a0b2f734c58bd0746e4d205d1a6ce5bb60 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:20:46 +0200 Subject: . --- INSTALL | 8 ++++---- plugingui/Makefile.mingw32 | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index 007e939..a1e89e1 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,7 @@ Installation Instructions ************************* -Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, +Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, @@ -309,10 +309,9 @@ causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf limitation. Until the limitation is lifted, you can use -this workaround: +an Autoconf bug. Until the bug is fixed you can use this workaround: - CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== @@ -368,3 +367,4 @@ operates. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. + diff --git a/plugingui/Makefile.mingw32 b/plugingui/Makefile.mingw32 index 3a9542a..7863463 100644 --- a/plugingui/Makefile.mingw32 +++ b/plugingui/Makefile.mingw32 @@ -40,6 +40,7 @@ CXX_SOURCES = \ $(top_srcdir)/plugingui/resource.cc \ $(top_srcdir)/plugingui/resource_data.cc \ $(top_srcdir)/plugingui/lodepng/lodepng.cpp \ + $(top_srcdir)/plugingui/pluginconfig.cc \ $(top_srcdir)/src/thread.cc \ $(top_srcdir)/src/semaphore.cc \ $(top_srcdir)/src/mutex.cc \ -- cgit v1.2.3 From 1ebb10c03a68c1b973e2a835ceb9e9f1f733872b Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:22:11 +0200 Subject: Added missing header. --- plugingui/pluginconfig.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 7c0bd9c..2d76238 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -36,6 +36,7 @@ #ifdef WIN32 #include #include +#include #else #endif -- cgit v1.2.3 From 656b0a0d500d1e238d0e0bca9dae3769d9aa9d7f Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:24:19 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 2d76238..913d7c7 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -71,6 +71,7 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); + std::string configpath = "."; // PathAppend(szPath, TEXT( // PathAppend(szPath, TEXT(CONFIGFILENAME)); // HANDLE hFile = CreateFile(szPath, GENERIC_READ | GENERIC_WRITE, 0, NULL); -- cgit v1.2.3 From 9e15b5befb1ad49a830d63b2c3dc59bff78487b7 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:29:14 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 913d7c7..d426e64 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -64,6 +64,7 @@ Config::~Config() FILE* openFilePtr(std::string mode) { #ifdef WIN32 + std::string configpath = "."; TCHAR szPath[256]; if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, @@ -71,10 +72,8 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); - std::string configpath = "."; -// PathAppend(szPath, TEXT( -// PathAppend(szPath, TEXT(CONFIGFILENAME)); -// HANDLE hFile = CreateFile(szPath, GENERIC_READ | GENERIC_WRITE, 0, NULL); + PathAppend(szPath, TEXT(CONFIGDIRNAME)); + HANDLE hFile = CreateFile(szPath, GENERIC_READ | GENERIC_WRITE, 0, NULL); } #else std::string configpath = strdup(getenv("HOME")); -- cgit v1.2.3 From f6d7d74ea3f9942f724565f060a7dbce59d56e3f Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:33:22 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index d426e64..7c96147 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -37,6 +37,7 @@ #include #include #include +#include #else #endif -- cgit v1.2.3 From 85a28457cee04bdbf265ab4553da75b599b3dbff Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:36:57 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 7c96147..81bff0e 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -72,9 +72,11 @@ FILE* openFilePtr(std::string mode) { NULL, 0, szPath))); { - DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); - PathAppend(szPath, TEXT(CONFIGDIRNAME)); - HANDLE hFile = CreateFile(szPath, GENERIC_READ | GENERIC_WRITE, 0, NULL); + DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); + PathAppend(szPath, TEXT(CONFIGDIRNAME)); + if(!Directory::exists(configpath)) { + CreateDirectory(szPath, NULL); + } } #else std::string configpath = strdup(getenv("HOME")); -- cgit v1.2.3 From c2eb6898f474ac018b649e28a73efa5deef1731c Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:37:58 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 81bff0e..94ca900 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -73,7 +73,7 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); - PathAppend(szPath, TEXT(CONFIGDIRNAME)); +// PathAppend(szPath, TEXT(CONFIGDIRNAME)); if(!Directory::exists(configpath)) { CreateDirectory(szPath, NULL); } -- cgit v1.2.3 From 121f3eacaf0e703744a678e565d33b30f9abdf85 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:38:35 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 94ca900..6bd4913 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -73,10 +73,10 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); -// PathAppend(szPath, TEXT(CONFIGDIRNAME)); - if(!Directory::exists(configpath)) { - CreateDirectory(szPath, NULL); - } + PathAppend(szPath, TEXT(CONFIGDIRNAME)); +// if(!Directory::exists(configpath)) { +// CreateDirectory(szPath, NULL); +// } } #else std::string configpath = strdup(getenv("HOME")); -- cgit v1.2.3 From e60bc9eb6815bfa161d14ac55a86ec6f763dcc11 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:39:11 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 6bd4913..ba21f69 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -73,7 +73,7 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); - PathAppend(szPath, TEXT(CONFIGDIRNAME)); + PathAppend(szPath, TEXT("drumgizmo")); // if(!Directory::exists(configpath)) { // CreateDirectory(szPath, NULL); // } -- cgit v1.2.3 From 21fbfc8d8f29ff6796c01e57efa568b84e19552a Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:40:14 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index ba21f69..ac41ef6 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -73,7 +73,7 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); - PathAppend(szPath, TEXT("drumgizmo")); + PathAppend(szPath, drumgizmo); // if(!Directory::exists(configpath)) { // CreateDirectory(szPath, NULL); // } -- cgit v1.2.3 From c7cc7a1ae1b379d681392f3e0672dcc5820ae45c Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 5 Aug 2014 20:40:35 +0200 Subject: Fixing windows. --- plugingui/pluginconfig.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index ac41ef6..59acba4 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -73,7 +73,7 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); - PathAppend(szPath, drumgizmo); + PathAppend(szPath, "drumgizmo"); // if(!Directory::exists(configpath)) { // CreateDirectory(szPath, NULL); // } -- cgit v1.2.3 From cfa067c18ba819c0cc6c1d8c9fd01f245f925528 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:17:48 +0200 Subject: Added some debug. --- plugingui/pluginconfig.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 59acba4..f89e8e5 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -47,7 +47,7 @@ #ifdef WIN32 #define SEP "\\" - #define CONFIGDIRNAME "drumgizmo" + #define CONFIGDIRNAME ".drumgizmo" #else #define SEP "/" #define CONFIGDIRNAME ".drumgizmo" @@ -83,7 +83,11 @@ FILE* openFilePtr(std::string mode) { configpath += SEP; configpath += CONFIGDIRNAME; if(!Directory::exists(configpath)) { - if( (mkdir(configpath.c_str(), 0755)) < 0) return NULL; + DEBUG(pluginconfig, "No configuration exists, creating directory '%s'\n", configpath.c_str()); + if( (mkdir(configpath.c_str(), 0755)) < 0) { + DEBUG(pluginconfig, "Could not create config directory\n"); + } + return NULL; } #endif @@ -91,6 +95,8 @@ FILE* openFilePtr(std::string mode) { std::string configfile = configpath; configfile += SEP; configfile += CONFIGFILENAME; + + DEBUG(pluginconfig, "Reading config file '%s'\n", configfile.c_str()); if(! (fp = fopen(configfile.c_str(), mode.c_str())) ) { return NULL; } @@ -100,6 +106,7 @@ FILE* openFilePtr(std::string mode) { void Config::load() { + DEBUG(pluginconfig, "Loading config file...\n"); FILE *fp = openFilePtr("r"); if(!fp) return; @@ -109,12 +116,18 @@ void Config::load() 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); + 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()); } } } -- cgit v1.2.3 From 5ef1c21b0441e8b261c2735a8ffd2d3864c66cea Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:20:40 +0200 Subject: Testing config file creation on windows XP. --- plugingui/pluginconfig.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index f89e8e5..633b436 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -73,7 +73,7 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); - PathAppend(szPath, "drumgizmo"); +// PathAppend(szPath, "drumgizmo"); // if(!Directory::exists(configpath)) { // CreateDirectory(szPath, NULL); // } -- cgit v1.2.3 From ec56e2b8dfc586784ddaf7efc9a70baa85e3ce63 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:23:02 +0200 Subject: Testing config file creation on windows XP. --- plugingui/pluginconfig.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 633b436..ad94d7e 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -72,6 +72,7 @@ FILE* openFilePtr(std::string mode) { NULL, 0, szPath))); { + configpath = szPath; DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); // PathAppend(szPath, "drumgizmo"); // if(!Directory::exists(configpath)) { -- cgit v1.2.3 From 3916d352a8dddb53ff920d0709ab501fee5df89c Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:23:43 +0200 Subject: Testing config file creation on windows XP. --- plugingui/pluginconfig.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index ad94d7e..457735e 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -73,7 +73,7 @@ FILE* openFilePtr(std::string mode) { 0, szPath))); { configpath = szPath; - DEBUG(config, "WINDOWS APP DATA PATH:%s\n", szPath); + DEBUG(config, "WINDOWS APP DATA PATH:%s\n", configpath.c_str()); // PathAppend(szPath, "drumgizmo"); // if(!Directory::exists(configpath)) { // CreateDirectory(szPath, NULL); -- cgit v1.2.3 From a7d4f433c5baa072d1645bd2ba51353651cf66e5 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:24:46 +0200 Subject: Testing config file creation on windows XP. --- plugingui/pluginconfig.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 457735e..38cf616 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -74,13 +74,10 @@ FILE* openFilePtr(std::string mode) { szPath))); { configpath = szPath; DEBUG(config, "WINDOWS APP DATA PATH:%s\n", configpath.c_str()); -// PathAppend(szPath, "drumgizmo"); -// if(!Directory::exists(configpath)) { -// CreateDirectory(szPath, NULL); -// } } #else std::string configpath = strdup(getenv("HOME")); +#endif configpath += SEP; configpath += CONFIGDIRNAME; if(!Directory::exists(configpath)) { @@ -90,7 +87,6 @@ FILE* openFilePtr(std::string mode) { } return NULL; } -#endif FILE *fp; std::string configfile = configpath; -- cgit v1.2.3 From 71c3a215093b1a22127ac0936ea0b988436af1c2 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:26:09 +0200 Subject: Testing config file creation on windows XP. --- plugingui/pluginconfig.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 38cf616..1ce1e66 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -82,7 +82,11 @@ FILE* openFilePtr(std::string mode) { configpath += CONFIGDIRNAME; 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 NULL; -- cgit v1.2.3 From 7ce9dc89f3d2b072c69d70b1b5b2282b99012380 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:29:16 +0200 Subject: Testing config file creation on windows XP. --- plugingui/pluginconfig.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 1ce1e66..d129414 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -63,7 +63,7 @@ Config::~Config() } -FILE* openFilePtr(std::string mode) { +static FILE* openFilePtr(std::string mode) { #ifdef WIN32 std::string configpath = "."; TCHAR szPath[256]; @@ -135,6 +135,8 @@ void Config::load() void Config::save() { + DEBUG(pluginconfig, "Saving configuration...\n"); + FILE *fp = openFilePtr("w"); if(!fp) return; -- cgit v1.2.3 From 173a40e8a55416d759e05739eb9fdfba0ff59bbd Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:37:52 +0200 Subject: Testing config file creation on windows XP. --- plugingui/pluginconfig.cc | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index d129414..690d234 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -63,9 +63,9 @@ Config::~Config() } -static FILE* openFilePtr(std::string mode) { -#ifdef WIN32 - std::string configpath = "."; +static std::string configPath() { + #ifdef WIN32 + std::string configpath; TCHAR szPath[256]; if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, @@ -73,13 +73,19 @@ static FILE* openFilePtr(std::string mode) { 0, szPath))); { configpath = szPath; - DEBUG(config, "WINDOWS APP DATA PATH:%s\n", configpath.c_str()); } #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 @@ -89,9 +95,16 @@ static FILE* openFilePtr(std::string mode) { #endif DEBUG(pluginconfig, "Could not create config directory\n"); } - return NULL; + return false; } + return true; +} + +static FILE* openConfigFile(std::string mode) { + + std::string configpath = configPath(); + FILE *fp; std::string configfile = configpath; configfile += SEP; @@ -108,7 +121,7 @@ static FILE* openFilePtr(std::string mode) { void Config::load() { DEBUG(pluginconfig, "Loading config file...\n"); - FILE *fp = openFilePtr("r"); + FILE *fp = openConfigFile("r"); if(!fp) return; lastkit.clear(); @@ -137,7 +150,9 @@ void Config::save() { DEBUG(pluginconfig, "Saving configuration...\n"); - FILE *fp = openFilePtr("w"); + createConfigPath(); + + FILE *fp = openConfigFile("w"); if(!fp) return; std::string buf; -- cgit v1.2.3 From 4d14d8fa699161143ba13adf478a8ee1d6716d50 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:39:53 +0200 Subject: Testing config file creation on windows XP. --- plugingui/pluginconfig.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index 690d234..d57d9df 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -110,7 +110,7 @@ static FILE* openConfigFile(std::string mode) { configfile += SEP; configfile += CONFIGFILENAME; - DEBUG(pluginconfig, "Reading config file '%s'\n", configfile.c_str()); + DEBUG(pluginconfig, "Opening config file '%s'\n", configfile.c_str()); if(! (fp = fopen(configfile.c_str(), mode.c_str())) ) { return NULL; } -- cgit v1.2.3 From 8a25d02638a3fc52fa3d0521d33f5c0bd0dcd368 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:41:04 +0200 Subject: Testing config file creation on windows XP. --- plugingui/plugingui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 7dd2ba6..2dd93f9 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -281,11 +281,11 @@ void PluginGUI::thread_main() void PluginGUI::deinit() { - if(window) delete window; if(config) { config->save(); delete config; } + if(window) delete window; } void closeEventHandler(void *ptr) -- cgit v1.2.3 From 53a8feecfc203ebdc5c630c6c88466590393ed23 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:53:10 +0200 Subject: Testing config file creation on windows XP. --- plugingui/plugingui.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 2dd93f9..6996159 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -300,6 +300,7 @@ void PluginGUI::init() config = new Config(); config->load(); + config->save(); window = new GUI::Window(); window->eventHandler()->registerCloseHandler(closeEventHandler, -- cgit v1.2.3 From 5dde7cb0f1e980695f24e4111eb811112b0407ca Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 17:53:51 +0200 Subject: Testing config file creation on windows XP. --- plugingui/plugingui.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 6996159..2dd93f9 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -300,7 +300,6 @@ void PluginGUI::init() config = new Config(); config->load(); - config->save(); window = new GUI::Window(); window->eventHandler()->registerCloseHandler(closeEventHandler, -- cgit v1.2.3 From 89b7b3c16e0aabb5470bb6b8191eac9fbbeb9e49 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 18:05:01 +0200 Subject: Testing config file creation on windows XP. --- plugingui/directory.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index 61b1441..141d944 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -320,11 +320,14 @@ bool Directory::isHidden(std::string path) { // TODO: Handle hidden and system files in windows #ifdef WIN32 - return false; + DWORD fattribs = GetFileAttributes(path.c_str()); + if(fattribs & FILE_ATTRIBUTE_HIDDEN) { + return false; + } + return true; #else unsigned pos = path.find_last_of("/\\"); std::string entry = path.substr(pos+1); - if(entry.size() > 1 && entry.at(0) == '.' && entry.at(1) != '.') { -- cgit v1.2.3 From 4b3d17e132fe9c88162ff46c1d33f0438c1ba67d Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 18:06:15 +0200 Subject: Testing file attribute filter on windows XP. --- plugingui/directory.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index 141d944..ce695dc 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -322,9 +322,9 @@ bool Directory::isHidden(std::string path) #ifdef WIN32 DWORD fattribs = GetFileAttributes(path.c_str()); if(fattribs & FILE_ATTRIBUTE_HIDDEN) { - return false; + return true; } - return true; + return false; #else unsigned pos = path.find_last_of("/\\"); std::string entry = path.substr(pos+1); -- cgit v1.2.3 From c71c82e1c86c811920a31916324cd6af263517f9 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 18:07:43 +0200 Subject: Testing file attribute filter on windows XP. --- plugingui/directory.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index ce695dc..a94b0b4 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -318,22 +318,29 @@ bool Directory::exists(std::string path) bool Directory::isHidden(std::string path) { + DEBUG(directory, "Is '%s' hidden?\n", path.c_str()); // TODO: Handle hidden and system files in windows #ifdef WIN32 DWORD fattribs = GetFileAttributes(path.c_str()); if(fattribs & FILE_ATTRIBUTE_HIDDEN) { + DEBUG(directory, "\t...yes!\n"); return true; } - return false; + else { + DEBUG(directory, "\t...no!\n"); + return false; + } #else unsigned pos = path.find_last_of("/\\"); std::string entry = path.substr(pos+1); if(entry.size() > 1 && entry.at(0) == '.' && entry.at(1) != '.') { + DEBUG(directory, "\t...yes!\n"); return true; } else { + DEBUG(directory, "\t...no!\n"); return false; } #endif -- cgit v1.2.3 From 690c230a3add27a5cb552f89ee40705b7965b2af Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 18:09:52 +0200 Subject: Testing file attribute filter on windows XP. --- plugingui/directory.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index a94b0b4..5a2c7a1 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -181,8 +181,8 @@ Directory::EntryList Directory::listFiles(std::string path, unsigned char filter #ifdef WIN32 - DEBUG(directory, "root is %s\n", Directory::root(path).c_str()); - DEBUG(directory, "current path %s is root? %d", path.c_str(), Directory::isRoot(path)); + DEBUG(directory, "Root is %s\n", Directory::root(path).c_str()); + DEBUG(directory, "Current path %s is root? %d", path.c_str(), Directory::isRoot(path)); if(Directory::isRoot(path)) entries.push_back(".."); #endif @@ -289,7 +289,7 @@ bool Directory::isDir() bool Directory::isDir(std::string path) { - DEBUG(directory, "Is '%s' dir?\n", path.c_str()); + DEBUG(directory, "Is '%s' a directory?\n", path.c_str()); struct stat st; if(stat(path.c_str(), &st) == 0) { if((st.st_mode & S_IFDIR) != 0) { -- cgit v1.2.3 From 8681d056216b49a9963cbaa177dd3c4b7f76cb69 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 18:17:31 +0200 Subject: Testing file attribute filter on windows XP. --- plugingui/directory.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index 5a2c7a1..48e67c6 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -151,7 +151,7 @@ Directory::EntryList Directory::listFiles(std::string path, unsigned char filter if(Directory::isRoot(path) && name == "..") continue; unsigned char entryinfo = 0; - if(isHidden(name)) { + if(isHidden(path + SEP + name)) { entryinfo |= DIRECTORY_HIDDEN; } @@ -293,11 +293,11 @@ bool Directory::isDir(std::string path) struct stat st; if(stat(path.c_str(), &st) == 0) { if((st.st_mode & S_IFDIR) != 0) { - DEBUG(directory, "Yes\n"); + DEBUG(directory, "\t...yes!\n"); return true; } } - DEBUG(directory, "No\n"); + DEBUG(directory, "\t...no!\n"); return false; } -- cgit v1.2.3 From 5a81864b7f9b2c205d779b74ddb2e25d0df75f3e Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 18:28:07 +0200 Subject: Testing file attribute filter on windows XP. --- plugingui/directory.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index 48e67c6..ff0fa05 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -319,8 +319,14 @@ bool Directory::exists(std::string path) bool Directory::isHidden(std::string path) { DEBUG(directory, "Is '%s' hidden?\n", path.c_str()); - // TODO: Handle hidden and system files in windows #ifdef WIN32 + // We dont want to filter out '..' pointing to root of a partition + unsigned pos = path.find_last_of("/\\"); + std::string entry = path.substr(pos+1); + if(entry == "..") { + return false; + } + DWORD fattribs = GetFileAttributes(path.c_str()); if(fattribs & FILE_ATTRIBUTE_HIDDEN) { DEBUG(directory, "\t...yes!\n"); -- cgit v1.2.3 From 28947d69c2babe1e2eb347ed01d0928ed05eac2d Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 18:30:20 +0200 Subject: Testing file attribute filter on windows XP. --- plugingui/directory.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index ff0fa05..1465c86 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -332,6 +332,10 @@ bool Directory::isHidden(std::string path) DEBUG(directory, "\t...yes!\n"); return true; } + else if(fattribs & FILE_ATTRIBUTE_SYSTEM) { + DEBUG(directory, "\t...yes!\n"); + return true; + } else { DEBUG(directory, "\t...no!\n"); return false; -- cgit v1.2.3 From 6f0edf4dbb11278f5cce9506b3af2b7940b45824 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 18:36:34 +0200 Subject: Added features (Needs testing on Windows 7): * Filtering out hidden and system files. * GUI configuration file to save values from session to session. --- plugingui/plugingui.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 2dd93f9..b235af3 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -82,11 +82,11 @@ static void knobChange2(void *ptr) #endif } -static void quit(void *ptr) { - PluginGUI *gui = (PluginGUI*)ptr; - - gui->stopThread(); -} +//static void quit(void *ptr) { +// PluginGUI *gui = (PluginGUI*)ptr; +// +// gui->stopThread(); +//} GUI::FileBrowser *fb; static void selectKitFile(void *ptr, std::string filename) @@ -450,11 +450,11 @@ void PluginGUI::init() fb = filebrowser; // Enable quit button - GUI::Button *btn_quit = new GUI::Button(window); - btn_quit->setText("Quit"); - btn_quit->move(50,280); - btn_quit->resize(80,80); - btn_quit->registerClickHandler(quit, this); +// GUI::Button *btn_quit = new GUI::Button(window); +// btn_quit->setText("Quit"); +// btn_quit->move(50,280); +// btn_quit->resize(80,80); +// btn_quit->registerClickHandler(quit, this); window->show(); -- cgit v1.2.3 From 5fbec7c02c6677d701675bfcfd529bb646b4bea8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 4 Oct 2014 17:31:19 +0200 Subject: Add samplerate() method to lv2 output engine. --- lv2/lv2.cc | 2 +- lv2/output_lv2.cc | 22 ++++++---------------- lv2/output_lv2.h | 6 +++++- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lv2/lv2.cc b/lv2/lv2.cc index 3aeb5f0..9ec7706 100644 --- a/lv2/lv2.cc +++ b/lv2/lv2.cc @@ -248,7 +248,7 @@ LV2_Handle instantiate(const struct _LV2_Descriptor *descriptor, dg_descriptor.get_pci = dg_get_pci; dglv2->in = new InputLV2(); - dglv2->out = new OutputLV2(); + dglv2->out = new OutputLV2(sample_rate); dglv2->buffer = NULL; dglv2->buffer_size = 0; diff --git a/lv2/output_lv2.cc b/lv2/output_lv2.cc index 8187a5a..b4a6877 100644 --- a/lv2/output_lv2.cc +++ b/lv2/output_lv2.cc @@ -28,8 +28,9 @@ #include -OutputLV2::OutputLV2() +OutputLV2::OutputLV2(double sample_rate) { + this->sample_rate = sample_rate; for(size_t i = 0; i < NUM_OUTPUTS; i++) { outputPorts[i].size = 0; outputPorts[i].samples = NULL; @@ -83,19 +84,8 @@ sample_t *OutputLV2::getBuffer(int ch) return NULL; } -#ifdef TEST_OUTPUT_LV2 -//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; +size_t OutputLV2::samplerate() +{ + return sample_rate; +} -#endif/*TEST_OUTPUT_LV2*/ diff --git a/lv2/output_lv2.h b/lv2/output_lv2.h index 1b4e8c9..272a78c 100644 --- a/lv2/output_lv2.h +++ b/lv2/output_lv2.h @@ -39,7 +39,7 @@ public: class OutputLV2 : public AudioOutputEngine { public: - OutputLV2(); + OutputLV2(double sample_rate); ~OutputLV2(); bool init(Channels channels); @@ -54,9 +54,13 @@ public: void post(size_t nsamples); sample_t *getBuffer(int c); + + size_t samplerate(); // sample_t *outputPort[NUM_OUTPUTS]; OutputPort outputPorts[NUM_OUTPUTS]; + + double sample_rate; }; #endif/*__DRUMGIZMO_OUTPUT_LV2_H__*/ -- cgit v1.2.3 From 484eb4f976568ba058c91a36f6482a404e35d486 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 12 Oct 2014 21:15:03 +0200 Subject: Add zita resampler and libsamplerate to comnfigure. --- configure.ac | 108 ++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 73 insertions(+), 35 deletions(-) diff --git a/configure.ac b/configure.ac index d8d45d4..68dffad 100644 --- a/configure.ac +++ b/configure.ac @@ -346,44 +346,82 @@ dnl Check for sndfile dnl ====================== PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.20) -AC_ARG_WITH(resample, [ --with-resample Build with resample support]) -if test x$with_resample == xyes; then + +AC_ARG_ENABLE([resampler], +[ --enable-resampler[=lib] Enable resampler using either 'zita' or 'src' (libsamplerate). Use 'auto' for autodetect [default=auto]],, + [enable_resampler="auto"]) +if test "x$enable_resampler" = "xyes"; then + enable_resampler="auto" +fi + +has_src=no +has_zita=no +if test x$enable_resampler != xno; then AC_MSG_WARN([*** Building resample support!]) - AC_DEFINE(WITH_RESAMPLE, [], [Use resample]) + AC_DEFINE(WITH_RESAMPLER, [], [Use resample]) - dnl ====================== - dnl Check for libsamplerate - dnl ====================== - PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.1.7) + if test x$enable_resampler == xauto || test x$enable_resampler == xsrc; then + dnl ====================== + dnl Check for libsamplerate + dnl ====================== + PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.1.7, has_src=yes, has_src=no) + fi -# dnl ====================== -# dnl Check for the zitaresampler library -# dnl ====================== -# AC_LANG_PUSH([C++]) -# tmp_CXXFLAGS="$CXXFLAGS" -# tmp_CPPFLAGS="$CPPFLAGS" -# tmp_CFLAGS="$CFLAGS" -# tmp_LDFLAGS="$LDFLAGS" -# tmp_LIBS="$LIBS" -# CXXFLAGS="" -# CPPFLAGS="$ZITA_CPPFLAGS" -# CFLAGS="" -# LDFLAGS="$ZITA_LDFLAGS" -# LIBS="" -# AC_CHECK_HEADER(zita-resampler/resampler.h, , -# AC_MSG_ERROR([*** zita-resampler header files not found! Set ZITA_CPPFLAGS to add searchpath.])) -# AC_CHECK_LIB(zita-resampler, _Z28zita_resampler_major_versionv, , -# AC_MSG_ERROR([*** zita-resampler library not found! Set ZITA_LDFLAGS to add searchpath.])) -# ZITA_CPPFLAGS="$CXXFLAGS $CPPFLAGS $CFLAGS" -# ZITA_LIBS="$LDFLAGS $LIBS" -# CXXFLAGS="$tmp_CXXFLAGS" -# CPPFLAGS="$tmp_CPPFLAGS" -# CFLAGS="$tmp_CFLAGS" -# LDFLAGS="$tmp_LDFLAGS" -# LIBS="$tmp_LIBS" -# AC_SUBST(ZITA_CPPFLAGS) -# AC_SUBST(ZITA_LIBS) -# AC_LANG_POP([C++]) + if test x$enable_resampler == xauto || test x$enable_resampler == xzita; then + dnl ====================== + dnl Check for the zitaresampler library + dnl ====================== + AC_LANG_PUSH([C++]) + tmp_CXXFLAGS="$CXXFLAGS" + tmp_CPPFLAGS="$CPPFLAGS" + tmp_CFLAGS="$CFLAGS" + tmp_LDFLAGS="$LDFLAGS" + tmp_LIBS="$LIBS" + CXXFLAGS="" + CPPFLAGS="$ZITA_CPPFLAGS" + CFLAGS="" + LDFLAGS="$ZITA_LDFLAGS" + LIBS="" + AC_CHECK_HEADER(zita-resampler/resampler.h, + AC_CHECK_LIB(zita-resampler, _Z28zita_resampler_major_versionv, has_zita=yes, has_zita=no), + has_zita=no) + ZITA_CPPFLAGS="$CXXFLAGS $CPPFLAGS $CFLAGS" + ZITA_LIBS="$LDFLAGS $LIBS -lzita-resampler" + CXXFLAGS="$tmp_CXXFLAGS" + CPPFLAGS="$tmp_CPPFLAGS" + CFLAGS="$tmp_CFLAGS" + LDFLAGS="$tmp_LDFLAGS" + LIBS="$tmp_LIBS" + AC_SUBST(ZITA_CPPFLAGS) + AC_SUBST(ZITA_LIBS) + AC_LANG_POP([C++]) + fi +fi + +if test x$enable_resampler == xauto; then + if test x$has_zita == xyes; then + enable_resampler=zita + elif test x$has_src == xyes; then + enable_resampler=src + else + AC_MSG_ERROR([*** No resampler library present. Either libsamplerate or zita-resampler must be installed.]) + fi +fi + +if test x$enable_resampler == xzita; then + if test x$has_zita == xyes; then + AC_DEFINE(USE_ZITA, [], [zita-resampler is present]) + else + AC_MSG_ERROR([*** zita-resampler library or headers not found. Set ZITA_LDFLAGS or ZITA_CPPFLAGS to add searchpath.]) + fi +fi + +if test x$enable_resampler == xsrc; then + if test x$has_src == xyes; then + AC_DEFINE(USE_SRC, [], [libsamplerate is present]) + else + AC_MSG_ERROR([*** Missing libsamplerate.]) + fi fi #dnl ====================== -- cgit v1.2.3 From fafc815d3b2f525e703ab9482a008201097ab90d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 12 Oct 2014 21:15:56 +0200 Subject: Add new resampler class and use it in engine. --- src/Makefile.am.drumgizmo | 1 + src/chresampler.cc | 170 ++++++++++++++++++++++++++++++++++++++++++++++ src/chresampler.h | 65 ++++++++++++++++++ src/drumgizmo.cc | 138 ++++++++++++++++++------------------- src/drumgizmo.h | 8 ++- 5 files changed, 313 insertions(+), 69 deletions(-) create mode 100644 src/chresampler.cc create mode 100644 src/chresampler.h diff --git a/src/Makefile.am.drumgizmo b/src/Makefile.am.drumgizmo index da5d839..26e2a30 100644 --- a/src/Makefile.am.drumgizmo +++ b/src/Makefile.am.drumgizmo @@ -3,6 +3,7 @@ DRUMGIZMO_SOURCES = \ $(top_srcdir)/src/audiofile.cc \ $(top_srcdir)/src/channel.cc \ $(top_srcdir)/src/channelmixer.cc \ + $(top_srcdir)/src/chresampler.cc \ $(top_srcdir)/src/configuration.cc \ $(top_srcdir)/src/configparser.cc \ $(top_srcdir)/src/drumgizmo.cc \ diff --git a/src/chresampler.cc b/src/chresampler.cc new file mode 100644 index 0000000..301e650 --- /dev/null +++ b/src/chresampler.cc @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * chresampler.cc + * + * Tue Sep 23 20:42:14 CEST 2014 + * Copyright 2014 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 "chresampler.h" + +#include +#include +#include + +#ifdef WITH_RESAMPLER + +#if defined(USE_ZITA) + #include +#elif defined(USE_SRC) + #include +#else + #error "No resampler selected" +#endif + +class CHResampler::Prv { +public: +#if defined(USE_ZITA) + Resampler zita; +#elif defined(USE_SRC) + SRC_STATE *state; + SRC_DATA data; +#endif +}; + +CHResampler::CHResampler() +{ + input_fs = 44100; + output_fs = 44100; + + prv = new Prv(); +#if defined(SRC) + prv->state = NULL; +#endif +} + +void CHResampler::setup(double input_fs, double output_fs) +{ + int nchan = 1; // always mono + + this->input_fs = input_fs; + this->output_fs = output_fs; + +#if defined(USE_ZITA) + DEBUG(resampler, "Using zita-resampler (%d -> %d)", (int)input_fs, (int)output_fs); + + int hlen = 72; // 16 ≤ hlen ≤ 96 + // delay is 2 * hlen, 72 corresponds to delay introduced by SRC. + prv->zita.setup(input_fs, output_fs, nchan, hlen); +#elif defined(USE_SRC) + DEBUG(resampler, "Using libsamplerate (%d -> %d)", (int)input_fs, (int)output_fs); + + int err; + prv->state = src_new(SRC_SINC_BEST_QUALITY, nchan, &err); + (void)err; + // printf("err: %d\n", err); + src_set_ratio(prv->state, output_fs / input_fs); + prv->data.src_ratio = output_fs / input_fs; + prv->data.end_of_input = 0; +#endif +} + +CHResampler::~CHResampler() +{ +#if defined(USE_ZITA) +#elif defined(USE_SRC) + if(prv->state) src_delete(prv->state); +#endif + delete prv; +} + +void CHResampler::setInputSamples(float *samples, size_t count) +{ +#if defined(USE_ZITA) + prv->zita.inp_data = samples; + prv->zita.inp_count = count; +#elif defined(USE_SRC) + prv->data.data_in = samples; + prv->data.input_frames = count; +#endif +} + +void CHResampler::setOutputSamples(float *samples, size_t count) +{ +#if defined(USE_ZITA) + prv->zita.out_data = samples; + prv->zita.out_count = count; +#elif defined(USE_SRC) + prv->data.data_out = samples; + prv->data.output_frames = count; +#endif +} + +void CHResampler::process() +{ +#if defined(USE_ZITA) + prv->zita.process(); +#elif defined(USE_SRC) + src_process(prv->state, &prv->data); + prv->data.output_frames -= prv->data.output_frames_gen; + prv->data.data_out += prv->data.output_frames_gen; + prv->data.input_frames -= prv->data.input_frames_used; + prv->data.data_in += prv->data.input_frames_used; +#endif +} + +size_t CHResampler::getInputSampleCount() +{ +#if defined(USE_ZITA) + return prv->zita.inp_count; +#elif defined(USE_SRC) + return prv->data.input_frames; +#endif +} + +size_t CHResampler::getOutputSampleCount() +{ +#if defined(USE_ZITA) + return prv->zita.out_count; +#elif defined(USE_SRC) + return prv->data.output_frames; +#endif +} + +double CHResampler::ratio() +{ + return input_fs / output_fs; +} + +#else + +// Dummy implementation +CHResampler::CHResampler() {} +CHResampler::~CHResampler() {} +void CHResampler::setup(double, double) {} +void CHResampler::setInputSamples(float *, size_t) {} +void CHResampler::setOutputSamples(float *, size_t) {} +void CHResampler::process() {} +size_t CHResampler::getInputSampleCount() { return 0; } +size_t CHResampler::getOutputSampleCount() { return 0; } +double CHResampler::ratio() { return 1; } + +#endif/*WITH_RESAMPLER*/ diff --git a/src/chresampler.h b/src/chresampler.h new file mode 100644 index 0000000..5943627 --- /dev/null +++ b/src/chresampler.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * chresampler.h + * + * Tue Sep 23 20:42:14 CEST 2014 + * Copyright 2014 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_CHRESAMPLER_H__ +#define __DRUMGIZMO_CHRESAMPLER_H__ + +#include + +/** + * Channel resampler class using either zita-resampler or secret rabbit code + * (really!!) depending on the value of the WITH_RESAMPLER macro. + * If WITH_RESAMPLER is unset the resampler is disabled entirely. + * If WITH_RESAMPLER=="zita" zita-resampler will be used. + * If WITH_RESAMPLER=="src" Secret Rabbit Code will be used. + */ +class CHResampler { +public: + CHResampler(); + ~CHResampler(); + + void setup(double input_fs, double output_fs); + + void setInputSamples(float *samples, size_t count); + void setOutputSamples(float *samples, size_t count); + + void process(); + + size_t getInputSampleCount(); + size_t getOutputSampleCount(); + + double ratio(); + +private: + class Prv; + Prv *prv; + + double input_fs; + double output_fs; +}; + + +#endif/*__DRUMGIZMO_CHRESAMPLER_H__*/ diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 8fb449a..5f27ae1 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -38,17 +38,6 @@ #include -// -// Warning: Zita currently not working... -// -#ifdef WITH_RESAMPLE -#ifdef ZITA -#include -#else -#include -#endif/*ZITA*/ -#endif/*WITH_RESAMPLE*/ - #include "drumkitparser.h" #include "audioinputenginemidi.h" #include "configuration.h" @@ -66,9 +55,12 @@ DrumGizmo::~DrumGizmo() bool DrumGizmo::loadkit(std::string file) { + printf("loadkit(%s)\n", file.c_str()); if(file == kit.file()) return 1; if(file == "") return 1; + printf("loadkit() go\n"); + DEBUG(drumgizmo, "loadkit(%s)\n", file.c_str()); // Remove all queue AudioFiles from loader before we actually delete them. @@ -80,12 +72,23 @@ bool DrumGizmo::loadkit(std::string file) DrumKitParser parser(file, kit); if(parser.parse()) { ERR(drumgizmo, "Drumkit parser failed: %s\n", file.c_str()); - return false; + printf("loadkit() parser failed\n"); + return false; } loader.loadKit(&kit); +#ifdef WITH_RESAMPLER + unsigned int output_fs = kit.samplerate(); + if(oe->samplerate() != UNKNOWN_SAMPLERATE) output_fs = oe->samplerate(); + for(int i = 0; i < MAX_NUM_CHANNELS; i++) { + resampler[i].setup(kit.samplerate(), output_fs); + } +#endif/*WITH_RESAMPLER*/ + + DEBUG(loadkit, "loadkit: Success\n"); + printf("loadkit() done\n"); return true; } @@ -171,13 +174,7 @@ void DrumGizmo::handleMessage(Message *msg) bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) { - double samplerate_scale = 1.0; -#ifdef WITH_RESAMPLE - if(oe->samplerate() != UNKNOWN_SAMPLERATE) { - samplerate_scale = (double)kit.samplerate() / (double)oe->samplerate(); - } -#endif/*WITH_RESAMPLE*/ - + // printf("."); fflush(stdout); // Handle engine messages, at most one in each iteration: handleMessages(1); @@ -260,7 +257,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) } else { //DEBUG(drumgizmo, "Adding event %d.\n", evs[e].offset); Event *evt = new EventSample(ch.num, 1.0, af, i->group(), i); - evt->offset = (evs[e].offset + pos) * samplerate_scale; + evt->offset = (evs[e].offset + pos) * resampler[0].ratio(); activeevents[ch.num].push_back(evt); } j++; @@ -278,59 +275,62 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) // // Write audio // +#ifndef WITH_RESAMPLER + // No resampling needed for(size_t c = 0; c < kit.channels.size(); c++) { - if(samplerate_scale == 1.0) { - // No resampling needed - sample_t *buf = samples; - bool internal = false; - if(oe->getBuffer(c)) { - buf = oe->getBuffer(c); - internal = true; - } - if(buf) { - memset(buf, 0, nsamples * sizeof(sample_t)); + sample_t *buf = samples; + bool internal = false; + if(oe->getBuffer(c)) { + buf = oe->getBuffer(c); + internal = true; + } + if(buf) { + memset(buf, 0, nsamples * sizeof(sample_t)); - getSamples(c, pos, buf, nsamples); - - if(!internal) oe->run(c, samples, nsamples); - } - } else { -#ifdef WITH_RESAMPLE - // Resampling needed - size_t nkitsamples = nsamples * samplerate_scale; - sample_t kitsamples[nkitsamples]; - - memset(kitsamples, 0, nkitsamples * sizeof(sample_t)); - getSamples(c, pos * samplerate_scale, kitsamples, nkitsamples); - -#ifdef ZITA - Resampler resampler; - resampler.setup(kit.samplerate(), oe->samplerate(), 1, 96); - - resampler.inp_data = kitsamples; - resampler.inp_count = nkitsamples; - - resampler.out_data = samples; - resampler.out_count = nsamples; - - resampler.process(); -#else - SRC_DATA src; - src.data_in = kitsamples; - src.input_frames = nkitsamples; - - src.data_out = samples; - src.output_frames = nsamples; - - src.src_ratio = 1.0 / samplerate_scale; + getSamples(c, pos, buf, nsamples); + + if(!internal) oe->run(c, samples, nsamples); + } + } +#else/*WITH_RESAMPLER*/ + // Resampling needed - src_simple(&src, SRC_SINC_BEST_QUALITY, 1); -#endif/*ZITA*/ + // + // NOTE: Channels must be processed one buffer at a time on all channels in + // parallel - NOT all buffers on one channel and then all buffer on the next + // one since this would mess up the event queue (it would jump back and forth + // in time) + // - oe->run(c, samples, nsamples); -#endif/*WITH_RESAMPLE*/ + // Prepare output buffer + for(size_t c = 0; c < kit.channels.size(); c++) { + resampler[c].setOutputSamples(resampler_output_buffer[c], nsamples); + } + + // Process channel data + size_t kitpos = pos * resampler[0].ratio(); + //printf("ratio: %f\n", resampler[c].ratio()); + while(resampler[0].getOutputSampleCount() > 0) { + for(size_t c = 0; c < kit.channels.size(); c++) { + if(resampler[c].getInputSampleCount() == 0) { + sample_t *sin = resampler_input_buffer[c]; + size_t insize = sizeof(resampler_input_buffer[c]) / sizeof(sample_t); + memset(resampler_input_buffer[c], 0, + sizeof(resampler_input_buffer[c])); + getSamples(c, kitpos, sin, insize); + kitpos += insize; + + resampler[c].setInputSamples(sin, insize); + } + resampler[c].process(); } } + + // Write output data to output engine. + for(size_t c = 0; c < kit.channels.size(); c++) { + oe->run(c, resampler_output_buffer[c], nsamples); + } +#endif/*WITH_RESAMPLER*/ ie->post(); oe->post(nsamples); @@ -359,6 +359,7 @@ void DrumGizmo::run(int endpos) free(samples); } +#undef SSE #ifdef SSE #define N 8 @@ -391,7 +392,8 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz) size_t n = 0; if(evt->offset > (size_t)pos) n = evt->offset - pos; size_t end = sz; - if(evt->t + end - n > af->size) end = af->size - evt->t + n; + if((evt->t + end - n) > af->size) end = af->size - evt->t + n; + if(end > sz) end = sz; if(evt->rampdown == NO_RAMPDOWN) { #ifdef SSE diff --git a/src/drumgizmo.h b/src/drumgizmo.h index 37b26e5..138e61c 100644 --- a/src/drumgizmo.h +++ b/src/drumgizmo.h @@ -45,7 +45,9 @@ #include "messagereceiver.h" -#define MAX_NUM_CHANNELS 512 +#include "chresampler.h" + +#define MAX_NUM_CHANNELS 64 class DrumGizmo : public MessageReceiver { public: @@ -87,6 +89,10 @@ private: std::list< Event* > activeevents[MAX_NUM_CHANNELS]; + CHResampler resampler[MAX_NUM_CHANNELS]; + sample_t resampler_output_buffer[MAX_NUM_CHANNELS][4096]; + sample_t resampler_input_buffer[MAX_NUM_CHANNELS][64]; + std::map audiofiles; #ifdef TEST_DRUMGIZMO -- cgit v1.2.3 From 5bcfa1aeab5def47b147c77f915028b76fdd4844 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 14 Oct 2014 17:21:06 +0200 Subject: Remove errornously committed changes for plugingui branch. --- plugingui/Makefile.am | 2 +- plugingui/Makefile.am.plugingui | 4 +- plugingui/Makefile.mingw32 | 2 +- plugingui/lineedit.cc | 73 +++++++++++++++--- plugingui/lineedit.h | 9 +++ plugingui/pluginconfig.cc | 165 ---------------------------------------- plugingui/pluginconfig.h | 48 ------------ plugingui/plugingui.cc | 9 ++- 8 files changed, 85 insertions(+), 227 deletions(-) delete mode 100644 plugingui/pluginconfig.cc delete mode 100644 plugingui/pluginconfig.h diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index 32228f4..3d09bb2 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -26,7 +26,6 @@ EXTRA_DIST = \ button.h \ checkbox.h \ colour.h \ - pluginconfig.h \ combobox.h \ directory.h \ eventhandler.h \ @@ -47,6 +46,7 @@ EXTRA_DIST = \ nativewindow_x11.h \ painter.h \ pixelbuffer.h \ + pluginconfig.h \ plugingui.h \ progressbar.h \ resource.h \ diff --git a/plugingui/Makefile.am.plugingui b/plugingui/Makefile.am.plugingui index bd703b2..b1698e4 100644 --- a/plugingui/Makefile.am.plugingui +++ b/plugingui/Makefile.am.plugingui @@ -1,4 +1,6 @@ +puglsources = + PLUGIN_GUI_SOURCES = \ $(top_srcdir)/hugin/hugin.c \ $(top_srcdir)/hugin/hugin_syslog.c \ @@ -26,11 +28,11 @@ PLUGIN_GUI_SOURCES = \ $(top_srcdir)/plugingui/knob.cc \ $(top_srcdir)/plugingui/filebrowser.cc \ $(top_srcdir)/plugingui/directory.cc \ + $(top_srcdir)/plugingui/pluginconfig.cc \ $(top_srcdir)/plugingui/image.cc \ $(top_srcdir)/plugingui/combobox.cc \ $(top_srcdir)/plugingui/progressbar.cc \ $(top_srcdir)/plugingui/verticalline.cc \ - $(top_srcdir)/plugingui/pluginconfig.cc \ $(top_srcdir)/plugingui/resource.cc \ $(top_srcdir)/plugingui/resource_data.cc \ $(top_srcdir)/plugingui/lodepng/lodepng.cpp diff --git a/plugingui/Makefile.mingw32 b/plugingui/Makefile.mingw32 index 7863463..b16535b 100644 --- a/plugingui/Makefile.mingw32 +++ b/plugingui/Makefile.mingw32 @@ -13,6 +13,7 @@ CXX_SOURCES = \ $(top_srcdir)/plugingui/nativewindow_x11.cc \ $(top_srcdir)/plugingui/nativewindow_win32.cc \ $(top_srcdir)/plugingui/plugingui.cc \ + $(top_srcdir)/plugingui/pluginconfig.cc \ $(top_srcdir)/plugingui/label.cc \ $(top_srcdir)/plugingui/eventhandler.cc \ $(top_srcdir)/plugingui/font.cc \ @@ -40,7 +41,6 @@ CXX_SOURCES = \ $(top_srcdir)/plugingui/resource.cc \ $(top_srcdir)/plugingui/resource_data.cc \ $(top_srcdir)/plugingui/lodepng/lodepng.cpp \ - $(top_srcdir)/plugingui/pluginconfig.cc \ $(top_srcdir)/src/thread.cc \ $(top_srcdir)/src/semaphore.cc \ $(top_srcdir)/src/mutex.cc \ diff --git a/plugingui/lineedit.cc b/plugingui/lineedit.cc index d6e717a..46354bb 100644 --- a/plugingui/lineedit.cc +++ b/plugingui/lineedit.cc @@ -30,6 +30,8 @@ #include "window.h" +#include + #include #define BORDER 10 @@ -38,6 +40,7 @@ GUI::LineEdit::LineEdit(Widget *parent) : GUI::Widget(parent) { pos = 0; + offsetpos = 0; setReadOnly(false); box.topLeft = new Image(":widget_tl.png"); @@ -72,7 +75,8 @@ bool GUI::LineEdit::readOnly() void GUI::LineEdit::setText(std::string text) { _text = text; - if(_text.size() < pos) pos = text.size(); + pos = text.size(); +// if(_text.size() < pos) pos = text.size(); repaintEvent(NULL); textChanged(); @@ -87,14 +91,16 @@ void GUI::LineEdit::buttonEvent(ButtonEvent *e) { if(readOnly()) return; + if(e->direction == 1) { - for(int i = 0; i < (int)_text.length(); i++) { - if(e->x < (int)(font.textWidth(_text.substr(0, i)) + BORDER)) { - pos = i; + for(int i = 0; i < (int)_visibletext.length(); i++) { + if(e->x < (int)(font.textWidth(_visibletext.substr(0, i)) + BORDER)) { + printf("i, Offset: %d, %d\n", i, offsetpos); + pos = i + offsetpos; break; } } - if(e->x >= (int)(font.textWidth(_text) + BORDER)) pos = _text.length(); +// if(e->x >= (int)(font.textWidth(_visibletext) + BORDER)) pos = _visibletext.length(); repaintEvent(NULL); } } @@ -111,7 +117,9 @@ void GUI::LineEdit::keyEvent(GUI::KeyEvent *e) if(e->keycode == GUI::KeyEvent::KEY_LEFT) { if(pos) pos--; - + if(offsetpos >= pos) walkstate = WALK_LEFT; +// else walkstate = NOOP; + } else if(e->keycode == GUI::KeyEvent::KEY_HOME) { pos = 0; @@ -120,7 +128,9 @@ void GUI::LineEdit::keyEvent(GUI::KeyEvent *e) } else if(e->keycode == GUI::KeyEvent::KEY_RIGHT) { if(pos < _text.length()) pos++; - + if(offsetpos + _visibletext.length() <= pos) walkstate = WALK_RIGHT; +// else walkstate = NOOP; + } else if(e->keycode == GUI::KeyEvent::KEY_DELETE) { if(pos < _text.length()) { std::string t = _text.substr(0, pos); @@ -144,6 +154,7 @@ void GUI::LineEdit::keyEvent(GUI::KeyEvent *e) _text = pre + e->text + post; change = true; pos++; + } else if(e->keycode == GUI::KeyEvent::KEY_ENTER) { if(handler) handler(ptr); } @@ -165,12 +176,56 @@ void GUI::LineEdit::repaintEvent(GUI::RepaintEvent *e) p.drawBox(0, 0, &box, w, h); p.setColour(GUI::Colour(183.0/255.0, 219.0/255.0 , 255.0/255.0, 1)); - p.drawText(BORDER - 4 + 3, height()/2+5 + 1 + 1 + 1, font, _text); + + if(walkstate == WALK_LEFT) { + _visibletext = _text.substr(pos, std::string::npos); + offsetpos = pos; + } + else if(walkstate == WALK_RIGHT) { + int d = (offsetpos < _text.length()) ? 1 : 0; + _visibletext = _text.substr(offsetpos + d); + offsetpos = offsetpos + d; + } + else { + _visibletext = _text; + offsetpos = 0; + } + while(true) { + int textwidth = font.textWidth(_visibletext); + if(textwidth > w - BORDER - 4 + 3) { + if(walkstate == WALK_LEFT) { + _visibletext = _visibletext.substr(0, _visibletext.length()-1); + } + else if(walkstate == WALK_RIGHT) { + _visibletext = _visibletext.substr(0, _visibletext.length()-1); + } + else { + if(offsetpos < pos) { + _visibletext = _visibletext.substr(1); + offsetpos++; + } + else { + _visibletext = _visibletext.substr(0, _visibletext.length() - 1); + } + } + } + else { + DEBUG(lienedit, "Full text: '%s'\n", _text.c_str()); + DEBUG(lineedit, "Drawing text in lineedit '%s'\n", _visibletext.c_str()); + DEBUG(lineedit, "Offset, pos: %d, %d\n", offsetpos, pos); + break; + } + } + + walkstate = NOOP; + + p.drawText(BORDER - 4 + 3, height()/2+5 + 1 + 1 + 1, font, _visibletext); if(readOnly()) return; if(hasKeyboardFocus()) { - size_t px = font.textWidth(_text.substr(0, pos)); +// size_t px = font.textWidth(_text.substr(0, pos - offsetpos)); + size_t px = font.textWidth(_visibletext.substr(0, pos - offsetpos)); //p.setColour(Colour(0.8)); p.drawLine(px + BORDER - 1 - 4 + 3, 6, px + BORDER - 1 - 4 + 3, height() - 7); diff --git a/plugingui/lineedit.h b/plugingui/lineedit.h index 2c37522..f85e9bd 100644 --- a/plugingui/lineedit.h +++ b/plugingui/lineedit.h @@ -65,6 +65,15 @@ private: std::string _text; size_t pos; + std::string _visibletext; + size_t offsetpos; + + enum state_t { + NOOP = 0, + WALK_LEFT = 1, + WALK_RIGHT = 2 + }; + state_t walkstate; bool readonly; diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc deleted file mode 100644 index d57d9df..0000000 --- a/plugingui/pluginconfig.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * config.cc - * - * Tue Jun 3 13:54:05 CEST 2014 - * Copyright 2014 Jonas Suhr Christensen - * jsc@umbraculum.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 "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() -{ - -} - -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()); - } - } -} - -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); - - fclose(fp); -} diff --git a/plugingui/pluginconfig.h b/plugingui/pluginconfig.h deleted file mode 100644 index d0e9bcd..0000000 --- a/plugingui/pluginconfig.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * config.h - * - * Tue Jun 3 13:51:29 CEST 2014 - * Copyright 2014 Jonas Suhr Christensen - * jsc@umbraculum.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_CONFIG_H__ -#define __DRUMGIZMO_CONFIG_H__ - -#include -#include - -#define DIRECTORY_HIDDEN 1 - -class Config { - - public: - Config(); - ~Config(); - - void load(); - void save(); - - std::string lastkit; - std::string lastmidimap; -}; - -#endif/*__DRUMGIZMO_CONFIG_H__*/ diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index b235af3..f345660 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -94,11 +94,13 @@ static void selectKitFile(void *ptr, std::string filename) PluginGUI *gui = (PluginGUI*)ptr; gui->lineedit->setText(filename); + fb->hide(); std::string drumkit = gui->lineedit->text(); gui->config->lastkit = drumkit; + gui->config->save(); gui->progress->setProgress(0); gui->progress->setState(GUI::ProgressBar::blue); @@ -132,6 +134,7 @@ static void selectMapFile(void *ptr, std::string filename) std::string midimap = gui->lineedit2->text(); gui->config->lastmidimap = midimap; + gui->config->save(); LoadMidimapMessage *msg = new LoadMidimapMessage(); msg->midimapfile = midimap; @@ -334,7 +337,8 @@ void PluginGUI::init() lineedit = new GUI::LineEdit(window); lineedit->move(XOFFSET, y); lineedit->resize(243, 29); - + lineedit->setReadOnly(true); + GUI::Button *btn_brw = new GUI::Button(window); btn_brw->setText("Browse..."); btn_brw->move(266, y - 6 + 4); @@ -364,7 +368,8 @@ void PluginGUI::init() lineedit2 = new GUI::LineEdit(window); lineedit2->move(XOFFSET, y); lineedit2->resize(243, 29); - + lineedit2->setReadOnly(true); + GUI::Button *btn_brw = new GUI::Button(window); btn_brw->setText("Browse..."); btn_brw->move(266, y - 6 + 4); -- cgit v1.2.3 From eae1fca4710303b57d157495bc08e69c4977ffa6 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 14 Oct 2014 17:22:08 +0200 Subject: Remove errornously committed changes for plugingui branch. --- INSTALL | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index a1e89e1..007e939 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,7 @@ Installation Instructions ************************* -Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, @@ -309,9 +309,10 @@ causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== @@ -367,4 +368,3 @@ operates. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. - -- cgit v1.2.3 From 6b1a30cc3d5e00bd210b27344fceb1c863b23ed6 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 14 Oct 2014 17:33:08 +0200 Subject: A bit of code cleanup in preparation for merging with master. --- src/drumgizmo.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 2370d43..9252afc 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -57,8 +57,6 @@ bool DrumGizmo::loadkit(std::string file) { if(file == "") return 1; - printf("loadkit() go\n"); - DEBUG(drumgizmo, "loadkit(%s)\n", file.c_str()); // Remove all queue AudioFiles from loader before we actually delete them. @@ -70,8 +68,7 @@ bool DrumGizmo::loadkit(std::string file) DrumKitParser parser(file, kit); if(parser.parse()) { ERR(drumgizmo, "Drumkit parser failed: %s\n", file.c_str()); - printf("loadkit() parser failed\n"); - return false; + return false; } loader.loadKit(&kit); @@ -86,7 +83,6 @@ bool DrumGizmo::loadkit(std::string file) DEBUG(loadkit, "loadkit: Success\n"); - printf("loadkit() done\n"); return true; } @@ -172,7 +168,6 @@ void DrumGizmo::handleMessage(Message *msg) bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) { - // printf("."); fflush(stdout); // Handle engine messages, at most one in each iteration: handleMessages(1); @@ -269,7 +264,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) } free(evs); - + // // Write audio // @@ -357,7 +352,6 @@ void DrumGizmo::run(int endpos) free(samples); } -#undef SSE #ifdef SSE #define N 8 -- cgit v1.2.3 From b49dd62df721b2d965c995e69340b085d3489bf6 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 16 Oct 2014 19:14:00 +0200 Subject: Quick and dirty fix for LV2 UI crash. --- lv2/lv2_gui.cc | 14 ++++++++++++-- plugingui/plugingui.cc | 22 ++++++++++++++++++++++ plugingui/plugingui.h | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lv2/lv2_gui.cc b/lv2/lv2_gui.cc index 7b56c5b..625c7f7 100644 --- a/lv2/lv2_gui.cc +++ b/lv2/lv2_gui.cc @@ -120,24 +120,31 @@ struct DG_GUI { static void ui_run(struct lv2_external_ui * _this_) { + //printf("ui_run begin\n"); fflush(stdout); struct DG_GUI *dggui = (struct DG_GUI *)_this_; dggui->gui->processEvents(); + //printf("ui_run end\n"); fflush(stdout); } static void ui_show(struct lv2_external_ui * _this_) { + //printf("ui_show begin\n"); fflush(stdout); struct DG_GUI *dggui = (struct DG_GUI *)_this_; dggui->gui->show(); + //printf("ui_show end\n"); fflush(stdout); } static void ui_hide(struct lv2_external_ui * _this_) { + //printf("ui_hide begin\n"); fflush(stdout); struct DG_GUI *dggui = (struct DG_GUI *)_this_; if(dggui->gui) dggui->gui->hide(); + //printf("ui_hide end\n"); fflush(stdout); } static void closeHandler(void *ptr) { + //printf("closeHandler begin\n"); fflush(stdout); struct DG_GUI *gui = (struct DG_GUI *)ptr; if(gui->ui_host_ptr && gui->ui_host_ptr->ui_closed) { @@ -146,6 +153,7 @@ static void closeHandler(void *ptr) delete gui->gui; gui->gui = NULL; + //printf("closeHandler end\n"); fflush(stdout); } static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor, @@ -156,7 +164,7 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor, LV2UI_Widget * widget, const LV2_Feature * const * features) { - printf("ui_instantiate\n"); + //printf("ui_instantiate begin\n"); fflush(stdout); struct DG_GUI* pt = new struct DG_GUI; @@ -167,7 +175,7 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor, std::string uri = (*features)->URI; void *data = (*features)->data; - printf("DGUI: feature: %s\n", uri.c_str()); + //printf("DGUI: feature: %s\n", uri.c_str()); if(uri == LV2_INSTANCE_ACCESS_URI) { pt->instance_handle = data; @@ -195,6 +203,8 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor, *widget = (LV2UI_Widget)pt; + //printf("ui_instantiate end\n"); fflush(stdout); + return pt; } diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index f345660..4a2f4fa 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -171,6 +171,9 @@ void closeClick(void *ptr) PluginGUI::PluginGUI() : MessageReceiver(MSGRCV_UI), sem("plugingui") { + initialised = false; + //printf("PluginGUI::PluginGUI() begin\n"); fflush(stdout); + windowClosedHandler = NULL; changeMidimapHandler = NULL; @@ -186,6 +189,8 @@ PluginGUI::PluginGUI() #endif/*USE_THREAD*/ sem.wait(); + + //printf("PluginGUI::PluginGUI() done\n"); fflush(stdout); } PluginGUI::~PluginGUI() @@ -301,6 +306,8 @@ void PluginGUI::init() { DEBUG(gui, "init"); + //printf("init begin\n"); fflush(stdout); + config = new Config(); config->load(); @@ -464,10 +471,17 @@ void PluginGUI::init() window->show(); sem.post(); + + //printf("init end\n"); fflush(stdout); + initialised = true; } void PluginGUI::show() { + while(!initialised) { + //printf("Waiting for init to finish\n"); fflush(stdout); + sleep(1); + } if(!window) init(); window->show(); @@ -475,11 +489,19 @@ void PluginGUI::show() void PluginGUI::hide() { + while(!initialised) { + //printf("Waiting for init to finish\n"); fflush(stdout); + sleep(1); + } if(window) window->hide(); } void PluginGUI::processEvents() { + if(!initialised) { + //printf("Not yet initialised\n"); fflush(stdout); + return; + } if(closing) { if(windowClosedHandler) windowClosedHandler(windowClosedPtr); closing = false; diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h index f94a062..36e8b1c 100644 --- a/plugingui/plugingui.h +++ b/plugingui/plugingui.h @@ -92,7 +92,7 @@ public: private: volatile bool running; volatile bool closing; - + volatile bool initialised; Semaphore sem; }; -- cgit v1.2.3 From 6299c6ef046ff3d845fc0fdefa96a2496fd4fdb1 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 17 Oct 2014 11:23:01 +0200 Subject: Fix GUI crash when running in thread mode and init wasn't done when show was called. --- plugingui/plugingui.cc | 24 ++++++------------------ plugingui/plugingui.h | 1 + 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 4a2f4fa..5408334 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -172,7 +172,6 @@ PluginGUI::PluginGUI() : MessageReceiver(MSGRCV_UI), sem("plugingui") { initialised = false; - //printf("PluginGUI::PluginGUI() begin\n"); fflush(stdout); windowClosedHandler = NULL; changeMidimapHandler = NULL; @@ -189,8 +188,6 @@ PluginGUI::PluginGUI() #endif/*USE_THREAD*/ sem.wait(); - - //printf("PluginGUI::PluginGUI() done\n"); fflush(stdout); } PluginGUI::~PluginGUI() @@ -306,8 +303,6 @@ void PluginGUI::init() { DEBUG(gui, "init"); - //printf("init begin\n"); fflush(stdout); - config = new Config(); config->load(); @@ -472,16 +467,13 @@ void PluginGUI::init() sem.post(); - //printf("init end\n"); fflush(stdout); initialised = true; } void PluginGUI::show() { - while(!initialised) { - //printf("Waiting for init to finish\n"); fflush(stdout); - sleep(1); - } + while(!initialised) usleep(10000); + if(!window) init(); window->show(); @@ -489,19 +481,15 @@ void PluginGUI::show() void PluginGUI::hide() { - while(!initialised) { - //printf("Waiting for init to finish\n"); fflush(stdout); - sleep(1); - } + while(!initialised) usleep(10000); + if(window) window->hide(); } void PluginGUI::processEvents() { - if(!initialised) { - //printf("Not yet initialised\n"); fflush(stdout); - return; - } + if(!initialised) return; + if(closing) { if(windowClosedHandler) windowClosedHandler(windowClosedPtr); closing = false; diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h index 36e8b1c..39643e1 100644 --- a/plugingui/plugingui.h +++ b/plugingui/plugingui.h @@ -93,6 +93,7 @@ private: volatile bool running; volatile bool closing; volatile bool initialised; + Semaphore sem; }; -- cgit v1.2.3 From 7f515019b2668cab22b6d12766f136334d9e26dc Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 17 Oct 2014 11:38:52 +0200 Subject: Remove debug. --- lv2/lv2_gui.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/lv2/lv2_gui.cc b/lv2/lv2_gui.cc index 625c7f7..7b56c5b 100644 --- a/lv2/lv2_gui.cc +++ b/lv2/lv2_gui.cc @@ -120,31 +120,24 @@ struct DG_GUI { static void ui_run(struct lv2_external_ui * _this_) { - //printf("ui_run begin\n"); fflush(stdout); struct DG_GUI *dggui = (struct DG_GUI *)_this_; dggui->gui->processEvents(); - //printf("ui_run end\n"); fflush(stdout); } static void ui_show(struct lv2_external_ui * _this_) { - //printf("ui_show begin\n"); fflush(stdout); struct DG_GUI *dggui = (struct DG_GUI *)_this_; dggui->gui->show(); - //printf("ui_show end\n"); fflush(stdout); } static void ui_hide(struct lv2_external_ui * _this_) { - //printf("ui_hide begin\n"); fflush(stdout); struct DG_GUI *dggui = (struct DG_GUI *)_this_; if(dggui->gui) dggui->gui->hide(); - //printf("ui_hide end\n"); fflush(stdout); } static void closeHandler(void *ptr) { - //printf("closeHandler begin\n"); fflush(stdout); struct DG_GUI *gui = (struct DG_GUI *)ptr; if(gui->ui_host_ptr && gui->ui_host_ptr->ui_closed) { @@ -153,7 +146,6 @@ static void closeHandler(void *ptr) delete gui->gui; gui->gui = NULL; - //printf("closeHandler end\n"); fflush(stdout); } static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor, @@ -164,7 +156,7 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor, LV2UI_Widget * widget, const LV2_Feature * const * features) { - //printf("ui_instantiate begin\n"); fflush(stdout); + printf("ui_instantiate\n"); struct DG_GUI* pt = new struct DG_GUI; @@ -175,7 +167,7 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor, std::string uri = (*features)->URI; void *data = (*features)->data; - //printf("DGUI: feature: %s\n", uri.c_str()); + printf("DGUI: feature: %s\n", uri.c_str()); if(uri == LV2_INSTANCE_ACCESS_URI) { pt->instance_handle = data; @@ -203,8 +195,6 @@ static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor, *widget = (LV2UI_Widget)pt; - //printf("ui_instantiate end\n"); fflush(stdout); - return pt; } -- cgit v1.2.3 From 3176ea311ab6ad13546f8410f4f2ebc9ef229df3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 29 Oct 2014 19:29:32 +0100 Subject: Add zita library to VST Makefile. --- vst/Makefile.mingw32.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vst/Makefile.mingw32.in b/vst/Makefile.mingw32.in index f8aab4d..1a13201 100644 --- a/vst/Makefile.mingw32.in +++ b/vst/Makefile.mingw32.in @@ -92,7 +92,10 @@ ZLIB_CFLAGS=@ZLIB_CFLAGS@ ZLIB_LIBS=@ZLIB_LIBS@ SRC_CFLAGS=@SAMPLERATE_CFLAGS@ -SRC_LIBS=@SAMPLERATE_CFLAGS@ +SRC_LIBS=@SAMPLERATE_LIBS@ + +ZITA_CXXFLAGS=@ZITA_CXXFLAGS@ +ZITA_LIBS=@ZITA_LIBS@ SRC = \ drumgizmo_vst.cc \ @@ -133,7 +136,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) $(EXPAT_LIBS) $(ZLIB_LIBS) $(SNDFILE_CFLAGS) $(SNDFILE_LIBS) $(SRC_LIBS) -shared -o drumgizmo_vst.dll -Wl,--out-implib,libdrumgizmo_vst.a + 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 clean: del -f drumgizmo_vst.dll libdrumgizmo_vst.a -- cgit v1.2.3 From 618ccf981bf16e848912cf8c4d72f58c7134642a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 3 Nov 2014 18:55:03 +0100 Subject: Use Drumgizmo::setSamplerate to control resampler target samplerate. --- drumgizmo/drumgizmoc.cc | 2 ++ lv2/lv2.cc | 2 +- lv2/output_lv2.cc | 9 +-------- lv2/output_lv2.h | 4 +--- src/audiooutputengine.h | 5 ----- src/drumgizmo.cc | 11 +++++++---- 6 files changed, 12 insertions(+), 21 deletions(-) diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index c96736f..d5fa817 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -248,6 +248,8 @@ int main(int argc, char *argv[]) return 1; } + gizmo.setSamplerate(oe->samplerate()); + if(!gizmo.init(preload)) { printf("Failed init engine.\n"); return 1; diff --git a/lv2/lv2.cc b/lv2/lv2.cc index 9ec7706..3aeb5f0 100644 --- a/lv2/lv2.cc +++ b/lv2/lv2.cc @@ -248,7 +248,7 @@ LV2_Handle instantiate(const struct _LV2_Descriptor *descriptor, dg_descriptor.get_pci = dg_get_pci; dglv2->in = new InputLV2(); - dglv2->out = new OutputLV2(sample_rate); + dglv2->out = new OutputLV2(); dglv2->buffer = NULL; dglv2->buffer_size = 0; diff --git a/lv2/output_lv2.cc b/lv2/output_lv2.cc index b4a6877..ef2500b 100644 --- a/lv2/output_lv2.cc +++ b/lv2/output_lv2.cc @@ -28,9 +28,8 @@ #include -OutputLV2::OutputLV2(double sample_rate) +OutputLV2::OutputLV2() { - this->sample_rate = sample_rate; for(size_t i = 0; i < NUM_OUTPUTS; i++) { outputPorts[i].size = 0; outputPorts[i].samples = NULL; @@ -83,9 +82,3 @@ sample_t *OutputLV2::getBuffer(int ch) if(ch < NUM_OUTPUTS) return outputPorts[ch].samples; return NULL; } - -size_t OutputLV2::samplerate() -{ - return sample_rate; -} - diff --git a/lv2/output_lv2.h b/lv2/output_lv2.h index 272a78c..c23cf2f 100644 --- a/lv2/output_lv2.h +++ b/lv2/output_lv2.h @@ -39,7 +39,7 @@ public: class OutputLV2 : public AudioOutputEngine { public: - OutputLV2(double sample_rate); + OutputLV2(); ~OutputLV2(); bool init(Channels channels); @@ -59,8 +59,6 @@ public: // sample_t *outputPort[NUM_OUTPUTS]; OutputPort outputPorts[NUM_OUTPUTS]; - - double sample_rate; }; #endif/*__DRUMGIZMO_OUTPUT_LV2_H__*/ diff --git a/src/audiooutputengine.h b/src/audiooutputengine.h index 25b6ea0..eafafe9 100644 --- a/src/audiooutputengine.h +++ b/src/audiooutputengine.h @@ -57,11 +57,6 @@ public: * Overload this method to force engine to use different buffer size. */ virtual size_t getBufferSize() { return 1024; } - - /** - * Overload this method to report output engine samplerate. - */ - virtual size_t samplerate() { return UNKNOWN_SAMPLERATE; } }; #endif/*__DRUMGIZMO_AUDIOOUTPUTENGINE_H__*/ diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 9252afc..60ced09 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -74,14 +74,11 @@ bool DrumGizmo::loadkit(std::string file) loader.loadKit(&kit); #ifdef WITH_RESAMPLER - unsigned int output_fs = kit.samplerate(); - if(oe->samplerate() != UNKNOWN_SAMPLERATE) output_fs = oe->samplerate(); for(int i = 0; i < MAX_NUM_CHANNELS; i++) { - resampler[i].setup(kit.samplerate(), output_fs); + resampler[i].setup(kit.samplerate(), Conf::samplerate); } #endif/*WITH_RESAMPLER*/ - DEBUG(loadkit, "loadkit: Success\n"); return true; @@ -443,6 +440,12 @@ int DrumGizmo::samplerate() void DrumGizmo::setSamplerate(int samplerate) { Conf::samplerate = samplerate; +#ifdef WITH_RESAMPLER + for(int i = 0; i < MAX_NUM_CHANNELS; i++) { + resampler[i].setup(kit.samplerate(), Conf::samplerate); + } +#endif/*WITH_RESAMPLER*/ + } std::string float2str(float a) -- cgit v1.2.3 From fc26537a907497eaf60aac0235e813fe8a26b23a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 3 Nov 2014 18:58:11 +0100 Subject: Use Drumgizmo::setSamplerate to control resampler target samplerate. --- lv2/output_lv2.h | 2 -- src/audiooutputengine.h | 2 -- src/drumgizmo.cc | 4 ++-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lv2/output_lv2.h b/lv2/output_lv2.h index c23cf2f..1b4e8c9 100644 --- a/lv2/output_lv2.h +++ b/lv2/output_lv2.h @@ -54,8 +54,6 @@ public: void post(size_t nsamples); sample_t *getBuffer(int c); - - size_t samplerate(); // sample_t *outputPort[NUM_OUTPUTS]; OutputPort outputPorts[NUM_OUTPUTS]; diff --git a/src/audiooutputengine.h b/src/audiooutputengine.h index eafafe9..7f15e49 100644 --- a/src/audiooutputengine.h +++ b/src/audiooutputengine.h @@ -33,8 +33,6 @@ #include "channel.h" -#define UNKNOWN_SAMPLERATE 0 - class AudioOutputEngine { public: virtual ~AudioOutputEngine() {} diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 60ced09..a8121a6 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -278,7 +278,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) memset(buf, 0, nsamples * sizeof(sample_t)); getSamples(c, pos, buf, nsamples); - + if(!internal) oe->run(c, samples, nsamples); } } @@ -296,7 +296,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) for(size_t c = 0; c < kit.channels.size(); c++) { resampler[c].setOutputSamples(resampler_output_buffer[c], nsamples); } - + // Process channel data size_t kitpos = pos * resampler[0].ratio(); //printf("ratio: %f\n", resampler[c].ratio()); -- cgit v1.2.3 From bdbed2238c63e892ef0b3581986b9489af8a82ca Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 3 Nov 2014 19:02:18 +0100 Subject: Fix VST compilation. --- vst/Makefile.mingw32.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vst/Makefile.mingw32.in b/vst/Makefile.mingw32.in index 1a13201..66e02ed 100644 --- a/vst/Makefile.mingw32.in +++ b/vst/Makefile.mingw32.in @@ -11,6 +11,7 @@ DG_SRC = \ @top_srcdir@/src/audiofile.cc \ @top_srcdir@/src/channel.cc \ @top_srcdir@/src/channelmixer.cc \ + @top_srcdir@/src/chresampler.cc \ @top_srcdir@/src/configuration.cc \ @top_srcdir@/src/configparser.cc \ @top_srcdir@/src/drumgizmo.cc \ @@ -94,7 +95,7 @@ ZLIB_LIBS=@ZLIB_LIBS@ SRC_CFLAGS=@SAMPLERATE_CFLAGS@ SRC_LIBS=@SAMPLERATE_LIBS@ -ZITA_CXXFLAGS=@ZITA_CXXFLAGS@ +ZITA_CXXFLAGS=@ZITA_CPPFLAGS@ ZITA_LIBS=@ZITA_LIBS@ SRC = \ -- cgit v1.2.3 From ea184bb32a1c37bd8e314daa98d90523b89cb1e9 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 3 Nov 2014 20:02:16 +0100 Subject: whitespace --- src/drumgizmo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index a8121a6..6b48cda 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -309,7 +309,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) sizeof(resampler_input_buffer[c])); getSamples(c, kitpos, sin, insize); kitpos += insize; - + resampler[c].setInputSamples(sin, insize); } resampler[c].process(); -- cgit v1.2.3 From fe8907b7dd31a4acbde211df929092e0f1014d06 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 4 Nov 2014 16:52:21 +0100 Subject: Add resampler unit tests. --- .gitignore | 6 ++- test/Makefile.am | 3 +- test/resampler.cc | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 test/resampler.cc diff --git a/.gitignore b/.gitignore index 32c3162..4cfbcc4 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,8 @@ Makefile.am.test *.dll plugingui/plugingui plugingui/rcgen -*.lo \ No newline at end of file +*.lo +test/result_*.xml +test/resampler +test/engine +test/gui \ No newline at end of file diff --git a/test/Makefile.am b/test/Makefile.am index 136ba28..e43a6ba 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -23,7 +23,8 @@ gui_SOURCES = \ gui.cc resampler_CXXFLAGS = -DOUTPUT=\"resampler\" $(CPPUNIT_CFLAGS) \ - $(ZITA_CXXFLAGS) $(SAMPLERATE_CFLAGS) + $(ZITA_CXXFLAGS) $(SAMPLERATE_CFLAGS) \ + -I$(top_srcdir)/hugin -DDISABLE_HUGIN resampler_LDFLAGS = $(ZITA_LIBS) $(SAMPLERATE_LIBS) $(CPPUNIT_LIBS) resampler_SOURCES = \ $(top_srcdir)/src/chresampler.cc \ diff --git a/test/resampler.cc b/test/resampler.cc new file mode 100644 index 0000000..445a5b3 --- /dev/null +++ b/test/resampler.cc @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * resampler.cc + * + * Sun Oct 5 20:16:22 CEST 2014 + * Copyright 2014 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 + +#include "../src/chresampler.h" +#include + +#define BUFSZ 500 + +static float round(float a) { return a<0.5?0:1; } + +class test_resampler : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(test_resampler); + CPPUNIT_TEST(resampling); + CPPUNIT_TEST(resampling_buffer_sizes); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() {} + void tearDown() {} + + void resampling() + { + CHResampler r; + CPPUNIT_ASSERT_EQUAL(1.0, r.ratio()); + + r.setup(44100, 48000); + CPPUNIT_ASSERT_EQUAL(44100.0/48000.0, r.ratio()); + + float in[BUFSZ]; + for(int i = 0; i < BUFSZ; i++) in[i] = 0;//(float)i/(float)BUFSZ; + in[100] = 1.0; + + float out[BUFSZ]; + r.setInputSamples(in, sizeof(in) / sizeof(float)); + r.setOutputSamples(out, sizeof(out) / sizeof(float)); + r.process(); + CPPUNIT_ASSERT_EQUAL((size_t)0, r.getInputSampleCount()); + + // CPPUNIT_ASSERT_EQUAL(, r.getOutputSampleCount()); + + int outidx = -1; + int inidx = -1; + for(int i = 0; i < BUFSZ - (int)r.getOutputSampleCount(); i++) { + if(in[i] == 1.0) inidx = i; + if(round(out[i]) == 1.0) outidx = i; + //printf("in[% 4d]\t= %f\t", i, in[i]); + //printf("out[% 4d]\t= %f\n", i, out[i]); + } + + CPPUNIT_ASSERT(inidx != -1); + CPPUNIT_ASSERT(outidx != -1); + + //printf("inidx: %d - outidx: %d\n", inidx, outidx); + //CPPUNIT_ASSERT_EQUAL(71, inidx - outidx); // This does not make sense... + } + + void resampling_buffer_sizes() + { + CHResampler r; + CPPUNIT_ASSERT_EQUAL(1.0, r.ratio()); + + double infs = 24000; + double outfs = 48000; + r.setup(infs, outfs); + CPPUNIT_ASSERT_EQUAL(infs / outfs, r.ratio()); + + float in[BUFSZ]; + float out[(int)(BUFSZ / r.ratio())]; + + // Preload resampler + r.setOutputSamples(out, 1); + while(r.getOutputSampleCount()) { + r.setInputSamples(in, 1); + r.process(); + } + + r.setInputSamples(in, sizeof(in) / sizeof(float)); + r.setOutputSamples(out, sizeof(out) / sizeof(float)); + r.process(); + CPPUNIT_ASSERT_EQUAL((size_t)0, r.getInputSampleCount()); + CPPUNIT_ASSERT_EQUAL((size_t)0, r.getOutputSampleCount()); + } +}; + +// Registers the fixture into the 'registry' +CPPUNIT_TEST_SUITE_REGISTRATION(test_resampler); -- cgit v1.2.3 From 36630b0fa3d29c54a666d3bb00a2fac804fa7df9 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 6 Nov 2014 08:03:56 +0100 Subject: Make cli output modules work with new samplerate() design. --- drumgizmo/audiooutputenginedl.cc | 22 +++---------------- drumgizmo/drumgizmoc.cc | 2 +- drumgizmo/output/alsa/alsa.cc | 29 +++++++++++-------------- drumgizmo/output/dummy/dummy.cc | 30 +++++++++++--------------- drumgizmo/output/jackaudio/jackaudio.cc | 17 --------------- drumgizmo/output/wavfile/wavfile.cc | 38 +++++++++++++++------------------ 6 files changed, 46 insertions(+), 92 deletions(-) diff --git a/drumgizmo/audiooutputenginedl.cc b/drumgizmo/audiooutputenginedl.cc index fcedd9d..2648e8f 100644 --- a/drumgizmo/audiooutputenginedl.cc +++ b/drumgizmo/audiooutputenginedl.cc @@ -114,7 +114,8 @@ AudioOutputEngineDL::AudioOutputEngineDL(std::string name) o_samplerate = (output_samplerate_func_t) dlsym(lib, "samplerate"); dlsym_error = dlerror(); if(dlsym_error) { - o_samplerate = NULL; + printf("Cannot load symbol samplerate: %s\n", dlsym_error); + return; } ptr = o_create(); @@ -190,22 +191,5 @@ size_t AudioOutputEngineDL::getBufferSize() size_t AudioOutputEngineDL::samplerate() { if(o_samplerate) return o_samplerate(ptr); - return UNKNOWN_SAMPLERATE; + return 44100; } - -#ifdef TEST_AUDIOOUTPUTENGINEDL -//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_AUDIOOUTPUTENGINEDL*/ diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index d5fa817..61f8eaa 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) return 1; } - AudioOutputEngine *oe = new AudioOutputEngineDL(outputengine); + AudioOutputEngineDL *oe = new AudioOutputEngineDL(outputengine); if(oe == NULL) { printf("Invalid output engine: %s\n", outputengine.c_str()); diff --git a/drumgizmo/output/alsa/alsa.cc b/drumgizmo/output/alsa/alsa.cc index 7b3a395..dc2ac73 100644 --- a/drumgizmo/output/alsa/alsa.cc +++ b/drumgizmo/output/alsa/alsa.cc @@ -49,6 +49,7 @@ public: void pre(size_t size); void run(int channel, sample_t* data, size_t size); void post(size_t size); + size_t samplerate(); private: snd_pcm_t *handle; @@ -157,6 +158,11 @@ void Alsa::post(size_t size) snd_pcm_writei(handle, data, size); } +size_t Alsa::samplerate() +{ + return srate; +} + extern "C" { void *create() { @@ -210,21 +216,10 @@ extern "C" { Alsa *alsa = (Alsa*)h; alsa->post(s); } -} - -#ifdef TEST_AUDIOOUTPUTENGINEALSA -//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_AUDIOOUTPUTENGINEALSA*/ + size_t samplerate(void *h) + { + Alsa *alsa = (Alsa*)h; + return alsa->samplerate(); + } +} diff --git a/drumgizmo/output/dummy/dummy.cc b/drumgizmo/output/dummy/dummy.cc index cd210dc..e60f2b7 100644 --- a/drumgizmo/output/dummy/dummy.cc +++ b/drumgizmo/output/dummy/dummy.cc @@ -43,6 +43,8 @@ public: void pre(size_t size); void run(int channel, sample_t* data, size_t size); void post(size_t size); + + size_t samplerate(); }; Dummy::Dummy() @@ -83,6 +85,11 @@ void Dummy::post(size_t size) { } +size_t Dummy::samplerate() +{ + return 44100; +} + extern "C" { void *create() { @@ -136,21 +143,10 @@ extern "C" { Dummy *dummy = (Dummy*)h; dummy->post(size); } -} - -#ifdef TEST_AUDIOOUTPUTENGINEDUMMY -//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_AUDIOOUTPUTENGINEDUMMY*/ + size_t samplerate(void *h) + { + Dummy *dummy = (Dummy*)h; + return dummy->samplerate(); + } +} diff --git a/drumgizmo/output/jackaudio/jackaudio.cc b/drumgizmo/output/jackaudio/jackaudio.cc index b7fa4f9..5c04146 100644 --- a/drumgizmo/output/jackaudio/jackaudio.cc +++ b/drumgizmo/output/jackaudio/jackaudio.cc @@ -218,20 +218,3 @@ extern "C" { return jack->samplerate(); } } - -#ifdef TEST_AUDIOINPUTENGINEJACKAUDIO -//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_AUDIOINPUTENGINEJACKAUDIO*/ diff --git a/drumgizmo/output/wavfile/wavfile.cc b/drumgizmo/output/wavfile/wavfile.cc index cb95715..fa4128e 100644 --- a/drumgizmo/output/wavfile/wavfile.cc +++ b/drumgizmo/output/wavfile/wavfile.cc @@ -44,6 +44,7 @@ public: void pre(size_t size); void run(int channel, sample_t* data, size_t size); void post(size_t size); + size_t samplerate(); private: SF_INFO sf_info; @@ -58,6 +59,10 @@ WavFile::WavFile() { fh = NULL; filename = "output"; + + sf_info.channels = 1;//channels; + sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; + sf_info.samplerate = 44100; } WavFile::~WavFile() @@ -74,10 +79,6 @@ WavFile::~WavFile() bool WavFile::init(int channels, char *cnames[]) { this->channels = channels; - - sf_info.channels = 1;//channels; - sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; - sf_info.samplerate = 44100; fh = (SNDFILE **)malloc(sizeof(SNDFILE *)*channels); @@ -102,6 +103,7 @@ bool WavFile::init(int channels, char *cnames[]) void WavFile::setParm(std::string parm, std::string value) { if(parm == "file") filename = value; + if(parm == "srate") sf_info.samplerate = atoi(value.c_str()); } bool WavFile::start() @@ -126,6 +128,11 @@ void WavFile::post(size_t size) { } +size_t WavFile::samplerate() +{ + return sf_info.samplerate; +} + extern "C" { void *create() { @@ -179,21 +186,10 @@ extern "C" { WavFile *sndfile = (WavFile*)h; sndfile->post(s); } -} - -#ifdef TEST_AUDIOOUTPUTENGINESNDFILE -//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_AUDIOOUTPUTENGINESNDFILE*/ + size_t samplerate(void *h) + { + WavFile *wavfile = (WavFile*)h; + return wavfile->samplerate(); + } +} -- cgit v1.2.3 From 2e7176bc558cb03d4e7c27769bab9cd45c703332 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 5 Dec 2014 20:32:14 +0100 Subject: Change check for libzita-resampler to not depend on cpp name mangling. --- configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 37e3013..641f2f7 100644 --- a/configure.ac +++ b/configure.ac @@ -351,13 +351,13 @@ if test x$enable_resampler != xno; then CXXFLAGS="" CPPFLAGS="$ZITA_CPPFLAGS" CFLAGS="" - LDFLAGS="$ZITA_LDFLAGS" + LDFLAGS="$ZITA_LDFLAGS -lzita-resampler -lpthread" LIBS="" - AC_CHECK_HEADER(zita-resampler/resampler.h, - AC_CHECK_LIB(zita-resampler, _Z28zita_resampler_major_versionv, has_zita=yes, has_zita=no), - has_zita=no) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include ], + [Resampler r] ) ], has_zita=yes, has_zita=no) ZITA_CPPFLAGS="$CXXFLAGS $CPPFLAGS $CFLAGS" - ZITA_LIBS="$LDFLAGS $LIBS -lzita-resampler" + ZITA_LIBS="$LDFLAGS $LIBS" CXXFLAGS="$tmp_CXXFLAGS" CPPFLAGS="$tmp_CPPFLAGS" CFLAGS="$tmp_CFLAGS" -- cgit v1.2.3