| 1 | /* |
|---|
| 2 | * libjdkmidi-2004 C++ Class Library for MIDI |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2004 J.D. Koftinoff Software, Ltd. |
|---|
| 5 | * www.jdkoftinoff.com |
|---|
| 6 | * jeffk@jdkoftinoff.com |
|---|
| 7 | * |
|---|
| 8 | * *** RELEASED UNDER THE GNU GENERAL PUBLIC LICENSE (GPL) April 27, 2004 *** |
|---|
| 9 | * |
|---|
| 10 | * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | * it under the terms of the GNU General Public License as published by |
|---|
| 12 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | * (at your option) any later version. |
|---|
| 14 | * |
|---|
| 15 | * This program is distributed in the hope that it will be useful, |
|---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | * GNU General Public License for more details. |
|---|
| 19 | * |
|---|
| 20 | * You should have received a copy of the GNU General Public License |
|---|
| 21 | * along with this program; if not, write to the Free Software |
|---|
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 23 | */ |
|---|
| 24 | #ifndef JDKMIDI_DRIVERWIN32_H |
|---|
| 25 | #define JDKMIDI_DRIVERWIN32_H |
|---|
| 26 | |
|---|
| 27 | #include "jdkmidi/driver.h" |
|---|
| 28 | #include "jdkmidi/sequencer.h" |
|---|
| 29 | |
|---|
| 30 | #ifdef WIN32 |
|---|
| 31 | #include "windows.h" |
|---|
| 32 | #include "mmsystem.h" |
|---|
| 33 | |
|---|
| 34 | namespace jdkmidi |
|---|
| 35 | { |
|---|
| 36 | |
|---|
| 37 | class MIDISequencerGUIEventNotifierWin32 : |
|---|
| 38 | public MIDISequencerGUIEventNotifier |
|---|
| 39 | { |
|---|
| 40 | public: |
|---|
| 41 | MIDISequencerGUIEventNotifierWin32 ( |
|---|
| 42 | HWND w, |
|---|
| 43 | DWORD wmmsg, |
|---|
| 44 | WPARAM wparam_value_=0 |
|---|
| 45 | ); |
|---|
| 46 | |
|---|
| 47 | virtual ~MIDISequencerGUIEventNotifierWin32(); |
|---|
| 48 | |
|---|
| 49 | virtual void Notify ( const MIDISequencer *seq, MIDISequencerGUIEvent e ); |
|---|
| 50 | virtual bool GetEnable() const; |
|---|
| 51 | virtual void SetEnable ( bool f ); |
|---|
| 52 | |
|---|
| 53 | private: |
|---|
| 54 | |
|---|
| 55 | HWND dest_window; |
|---|
| 56 | DWORD window_msg; |
|---|
| 57 | WPARAM wparam_value; |
|---|
| 58 | bool en; |
|---|
| 59 | }; |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | class MIDIDriverWin32 : public MIDIDriver |
|---|
| 64 | { |
|---|
| 65 | public: |
|---|
| 66 | MIDIDriverWin32 ( int queue_size ); |
|---|
| 67 | virtual ~MIDIDriverWin32(); |
|---|
| 68 | |
|---|
| 69 | void ResetMIDIOut(); |
|---|
| 70 | |
|---|
| 71 | bool StartTimer ( int resolution_ms ); |
|---|
| 72 | bool OpenMIDIInPort ( int id ); |
|---|
| 73 | bool OpenMIDIOutPort ( int id ); |
|---|
| 74 | |
|---|
| 75 | void StopTimer(); |
|---|
| 76 | void CloseMIDIInPort(); |
|---|
| 77 | void CloseMIDIOutPort(); |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | bool HardwareMsgOut ( const MIDITimedBigMessage &msg ); |
|---|
| 81 | |
|---|
| 82 | protected: |
|---|
| 83 | |
|---|
| 84 | static void CALLBACK win32_timer ( |
|---|
| 85 | UINT wTimerID, |
|---|
| 86 | UINT msg, |
|---|
| 87 | DWORD dwUser, |
|---|
| 88 | DWORD dw1, |
|---|
| 89 | DWORD dw2 |
|---|
| 90 | ); |
|---|
| 91 | |
|---|
| 92 | static void CALLBACK win32_midi_in ( |
|---|
| 93 | HMIDIIN hMidiIn, |
|---|
| 94 | UINT wMsg, |
|---|
| 95 | DWORD dwInstance, |
|---|
| 96 | DWORD dwParam1, |
|---|
| 97 | DWORD dwParam2 |
|---|
| 98 | ); |
|---|
| 99 | |
|---|
| 100 | HMIDIIN in_handle; |
|---|
| 101 | HMIDIOUT out_handle; |
|---|
| 102 | int timer_id; |
|---|
| 103 | int timer_res; |
|---|
| 104 | |
|---|
| 105 | bool in_open; |
|---|
| 106 | bool out_open; |
|---|
| 107 | bool timer_open; |
|---|
| 108 | }; |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | } |
|---|
| 112 | #endif |
|---|
| 113 | |
|---|
| 114 | #endif |
|---|