summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/synti/libsynti
diff options
context:
space:
mode:
Diffstat (limited to 'muse_qt4_evolution/synti/libsynti')
-rw-r--r--muse_qt4_evolution/synti/libsynti/CMakeLists.txt39
-rw-r--r--muse_qt4_evolution/synti/libsynti/evdata.h66
-rw-r--r--muse_qt4_evolution/synti/libsynti/gui.cpp124
-rw-r--r--muse_qt4_evolution/synti/libsynti/gui.h72
-rw-r--r--muse_qt4_evolution/synti/libsynti/mess.cpp123
-rw-r--r--muse_qt4_evolution/synti/libsynti/mess.h105
-rw-r--r--muse_qt4_evolution/synti/libsynti/mess2.cpp128
-rw-r--r--muse_qt4_evolution/synti/libsynti/mess2.h57
-rw-r--r--muse_qt4_evolution/synti/libsynti/midievent.cpp21
-rw-r--r--muse_qt4_evolution/synti/libsynti/midievent.h55
-rw-r--r--muse_qt4_evolution/synti/libsynti/mono.cpp47
-rw-r--r--muse_qt4_evolution/synti/libsynti/mono.h47
-rw-r--r--muse_qt4_evolution/synti/libsynti/poly.cpp35
-rw-r--r--muse_qt4_evolution/synti/libsynti/poly.h39
14 files changed, 958 insertions, 0 deletions
diff --git a/muse_qt4_evolution/synti/libsynti/CMakeLists.txt b/muse_qt4_evolution/synti/libsynti/CMakeLists.txt
new file mode 100644
index 00000000..c30048dc
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/CMakeLists.txt
@@ -0,0 +1,39 @@
+#=============================================================================
+# 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.
+#=============================================================================
+
+include(${PROJECT_SOURCE_DIR}/pch.txt)
+
+add_library(synti
+ ${PROJECT_BINARY_DIR}/all-pic.h.pch
+ mess.cpp
+ mess2.cpp
+ gui.cpp
+ mono.cpp
+ poly.cpp
+ midievent.cpp
+ )
+
+#
+# -fPIC is necessary for 64 bit systems
+#
+set_target_properties( synti
+ PROPERTIES COMPILE_FLAGS "-fPIC -include ${PROJECT_BINARY_DIR}/all-pic.h"
+ )
+
diff --git a/muse_qt4_evolution/synti/libsynti/evdata.h b/muse_qt4_evolution/synti/libsynti/evdata.h
new file mode 100644
index 00000000..29f6441e
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/evdata.h
@@ -0,0 +1,66 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: evdata.h,v 1.1 2004/02/13 13:55:03 wschweer Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __EVDATA_H__
+#define __EVDATA_H__
+
+#include <memory.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/muse_qt4_evolution/synti/libsynti/gui.cpp b/muse_qt4_evolution/synti/libsynti/gui.cpp
new file mode 100644
index 00000000..30fd177b
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/gui.cpp
@@ -0,0 +1,124 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// software synthesizer helper library
+// $Id: gui.cpp,v 1.7 2005/05/11 14:18:48 wschweer Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "gui.h"
+#include "muse/midi.h"
+
+#include <unistd.h>
+
+//---------------------------------------------------------
+// MessGui
+//---------------------------------------------------------
+
+MessGui::MessGui()
+ {
+ //
+ // prepare for interprocess communication:
+ //
+ int filedes[2]; // 0 - reading 1 - writing
+ if (pipe(filedes) == -1) {
+ perror("thread:creating pipe4");
+ exit(-1);
+ }
+ readFd = filedes[0];
+ writeFd = filedes[1];
+ wFifoSize = 0;
+ wFifoWindex = 0;
+ wFifoRindex = 0;
+ rFifoSize = 0;
+ rFifoWindex = 0;
+ rFifoRindex = 0;
+ }
+
+//---------------------------------------------------------
+// MessGui
+//---------------------------------------------------------
+
+MessGui::~MessGui()
+ {
+ }
+
+//---------------------------------------------------------
+// readMessage
+//---------------------------------------------------------
+
+void MessGui::readMessage()
+ {
+ char c;
+ while (rFifoSize) {
+ ::read(readFd, &c, 1);
+ processEvent(rFifo[rFifoRindex]);
+ rFifoRindex = (rFifoRindex + 1) % EVENT_FIFO_SIZE;
+ --rFifoSize;
+ }
+ }
+
+//---------------------------------------------------------
+// sendController
+//---------------------------------------------------------
+
+void MessGui::sendController(int ch, int idx, int val)
+ {
+ sendEvent(MidiEvent(0, ch, ME_CONTROLLER, idx, val));
+ }
+
+//---------------------------------------------------------
+// sendSysex
+//---------------------------------------------------------
+
+void MessGui::sendSysex(unsigned char* p, int n)
+ {
+ sendEvent(MidiEvent(0, ME_SYSEX, p, n));
+ }
+
+//---------------------------------------------------------
+// writeEvent
+// send an event to synti gui
+//---------------------------------------------------------
+
+void MessGui::writeEvent(const MidiEvent& ev)
+ {
+ if (rFifoSize == EVENT_FIFO_SIZE) {
+ printf("event synti->gui fifo overflow\n");
+ return;
+ }
+ rFifo[rFifoWindex] = ev;
+ rFifoWindex = (rFifoWindex + 1) % EVENT_FIFO_SIZE;
+ ++rFifoSize;
+ write(writeFd, "x", 1); // wakeup GUI
+ }
+
+//---------------------------------------------------------
+// sendEvent
+//---------------------------------------------------------
+
+void MessGui::sendEvent(const MidiEvent& ev)
+ {
+ if (wFifoSize == EVENT_FIFO_SIZE) {
+ printf("event gui->synti fifo overflow\n");
+ return;
+ }
+ wFifo[wFifoWindex] = ev;
+ wFifoWindex = (wFifoWindex + 1) % EVENT_FIFO_SIZE;
+ ++wFifoSize;
+ }
+
+//---------------------------------------------------------
+// readEvent
+// read event from synti gui
+//---------------------------------------------------------
+
+MidiEvent MessGui::readEvent()
+ {
+ MidiEvent ev = wFifo[wFifoRindex];
+ wFifoRindex = (wFifoRindex + 1) % EVENT_FIFO_SIZE;
+ --wFifoSize;
+ return ev;
+ }
+
diff --git a/muse_qt4_evolution/synti/libsynti/gui.h b/muse_qt4_evolution/synti/libsynti/gui.h
new file mode 100644
index 00000000..27bebe3f
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/gui.h
@@ -0,0 +1,72 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// software synthesizer helper library
+// $Id: gui.h,v 1.5 2005/05/11 14:18:48 wschweer Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SYNTH_GUI_H__
+#define __SYNTH_GUI_H__
+
+#include "midievent.h"
+
+const int EVENT_FIFO_SIZE = 256;
+class QWidget;
+
+//---------------------------------------------------------
+// MessGui
+// manage IO from synti-GUI to Host
+//---------------------------------------------------------
+
+class MessGui {
+ int writeFd;
+
+ // Event Fifo synti -> GUI
+ MidiEvent rFifo[EVENT_FIFO_SIZE];
+ volatile int rFifoSize;
+ int rFifoWindex;
+ int rFifoRindex;
+
+ // Event Fifo GUI -> synti
+ MidiEvent wFifo[EVENT_FIFO_SIZE];
+ volatile int wFifoSize;
+ int wFifoWindex;
+ int wFifoRindex;
+
+ protected:
+ int readFd;
+ void readMessage();
+ void sendEvent(const MidiEvent& ev);
+ void sendController(int ch, int idx, int val);
+ void sendSysex(unsigned char*, int);
+
+ virtual void processEvent(const MidiEvent&) {};
+
+ public:
+ MessGui();
+ virtual ~MessGui();
+
+ void writeEvent(const MidiEvent&);
+ int fifoSize() const { return wFifoSize; }
+ MidiEvent readEvent();
+ };
+
+//---------------------------------------------------------
+// SynthGuiCtrl
+//---------------------------------------------------------
+
+struct SynthGuiCtrl {
+ enum EditorType { SLIDER, SWITCH, COMBOBOX };
+ QWidget* editor;
+ QWidget* label;
+ EditorType type;
+
+ SynthGuiCtrl() {}
+ SynthGuiCtrl(QWidget* w, QWidget* l, const EditorType t)
+ : editor(w), label(l), type(t) {}
+ };
+
+#endif
+
diff --git a/muse_qt4_evolution/synti/libsynti/mess.cpp b/muse_qt4_evolution/synti/libsynti/mess.cpp
new file mode 100644
index 00000000..49f030f8
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/mess.cpp
@@ -0,0 +1,123 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mess.cpp,v 1.3 2005/05/11 14:18:48 wschweer Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "mess.h"
+#include "muse/midi.h"
+
+static const int FIFO_SIZE = 32;
+
+//---------------------------------------------------------
+// MessP
+// private data for class Mess
+//---------------------------------------------------------
+
+struct MessP {
+ // Event Fifo synti -> Host:
+ MidiEvent fifo[FIFO_SIZE];
+ volatile int fifoSize;
+ int fifoWindex;
+ int fifoRindex;
+ };
+
+//---------------------------------------------------------
+// Mess
+//---------------------------------------------------------
+
+Mess::Mess(int n)
+ {
+ _channels = n;
+ _sampleRate = 44100;
+ d = new MessP;
+ d->fifoSize = 0;
+ d->fifoWindex = 0;
+ d->fifoRindex = 0;
+ }
+
+//---------------------------------------------------------
+// Mess
+//---------------------------------------------------------
+
+Mess::~Mess()
+ {
+ delete d;
+ }
+
+//---------------------------------------------------------
+// getGeometry
+// dummy
+//---------------------------------------------------------
+
+void Mess::getGeometry(int* x, int* y, int* w, int* h) const
+ {
+ x = 0;
+ y = 0;
+ w = 0;
+ h = 0;
+ }
+
+//---------------------------------------------------------
+// sendEvent
+// send Event synti -> host
+//---------------------------------------------------------
+
+void Mess::sendEvent(MidiEvent ev)
+ {
+ if (d->fifoSize == FIFO_SIZE) {
+ printf("event synti->host fifo overflow\n");
+ return;
+ }
+ d->fifo[d->fifoWindex] = ev;
+ d->fifoWindex = (d->fifoWindex + 1) % FIFO_SIZE;
+ ++(d->fifoSize);
+ }
+
+//---------------------------------------------------------
+// receiveEvent
+// called from host
+//---------------------------------------------------------
+
+MidiEvent Mess::receiveEvent()
+ {
+ MidiEvent ev = d->fifo[d->fifoRindex];
+ d->fifoRindex = (d->fifoRindex + 1) % FIFO_SIZE;
+ --(d->fifoSize);
+ return ev;
+ }
+
+//---------------------------------------------------------
+// eventsPending
+// called from host:
+// while (eventsPending()) {
+// receiveEvent();
+// ...
+//---------------------------------------------------------
+
+int Mess::eventsPending() const
+ {
+ return d->fifoSize;
+ }
+
+//---------------------------------------------------------
+// processEvent
+// return true if synti is busy
+//---------------------------------------------------------
+
+bool Mess::processEvent(const MidiEvent& ev)
+ {
+ switch(ev.type()) {
+ case ME_NOTEON:
+ return playNote(ev.channel(), ev.dataA(), ev.dataB());
+ case ME_NOTEOFF:
+ return playNote(ev.channel(), ev.dataA(), 0);
+ case ME_SYSEX:
+ return sysex(ev.len(), ev.data());
+ case ME_CONTROLLER:
+ return setController(ev.channel(), ev.dataA(), ev.dataB());
+ }
+ return false;
+ }
+
diff --git a/muse_qt4_evolution/synti/libsynti/mess.h b/muse_qt4_evolution/synti/libsynti/mess.h
new file mode 100644
index 00000000..c407d17e
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/mess.h
@@ -0,0 +1,105 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mess.h,v 1.6 2005/05/11 14:18:48 wschweer Exp $
+// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MESS_H__
+#define __MESS_H__
+
+#define MESS_MAJOR_VERSION 3
+#define MESS_MINOR_VERSION 1
+
+#include "midievent.h"
+
+class QWidget;
+class MessP;
+
+//---------------------------------------------------------
+// MidiPatch
+//---------------------------------------------------------
+
+#define MP_TYPE_GM 1
+#define MP_TYPE_GS 2
+#define MP_TYPE_XG 4
+#define MP_TYPE_LBANK 8
+#define MP_TYPE_HBANK 16
+
+struct MidiPatch {
+ signed char typ; // 1 - GM 2 - GS 4 - XG 8 - LBANK 16 - HBANK
+ signed char hbank, lbank, prog;
+ const char* name;
+ };
+
+//---------------------------------------------------------
+// Mess
+// MusE experimental software synth
+// Instance virtual interface class
+//---------------------------------------------------------
+
+class Mess {
+ MessP* d;
+
+ int _sampleRate;
+ int _channels; // 1 - mono, 2 - stereo
+
+ public:
+ Mess(int channels);
+ virtual ~Mess();
+
+ int channels() const { return _channels; }
+ int sampleRate() const { return _sampleRate; }
+ void setSampleRate(int r) { _sampleRate = r; }
+
+ virtual void process(float** data, int offset, int len) = 0;
+
+ // The synti has to (re-)implement processEvent() or provide
+ // the playNote()/setControll()/sysex() functions.
+ // The even routines return true if synti is busy and the
+ // event must be send again.
+
+ virtual bool processEvent(const MidiEvent&);
+ virtual bool setController(int, int, int) { return false; }
+ virtual bool playNote(int, int, int) { return false; }
+ virtual bool sysex(int, const unsigned char*) { return false; }
+
+ virtual void getInitData(int*, const unsigned char**) {}
+ virtual int getControllerInfo(int, const char**, int*, int*, int*) {return 0;}
+ virtual const char* getPatchName(int, int, int) const { return "?"; }
+ virtual const MidiPatch* getPatchInfo(int, const MidiPatch*) const { return 0; }
+
+ // synthesizer -> host communication
+ void sendEvent(MidiEvent); // called from synti
+ MidiEvent receiveEvent(); // called from host
+ int eventsPending() const;
+
+ // 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) {}
+ };
+
+//---------------------------------------------------------
+// MESS
+// Class descriptor
+//---------------------------------------------------------
+
+struct MESS {
+ const char* name;
+ const char* description;
+ const char* version;
+ int majorMessVersion, minorMessVersion;
+ // QWidget* parent allows for a threaded GUI using the Qt Library
+ // can be ignored by synti
+ Mess* (*instantiate)(int sr, const char* name);
+ };
+
+extern "C" {
+ const MESS* mess_descriptor();
+ }
+
+#endif
+
diff --git a/muse_qt4_evolution/synti/libsynti/mess2.cpp b/muse_qt4_evolution/synti/libsynti/mess2.cpp
new file mode 100644
index 00000000..588edac9
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/mess2.cpp
@@ -0,0 +1,128 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id:$
+// (C) Copyright 2007 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "mess2.h"
+
+QList<SynthCtrl*> Mess2::ctrl;
+
+//---------------------------------------------------------
+// Mess2
+//---------------------------------------------------------
+
+Mess2::Mess2(int channels)
+ : Mess(channels)
+ {
+ initData = 0;
+ }
+
+//---------------------------------------------------------
+// Mess2
+//---------------------------------------------------------
+
+Mess2::~Mess2()
+ {
+ if (initData)
+ delete[] initData;
+ }
+
+//---------------------------------------------------------
+// addController
+//---------------------------------------------------------
+
+void Mess2::addController(const char* name, int id, int min, int max, int init)
+ {
+ SynthCtrl* c = new SynthCtrl(name, id, min, max, init);
+ ctrl.append(c);
+ }
+
+//---------------------------------------------------------
+// controllerIdx
+//---------------------------------------------------------
+
+int Mess2::controllerIdx(const char* name)
+ {
+ for (int i = 0; i < ctrl.size(); ++i) {
+ if (strcmp(ctrl[i]->name, name) == 0)
+ return i;
+ }
+ return -1;
+ }
+
+//---------------------------------------------------------
+// controllerIdx
+//---------------------------------------------------------
+
+int Mess2::controllerIdx(int ctrlId)
+ {
+ for (int i = 0; i < ctrl.size(); ++i) {
+ if (ctrl[i]->ctrl == ctrlId)
+ return i;
+ }
+ return -1;
+ }
+
+//---------------------------------------------------------
+// controllerId
+//---------------------------------------------------------
+
+int Mess2::controllerId(int idx)
+ {
+ if (idx < 0 || idx >= ctrl.size()) {
+ printf("controllId::illegal controller index %d\n", idx);
+ return -1;
+ }
+ return ctrl[idx]->ctrl;
+ }
+
+//---------------------------------------------------------
+// controllerName
+//---------------------------------------------------------
+
+const char* Mess2::controllerName(int idx)
+ {
+ if (idx < 0 || idx >= ctrl.size()) {
+ printf("controllerName::illegal controller index %d\n", idx);
+ return "?";
+ }
+ return ctrl[idx]->name;
+ }
+
+//---------------------------------------------------------
+// getInitData
+//---------------------------------------------------------
+
+void Mess2::getInitData(int* bytes, const unsigned char** data)
+ {
+ if (initData)
+ delete[] initData;
+ int n = ctrl.size() * sizeof(int);
+ initData = new unsigned char[n];
+ int* p = (int*)initData;
+ foreach(SynthCtrl* c, ctrl) {
+ *p++ = c->val;
+ }
+ *data = initData;
+ *bytes = n;
+ }
+
+//---------------------------------------------------------
+// getControllerInfo
+//---------------------------------------------------------
+
+int Mess2::getControllerInfo(int idx, const char** name, int* id, int* min, int* max)
+ {
+ if (idx < 0 || idx >= ctrl.size())
+ return 0;
+ *name = ctrl[idx]->name;
+ *id = ctrl[idx]->ctrl;
+ *min = ctrl[idx]->min;
+ *max = ctrl[idx]->max;
+ ++idx;
+ return (idx >= ctrl.size()) ? 0 : idx;
+ }
+
+
diff --git a/muse_qt4_evolution/synti/libsynti/mess2.h b/muse_qt4_evolution/synti/libsynti/mess2.h
new file mode 100644
index 00000000..207eb6c3
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/mess2.h
@@ -0,0 +1,57 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id:$
+// (C) Copyright 2007 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MESS2_H__
+#define __MESS2_H__
+
+#include "mess.h"
+
+//---------------------------------------------------------
+// SynthCtlr
+//---------------------------------------------------------
+
+struct SynthCtrl {
+ const char* name;
+ int ctrl;
+ int min;
+ int max;
+ int init;
+ int val;
+ SynthCtrl(const char* n, int i, int a, int b, int c)
+ : name(n), ctrl(i), min(a), max(b), init(c)
+ {}
+ };
+
+//---------------------------------------------------------
+// Mess2
+// MusE experimental software synth
+// extended interface
+//---------------------------------------------------------
+
+class Mess2 : public Mess {
+ unsigned char* initData;
+
+ void getInitData(int*, const unsigned char**);
+ int getControllerInfo(int, const char**, int*, int*, int*);
+
+ protected:
+ static QList<SynthCtrl*> ctrl;
+
+ static void addController(const char* name,
+ int ctrl, int min = 0, int max = 16384, int init = 0);
+ static int controllerIdx(const char* name);
+ static int controllerId(int idx);
+ static int controllerIdx(int id);
+ static const char* controllerName(int idx);
+
+ public:
+ Mess2(int channels);
+ virtual ~Mess2();
+ };
+
+#endif
+
diff --git a/muse_qt4_evolution/synti/libsynti/midievent.cpp b/muse_qt4_evolution/synti/libsynti/midievent.cpp
new file mode 100644
index 00000000..7c1e14fd
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/midievent.cpp
@@ -0,0 +1,21 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mpevent.cpp,v 1.3 2005/05/11 14:18:48 wschweer Exp $
+//
+// (C) Copyright 2002-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "midievent.h"
+
+//---------------------------------------------------------
+// MidiEvent
+//---------------------------------------------------------
+
+MidiEvent::MidiEvent(unsigned t, int tpe, const unsigned char* data, int len)
+ {
+ _time = t;
+ edata.setData(data, len);
+ _type = tpe;
+ }
+
diff --git a/muse_qt4_evolution/synti/libsynti/midievent.h b/muse_qt4_evolution/synti/libsynti/midievent.h
new file mode 100644
index 00000000..a435d257
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/midievent.h
@@ -0,0 +1,55 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mpevent.h,v 1.3 2005/05/11 14:18:48 wschweer Exp $
+//
+// (C) Copyright 1999-2002 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDIEVENT_H__
+#define __MIDIEVENT_H__
+
+#include "evdata.h"
+
+//---------------------------------------------------------
+// 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() {}
+
+ 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); }
+ bool isNote() const { return _type == 0x90; }
+ bool isNoteOff() const { return (_type == 0x80)||(_type == 0x90 && _b == 0); }
+ };
+
+#endif
+
diff --git a/muse_qt4_evolution/synti/libsynti/mono.cpp b/muse_qt4_evolution/synti/libsynti/mono.cpp
new file mode 100644
index 00000000..14a23aca
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/mono.cpp
@@ -0,0 +1,47 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// software synthesizer helper library
+// $Id: mono.cpp,v 1.2 2004/04/15 13:46:18 wschweer Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "mono.h"
+
+//---------------------------------------------------------
+// playNote
+//---------------------------------------------------------
+
+bool MessMono::playNote(int channel, int pitch, int velo)
+ {
+ if (velo == 0) {
+ if (pitchStack.empty())
+ return false;
+ if (pitchStack.back().pitch == pitch) {
+ pitchStack.pop_back();
+ if (pitchStack.empty()) {
+ note(channel, pitch, 0);
+ return false;
+ }
+ PitchVelo pv = pitchStack.back();
+ note(pv.channel, pv.pitch, pv.velo); // change pitch
+ return false;
+ }
+ for (std::list<PitchVelo>::iterator i = pitchStack.begin();
+ i != pitchStack.end(); ++i) {
+ if ((*i).pitch == pitch) {
+ pitchStack.erase(i);
+ return false;
+ }
+ }
+ // no noteon found
+ // emergency stop:
+ note(channel, pitch, velo);
+ return false;
+ }
+ pitchStack.push_back(PitchVelo(channel, pitch, velo));
+ note(channel, pitch, velo);
+ return false;
+ }
+
diff --git a/muse_qt4_evolution/synti/libsynti/mono.h b/muse_qt4_evolution/synti/libsynti/mono.h
new file mode 100644
index 00000000..f2f8bdf7
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/mono.h
@@ -0,0 +1,47 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// software synthesizer helper library
+// $Id: mono.h,v 1.4 2004/04/15 13:46:18 wschweer Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SYNTH_MONO_H__
+#define __SYNTH_MONO_H
+
+#include <list>
+#include "mess.h"
+
+//---------------------------------------------------------
+// PitchVelo
+//---------------------------------------------------------
+
+struct PitchVelo {
+ signed char channel;
+ signed char pitch;
+ signed char velo;
+ PitchVelo(signed char a, signed char b, signed char c)
+ : channel(a), pitch(b), velo(c) {}
+ };
+
+//---------------------------------------------------------
+// MessMono
+// implements some functions for monophone
+// synthesizer
+//---------------------------------------------------------
+
+class MessMono : public Mess {
+ std::list<PitchVelo> pitchStack;
+
+ protected:
+ virtual bool playNote(int channel, int pitch, int velo);
+ virtual void note(int channel, int pitch, int velo) = 0;
+
+ public:
+ MessMono() : Mess(1) {}
+ virtual ~MessMono() {}
+ };
+
+#endif
+
diff --git a/muse_qt4_evolution/synti/libsynti/poly.cpp b/muse_qt4_evolution/synti/libsynti/poly.cpp
new file mode 100644
index 00000000..e76fe966
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/poly.cpp
@@ -0,0 +1,35 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// software synthesizer helper library
+// $Id: poly.cpp,v 1.3 2004/06/01 14:25:50 wschweer Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "poly.h"
+#include "muse/midictrl.h"
+
+//---------------------------------------------------------
+// playNote
+//---------------------------------------------------------
+
+bool MessPoly::playNote(int /*channel*/, int /*pitch*/, int /*velo*/)
+ {
+ return false;
+ }
+
+//---------------------------------------------------------
+// setController
+//---------------------------------------------------------
+
+bool MessPoly::setController(int /*channel*/, int num, int /*val*/)
+ {
+ switch(num) {
+ case CTRL_VOLUME:
+ case CTRL_EXPRESSION:
+ break;
+ }
+ return false;
+ }
+
diff --git a/muse_qt4_evolution/synti/libsynti/poly.h b/muse_qt4_evolution/synti/libsynti/poly.h
new file mode 100644
index 00000000..b990b198
--- /dev/null
+++ b/muse_qt4_evolution/synti/libsynti/poly.h
@@ -0,0 +1,39 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// software synthesizer helper library
+// $Id: poly.h,v 1.2 2004/04/15 13:46:18 wschweer Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SYNTH_POLY_H__
+#define __SYNTH_POLY_H
+
+#include <list>
+#include "mess.h"
+
+//---------------------------------------------------------
+// MessPoly
+// implements some functions for monophone
+// synthesizer
+//---------------------------------------------------------
+
+class MessPoly : public Mess {
+ float volume;
+ float expression;
+
+ // cached values:
+ float mainLevel;
+
+ protected:
+ virtual bool playNote(int channel, int pitch, int velo);
+ virtual bool setController(int, int, int);
+
+ public:
+ MessPoly() : Mess(1) {}
+ virtual ~MessPoly() {}
+ };
+
+#endif
+