1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/*
MIDI Sequencer C++ library
Copyright (C) 2006-2025, Pedro Lopez-Cabanillas <plcl@users.sf.net>
This library 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 3 of the License, or
(at your option) any later version.
This library 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef DUMPMIDI_H_
#define DUMPMIDI_H_
/* MidiClient can deliver SequencerEvents with only
* signals or posting QEvents to the QApplication loop */
#undef USE_QEVENTS
//#define USE_QEVENTS
/* Subscribe to Announce port to receive client and port events */
#undef SUBSCRIBE_ANNOUNCE
//#define SUBSCRIBE_ANNOUNCE
/* To get timestamped events from ALSA, you need a running queue */
//#undef WANT_TIMESTAMPS
#define WANT_TIMESTAMPS
#include <QObject>
#include <QReadWriteLock>
#include <drumstick/alsaevent.h>
#include <drumstick/alsaclient.h>
#include <drumstick/alsaport.h>
#include <drumstick/alsaqueue.h>
#include <drumstick/subscription.h>
class QDumpMIDI : public QObject, public drumstick::ALSA::SequencerEventHandler
{
Q_OBJECT
public:
QDumpMIDI();
virtual ~QDumpMIDI();
void dumpEvent(drumstick::ALSA::SequencerEvent* ev);
void subscribe(const QString& portName);
void stop();
bool stopped();
void run();
virtual void handleSequencerEvent(drumstick::ALSA::SequencerEvent* ev);
public Q_SLOTS:
void subscription( drumstick::ALSA::MidiPort* port, drumstick::ALSA::Subscription* subs );
#ifdef USE_QEVENTS
protected:
virtual void customEvent( QEvent *ev );
#else
void sequencerEvent( drumstick::ALSA::SequencerEvent* ev );
#endif
private:
drumstick::ALSA::MidiClient* m_Client;
drumstick::ALSA::MidiPort* m_Port;
#ifdef WANT_TIMESTAMPS
drumstick::ALSA::MidiQueue* m_Queue;
#endif
bool m_Stopped;
QReadWriteLock m_mutex;
};
#endif /*DUMPMIDI_H_*/
|