summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-01-28 18:17:01 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-28 18:17:01 +0100
commit180eacc2af8a69b8ee947750ae7708b78c499f7d (patch)
tree915875240faf34c2c0bedeef1d8e25df213a1b19
parent6e2fb62b35b5545c866dc1acf00857e1d160ff5e (diff)
Revert files that shouldn't have been changed in this branch...
-rw-r--r--drumgizmo/audioinputenginedl.cc75
-rw-r--r--drumgizmo/audioinputenginedl.h4
-rw-r--r--drumgizmo/audiooutputenginedl.cc5
-rw-r--r--drumgizmo/audiooutputenginedl.h4
-rw-r--r--drumgizmo/drumgizmoc.cc25
-rw-r--r--drumgizmo/input/test/test.cc64
-rw-r--r--drumgizmo/jackclient.cc31
-rw-r--r--drumgizmo/jackclient.h7
-rw-r--r--drumgizmo/output/alsa/alsa.cc12
-rw-r--r--drumgizmo/output/jackaudio/jackaudio.cc1
-rw-r--r--plugingui/font.cc4
-rw-r--r--plugingui/widget.cc1
12 files changed, 97 insertions, 136 deletions
diff --git a/drumgizmo/audioinputenginedl.cc b/drumgizmo/audioinputenginedl.cc
index e13bdd1..cba59fa 100644
--- a/drumgizmo/audioinputenginedl.cc
+++ b/drumgizmo/audioinputenginedl.cc
@@ -176,7 +176,76 @@ void AudioInputEngineDL::post()
return i_post(ptr);
}
-void AudioInputEngineDL::setEngine(DrumGizmo* drumgizmo)
-{
- jackclient->setEngine(drumgizmo);
+//#include "audioinputenginedummy.h"
+//#include "audioinputenginejackmidi.h"
+//#include "audioinputenginemidifile.h"
+
+/*
+
+typedef Device* (*create_func_t)(void);
+typedef void (*destroy_func_t)(Device*);
+
+struct device_t {
+ Device* dev;
+ destroy_func_t destroyer;
+ void* lib;
+};
+
+int load_shared_device(device_t &dev, std::string devlib,
+ std::string devfile, ConfMap devconfmap) {
+ // load library
+ dev.lib = dlopen(devlib.c_str(), RTLD_LAZY);
+ if(!dev.lib ) {
+ printf("Cannot load device: %s\n", dlerror());
+ return -1;
+ }
+
+ create_func_t create_device = (create_func_t) dlsym(dev.lib, "create");
+ const char* dlsym_error = dlerror();
+ if(dlsym_error) {
+ printf("Cannot load symbol create: %s\n", dlsym_error);
+ return -1;
+ }
+
+ dev.destroyer = (destroy_func_t) dlsym(dev.lib, "destroy");
+ dlsym_error = dlerror();
+ if(dlsym_error) {
+ printf("Cannot load symbol destroy: %s\n", dlsym_error);
+ return -1;
+ }
+
+ dev.dev = create_device();
+
+ // initialize device
+ DevData devdata = dev.dev->init(devfile, devconfmap);
+ if(devdata.retval != DevData::VALUE_SUCCESS) {
+ printf("Error while initializing device: %s\n", devdata.msg.c_str());
+ return -1;
+ }
+
+ return 0;
}
+
+void unload_shared_device(device_t &dev) {
+
+ dev.destroyer(dev.dev);
+ dlclose(dev.lib);
+}
+*/
+
+#ifdef TEST_AUDIOINPUTENGINEDL
+//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_AUDIOINPUTENGINEDL*/
diff --git a/drumgizmo/audioinputenginedl.h b/drumgizmo/audioinputenginedl.h
index 1cf2c1d..94bd89d 100644
--- a/drumgizmo/audioinputenginedl.h
+++ b/drumgizmo/audioinputenginedl.h
@@ -40,8 +40,6 @@ typedef void (*input_pre_func_t)(void*);
typedef event_t* (*input_run_func_t)(void*,size_t,size_t,size_t*);
typedef void (*input_post_func_t)(void*);
-class DrumGizmo;
-
class AudioInputEngineDL : public AudioInputEngine {
public:
AudioInputEngineDL(std::string name);
@@ -58,8 +56,6 @@ public:
event_t *run(size_t pos, size_t len, size_t *nevents);
void post();
- void setEngine(DrumGizmo* drumgizmo);
-
private:
void *ptr{nullptr};
input_create_func_t i_create{nullptr};
diff --git a/drumgizmo/audiooutputenginedl.cc b/drumgizmo/audiooutputenginedl.cc
index 2e573cd..042db4a 100644
--- a/drumgizmo/audiooutputenginedl.cc
+++ b/drumgizmo/audiooutputenginedl.cc
@@ -195,8 +195,3 @@ size_t AudioOutputEngineDL::samplerate()
if(o_samplerate) return o_samplerate(ptr);
return 44100;
}
-
-void AudioOutputEngineDL::setEngine(DrumGizmo* drumgizmo)
-{
- jackclient->setEngine(drumgizmo);
-}
diff --git a/drumgizmo/audiooutputenginedl.h b/drumgizmo/audiooutputenginedl.h
index 39525fa..4b31015 100644
--- a/drumgizmo/audiooutputenginedl.h
+++ b/drumgizmo/audiooutputenginedl.h
@@ -48,8 +48,6 @@ 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 DrumGizmo;
-
class AudioOutputEngineDL : public AudioOutputEngine {
public:
AudioOutputEngineDL(std::string name);
@@ -69,8 +67,6 @@ public:
size_t getBufferSize();
size_t samplerate();
- void setEngine(DrumGizmo* drumgizmo);
-
private:
void *ptr{nullptr};
output_create_func_t o_create{nullptr};
diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc
index 8983aa3..1ccc151 100644
--- a/drumgizmo/drumgizmoc.cc
+++ b/drumgizmo/drumgizmoc.cc
@@ -147,7 +147,7 @@ int CliMain::run(int argc, char *argv[])
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
-
+
c = getopt_long(argc, argv, "hvpo:O:i:I:e:a"
#ifndef DISABLE_HUGIN
"D:"
@@ -228,7 +228,7 @@ int CliMain::run(int argc, char *argv[])
return 1;
}
- AudioInputEngineDL *ie = new AudioInputEngineDL(inputengine);
+ AudioInputEngine *ie = new AudioInputEngineDL(inputengine);
if(ie == NULL) {
printf("Invalid input engine: %s\n", inputengine.c_str());
@@ -327,10 +327,6 @@ int CliMain::run(int argc, char *argv[])
printf("Using kitfile: %s\n", kitfile.c_str());
DrumGizmo gizmo(oe, ie);
- oe->setEngine(&gizmo);
- ie->setEngine(&gizmo);
-
- gizmo.setFrameSize(oe->getBufferSize());
if(kitfile == "" || !gizmo.loadkit(kitfile)) {
printf("Failed to load \"%s\".\n", kitfile.c_str());
@@ -361,22 +357,7 @@ int CliMain::run(int argc, char *argv[])
return 1;
}
- size_t pos = 0;
- size_t nsamples = oe->getBufferSize();
- sample_t *samples = (sample_t *)malloc(nsamples * sizeof(sample_t));
-
- ie->start();
- oe->start();
-
- while(gizmo.run(pos, samples, nsamples) == true) {
- pos += nsamples;
- if(endpos != -1 && pos >= (size_t)endpos) break;
- }
-
- ie->stop();
- oe->stop();
-
- free(samples);
+ gizmo.run(endpos);
printf("Quit.\n"); fflush(stdout);
diff --git a/drumgizmo/input/test/test.cc b/drumgizmo/input/test/test.cc
index 6032f02..b7b4a7d 100644
--- a/drumgizmo/input/test/test.cc
+++ b/drumgizmo/input/test/test.cc
@@ -31,13 +31,7 @@
class Test {
public:
- Test()
- : p(0.1)
- , instr(-1)
- , nth(-1)
- , nth_counter(0)
- {}
-
+ Test() { p = 0.1; instr = -1; len = -1; }
~Test() {}
bool init(int instruments, char *inames[]);
@@ -54,14 +48,11 @@ public:
private:
float p;
int instr;
- int nth;
- int nth_counter;
- int num_instruments;
+ int len;
};
bool Test::init(int instruments, char *inames[])
{
- num_instruments = instruments;
return true;
}
@@ -69,7 +60,7 @@ void Test::setParm(std::string parm, std::string value)
{
if(parm == "p") p = atof(value.c_str());
if(parm == "instr") instr = atoi(value.c_str());
- if(parm == "nth") nth = atoi(value.c_str());
+ if(parm == "len") len = atoi(value.c_str());
}
bool Test::start()
@@ -85,46 +76,23 @@ void Test::pre()
{
}
-#define BUFFER_MAX 1000
event_t *Test::run(size_t pos, size_t nsamples, size_t *nevents)
{
- *nevents = 0;
- event_t *evs = (event_t *)malloc(sizeof(event_t) * BUFFER_MAX);
-
- for(size_t i = 0; i < nsamples; ++i) {
-
- if(nth != -1) {
- if(nth_counter < nth) {
- ++nth_counter;
- continue;
- }
- nth_counter = 0;
- } else {
- if((float)rand() / (float)RAND_MAX > p) {
- continue;
- }
- }
-
- evs[*nevents].type = TYPE_ONSET;
-
- if(instr != -1) {
- // Use specified instrument
- evs[*nevents].instrument = instr;
- } else {
- // Use random instrument
- evs[*nevents].instrument = rand() % num_instruments;
- }
-
- evs[*nevents].velocity = (float)rand()/(float)RAND_MAX;
- evs[*nevents].offset = nsamples?rand()%nsamples:0;
-
- (*nevents)++;
-
- if(*nevents == BUFFER_MAX) {
- break;
- }
+ if((float)rand() / (float)RAND_MAX > p) {
+ *nevents = 0;
+ return NULL;
}
+ *nevents = 1;
+ event_t *evs = (event_t *)malloc(sizeof(event_t));
+ evs[0].type = TYPE_ONSET;
+ if(len != -1 && (int)pos > len * 44100) evs[0].type = TYPE_STOP;
+
+ if(instr != -1) evs[0].instrument = instr;
+ else evs[0].instrument = rand() % 32;
+
+ evs[0].velocity = (float)rand()/(float)RAND_MAX;
+ evs[0].offset = nsamples?rand()%nsamples:0;
return evs;
}
diff --git a/drumgizmo/jackclient.cc b/drumgizmo/jackclient.cc
index a24d53a..e4af141 100644
--- a/drumgizmo/jackclient.cc
+++ b/drumgizmo/jackclient.cc
@@ -26,33 +26,20 @@
*/
#include "jackclient.h"
-#include <drumgizmo.h>
-
extern "C"
{
-
-static int jack_process_callback(jack_nframes_t nframes, void *arg)
-{
- return ((JackClient*)arg)->process(nframes);
-}
-
-static void jack_free_wheel_callback(int starting, void *arg)
-{
- ((JackClient*)arg)->setFreeWheel(starting);
-}
-
+ int _wrap_jack_process(jack_nframes_t nframes, void *arg){
+ return ((JackClient*)arg)->process(nframes);}
} // extern "C"
JackClient::JackClient()
: refcnt(0)
- , drumgizmo(NULL)
{
jack_status_t status;
jack_client = jack_client_open("DrumGizmo", JackNullOption, &status);
- jack_set_process_callback(jack_client, jack_process_callback, this);
- jack_set_freewheel_callback(jack_client, jack_free_wheel_callback, this);
+ jack_set_process_callback(jack_client, _wrap_jack_process, this);
active = false;
}
@@ -92,18 +79,6 @@ int JackClient::process(jack_nframes_t nframes)
return 0;
}
-void JackClient::setFreeWheel(bool freewheel)
-{
- if(drumgizmo) {
- drumgizmo->setFreeWheel(freewheel);
- }
-}
-
-void JackClient::setEngine(DrumGizmo* drumgizmo)
-{
- this->drumgizmo = drumgizmo;
-}
-
JackClient *jackclient = NULL;
JackClient *init_jack_client()
diff --git a/drumgizmo/jackclient.h b/drumgizmo/jackclient.h
index 8c5954d..f093220 100644
--- a/drumgizmo/jackclient.h
+++ b/drumgizmo/jackclient.h
@@ -36,8 +36,6 @@ public:
virtual void jack_process(jack_nframes_t nframes) = 0;
};
-class DrumGizmo;
-
class JackClient {
public:
JackClient();
@@ -53,17 +51,12 @@ public:
void activate();
int process(jack_nframes_t nframes);
- void setFreeWheel(bool freewheel);
-
jack_client_t *jack_client;
- void setEngine(DrumGizmo* drumgizmo);
-
// Sort of private...
int refcnt;
private:
- DrumGizmo* drumgizmo;
std::set<JackProcess *> jack_processes;
bool active;
};
diff --git a/drumgizmo/output/alsa/alsa.cc b/drumgizmo/output/alsa/alsa.cc
index f9a2068..71e0c3d 100644
--- a/drumgizmo/output/alsa/alsa.cc
+++ b/drumgizmo/output/alsa/alsa.cc
@@ -49,7 +49,6 @@ public:
void pre(size_t size);
void run(int channel, sample_t* data, size_t size);
void post(size_t size);
- size_t bufsize();
size_t samplerate();
private:
@@ -159,11 +158,6 @@ void Alsa::post(size_t size)
snd_pcm_writei(handle, data, size);
}
-size_t Alsa::bufsize()
-{
- return frames;
-}
-
size_t Alsa::samplerate()
{
return srate;
@@ -223,12 +217,6 @@ extern "C" {
alsa->post(s);
}
- size_t bufsize(void *h)
- {
- Alsa *alsa = (Alsa*)h;
- return alsa->bufsize();
- }
-
size_t samplerate(void *h)
{
Alsa *alsa = (Alsa*)h;
diff --git a/drumgizmo/output/jackaudio/jackaudio.cc b/drumgizmo/output/jackaudio/jackaudio.cc
index e027742..511c145 100644
--- a/drumgizmo/output/jackaudio/jackaudio.cc
+++ b/drumgizmo/output/jackaudio/jackaudio.cc
@@ -130,6 +130,7 @@ void JackAudio::post(size_t size)
void JackAudio::jack_process(jack_nframes_t nframes)
{
+ //printf("o"); fflush(stdout);
for(size_t c = 0; c < nchannels; c++) {
jack_default_audio_sample_t *out =
(jack_default_audio_sample_t *) jack_port_get_buffer(output_port[c],
diff --git a/plugingui/font.cc b/plugingui/font.cc
index d02efe7..bcaa027 100644
--- a/plugingui/font.cc
+++ b/plugingui/font.cc
@@ -88,9 +88,9 @@ size_t Font::textHeight(const std::string& text) const
return img_font.height();
}
-void Font::setLetterSpacing(int letter_spacing)
+void Font::setLetterSpacing(int letterSpacing)
{
- spacing = letter_spacing;
+ spacing = letterSpacing;
}
int Font::letterSpacing() const
diff --git a/plugingui/widget.cc b/plugingui/widget.cc
index 5c8ff46..4b92e65 100644
--- a/plugingui/widget.cc
+++ b/plugingui/widget.cc
@@ -136,7 +136,6 @@ size_t Widget::height()
size_t Widget::windowX()
{
size_t window_x = x();
-
if(parent)
{
window_x += parent->windowX();