summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/.gitignore3
-rw-r--r--src/Makefile.am.drumgizmo20
-rw-r--r--src/audiooutputengine.h3
-rw-r--r--src/drumgizmo.cc30
-rw-r--r--src/drumgizmo.h8
-rw-r--r--src/instrumentparser.cc2
-rw-r--r--src/saxparser.cc12
-rw-r--r--src/saxparser.h3
8 files changed, 59 insertions, 22 deletions
diff --git a/src/.gitignore b/src/.gitignore
index 195bd0f..f3a3feb 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1 +1,2 @@
-Makefile.am.test \ No newline at end of file
+Makefile.am.test
+*.log \ No newline at end of file
diff --git a/src/Makefile.am.drumgizmo b/src/Makefile.am.drumgizmo
new file mode 100644
index 0000000..98f1b82
--- /dev/null
+++ b/src/Makefile.am.drumgizmo
@@ -0,0 +1,20 @@
+DRUMGIZMO_SOURCES = \
+ $(top_srcdir)/src/audiofile.cc \
+ $(top_srcdir)/src/channel.cc \
+ $(top_srcdir)/src/channelmixer.cc \
+ $(top_srcdir)/src/configuration.cc \
+ $(top_srcdir)/src/drumgizmo.cc \
+ $(top_srcdir)/src/drumkit.cc \
+ $(top_srcdir)/src/drumkitparser.cc \
+ $(top_srcdir)/src/events.cc \
+ $(top_srcdir)/src/instrument.cc \
+ $(top_srcdir)/src/instrumentparser.cc \
+ $(top_srcdir)/src/midimapparser.cc \
+ $(top_srcdir)/src/midimapper.cc \
+ $(top_srcdir)/src/mutex.cc \
+ $(top_srcdir)/src/path.cc \
+ $(top_srcdir)/src/sample.cc \
+ $(top_srcdir)/src/saxparser.cc \
+ $(top_srcdir)/src/velocity.cc
+
+DRUMGIZMO_LIBS = $(SNDFILE_LIBS) $(EXPAT_LIBS) \ No newline at end of file
diff --git a/src/audiooutputengine.h b/src/audiooutputengine.h
index 864ecc5..d2d2310 100644
--- a/src/audiooutputengine.h
+++ b/src/audiooutputengine.h
@@ -45,6 +45,9 @@ public:
virtual void pre(size_t nsamples) = 0;
virtual void run(int ch, sample_t *samples, size_t nsamples) = 0;
virtual void post(size_t nsamples) = 0;
+
+ // Reimplement this if you wish to use internal buffer directly.
+ virtual sample_t *getBuffer(int ch) { return NULL; }
};
#endif/*__DRUMGIZMO_AUDIOOUTPUTENGINE_H__*/
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index 5b48e0c..7af13d2 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -121,7 +121,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples)
*/
if(d < (int)kit.instruments.size()) {
- i = &kit.instruments[d];
+ i = kit.instruments[d];
}
if(i == NULL) {
@@ -203,16 +203,8 @@ void DrumGizmo::run()
}
#ifdef SSE
-#define SZ 16
-typedef float v4sf __attribute__ ((vector_size (sizeof(float)*SZ)));
-
-union f4vector
-{
- v4sf v;
- float f[SZ];
-};
-#else/*SSE*/
-#define SZ 0
+#define N 8
+typedef float vNsf __attribute__ ((vector_size(sizeof(float)*N)));
#endif/*SSE*/
void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
@@ -238,13 +230,13 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
if(evt->t + end - n > af->size) end = af->size - evt->t + n;
#ifdef SSE
- size_t optend = ((end - n) / SZ) * SZ;
- for(; n < optend; n+=SZ) {
- *(v4sf*)&(s[n]) += *(v4sf*)&(af->data[evt->t]);
- evt->t += SZ;
+ size_t optend = ((end - n) / N) * N + n;
+ for(; n < optend; n += N) {
+ *(vNsf*)&(s[n]) += *(vNsf*)&(af->data[evt->t]);
+ evt->t += N;
}
#endif
-
+ //printf("n: %d end: %d, diff: %d", n, end, end - n); fflush(stdout);
for(; n < end; n++) {
s[n] += af->data[evt->t];
evt->t++;
@@ -386,7 +378,7 @@ void DrumGizmo::setConfigString(std::string cfg)
}
#ifdef TEST_DRUMGIZMO
-//deps: instrument.cc sample.cc channel.cc audiofile.cc drumkitparser.cc configuration.cc saxparser.cc instrumentparser.cc path.cc
+//deps: instrument.cc sample.cc channel.cc audiofile.cc drumkit.cc drumkitparser.cc configuration.cc saxparser.cc instrumentparser.cc path.cc
//cflags: $(SNDFILE_CFLAGS) $(EXPAT_CFLAGS) -I../include -DSSE -msse -msse2 -msse3
//libs: $(SNDFILE_LIBS) $(EXPAT_LIBS)
#include "test.h"
@@ -511,8 +503,8 @@ TEST_BEGIN;
createTestKit();
size_t size = PCM_SIZE;
-for(size_t chunksz = 1; chunksz < offset + size + padding + 1; chunksz++) {
-
+//for(size_t chunksz = 1; chunksz < size + 1; chunksz++) {
+size_t chunksz = 16; {
sample_t samples[chunksz];
for(size_t offset = 0; offset < chunksz + size + 1; offset++) {
diff --git a/src/drumgizmo.h b/src/drumgizmo.h
index 2f85d51..a3ad3ca 100644
--- a/src/drumgizmo.h
+++ b/src/drumgizmo.h
@@ -46,6 +46,7 @@ public:
~DrumGizmo();
bool loadkit(const std::string &kitfile);
+ std::string drumkitfile();
bool init(bool preload = true);
@@ -57,6 +58,11 @@ public:
bool isRunning() { return is_running; }
+ std::string configString();
+ void setConfigString(std::string cfg);
+
+ std::string midimapfile;
+
private:
bool is_running;
@@ -71,6 +77,8 @@ private:
public:
#endif
DrumKit kit;
+
+ std::string kitfile;
};
diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc
index 5198959..fdeb934 100644
--- a/src/instrumentparser.cc
+++ b/src/instrumentparser.cc
@@ -35,7 +35,7 @@ InstrumentParser::InstrumentParser(const std::string &file, Instrument &i)
: instrument(i)
{
s = NULL;
- printf("Parsing instrument in %s\n", file.c_str());
+ // printf("Parsing instrument in %s\n", file.c_str());
path = getPath(file);
fd = fopen(file.c_str(), "r");
if(!fd) return;
diff --git a/src/saxparser.cc b/src/saxparser.cc
index 1090ef3..b6bfa7c 100644
--- a/src/saxparser.cc
+++ b/src/saxparser.cc
@@ -108,6 +108,18 @@ int SAXParser::parse()
return 0;
}
+int SAXParser::parse(std::string buffer)
+{
+ if(!XML_Parse(p, buffer.c_str(), buffer.length(), true)) {
+ parseError((char*)buffer.c_str(), buffer.length(),
+ XML_ErrorString(XML_GetErrorCode(p)),
+ (int)XML_GetCurrentLineNumber(p));
+ return 1;
+ }
+
+ return 0;
+}
+
void SAXParser::parseError(char *buf, size_t len, std::string error, int lineno)
{
fprintf(stderr, "SAXParser error at line %d: %s\n", lineno, error.c_str());
diff --git a/src/saxparser.h b/src/saxparser.h
index c3700bf..aff90d7 100644
--- a/src/saxparser.h
+++ b/src/saxparser.h
@@ -39,7 +39,8 @@ public:
virtual ~SAXParser();
int parse();
-
+ int parse(std::string buffer);
+
virtual void characterData(std::string &data) {}
virtual void startTag(std::string name, attr_t attr) {}
virtual void endTag(std::string name) {}