diff options
author | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
commit | e40fc849149dd97c248866a4a1d026dda5e57b62 (patch) | |
tree | b12b358f3b3a0608001d30403358f8443118ec5f /attic/muse_qt4_evolution/midiplugins/libmidiplugin | |
parent | 1bd4f2e8d9745cabb667b043171cad22c8577768 (diff) |
clean3
Diffstat (limited to 'attic/muse_qt4_evolution/midiplugins/libmidiplugin')
6 files changed, 376 insertions, 0 deletions
diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/CMakeLists.txt new file mode 100644 index 00000000..5988205f --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/CMakeLists.txt @@ -0,0 +1,26 @@ +#============================================================================= +# MusE +# Linux Music Editor +# $Id:$ +# +# Copyright (C) 2002-2006 by Werner Schweer and others +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#============================================================================= + +add_library ( midiplugin mempi.cpp ) + +set_target_properties( midiplugin + PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h" + ) + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/evdata.h b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/evdata.h new file mode 100644 index 00000000..8247b6e0 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/evdata.h @@ -0,0 +1,64 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: evdata.h,v 1.2 2005/05/11 14:18:39 wschweer Exp $ +// +// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __EVDATA_H__ +#define __EVDATA_H__ + +//--------------------------------------------------------- +// EvData +// variable len event data (sysex, meta etc.) +//--------------------------------------------------------- + +class EvData { + int* refCount; + + public: + unsigned char* data; + int dataLen; + + EvData() { + data = 0; + dataLen = 0; + refCount = new int(1); + } + EvData(const EvData& ed) { + data = ed.data; + dataLen = ed.dataLen; + refCount = ed.refCount; + (*refCount)++; + } + + EvData& operator=(const EvData& ed) { + if (data == ed.data) + return *this; + if (--(*refCount) == 0) { + delete refCount; + delete[] data; + } + data = ed.data; + dataLen = ed.dataLen; + refCount = ed.refCount; + (*refCount)++; + return *this; + } + + ~EvData() { + if (--(*refCount) == 0) { + delete[] data; + delete refCount; + } + } + void setData(const unsigned char* p, int l) { + data = new unsigned char[l]; + memcpy(data, p, l); + dataLen = l; + } + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.cpp b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.cpp new file mode 100644 index 00000000..91171c3b --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.cpp @@ -0,0 +1,81 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mempi.cpp,v 1.4 2005/05/24 15:27:48 wschweer Exp $ +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "mempi.h" + +static const int FIFO_SIZE = 128; + +//--------------------------------------------------------- +// MidiEvent +//--------------------------------------------------------- + +MidiEvent::MidiEvent(unsigned t, int tpe, const unsigned char* data, int len) + { + _time = t; + edata.setData(data, len); + _type = tpe; + } + +//--------------------------------------------------------- +// operator < +//--------------------------------------------------------- + +bool MidiEvent::operator<(const MidiEvent& e) const + { + if (time() != e.time()) + return time() < e.time(); + + // play note off events first to prevent overlapping + // notes + + if (channel() == e.channel()) + return type() == 0x80 + || (type() == 0x90 && dataB() == 0); + + int map[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15 }; + return map[channel()] < map[e.channel()]; + } + +//--------------------------------------------------------- +// MempiP +// Mempi private data structure +//--------------------------------------------------------- + +struct MempiP { + int dummy; + }; + +//--------------------------------------------------------- +// Mempi +//--------------------------------------------------------- + +Mempi::Mempi(const char* n, const MempiHost* h) + { + _name = strdup(n); + host = h; + d = new MempiP; + } + +Mempi::~Mempi() + { + delete _name; + delete d; + } + +//--------------------------------------------------------- +// getGeometry +// dummy +//--------------------------------------------------------- + +void Mempi::getGeometry(int* x, int* y, int* w, int* h) const + { + x = 0; + y = 0; + w = 0; + h = 0; + } + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.h b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.h new file mode 100644 index 00000000..a5f114b6 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.h @@ -0,0 +1,97 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mempi.h,v 1.10 2005/07/16 09:31:50 wschweer Exp $ +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +// +// MusE experimental midi plugin interface +// + +#ifndef __MEMPI_H__ +#define __MEMPI_H__ + +#define MEMPI_MAJOR_VERSION 1 +#define MEMPI_MINOR_VERSION 1 + +#include <set> +#include "evdata.h" +#include "memory.h" +#include "midievent.h" + +class MempiP; + +//--------------------------------------------------------- +// MempiHost +// Host Infos +//--------------------------------------------------------- + +struct MempiHost { + virtual int division() const; // midi division + virtual int tempo(unsigned tick) const; + virtual unsigned tick2frame(unsigned tick) const; + virtual unsigned frame2tick(unsigned frame) const; + virtual void bar(int tick, int* bar, int* beat, unsigned* rest) const; + virtual unsigned bar2tick(int bar, int beat, int tick) const; + virtual ~MempiHost() {} + }; + +//--------------------------------------------------------- +// Mempi +// Instance class +// MusE experimental midi plugin interface +// Instance virtual interface class +//--------------------------------------------------------- + +class Mempi { + MempiP* d; + const char* _name; // mempi instance name + + protected: + const MempiHost* host; + + public: + // modul interface + Mempi(const char* name, const MempiHost*); + virtual ~Mempi(); + virtual bool init() { return false; } + const char* name() const { return _name; } + + // process interface + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*) = 0; + + // session interface + virtual void getInitData(int*, const unsigned char**) const {} + virtual void setInitData(int, const unsigned char*) {} + + // GUI interface routines + virtual bool hasGui() const { return false; } + virtual bool guiVisible() const { return false; } + virtual void showGui(bool) {} + virtual void getGeometry(int* x, int* y, int* w, int* h) const; + virtual void setGeometry(int, int, int, int) {} + }; + +//--------------------------------------------------------- +// MEMPI +// Class descriptor +//--------------------------------------------------------- + +enum MempiType { MEMPI_FILTER = 0, MEMPI_GENERATOR = 1 }; + +struct MEMPI { + const char* name; + const char* description; + const char* version; + MempiType type; + int majorMempiVersion, minorMempiVersion; + Mempi* (*instantiate)(const char* name, const MempiHost*); + }; + +extern "C" { + const MEMPI* mempi_descriptor(); + } + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.cpp b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.cpp new file mode 100644 index 00000000..972bc8a2 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.cpp @@ -0,0 +1,21 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mpevent.cpp,v 1.1 2005/05/08 17:01:30 wschweer Exp $ +// +// (C) Copyright 2002-2004 Werner Schweer (ws@seh.de) +//========================================================= + +#include "midievent.h" + +//--------------------------------------------------------- +// MEvent +//--------------------------------------------------------- + +MEvent::MEvent(unsigned t, int tpe, const unsigned char* data, int len) + { + _time = t; + edata.setData(data, len); + _type = tpe; + } + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.h b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.h new file mode 100644 index 00000000..a21bec88 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.h @@ -0,0 +1,87 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mpevent.h,v 1.3 2005/06/06 14:24:53 wschweer Exp $ +// +// (C) Copyright 1999-2002 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MIDIEVENT_H__ +#define __MIDIEVENT_H__ + +#include <set> +#include "evdata.h" +#include <ext/mt_allocator.h> + +class Event; +class EvData; + +//--------------------------------------------------------- +// MidiEvent +//--------------------------------------------------------- + +class MidiEvent { + unsigned _time; + EvData edata; + unsigned char _channel, _type; + int _a, _b; + + public: + MidiEvent() {} + MidiEvent(unsigned tm, int c, int t, int a, int b) + : _time(tm), _channel(c & 0xf), _type(t), _a(a), _b(b) {} + MidiEvent(unsigned t, int type, const unsigned char* data, int len); + MidiEvent(unsigned t, int tpe, EvData d) : _time(t), edata(d), _type(tpe) {} + MidiEvent(unsigned t, int channel, const Event& e); + + ~MidiEvent() {} + + MidiEvent& operator=(const MidiEvent& ed) { + _time = ed._time; + edata = ed.edata; + _channel = ed._channel; + _type = ed._type; + _a = ed._a; + _b = ed._b; + return *this; + } + + int channel() const { return _channel; } + int type() const { return _type; } + int dataA() const { return _a; } + int dataB() const { return _b; } + unsigned time() const { return _time; } + + void setChannel(int val) { _channel = val; } + void setType(int val) { _type = val; } + void setA(int val) { _a = val; } + void setB(int val) { _b = val; } + void setTime(unsigned val) { _time = val; } + + const EvData& eventData() const { return edata; } + unsigned char* data() const { return edata.data; } + int len() const { return edata.dataLen; } + void setData(const EvData& e) { edata = e; } + void setData(const unsigned char* p, int len) { edata.setData(p, len); } + void dump() const; + bool isNote() const { return _type == 0x90; } + bool isNoteOff() const { return (_type == 0x80)||(_type == 0x90 && _b == 0); } + bool operator<(const MidiEvent&) const; + }; + +//--------------------------------------------------------- +// MidiEventList +//--------------------------------------------------------- + +// typedef std::multiset<MidiEvent, std::less<MidiEvent>, +// __gnu_cxx::__mt_alloc<MidiEvent> > MPEL; + +struct MidiEventList : public std::multiset<MidiEvent, std::less<MidiEvent> > + { + }; + +typedef MidiEventList::iterator iMidiEvent; +typedef MidiEventList::const_iterator ciMidiEvent; + +#endif + |