MidiWinMM.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * MidiWinMM.h - WinMM MIDI client
  3. *
  4. * Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef MIDI_WINMM_H
  25. #define MIDI_WINMM_H
  26. #include "lmmsconfig.h"
  27. #ifdef LMMS_BUILD_WIN32
  28. #include <windows.h>
  29. #include <mmsystem.h>
  30. #include "MidiClient.h"
  31. #include "MidiPort.h"
  32. class QLineEdit;
  33. class MidiWinMM : public QObject, public MidiClient
  34. {
  35. Q_OBJECT
  36. public:
  37. MidiWinMM();
  38. virtual ~MidiWinMM();
  39. inline static QString probeDevice()
  40. {
  41. return QString(); // no midi device name
  42. }
  43. inline static QString name()
  44. {
  45. return QT_TRANSLATE_NOOP( "MidiSetupWidget", "WinMM MIDI" );
  46. }
  47. inline static QString configSection()
  48. {
  49. return QString(); // no configuration settings
  50. }
  51. virtual void processOutEvent( const MidiEvent & _me,
  52. const TimePos & _time,
  53. const MidiPort * _port );
  54. virtual void applyPortMode( MidiPort * _port );
  55. virtual void removePort( MidiPort * _port );
  56. // list devices as ports
  57. virtual QStringList readablePorts() const
  58. {
  59. return m_inputDevices.values();
  60. }
  61. virtual QStringList writablePorts() const
  62. {
  63. return m_outputDevices.values();
  64. }
  65. // return name of port which specified MIDI event came from
  66. virtual QString sourcePortName( const MidiEvent & ) const;
  67. // (un)subscribe given MidiPort to/from destination-port
  68. virtual void subscribeReadablePort( MidiPort * _port,
  69. const QString & _dest,
  70. bool _subscribe = true );
  71. virtual void subscribeWritablePort( MidiPort * _port,
  72. const QString & _dest,
  73. bool _subscribe = true );
  74. virtual void connectRPChanged( QObject * _receiver,
  75. const char * _member )
  76. {
  77. connect( this, SIGNAL( readablePortsChanged() ),
  78. _receiver, _member );
  79. }
  80. virtual void connectWPChanged( QObject * _receiver,
  81. const char * _member )
  82. {
  83. connect( this, SIGNAL( writablePortsChanged() ),
  84. _receiver, _member );
  85. }
  86. virtual bool isRaw() const
  87. {
  88. return false;
  89. }
  90. private:// slots:
  91. void updateDeviceList();
  92. private:
  93. void openDevices();
  94. void closeDevices();
  95. static void WINAPI CALLBACK inputCallback( HMIDIIN _hm, UINT _msg,
  96. DWORD_PTR _inst,
  97. DWORD_PTR _param1,
  98. DWORD_PTR _param2 );
  99. void handleInputEvent( HMIDIIN _hm, DWORD _ev );
  100. QMap<HMIDIIN, QString> m_inputDevices;
  101. QMap<HMIDIOUT, QString> m_outputDevices;
  102. // subscriptions
  103. typedef QMap<QString, MidiPortList> SubMap;
  104. SubMap m_inputSubs;
  105. SubMap m_outputSubs;
  106. signals:
  107. void readablePortsChanged();
  108. void writablePortsChanged();
  109. } ;
  110. #endif
  111. #endif