added support for easy MIDI-port-subscription inside LMMS
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@29 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -43,11 +43,13 @@
|
||||
#ifdef QT4
|
||||
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
#else
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qthread.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -91,6 +93,38 @@ public:
|
||||
virtual void FASTCALL removePort( midiPort * _port );
|
||||
|
||||
|
||||
// list seq-ports from ALSA
|
||||
inline virtual const QStringList & readablePorts( void ) const
|
||||
{
|
||||
return( m_readablePorts );
|
||||
}
|
||||
|
||||
virtual const QStringList & writeablePorts( void ) const
|
||||
{
|
||||
return( m_writeablePorts );
|
||||
}
|
||||
|
||||
// (un)subscribe given midiPort to/from destination-port
|
||||
virtual void subscribeReadablePort( midiPort * _port,
|
||||
const QString & _dest,
|
||||
bool _unsubscribe = FALSE );
|
||||
virtual void subscribeWriteablePort( midiPort * _port,
|
||||
const QString & _dest,
|
||||
bool _unsubscribe = FALSE );
|
||||
virtual void connectRPChanged( QObject * _receiver,
|
||||
const char * _member )
|
||||
{
|
||||
connect( this, SIGNAL( readablePortsChanged() ),
|
||||
_receiver, _member );
|
||||
}
|
||||
|
||||
virtual void connectWPChanged( QObject * _receiver,
|
||||
const char * _member )
|
||||
{
|
||||
connect( this, SIGNAL( writeablePortsChanged() ),
|
||||
_receiver, _member );
|
||||
}
|
||||
|
||||
|
||||
class setupWidget : public midiClient::setupWidget
|
||||
{
|
||||
@@ -108,6 +142,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void changeQueueTempo( int _bpm );
|
||||
void updatePortList( void );
|
||||
|
||||
|
||||
private:
|
||||
@@ -127,6 +162,16 @@ private:
|
||||
|
||||
volatile bool m_quit;
|
||||
|
||||
|
||||
QTimer m_portListUpdateTimer;
|
||||
QStringList m_readablePorts;
|
||||
QStringList m_writeablePorts;
|
||||
|
||||
|
||||
signals:
|
||||
void readablePortsChanged( void );
|
||||
void writeablePortsChanged( void );
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,10 +31,12 @@
|
||||
#ifdef QT4
|
||||
|
||||
#include <QVector>
|
||||
#include <QStringList>
|
||||
|
||||
#else
|
||||
|
||||
#include <qvaluevector.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -74,6 +76,38 @@ public:
|
||||
// re-implemented methods HAVE to call removePort() of base-class!!
|
||||
virtual void FASTCALL removePort( midiPort * _port );
|
||||
|
||||
|
||||
// returns whether client works with raw-MIDI, only needs to be
|
||||
// re-implemented by midiClientRaw for returning TRUE
|
||||
inline virtual bool isRaw( void ) const
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
// if not raw-client, return all readable/writeable ports
|
||||
virtual const QStringList & readablePorts( void ) const;
|
||||
virtual const QStringList & writeablePorts( void ) const;
|
||||
|
||||
// (un)subscribe given midiPort to/from destination-port
|
||||
virtual void subscribeReadablePort( midiPort * _port,
|
||||
const QString & _dest,
|
||||
bool _unsubscribe = FALSE );
|
||||
virtual void subscribeWriteablePort( midiPort * _port,
|
||||
const QString & _dest,
|
||||
bool _unsubscribe = FALSE );
|
||||
|
||||
// qobject-derived classes can use this for make a slot being
|
||||
// connected to signal of non-raw-MIDI-client if port-lists change
|
||||
virtual void connectRPChanged( QObject *, const char * )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void connectWPChanged( QObject *, const char * )
|
||||
{
|
||||
}
|
||||
|
||||
// tries to open either MIDI-driver from config-file or (if it fails)
|
||||
// any other working
|
||||
static midiClient * openMidiClient( void );
|
||||
|
||||
|
||||
@@ -102,6 +136,7 @@ protected:
|
||||
|
||||
|
||||
|
||||
|
||||
const Uint8 RAW_MIDI_PARSE_BUF_SIZE = 16;
|
||||
|
||||
|
||||
@@ -111,22 +146,34 @@ public:
|
||||
midiClientRaw( void );
|
||||
virtual ~midiClientRaw();
|
||||
|
||||
// we are raw-clients for sure!
|
||||
inline virtual bool isRaw( void ) const
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
// generic raw-MIDI-parser which generates appropriate MIDI-events
|
||||
void FASTCALL parseData( const Uint8 _c );
|
||||
|
||||
// to be implemented by actual client-implementation
|
||||
virtual void FASTCALL sendByte( const Uint8 _c ) = 0;
|
||||
|
||||
|
||||
private:
|
||||
// this does MIDI-event-process
|
||||
void processParsedEvent();
|
||||
virtual void FASTCALL processOutEvent( const midiEvent & _me,
|
||||
const midiTime & _time,
|
||||
const midiPort * _port );
|
||||
|
||||
// small helper function returning length of a certain event - this
|
||||
// is neccessary for parsing raw-MIDI-data
|
||||
static Uint8 FASTCALL eventLength( const Uint8 _event );
|
||||
|
||||
|
||||
// data being used for parsing
|
||||
struct midiParserData
|
||||
{
|
||||
Uint8 m_status; // identifies the type of event, that
|
||||
@@ -142,7 +189,9 @@ private:
|
||||
// buffer for incoming data
|
||||
midiEvent m_midiEvent; // midi-event
|
||||
} m_midiParseData;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "settings.h"
|
||||
|
||||
|
||||
class QComboBox;
|
||||
class QMenu;
|
||||
class QPixmap;
|
||||
|
||||
class channelTrack;
|
||||
@@ -78,7 +78,10 @@ protected slots:
|
||||
void inputChannelChanged( int );
|
||||
void outputChannelChanged( int );
|
||||
void midiPortModeToggled( bool );
|
||||
|
||||
void readablePortsChanged( void );
|
||||
void writeablePortsChanged( void );
|
||||
void activatedReadablePort( int _id );
|
||||
void activatedWriteablePort( int _id );
|
||||
|
||||
private:
|
||||
channelTrack * m_channelTrack;
|
||||
@@ -90,6 +93,8 @@ private:
|
||||
ledCheckBox * m_receiveCheckBox;
|
||||
ledCheckBox * m_sendCheckBox;
|
||||
ledCheckBox * m_routeCheckBox;
|
||||
QMenu * m_readablePorts;
|
||||
QMenu * m_writeablePorts;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user