Ardour
9.0-pre0-582-g084a23a80d
winmmemidi_input_device.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
3
* Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
*/
19
20
#ifndef WINMME_MIDI_INPUT_DEVICE_H
21
#define WINMME_MIDI_INPUT_DEVICE_H
22
23
#include <windows.h>
24
#include <mmsystem.h>
25
26
#include <stdint.h>
27
28
#include <string>
29
#include <memory>
30
31
#include <
pbd/ringbuffer.h
>
32
33
namespace
ARDOUR
{
34
35
class
WinMMEMidiInputDevice
{
36
public
:
// ctors
37
WinMMEMidiInputDevice
(
int
index);
38
39
~WinMMEMidiInputDevice
();
40
41
public
:
// methods
42
49
bool
dequeue_midi_event
(uint64_t timestamp_start,
50
uint64_t timestamp_end,
51
uint64_t& timestamp,
52
uint8_t* data,
53
size_t
& size);
54
55
bool
start
();
56
bool
stop
();
57
58
void
set_enabled
(
bool
enable);
59
60
bool
get_enabled
();
61
65
std::string
name
()
const
{
return
m_name
; }
66
67
private
:
// methods
68
bool
open
(UINT index, std::string& error_msg);
69
bool
close
(std::string& error_msg);
70
71
bool
add_sysex_buffer
(std::string& error_msg);
72
bool
set_device_name
(UINT index);
73
74
std::string
get_error_string
(MMRESULT error_code);
75
76
static
void
CALLBACK
winmm_input_callback
(HMIDIIN handle,
77
UINT msg,
78
DWORD_PTR instance,
79
DWORD_PTR midi_msg,
80
DWORD timestamp);
81
82
void
handle_short_msg
(
const
uint8_t* midi_data, uint32_t timestamp);
83
84
void
handle_sysex_msg
(MIDIHDR*
const
midi_header, uint32_t timestamp);
85
86
bool
enqueue_midi_msg
(
const
uint8_t* midi_data,
size_t
size, uint32_t timestamp);
87
88
private
:
// data
89
HMIDIIN
m_handle
;
90
MIDIHDR
m_sysex_header
;
91
92
bool
m_started
;
93
94
std::string
m_name
;
95
96
// can't use unique_ptr yet
97
const
std::unique_ptr<PBD::RingBuffer<uint8_t> >
m_midi_buffer
;
98
std::unique_ptr<uint8_t[]>
m_sysex_buffer
;
99
};
100
101
}
102
103
#endif
// WINMME_MIDI_INPUT_DEVICE_H
ARDOUR::WinMMEMidiInputDevice
Definition:
winmmemidi_input_device.h:35
ARDOUR::WinMMEMidiInputDevice::m_started
bool m_started
Definition:
winmmemidi_input_device.h:92
ARDOUR::WinMMEMidiInputDevice::m_name
std::string m_name
Definition:
winmmemidi_input_device.h:94
ARDOUR::WinMMEMidiInputDevice::set_enabled
void set_enabled(bool enable)
ARDOUR::WinMMEMidiInputDevice::open
bool open(UINT index, std::string &error_msg)
ARDOUR::WinMMEMidiInputDevice::m_midi_buffer
const std::unique_ptr< PBD::RingBuffer< uint8_t > > m_midi_buffer
Definition:
winmmemidi_input_device.h:97
ARDOUR::WinMMEMidiInputDevice::WinMMEMidiInputDevice
WinMMEMidiInputDevice(int index)
ARDOUR::WinMMEMidiInputDevice::stop
bool stop()
ARDOUR::WinMMEMidiInputDevice::dequeue_midi_event
bool dequeue_midi_event(uint64_t timestamp_start, uint64_t timestamp_end, uint64_t ×tamp, uint8_t *data, size_t &size)
ARDOUR::WinMMEMidiInputDevice::get_error_string
std::string get_error_string(MMRESULT error_code)
ARDOUR::WinMMEMidiInputDevice::~WinMMEMidiInputDevice
~WinMMEMidiInputDevice()
ARDOUR::WinMMEMidiInputDevice::name
std::string name() const
Definition:
winmmemidi_input_device.h:65
ARDOUR::WinMMEMidiInputDevice::close
bool close(std::string &error_msg)
ARDOUR::WinMMEMidiInputDevice::get_enabled
bool get_enabled()
ARDOUR::WinMMEMidiInputDevice::m_sysex_header
MIDIHDR m_sysex_header
Definition:
winmmemidi_input_device.h:90
ARDOUR::WinMMEMidiInputDevice::add_sysex_buffer
bool add_sysex_buffer(std::string &error_msg)
ARDOUR::WinMMEMidiInputDevice::set_device_name
bool set_device_name(UINT index)
ARDOUR::WinMMEMidiInputDevice::handle_short_msg
void handle_short_msg(const uint8_t *midi_data, uint32_t timestamp)
ARDOUR::WinMMEMidiInputDevice::start
bool start()
ARDOUR::WinMMEMidiInputDevice::handle_sysex_msg
void handle_sysex_msg(MIDIHDR *const midi_header, uint32_t timestamp)
ARDOUR::WinMMEMidiInputDevice::m_handle
HMIDIIN m_handle
Definition:
winmmemidi_input_device.h:89
ARDOUR::WinMMEMidiInputDevice::winmm_input_callback
static void CALLBACK winmm_input_callback(HMIDIIN handle, UINT msg, DWORD_PTR instance, DWORD_PTR midi_msg, DWORD timestamp)
ARDOUR::WinMMEMidiInputDevice::m_sysex_buffer
std::unique_ptr< uint8_t[]> m_sysex_buffer
Definition:
winmmemidi_input_device.h:98
ARDOUR::WinMMEMidiInputDevice::enqueue_midi_msg
bool enqueue_midi_msg(const uint8_t *midi_data, size_t size, uint32_t timestamp)
ARDOUR
Definition:
analysis_window.h:44
ringbuffer.h
libs
backends
portaudio
winmmemidi_input_device.h
Generated on Wed Dec 25 2024 05:44:58 for Ardour by
1.9.1