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/dummy/Makefile.am | 26 ++++++ drumgizmo/input/dummy/dummy.cc | 185 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+) create mode 100644 drumgizmo/input/dummy/Makefile.am create mode 100644 drumgizmo/input/dummy/dummy.cc (limited to 'drumgizmo/input/dummy') diff --git a/drumgizmo/input/dummy/Makefile.am b/drumgizmo/input/dummy/Makefile.am new file mode 100644 index 0000000..10bd70f --- /dev/null +++ b/drumgizmo/input/dummy/Makefile.am @@ -0,0 +1,26 @@ + +dummysources = \ + dummy.cc + +if HAVE_INPUT_DUMMY + +dummyltlibs = libdummy.la +dummybuildsources = $(dummysources) + +else + +dummyltlibs = +dummybuildsources = + +endif + +EXTRA_DIST = $(dummysources) + +lib_LTLIBRARIES = $(dummyltlibs) + +libdir = $(INPUT_PLUGIN_DIR) + +INCLUDES = -I$(top_srcdir)/include +libdummy_la_LDFLAGS = +libdummy_la_LIBADD = +libdummy_la_SOURCES = $(dummybuildsources) diff --git a/drumgizmo/input/dummy/dummy.cc b/drumgizmo/input/dummy/dummy.cc new file mode 100644 index 0000000..4a570db --- /dev/null +++ b/drumgizmo/input/dummy/dummy.cc @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * dummy.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 Dummy { +public: + Dummy() {} + ~Dummy() {} + + 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(); +}; + +bool Dummy::init(int instruments, char *inames[]) +{ + return true; +} + +void Dummy::setParm(std::string parm, std::string value) +{ +} + +bool Dummy::start() +{ + return true; +} + +void Dummy::stop() +{ +} + +void Dummy::pre() +{ +} + +event_t *Dummy::run(size_t pos, size_t len, size_t *nevents) +{ + *nevents = 0; + return NULL; + /* + if(rand() % 10 != 0) return; + + Instrument *i = NULL; + int d = rand() % drumkit->instruments.size(); + Instruments::iterator it = drumkit->instruments.begin(); + while(d--) { + i = &(it->second); + it++; + } + + if(i == NULL) return; + + Sample *s = i->sample((double)rand()/(double)RAND_MAX); + + if(s == NULL) { + printf("Missing Sample.\n"); + // continue; + } + + Channels::iterator j = drumkit->channels.begin(); + while(j != drumkit->channels.end()) { + Channel &ch = *j; + AudioFile *af = s->getAudioFile(&ch); + if(af == NULL) { + printf("Missing AudioFile.\n"); + } else { + printf("Adding event.\n"); + Event *evt = new EventSample(ch.num, 1.0, af); + eventqueue->post(evt, pos); + } + j++; + } + */ +} + +void Dummy::post() +{ +} + +extern "C" { + void *create() + { + return new Dummy(); + } + + void destroy(void *h) + { + Dummy *dummy = (Dummy*)h; + delete dummy; + } + + bool init(void *h, int i, char *inames[]) + { + Dummy *dummy = (Dummy*)h; + return dummy->init(i, inames); + } + + void setparm(void *h, const char *parm, const char *value) + { + Dummy *dummy = (Dummy*)h; + dummy->setParm(parm, value); + } + + bool start(void *h) + { + Dummy *dummy = (Dummy*)h; + return dummy->start(); + } + + void stop(void *h) + { + Dummy *dummy = (Dummy*)h; + dummy->stop(); + } + + void pre(void *h) + { + Dummy *dummy = (Dummy*)h; + dummy->pre(); + } + + event_t *run(void *h, size_t pos, size_t len, size_t *nev) + { + Dummy *dummy = (Dummy*)h; + return dummy->run(pos, len, nev); + } + + void post(void *h) + { + Dummy *dummy = (Dummy*)h; + dummy->post(); + } +} + +#ifdef TEST_AUDIOINPUTENGINEDUMMY +//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_AUDIOINPUTENGINEDUMMY*/ -- cgit v1.2.3