From cd0e36773992e26985bdec1f7a5341f83fa3e521 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 15 Jul 2011 13:02:33 +0000 Subject: New input/output plugin architecture. New LV2 plugin. --- drumgizmo/input/test/Makefile.am | 26 ++++++ drumgizmo/input/test/test.cc | 170 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 drumgizmo/input/test/Makefile.am create mode 100644 drumgizmo/input/test/test.cc (limited to 'drumgizmo/input/test') diff --git a/drumgizmo/input/test/Makefile.am b/drumgizmo/input/test/Makefile.am new file mode 100644 index 0000000..ca45de0 --- /dev/null +++ b/drumgizmo/input/test/Makefile.am @@ -0,0 +1,26 @@ + +testsources = \ + test.cc + +if HAVE_INPUT_TEST + +testltlibs = libtest.la +testbuildsources = $(testsources) + +else + +testltlibs = +testbuildsources = + +endif + +EXTRA_DIST = $(testsources) + +lib_LTLIBRARIES = $(testltlibs) + +libdir = $(INPUT_PLUGIN_DIR) + +INCLUDES = -I$(top_srcdir)/include +libtest_la_LDFLAGS = +libtest_la_LIBADD = +libtest_la_SOURCES = $(testbuildsources) diff --git a/drumgizmo/input/test/test.cc b/drumgizmo/input/test/test.cc new file mode 100644 index 0000000..457733f --- /dev/null +++ b/drumgizmo/input/test/test.cc @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * audioinputenginedummy.cc + * + * Sat Apr 30 21:11:54 CEST 2011 + * Copyright 2011 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 +#include + +class Test { +public: + Test() { p = 0.1; instr = -1; } + ~Test() {} + + bool init(int instruments, char *inames[]); + + void setParm(std::string parm, std::string value); + + bool start(); + void stop(); + + void pre(); + event_t *run(size_t pos, size_t len, size_t *nevents); + void post(); + +private: + float p; + int instr; +}; + +bool Test::init(int instruments, char *inames[]) +{ + return true; +} + +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()); +} + +bool Test::start() +{ + return true; +} + +void Test::stop() +{ +} + +void Test::pre() +{ +} + +event_t *Test::run(size_t pos, size_t len, size_t *nevents) +{ + 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(instr != -1) evs[0].instrument = instr; + else evs[0].instrument = rand() % 32; + + evs[0].velocity = (float)rand()/(float)RAND_MAX; + evs[0].offset = len?rand()%len:0; + return evs; +} + +void Test::post() +{ +} + +extern "C" { + void *create() + { + return new Test(); + } + + void destroy(void *h) + { + Test *test = (Test*)h; + delete test; + } + + bool init(void *h, int i, char *inames[]) + { + Test *test = (Test*)h; + return test->init(i, inames); + } + + void setparm(void *h, const char *parm, const char *value) + { + Test *test = (Test*)h; + test->setParm(parm, value); + } + + bool start(void *h) + { + Test *test = (Test*)h; + return test->start(); + } + + void stop(void *h) + { + Test *test = (Test*)h; + test->stop(); + } + + void pre(void *h) + { + Test *test = (Test*)h; + test->pre(); + } + + event_t *run(void *h, size_t pos, size_t len, size_t *nev) + { + Test *test = (Test*)h; + return test->run(pos, len, nev); + } + + void post(void *h) + { + Test *test = (Test*)h; + test->post(); + } +} + +#ifdef TEST_AUDIOINPUTENGINETEST +//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_AUDIOINPUTENGINETEST*/ -- cgit v1.2.3