summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2009-02-20 17:22:14 +0000
committerdeva <deva>2009-02-20 17:22:14 +0000
commitfda7eaa26e0d796cac151275fc5b9bcb7b312c2b (patch)
tree7979c3678a08439218024c38cf04cc69d6dbbb10
parent3a2fbb13a8571832fd8b7bd7b3e378b3f38814b2 (diff)
Incremented version number.
-rw-r--r--configure.in2
-rw-r--r--src/audiofile.cc14
-rw-r--r--src/audiofile.h2
-rw-r--r--src/drumgizmo.cc23
-rw-r--r--src/drumkitparser.cc5
-rw-r--r--src/drumkitparser.h3
6 files changed, 35 insertions, 14 deletions
diff --git a/configure.in b/configure.in
index aafe24b..ed725fa 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
# Filename: configure.in
AC_INIT(src/drumgizmo.cc)
-AM_INIT_AUTOMAKE( drumgizmo, 0.0.1 )
+AM_INIT_AUTOMAKE( drumgizmo, 0.0.2 )
AC_PROG_CXX
diff --git a/src/audiofile.cc b/src/audiofile.cc
index c3dba3c..b8b4ef9 100644
--- a/src/audiofile.cc
+++ b/src/audiofile.cc
@@ -31,12 +31,22 @@
#include <sndfile.h>
-AudioFile::AudioFile(std::string filename, bool preload)
+AudioFile::AudioFile(std::string filename, bool preload, int min_velocity)
{
this->filename = filename;
data = NULL;
size = 0;
- if(preload) load();
+
+ char *p = (char*)filename.c_str() + filename.length() - 6;
+ int num = atoi(p);
+ if(num < 0) num *= -1;
+
+ printf("%s", filename.c_str());
+ if(preload && num >= min_velocity) {
+ printf(" ... loading");
+ load();
+ }
+ printf("\n");
}
AudioFile::~AudioFile()
diff --git a/src/audiofile.h b/src/audiofile.h
index 4cd863b..879cc95 100644
--- a/src/audiofile.h
+++ b/src/audiofile.h
@@ -32,7 +32,7 @@
class AudioFile {
public:
- AudioFile(std::string filename, bool preload = false);
+ AudioFile(std::string filename, bool preload = false, int min_velocity = 0);
~AudioFile();
void load();
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index 77b8433..cfc8ad5 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -46,10 +46,11 @@ static const char copyright_str[] =
static const char usage_str[] =
"Usage: %s [options] drumkitfile\n"
"Options:\n"
-" -p, --preload Load entire kit audio files into memory (uses ALOT of memory).\n"
-" -m, --midi midifile Load midifile, and play it.\n"
-" -v, --version Print version information and exit.\n"
-" -h, --help Print this message and exit.\n"
+" -p, --preload Load entire kit audio files into memory (uses ALOT of memory).\n"
+" -P, --preload_vel vel Load all files with velocity above vel into memory (uses a little less memory).\n"
+" -m, --midi midifile Load midifile, and play it.\n"
+" -v, --version Print version information and exit.\n"
+" -h, --help Print this message and exit.\n"
;
int main(int argc, char *argv[])
@@ -57,18 +58,21 @@ int main(int argc, char *argv[])
int c;
char *midifile = NULL;
- bool preload = false;
+ bool preload = true;
+ int min_velocity = 18;
int option_index = 0;
while(1) {
static struct option long_options[] = {
+ {"preload_vel", required_argument, 0, 'P'},
+ {"preload", no_argument, 0, 'p'},
{"midi", required_argument, 0, 'm'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
- c = getopt_long (argc, argv, "hvpm:", long_options, &option_index);
+ c = getopt_long (argc, argv, "hvpP:m:", long_options, &option_index);
if (c == -1)
break;
@@ -82,6 +86,11 @@ int main(int argc, char *argv[])
preload = true;
break;
+ case 'P':
+ preload = true;
+ min_velocity = atoi(optarg);
+ break;
+
case '?':
case 'h':
printf(version_str);
@@ -114,7 +123,7 @@ int main(int argc, char *argv[])
printf("Using kitfile: %s\n", kitfile.c_str());
- DrumKitParser parser(kitfile, preload);
+ DrumKitParser parser(kitfile, preload, min_velocity);
if(parser.parse()) return 1;
JackClient client(parser.getDrumkit());
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc
index 921eefa..ae557dd 100644
--- a/src/drumkitparser.cc
+++ b/src/drumkitparser.cc
@@ -28,7 +28,7 @@
#define DIR_SEPERATOR '/'
-DrumKitParser::DrumKitParser(std::string kitfile, bool preload)
+DrumKitParser::DrumKitParser(std::string kitfile, bool preload, int min_velocity)
{
std::string file;
std::string path;
@@ -44,6 +44,7 @@ DrumKitParser::DrumKitParser(std::string kitfile, bool preload)
}
this->preload = preload;
+ this->min_velocity = min_velocity;
dk = NULL;
fd = fopen(file.c_str(), "r");
@@ -79,7 +80,7 @@ void DrumKitParser::startTag(std::string name, std::map< std::string, std::strin
}
if(name == "audiofile") {
- AudioFile *af = new AudioFile(attributes["name"], preload);
+ AudioFile *af = new AudioFile(attributes["name"], preload, min_velocity);
af->channel = attributes["channel"];
lastsample->audiofiles[attributes["name"]] = af;
}
diff --git a/src/drumkitparser.h b/src/drumkitparser.h
index 6192286..22fe83e 100644
--- a/src/drumkitparser.h
+++ b/src/drumkitparser.h
@@ -32,7 +32,7 @@
class DrumKitParser : public SAXParser {
public:
- DrumKitParser(std::string kitfile, bool preload = false);
+ DrumKitParser(std::string kitfile, bool preload = false, int min_velocity = -1);
~DrumKitParser();
void startTag(std::string name, std::map< std::string, std::string> attributes);
@@ -52,6 +52,7 @@ private:
Velocity *lastvelocity;
bool preload;
+ int min_velocity;
};
#endif/*__DRUMGIZMO_DRUMKITPARSER_H__*/