Add a new MSVC project for building the Portaudio backend
[ardour.git] / libs / backends / wavesaudio / waves_midi_device_manager.h
1 /*
2     Copyright (C) 2013 Waves Audio Ltd.
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __libardour_waves_midi_device_manager_h__
21 #define __libardour_waves_midi_device_manager_h__
22
23 #include "waves_midi_device.h"
24
25 namespace ARDOUR {
26
27 class WavesAudioBackend;
28
29 class WavesMidiDeviceManager {
30 public:
31     WavesMidiDeviceManager (WavesAudioBackend& audiobackend);
32     ~WavesMidiDeviceManager ();
33
34     inline const std::vector<WavesMidiDevice *>& devices () const 
35     {
36         return _devices;
37     }
38
39     int start ();
40     int stop ();
41     int stream (bool yn);
42     int is_streaming () { return _streaming; }
43     void do_read ();
44     void do_write ();
45
46 private:
47
48     int _create_devices ();
49     void _close_devices ();
50
51     int _delete_devices ();
52     static void __portmidi_callback (PtTimestamp timestamp, void * userData);
53     void _portmidi_callback (PtTimestamp timestamp);
54     /** __get_time_ms is given to Pm_Open functions (see WavesMidiDevice.cc)
55      *  to provide the time in milliseconds using the time of audio
56      *  transport. 
57      *  time_info is a pointer on the backend instance, which agregates the
58      *  audio and miditransports. It's not checked for correctness to consume
59      *  no time. 
60      */
61     static PmTimestamp __get_time_ms (void *time_info);
62
63     WavesMidiDevice* _get_device (const std::string& name);
64
65     std::vector<WavesMidiDevice*> _devices; // Vector for midi devices
66     bool _active;
67     bool _streaming;
68
69     size_t _input_device_count;
70     size_t _output_device_count;
71     WavesAudioBackend& _audiobackend;
72 };
73
74 } // namespace
75
76 #endif /* __libardour_waves_midi_device_manager_h__ */
77