From bf0d6494e74e92206d889aeb6269cc4e514a720e Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Mon, 23 Oct 2006 13:22:04 +0000 Subject: rename mpevent to midievent --- muse/midiplugins/libmidiplugin/mempi.h | 2 +- muse/midiplugins/libmidiplugin/midievent.cpp | 21 +++++ muse/midiplugins/libmidiplugin/midievent.h | 104 +++++++++++++++++++++++ muse/midiplugins/libmidiplugin/mpevent.cpp | 21 ----- muse/midiplugins/libmidiplugin/mpevent.h | 104 ----------------------- muse/midiplugins/metronom/metronom.cpp | 4 +- muse/midiplugins/transform/transform.cpp | 2 +- muse/midiplugins/trigg/trigg.cpp | 2 +- muse/muse/CMakeLists.txt | 4 +- muse/muse/audio.cpp | 2 +- muse/muse/audio.h | 2 +- muse/muse/driver/jack.cpp | 13 +-- muse/muse/driver/jackaudio.h | 3 +- muse/muse/midievent.cpp | 122 +++++++++++++++++++++++++++ muse/muse/midievent.h | 4 +- muse/muse/midieventbase.h | 4 +- muse/muse/midififo.h | 2 +- muse/muse/midifile.h | 2 +- muse/muse/midirc.h | 2 +- muse/muse/midiseq.h | 2 +- muse/muse/mpevent.cpp | 122 --------------------------- muse/muse/preferences.h | 2 +- muse/muse/track.h | 2 +- muse/synti/fluidsynth/fluidsynti.h | 3 +- muse/synti/libsynti/CMakeLists.txt | 2 +- muse/synti/libsynti/gui.h | 2 +- muse/synti/libsynti/mess.h | 2 +- muse/synti/libsynti/midievent.cpp | 21 +++++ muse/synti/libsynti/midievent.h | 55 ++++++++++++ muse/synti/libsynti/mpevent.cpp | 21 ----- muse/synti/libsynti/mpevent.h | 55 ------------ muse/synti/organ/organ.cpp | 2 +- muse/synti/organ/organgui.h | 2 +- 33 files changed, 358 insertions(+), 355 deletions(-) create mode 100644 muse/midiplugins/libmidiplugin/midievent.cpp create mode 100644 muse/midiplugins/libmidiplugin/midievent.h delete mode 100644 muse/midiplugins/libmidiplugin/mpevent.cpp delete mode 100644 muse/midiplugins/libmidiplugin/mpevent.h create mode 100644 muse/muse/midievent.cpp delete mode 100644 muse/muse/mpevent.cpp create mode 100644 muse/synti/libsynti/midievent.cpp create mode 100644 muse/synti/libsynti/midievent.h delete mode 100644 muse/synti/libsynti/mpevent.cpp delete mode 100644 muse/synti/libsynti/mpevent.h diff --git a/muse/midiplugins/libmidiplugin/mempi.h b/muse/midiplugins/libmidiplugin/mempi.h index 3d8ef68e..122b5a17 100644 --- a/muse/midiplugins/libmidiplugin/mempi.h +++ b/muse/midiplugins/libmidiplugin/mempi.h @@ -18,7 +18,7 @@ #include #include "evdata.h" #include "memory.h" -#include "mpevent.h" +#include "midievent.h" class MempiP; diff --git a/muse/midiplugins/libmidiplugin/midievent.cpp b/muse/midiplugins/libmidiplugin/midievent.cpp new file mode 100644 index 00000000..972bc8a2 --- /dev/null +++ b/muse/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/muse/midiplugins/libmidiplugin/midievent.h b/muse/midiplugins/libmidiplugin/midievent.h new file mode 100644 index 00000000..86a7e734 --- /dev/null +++ b/muse/midiplugins/libmidiplugin/midievent.h @@ -0,0 +1,104 @@ +//========================================================= +// 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 +#include "evdata.h" +#include + +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; + }; + +//--------------------------------------------------------- +// MPEventList +//--------------------------------------------------------- + +// typedef std::multiset, +// __gnu_cxx::__mt_alloc > MPEL; + +typedef std::multiset > MPEL; + +struct MPEventList : public MPEL { + void add(const MidiEvent& ev) { MPEL::insert(ev); } + }; + +typedef MPEventList::iterator iMPEvent; +typedef MPEventList::const_iterator ciMPEvent; + +//--------------------------------------------------------- +// MREventList +//--------------------------------------------------------- + +// typedef std::list > MREL; + +typedef std::list MREL; + +struct MREventList : public MREL { + void add(const MidiEvent& ev) { MREL::push_back(ev); } + }; + +typedef MREventList::iterator iMREvent; +typedef MREventList::const_iterator ciMREvent; + +#endif + diff --git a/muse/midiplugins/libmidiplugin/mpevent.cpp b/muse/midiplugins/libmidiplugin/mpevent.cpp deleted file mode 100644 index 872261e1..00000000 --- a/muse/midiplugins/libmidiplugin/mpevent.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//========================================================= -// 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 "mpevent.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/muse/midiplugins/libmidiplugin/mpevent.h b/muse/midiplugins/libmidiplugin/mpevent.h deleted file mode 100644 index b7bdee60..00000000 --- a/muse/midiplugins/libmidiplugin/mpevent.h +++ /dev/null @@ -1,104 +0,0 @@ -//========================================================= -// 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 __MPEVENT_H__ -#define __MPEVENT_H__ - -#include -#include "evdata.h" -#include - -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; - }; - -//--------------------------------------------------------- -// MPEventList -//--------------------------------------------------------- - -// typedef std::multiset, -// __gnu_cxx::__mt_alloc > MPEL; - -typedef std::multiset > MPEL; - -struct MPEventList : public MPEL { - void add(const MidiEvent& ev) { MPEL::insert(ev); } - }; - -typedef MPEventList::iterator iMPEvent; -typedef MPEventList::const_iterator ciMPEvent; - -//--------------------------------------------------------- -// MREventList -//--------------------------------------------------------- - -// typedef std::list > MREL; - -typedef std::list MREL; - -struct MREventList : public MREL { - void add(const MidiEvent& ev) { MREL::push_back(ev); } - }; - -typedef MREventList::iterator iMREvent; -typedef MREventList::const_iterator ciMREvent; - -#endif - diff --git a/muse/midiplugins/metronom/metronom.cpp b/muse/midiplugins/metronom/metronom.cpp index 28fb00a1..7b845e91 100644 --- a/muse/midiplugins/metronom/metronom.cpp +++ b/muse/midiplugins/metronom/metronom.cpp @@ -11,7 +11,7 @@ #include "metronomgui.h" #include "metronom.h" #include "midi.h" -#include "mpevent.h" +#include "midievent.h" //--------------------------------------------------------- // Metronom @@ -81,7 +81,7 @@ void Metronom::setGeometry(int x, int y, int w, int h) // process //--------------------------------------------------------- -void Metronom::process(unsigned from, unsigned to, MPEventList* il, MPEventList* ol) +void Metronom::process(unsigned from, unsigned to, MPEventList* /*il*/, MPEventList* ol) { if (from == to) { nextTick = 0; diff --git a/muse/midiplugins/transform/transform.cpp b/muse/midiplugins/transform/transform.cpp index 6c2b2968..2a4e7b4d 100644 --- a/muse/midiplugins/transform/transform.cpp +++ b/muse/midiplugins/transform/transform.cpp @@ -6,7 +6,7 @@ // (C) Copyright 2001-2005 Werner Schweer (ws@seh.de) //========================================================= -#include "mpevent.h" +#include "midievent.h" #include "transform.h" static int eventTypeTable[] = { diff --git a/muse/midiplugins/trigg/trigg.cpp b/muse/midiplugins/trigg/trigg.cpp index 612b9c6b..0d13daca 100644 --- a/muse/midiplugins/trigg/trigg.cpp +++ b/muse/midiplugins/trigg/trigg.cpp @@ -11,7 +11,7 @@ #include "trigggui.h" #include "trigg.h" #include "midi.h" -#include "mpevent.h" +#include "midievent.h" //--------------------------------------------------------- // Trigg diff --git a/muse/muse/CMakeLists.txt b/muse/muse/CMakeLists.txt index e01af72f..54b6146e 100644 --- a/muse/muse/CMakeLists.txt +++ b/muse/muse/CMakeLists.txt @@ -110,9 +110,9 @@ add_executable ( muse icons.cpp event.cpp eventlist.cpp - midievent.cpp + midieventbase.cpp waveevent.cpp - mpevent.cpp + midievent.cpp wave.cpp seqmsg.cpp help.cpp diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp index e6e84ab6..ede753f1 100644 --- a/muse/muse/audio.cpp +++ b/muse/muse/audio.cpp @@ -462,7 +462,7 @@ void Audio::process(unsigned frames) MidiOutPortList* mol = song->midiOutPorts(); for (iMidiOutPort i = mol->begin(); i != mol->end(); ++i) - audioDriver->startMidiCycle(mol->jackPort(0)); + audioDriver->startMidiCycle((*i)->jackPort(0)); GroupList* gl = song->groups(); SynthIList* sl = song->syntis(); diff --git a/muse/muse/audio.h b/muse/muse/audio.h index afcd092b..985466dd 100644 --- a/muse/muse/audio.h +++ b/muse/muse/audio.h @@ -22,7 +22,7 @@ #define __AUDIO_H__ #include "thread.h" -#include "mpevent.h" +#include "midievent.h" #include "route.h" #include "al/pos.h" #include "event.h" diff --git a/muse/muse/driver/jack.cpp b/muse/muse/driver/jack.cpp index 57a5348f..56d78de5 100644 --- a/muse/muse/driver/jack.cpp +++ b/muse/muse/driver/jack.cpp @@ -798,19 +798,22 @@ bool initJackAudio() // putEvent //--------------------------------------------------------- -void JackAudio::putEvent(Port p, const MidiEvent& e) +void JackAudio::putEvent(Port port, const MidiEvent& e) { if (midiOutputTrace) { - printf("MidiOut<%s>: jackMidi: ", portName(p).toLatin1().data()); + printf("MidiOut<%s>: jackMidi: ", portName(port).toLatin1().data()); e.dump(); } + void* pb = jack_port_get_buffer((jack_port_t*)port, segmentSize); + int pos = 0; unsigned char* p = jack_midi_event_reserve(pb, pos, 3, segmentSize); if (p == 0) { fprintf(stderr, "JackMidi: buffer overflow, event lost\n"); return; } - p[0] = e.dataA(); - p[1] + p[0] = e.type() | e.channel(); + p[1] = e.dataA(); + p[2] = e.dataB(); } //--------------------------------------------------------- @@ -819,7 +822,7 @@ void JackAudio::putEvent(Port p, const MidiEvent& e) void JackAudio::startMidiCycle(Port port) { - void* port_buf = jack_port_get_buffer(port, segmentSize); + void* port_buf = jack_port_get_buffer((jack_port_t*)port, segmentSize); jack_midi_clear_buffer(port_buf, segmentSize); } diff --git a/muse/muse/driver/jackaudio.h b/muse/muse/driver/jackaudio.h index c4d0cdaa..c4611ac6 100644 --- a/muse/muse/driver/jackaudio.h +++ b/muse/muse/driver/jackaudio.h @@ -22,6 +22,7 @@ #define __JACKAUDIO_H__ #include +#include #include "audiodev.h" //--------------------------------------------------------- @@ -79,7 +80,7 @@ class JackAudio : public AudioDriver { void graphChanged(); virtual bool equal(Port a, Port b) { return a == b; } virtual void putEvent(Port, const MidiEvent&); - virutal void startMidiCycle(Port); + virtual void startMidiCycle(Port); }; #endif diff --git a/muse/muse/midievent.cpp b/muse/muse/midievent.cpp new file mode 100644 index 00000000..573302c0 --- /dev/null +++ b/muse/muse/midievent.cpp @@ -0,0 +1,122 @@ +//============================================================================= +// 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 "midievent.h" + +#include "helper.h" +#include "event.h" +#include "midictrl.h" +#include "muse/midi.h" + +//--------------------------------------------------------- +// MidiEvent +//--------------------------------------------------------- + +MidiEvent::MidiEvent(unsigned t, int tpe, const unsigned char* data, int len) + { + _time = t; + edata.setData(data, len); + _type = tpe; + } + +MidiEvent::MidiEvent(unsigned tick, int channel, const Event& e) + { + setChannel(channel); + setTime(tick); + switch(e.type()) { + case Note: + setType(ME_NOTEON); + setA(e.dataA()); + setB(e.dataB()); + break; + case Controller: + setType(ME_CONTROLLER); + setA(e.dataA()); // controller number + setB(e.dataB()); // controller value + break; + case PAfter: + setType(ME_POLYAFTER); + setA(e.dataA()); + setB(e.dataB()); + break; + case CAfter: + setType(ME_AFTERTOUCH); + setA(e.dataA()); + setB(0); + break; + case Sysex: + setType(ME_SYSEX); + setData(e.eventData()); + break; + default: + printf("MEvent::MEvent(): event type %d not implemented\n", + type()); + break; + } + } + +//--------------------------------------------------------- +// dump +//--------------------------------------------------------- + +void MidiEvent::dump() const + { + printf("chan:%d ", _channel+1); + if (_type == 0x90) { // NoteOn + QString s = pitch2string(_a); + printf("NoteOn %3s(0x%02x) %3d\n", s.toLatin1().data(), _a, _b); + } + else if (_type == 0xf0) { + printf("SysEx len %d ", len()); + int n = len() < 7 ? len() : 7; + unsigned char* p = data(); + for (int i = 0; i < n; ++i) + printf("%02x ", *p++); + printf("\n"); + } + else if (_type == 0xb0) + printf("Ctrl %d(0x%02x) %d(0x%02x)\n", _a, _a, _b, _b); + else if (_type == 0xc0) + printf("Prog %d(0x%02x)\n", _a, _a); + else if (_type == 0xd0) + printf("Aftertouch %d\n", _a); + else + printf("type:0x%02x a=%d(0x%02x) b=%d(0x%02x)\n", _type, _a, _a, _b, _b); + } + +//--------------------------------------------------------- +// 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() == ME_NOTEOFF + || (type() == ME_NOTEON && 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()]; + } diff --git a/muse/muse/midievent.h b/muse/muse/midievent.h index 3712a607..6bfdcb6d 100644 --- a/muse/muse/midievent.h +++ b/muse/muse/midievent.h @@ -18,8 +18,8 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //============================================================================= -#ifndef __MPEVENT_H__ -#define __MPEVENT_H__ +#ifndef __MIDIEVENT_H__ +#define __MIDIEVENT_H__ #include #include "evdata.h" diff --git a/muse/muse/midieventbase.h b/muse/muse/midieventbase.h index 93cb5529..5eee7fbe 100644 --- a/muse/muse/midieventbase.h +++ b/muse/muse/midieventbase.h @@ -18,8 +18,8 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //============================================================================= -#ifndef __MIDI_EVENT_H__ -#define __MIDI_EVENT_H__ +#ifndef __MIDI_EVENT_BASE_H__ +#define __MIDI_EVENT_BASE_H__ #include "eventbase.h" diff --git a/muse/muse/midififo.h b/muse/muse/midififo.h index 5572f882..282e0e7d 100644 --- a/muse/muse/midififo.h +++ b/muse/muse/midififo.h @@ -21,7 +21,7 @@ #ifndef __MIDIFIFO_H__ #define __MIDIFIFO_H__ -#include "mpevent.h" +#include "midievent.h" #define MIDI_FIFO_SIZE 512 diff --git a/muse/muse/midifile.h b/muse/muse/midifile.h index d88b58ac..c17fb9f7 100644 --- a/muse/muse/midifile.h +++ b/muse/muse/midifile.h @@ -22,7 +22,7 @@ #define __MIDIFILE_H__ #include "globaldefs.h" -#include "mpevent.h" +#include "midievent.h" struct MPEventList; class MidiEvent; diff --git a/muse/muse/midirc.h b/muse/muse/midirc.h index a992f198..670fca63 100644 --- a/muse/muse/midirc.h +++ b/muse/muse/midirc.h @@ -22,7 +22,7 @@ #define __MIDIRC_H__ #include "event.h" -#include "mpevent.h" +#include "midievent.h" enum { RC_STOP, RC_PLAY, RC_RECORD, RC_GOTO_LEFT_MARK diff --git a/muse/muse/midiseq.h b/muse/muse/midiseq.h index 3cadc737..8f29a292 100644 --- a/muse/muse/midiseq.h +++ b/muse/muse/midiseq.h @@ -22,7 +22,7 @@ #define __MIDISEQ_H__ #include "thread.h" -#include "mpevent.h" +#include "midievent.h" #include "driver/timerdev.h" namespace AL { diff --git a/muse/muse/mpevent.cpp b/muse/muse/mpevent.cpp deleted file mode 100644 index 573302c0..00000000 --- a/muse/muse/mpevent.cpp +++ /dev/null @@ -1,122 +0,0 @@ -//============================================================================= -// 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 "midievent.h" - -#include "helper.h" -#include "event.h" -#include "midictrl.h" -#include "muse/midi.h" - -//--------------------------------------------------------- -// MidiEvent -//--------------------------------------------------------- - -MidiEvent::MidiEvent(unsigned t, int tpe, const unsigned char* data, int len) - { - _time = t; - edata.setData(data, len); - _type = tpe; - } - -MidiEvent::MidiEvent(unsigned tick, int channel, const Event& e) - { - setChannel(channel); - setTime(tick); - switch(e.type()) { - case Note: - setType(ME_NOTEON); - setA(e.dataA()); - setB(e.dataB()); - break; - case Controller: - setType(ME_CONTROLLER); - setA(e.dataA()); // controller number - setB(e.dataB()); // controller value - break; - case PAfter: - setType(ME_POLYAFTER); - setA(e.dataA()); - setB(e.dataB()); - break; - case CAfter: - setType(ME_AFTERTOUCH); - setA(e.dataA()); - setB(0); - break; - case Sysex: - setType(ME_SYSEX); - setData(e.eventData()); - break; - default: - printf("MEvent::MEvent(): event type %d not implemented\n", - type()); - break; - } - } - -//--------------------------------------------------------- -// dump -//--------------------------------------------------------- - -void MidiEvent::dump() const - { - printf("chan:%d ", _channel+1); - if (_type == 0x90) { // NoteOn - QString s = pitch2string(_a); - printf("NoteOn %3s(0x%02x) %3d\n", s.toLatin1().data(), _a, _b); - } - else if (_type == 0xf0) { - printf("SysEx len %d ", len()); - int n = len() < 7 ? len() : 7; - unsigned char* p = data(); - for (int i = 0; i < n; ++i) - printf("%02x ", *p++); - printf("\n"); - } - else if (_type == 0xb0) - printf("Ctrl %d(0x%02x) %d(0x%02x)\n", _a, _a, _b, _b); - else if (_type == 0xc0) - printf("Prog %d(0x%02x)\n", _a, _a); - else if (_type == 0xd0) - printf("Aftertouch %d\n", _a); - else - printf("type:0x%02x a=%d(0x%02x) b=%d(0x%02x)\n", _type, _a, _a, _b, _b); - } - -//--------------------------------------------------------- -// 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() == ME_NOTEOFF - || (type() == ME_NOTEON && 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()]; - } diff --git a/muse/muse/preferences.h b/muse/muse/preferences.h index 13aaf252..69cc49a2 100644 --- a/muse/muse/preferences.h +++ b/muse/muse/preferences.h @@ -22,7 +22,7 @@ #define __PREFERENCES_H__ #include "ui_preferences.h" -#include "mpevent.h" +#include "midievent.h" class MusE; class Arranger; diff --git a/muse/muse/track.h b/muse/muse/track.h index 278a2105..0dcc3410 100644 --- a/muse/muse/track.h +++ b/muse/muse/track.h @@ -25,7 +25,7 @@ #include "route.h" #include "ctrl.h" #include "globaldefs.h" -#include "mpevent.h" +#include "midievent.h" #include "midififo.h" namespace AL { diff --git a/muse/synti/fluidsynth/fluidsynti.h b/muse/synti/fluidsynth/fluidsynti.h index 41ca2dc4..f41d4322 100644 --- a/muse/synti/fluidsynth/fluidsynti.h +++ b/muse/synti/fluidsynth/fluidsynti.h @@ -11,13 +11,12 @@ #define __MUSE_FLUIDSYNTI_H__ #include -// #include #include #include #include "fluidsynthgui.h" #include "libsynti/mess.h" #include "muse/debug.h" -#include "libsynti/mpevent.h" +#include "libsynti/midievent.h" #include "muse/midictrl.h" #define FS_DEBUG_DATA 0 //Turn on/off debug print of midi data sent to fluidsynth diff --git a/muse/synti/libsynti/CMakeLists.txt b/muse/synti/libsynti/CMakeLists.txt index 3cd62bed..70dc7dc3 100644 --- a/muse/synti/libsynti/CMakeLists.txt +++ b/muse/synti/libsynti/CMakeLists.txt @@ -18,7 +18,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #============================================================================= -add_library(synti mess.cpp gui.cpp mono.cpp poly.cpp mpevent.cpp) +add_library(synti mess.cpp gui.cpp mono.cpp poly.cpp midievent.cpp) # # -fPIC is necessary for 64 bit systems diff --git a/muse/synti/libsynti/gui.h b/muse/synti/libsynti/gui.h index 24d7fe52..27bebe3f 100644 --- a/muse/synti/libsynti/gui.h +++ b/muse/synti/libsynti/gui.h @@ -10,7 +10,7 @@ #ifndef __SYNTH_GUI_H__ #define __SYNTH_GUI_H__ -#include "mpevent.h" +#include "midievent.h" const int EVENT_FIFO_SIZE = 256; class QWidget; diff --git a/muse/synti/libsynti/mess.h b/muse/synti/libsynti/mess.h index 8187a3f3..33a43af5 100644 --- a/muse/synti/libsynti/mess.h +++ b/muse/synti/libsynti/mess.h @@ -11,7 +11,7 @@ #define MESS_MAJOR_VERSION 2 #define MESS_MINOR_VERSION 1 -#include "mpevent.h" +#include "midievent.h" class QWidget; class MessP; diff --git a/muse/synti/libsynti/midievent.cpp b/muse/synti/libsynti/midievent.cpp new file mode 100644 index 00000000..7c1e14fd --- /dev/null +++ b/muse/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/synti/libsynti/midievent.h b/muse/synti/libsynti/midievent.h new file mode 100644 index 00000000..a435d257 --- /dev/null +++ b/muse/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/synti/libsynti/mpevent.cpp b/muse/synti/libsynti/mpevent.cpp deleted file mode 100644 index c1d44c91..00000000 --- a/muse/synti/libsynti/mpevent.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//========================================================= -// 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 "mpevent.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/synti/libsynti/mpevent.h b/muse/synti/libsynti/mpevent.h deleted file mode 100644 index 67af3a88..00000000 --- a/muse/synti/libsynti/mpevent.h +++ /dev/null @@ -1,55 +0,0 @@ -//========================================================= -// 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 __MPEVENT_H__ -#define __MPEVENT_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/synti/organ/organ.cpp b/muse/synti/organ/organ.cpp index f2196493..0bdcc6a4 100644 --- a/muse/synti/organ/organ.cpp +++ b/muse/synti/organ/organ.cpp @@ -11,7 +11,7 @@ //========================================================= #include "muse/midi.h" -#include "libsynti/mpevent.h" +#include "libsynti/midievent.h" #include "organ.h" #include "organgui.h" diff --git a/muse/synti/organ/organgui.h b/muse/synti/organ/organgui.h index f58bb4aa..f8e1b5b7 100644 --- a/muse/synti/organ/organgui.h +++ b/muse/synti/organ/organgui.h @@ -12,7 +12,7 @@ #include "ui_organgui.h" #include "organ.h" #include "libsynti/gui.h" -#include "libsynti/mpevent.h" +#include "libsynti/midievent.h" class QSignalMapper; -- cgit v1.2.3