2 * Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
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.
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.
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.
19 #ifndef WINMME_MIDI_INPUT_DEVICE_H
20 #define WINMME_MIDI_INPUT_DEVICE_H
29 #include <boost/scoped_array.hpp>
30 #include <boost/scoped_ptr.hpp>
32 #include <pbd/ringbuffer.h>
36 class WinMMEMidiInputDevice {
38 WinMMEMidiInputDevice (int index);
40 ~WinMMEMidiInputDevice ();
45 * Dequeue events that have accumulated in winmm_input_callback.
47 * This is called by the audio processing thread/callback to transfer events
48 * into midi ports before processing.
50 bool dequeue_midi_event (uint64_t timestamp_start,
51 uint64_t timestamp_end,
59 void set_enabled (bool enable);
64 * @return Name of midi device
66 std::string name () const { return m_name; }
69 bool open (UINT index, std::string& error_msg);
70 bool close (std::string& error_msg);
72 bool add_sysex_buffer (std::string& error_msg);
73 bool set_device_name (UINT index);
75 std::string get_error_string (MMRESULT error_code);
77 static void CALLBACK winmm_input_callback (HMIDIIN handle,
83 void handle_short_msg (const uint8_t* midi_data, uint32_t timestamp);
85 void handle_sysex_msg (MIDIHDR* const midi_header, uint32_t timestamp);
87 bool enqueue_midi_msg (const uint8_t* midi_data, size_t size, uint32_t timestamp);
91 MIDIHDR m_sysex_header;
98 // can't use unique_ptr yet
99 boost::scoped_ptr<RingBuffer<uint8_t> > m_midi_buffer;
100 boost::scoped_array<uint8_t> m_sysex_buffer;
105 #endif // WINMME_MIDI_INPUT_DEVICE_H