Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
windows_mme_device.h
1// SPDX-FileCopyrightText: © 2020 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3/*
4 * This file incorporates work covered by the following copyright and
5 * permission notice:
6 *
7 * ---
8 *
9 * Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 *
24 * ---
25 */
26
27#include "zrythm-config.h"
28
29#ifdef _WOE32
30
31# ifndef __AUDIO_WINDOWS_MME_DEVICE_H__
32# define __AUDIO_WINDOWS_MME_DEVICE_H__
33
34# include <windows.h>
35
36# include <stdint.h>
37
38# include "zix/ring.h"
39
40typedef struct AudioEngine AudioEngine;
41typedef struct MidiEvent MidiEvent;
42
49# define MIDI_BUFFER_SIZE 32768
50# define SYSEX_BUFFER_SIZE 32768
51
56enum WindowsMmeDeviceFlow
57{
58 WINDOWS_MME_DEVICE_FLOW_OUTPUT,
59 WINDOWS_MME_DEVICE_FLOW_INPUT,
60};
61
62typedef struct WindowsMmeDevice
63{
65 int is_input;
66
68 int id;
69
70 unsigned int manufacturer_id;
71 unsigned int product_id;
72 unsigned int driver_ver_major;
73 unsigned int driver_ver_minor;
74
75 char * name;
76
78 int opened;
79
81 int started;
82
83 /* ---- INPUT ---- */
84 HMIDIIN in_handle;
85 MIDIHDR sysex_header;
86
87 /* ---- OUTPUT ---- */
88 HMIDIOUT out_handle;
89
91 ZixRing * midi_ring;
92
93 uint8_t sysex_buffer[SYSEX_BUFFER_SIZE];
94
95} WindowsMmeDevice;
96
97WindowsMmeDevice *
98windows_mme_device_new (int input, int index);
99
108int
109windows_mme_device_open (WindowsMmeDevice * dev, int start);
110
116int
117windows_mme_device_close (WindowsMmeDevice * self, int free);
118
119int
120windows_mme_device_start (WindowsMmeDevice * self);
121
122int
123windows_mme_device_stop (WindowsMmeDevice * self);
124
145void
146windows_mme_device_input_cb (
147 HMIDIIN hMidiIn,
148 UINT wMsg,
149 DWORD_PTR dwInstance,
150 DWORD_PTR dwParam1,
151 DWORD_PTR dwParam2);
152
165int
166windows_mme_device_dequeue_midi_event_struct (
167 WindowsMmeDevice * self,
168 uint64_t timestamp_start,
169 uint64_t timestamp_end,
170 MidiEvent * ev);
171
176int
177windows_mme_device_dequeue_midi_event (
178 WindowsMmeDevice * self,
179 uint64_t timestamp_start,
180 uint64_t timestamp_end,
181 uint64_t * timestamp,
182 uint8_t * midi_data,
183 size_t * data_size);
184
189void
190windows_mme_device_print_info (WindowsMmeDevice * dev);
191
192void
193windows_mme_device_free (WindowsMmeDevice * dev);
194
199# endif
200#endif // _WOE32
The audio engine.
Definition engine.h:358
Timed MIDI event.
Definition midi_event.h:45