From b69389f609c8c9c441d0251510f6b578a9437f6a Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 13 May 2014 11:44:45 +0200 Subject: Added filter to exclude hidden directories. --- plugingui/directory.cc | 61 +++++++++++++++++++++++++++++++++++++------------- plugingui/directory.h | 5 ++++- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/plugingui/directory.cc b/plugingui/directory.cc index 057aead..d481d24 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -77,7 +77,8 @@ size_t Directory::count() void Directory::refresh() { - _files = listFiles(_path); + _files = listFiles(_path, DIRECTORY_HIDDEN); +// _files = listFiles(_path); } bool Directory::cd(std::string dir) @@ -128,7 +129,7 @@ std::string Directory::cleanPath(std::string path) return Directory::pathToStr(pathlst); } -Directory::EntryList Directory::listFiles(std::string path) +Directory::EntryList Directory::listFiles(std::string path, unsigned char filter) { DEBUG(directory, "Listing files in '%s'\n", path.c_str()); @@ -149,12 +150,19 @@ Directory::EntryList Directory::listFiles(std::string path) if(Directory::isRoot(path) && name == "..") continue; + unsigned char entryinfo = 0; + if(isHidden(name)) { + entryinfo |= DIRECTORY_HIDDEN; + } + std::string entrypath = path; entrypath += SEP; entrypath += entry->d_name; if(Directory::isDir(entrypath)) { - if(name == "..") directories.push_back(entry->d_name); - else directories.push_back(std::string(SEP) + entry->d_name); + if(!(entryinfo && filter)) { + if(name == "..") directories.push_back(entry->d_name); + else directories.push_back(std::string(SEP) + entry->d_name); + } } else { int drumkit_suffix_length = strlen(DRUMKIT_SUFFIX); @@ -164,7 +172,10 @@ Directory::EntryList Directory::listFiles(std::string path) continue; } - files.push_back(entry->d_name); + +// if(!(entryinfo && filter)) { + files.push_back(entry->d_name); +// } } } @@ -276,6 +287,20 @@ bool Directory::isDir() return isDir(_path); } +bool Directory::isDir(std::string path) +{ + DEBUG(directory, "Is '%s' dir?\n", path.c_str()); + struct stat st; + if(stat(path.c_str(), &st) == 0) { + if((st.st_mode & S_IFDIR) != 0) { + DEBUG(directory, "Yes\n"); + return true; + } + } + DEBUG(directory, "No\n"); + return false; +} + bool Directory::fileExists(std::string filename) { return !isDir(_path + SEP + filename); @@ -291,18 +316,24 @@ bool Directory::exists(std::string path) } } -bool Directory::isDir(std::string path) +bool Directory::isHidden(std::string path) { - DEBUG(directory, "Is '%s' dir?\n", path.c_str()); - struct stat st; - if(stat(path.c_str(), &st) == 0) { - if((st.st_mode & S_IFDIR) != 0) { - DEBUG(directory, "Yes\n"); - return true; - } + // TODO: Handle hidden and system files in windows +#ifdef WIN32 + 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) != '.') { + return true; } - DEBUG(directory, "No\n"); - return false; + else { + return false; + } +#endif } Directory::Path Directory::parsePath(std::string path_str) diff --git a/plugingui/directory.h b/plugingui/directory.h index 50d5fae..04ed3e7 100644 --- a/plugingui/directory.h +++ b/plugingui/directory.h @@ -36,6 +36,8 @@ #include #include +#define DIRECTORY_HIDDEN 1 + class Directory { public: @@ -70,10 +72,11 @@ class Directory { static std::string root(); static std::string root(std::string path); static std::string cleanPath(std::string path); - static Directory::EntryList listFiles(std::string path); + static Directory::EntryList listFiles(std::string path, unsigned char filter = 0); static bool isRoot(std::string path); static Directory::DriveList drives(); static bool isDir(std::string path); + static bool isHidden(std::string entry); static bool exists(std::string path); static std::string pathDirectory(std::string filepath); -- cgit v1.2.3 From b79a14e33ade7285d7309ef544d89c60f3d5b3ec Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 14 May 2014 16:52:21 +0200 Subject: Make lower limit to 'width' (ie. stddev) of normal distribution function. --- src/powerlist.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/powerlist.cc b/src/powerlist.cc index 1888733..96f2c9b 100644 --- a/src/powerlist.cc +++ b/src/powerlist.cc @@ -32,6 +32,14 @@ #include +/** + * Minimum sample set size. + * Smaller means wider 'velocity groups'. + * Limited by sample set size, ie. only kicks in if sample set size is smaller + * than this number. + */ +#define MIN_SAMPLE_SET_SIZE 10 + // Enable to calculate power on old samples without power attribute //#define AUTO_CALCULATE_POWER @@ -213,8 +221,12 @@ Sample *PowerList::get(level_t level) float power_span = power_max - power_min; + // Width is limited to at least 10. Fioxes problem with instrument with a + // sample set smaller than MIN_SAMPLE_SET_SIZE. + float width = fmax(samples.size(), MIN_SAMPLE_SET_SIZE); + // Spread out at most 1.5 samples away from center - float stddev = power_span / samples.size() * 1.5; + float stddev = power_span / width * 1.5; // Cut off mean value with stddev/2 in both ends in order to make room for // downwards expansion on velocity 0 and upwards expansion on velocity 1. -- cgit v1.2.3 From f35591647d0c67fafda439f961d9c47f7a62a346 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 17 May 2014 12:05:44 +0200 Subject: Adjust MIN_SAMPLE_SET_SIZE to match empirical value found by muldjord. --- src/powerlist.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/powerlist.cc b/src/powerlist.cc index 96f2c9b..6fc77ad 100644 --- a/src/powerlist.cc +++ b/src/powerlist.cc @@ -38,7 +38,7 @@ * Limited by sample set size, ie. only kicks in if sample set size is smaller * than this number. */ -#define MIN_SAMPLE_SET_SIZE 10 +#define MIN_SAMPLE_SET_SIZE 26 // Enable to calculate power on old samples without power attribute //#define AUTO_CALCULATE_POWER @@ -225,8 +225,9 @@ Sample *PowerList::get(level_t level) // sample set smaller than MIN_SAMPLE_SET_SIZE. float width = fmax(samples.size(), MIN_SAMPLE_SET_SIZE); - // Spread out at most 1.5 samples away from center - float stddev = power_span / width * 1.5; + // Spread out at most ~2 samples away from center if all samples have a + // uniform distribution over the power spectrum (which they probably don't). + float stddev = power_span / width; // Cut off mean value with stddev/2 in both ends in order to make room for // downwards expansion on velocity 0 and upwards expansion on velocity 1. -- cgit v1.2.3 From 488070f321b1fb24bb0a7022c321c574fd4b06ac Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 17 May 2014 12:19:35 +0200 Subject: Use new lodepng code instead of libpng in win32 plugingui test application. --- plugingui/Makefile.mingw32 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugingui/Makefile.mingw32 b/plugingui/Makefile.mingw32 index d1cd3bc..3a9542a 100644 --- a/plugingui/Makefile.mingw32 +++ b/plugingui/Makefile.mingw32 @@ -3,7 +3,7 @@ include Makefile.am.plugingui CFLAGS=-DSTANDALONE -DWIN32 -DUSE_THREAD ${PLUGIN_GUI_CFLAGS} \ -I$(top_srcdir)/src -I/local/include -LDFLAGS=-mconsole -lgdi32 -lsetupapi -lws2_32 -L/local/lib -lpng -lz -pthread +LDFLAGS=-mconsole -lgdi32 -lsetupapi -lws2_32 -L/local/lib -lz -pthread C_SOURCES = \ $(top_srcdir)/hugin/hugin.c \ @@ -39,6 +39,7 @@ CXX_SOURCES = \ $(top_srcdir)/plugingui/progressbar.cc \ $(top_srcdir)/plugingui/resource.cc \ $(top_srcdir)/plugingui/resource_data.cc \ + $(top_srcdir)/plugingui/lodepng/lodepng.cpp \ $(top_srcdir)/src/thread.cc \ $(top_srcdir)/src/semaphore.cc \ $(top_srcdir)/src/mutex.cc \ -- cgit v1.2.3