added rudimentary WinMM MIDI support

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1355 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-07-22 13:14:15 +00:00
parent 42ab630582
commit c238f579c2
12 changed files with 643 additions and 29 deletions

View File

@@ -73,12 +73,12 @@ public:
// list seq-ports from ALSA
inline virtual const QStringList & readablePorts( void ) const
virtual QStringList readablePorts( void ) const
{
return( m_readablePorts );
}
virtual const QStringList & writeablePorts( void ) const
virtual QStringList writeablePorts( void ) const
{
return( m_writeablePorts );
}

View File

@@ -63,14 +63,20 @@ public:
// returns whether client works with raw-MIDI, only needs to be
// re-implemented by midiClientRaw for returning TRUE
inline virtual bool isRaw( void ) const
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;
virtual QStringList readablePorts( void ) const
{
return QStringList();
}
virtual QStringList writeablePorts( void ) const
{
return QStringList();
}
// (un)subscribe given midiPort to/from destination-port
virtual void subscribeReadablePort( midiPort * _port,
@@ -100,7 +106,8 @@ public:
public:
setupWidget( const QString & _caption, QWidget * _parent ) :
tabWidget( tabWidget::tr( "Settings for %1" ).arg(
tr( _caption.toAscii() ) ).toUpper(), _parent )
tr( _caption.toAscii() ) ).toUpper(),
_parent )
{
}
@@ -137,7 +144,7 @@ public:
virtual ~midiClientRaw();
// we are raw-clients for sure!
inline virtual bool isRaw( void ) const
virtual bool isRaw( void ) const
{
return( TRUE );
}

View File

@@ -87,6 +87,16 @@ public:
void setMode( Modes _mode );
inline bool inputEnabled( void ) const
{
return( mode() == Input || mode() == Duplex );
}
inline bool outputEnabled( void ) const
{
return( mode() == Output || mode() == Duplex );
}
inline void enableDefaultVelocityForInEvents( const bool _on )
{
m_defaultVelocityInEnabledModel.setValue( _on );
@@ -171,5 +181,7 @@ private:
} ;
typedef QList<midiPort *> midiPortList;
#endif

154
include/midi_winmm.h Normal file
View File

@@ -0,0 +1,154 @@
/*
* midi_winmm.h - WinMM MIDI client
*
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program 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 2 of the License, or (at your option) any later version.
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _MIDI_WINMM_H
#define _MIDI_WINMM_H
#include "lmmsconfig.h"
#ifdef LMMS_BUILD_WIN32
#include <windows.h>
#include <mmsystem.h>
#include <QtCore/QTimer>
#include "midi_client.h"
#include "midi_port.h"
class QLineEdit;
class midiWinMM : public QObject, public midiClient
{
Q_OBJECT
public:
midiWinMM( void );
virtual ~midiWinMM();
static QString probeDevice( void );
inline static QString name( void )
{
return( QT_TRANSLATE_NOOP( "setupWidget", "WinMM MIDI" ) );
}
virtual void processOutEvent( const midiEvent & _me,
const midiTime & _time,
const midiPort * _port );
virtual void applyPortMode( midiPort * _port );
virtual void removePort( midiPort * _port );
// list devices as ports
virtual QStringList readablePorts( void ) const
{
return( m_inputDevices.values() );
}
virtual QStringList writeablePorts( void ) const
{
return( m_outputDevices.values() );
}
// (un)subscribe given midiPort to/from destination-port
virtual void subscribeReadablePort( midiPort * _port,
const QString & _dest,
bool _subscribe = TRUE );
virtual void subscribeWriteablePort( midiPort * _port,
const QString & _dest,
bool _subscribe = TRUE );
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 );
}
virtual bool isRaw( void ) const
{
return( FALSE );
}
class setupWidget : public midiClient::setupWidget
{
public:
setupWidget( QWidget * _parent );
virtual ~setupWidget();
virtual void saveSettings( void );
private:
QLineEdit * m_device;
} ;
private slots:
void updateDeviceList( void );
private:
void openDevices( void );
void closeDevices( void );
static void CALLBACK inputCallback( HMIDIIN _hm, UINT _msg,
DWORD_PTR _inst,
DWORD_PTR _param1,
DWORD_PTR _param2 );
void handleInputEvent( HMIDIIN _hm, DWORD _ev );
QTimer m_deviceListUpdateTimer;
QMap<HMIDIIN, QString> m_inputDevices;
QMap<HMIDIOUT, QString> m_outputDevices;
// subscriptions
typedef QMap<QString, midiPortList> subMap;
subMap m_inputSubs;
subMap m_outputSubs;
signals:
void readablePortsChanged( void );
void writeablePortsChanged( void );
} ;
#endif
#endif