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 _WIN32
30
31# ifndef __AUDIO_WINDOWS_MME_DEVICE_H__
32# define __AUDIO_WINDOWS_MME_DEVICE_H__
33
34# include <windows.h>
35
36# include "zix/ring.h"
37# include <stdint.h>
38
39typedef struct AudioEngine AudioEngine;
40typedef struct MidiEvent MidiEvent;
41
48# define MIDI_BUFFER_SIZE 32768
49# define SYSEX_BUFFER_SIZE 32768
50
55enum WindowsMmeDeviceFlow
56{
57 WINDOWS_MME_DEVICE_FLOW_OUTPUT,
58 WINDOWS_MME_DEVICE_FLOW_INPUT,
59};
60
61typedef struct WindowsMmeDevice
62{
64 int is_input;
65
67 int id;
68
69 unsigned int manufacturer_id;
70 unsigned int product_id;
71 unsigned int driver_ver_major;
72 unsigned int driver_ver_minor;
73
74 char * name;
75
77 int opened;
78
80 int started;
81
82 /* ---- INPUT ---- */
83 HMIDIIN in_handle;
84 MIDIHDR sysex_header;
85
86 /* ---- OUTPUT ---- */
87 HMIDIOUT out_handle;
88
90 ZixRing * midi_ring;
91
92 uint8_t sysex_buffer[SYSEX_BUFFER_SIZE];
93
94} WindowsMmeDevice;
95
96WindowsMmeDevice *
97windows_mme_device_new (int input, int index);
98
107int
108windows_mme_device_open (WindowsMmeDevice * dev, int start);
109
115int
116windows_mme_device_close (WindowsMmeDevice * self, int free);
117
118int
119windows_mme_device_start (WindowsMmeDevice * self);
120
121int
122windows_mme_device_stop (WindowsMmeDevice * self);
123
144void
145windows_mme_device_input_cb (
146 HMIDIIN hMidiIn,
147 UINT wMsg,
148 DWORD_PTR dwInstance,
149 DWORD_PTR dwParam1,
150 DWORD_PTR dwParam2);
151
164int
165windows_mme_device_dequeue_midi_event_struct (
166 WindowsMmeDevice * self,
167 uint64_t timestamp_start,
168 uint64_t timestamp_end,
169 MidiEvent * ev);
170
175int
176windows_mme_device_dequeue_midi_event (
177 WindowsMmeDevice * self,
178 uint64_t timestamp_start,
179 uint64_t timestamp_end,
180 uint64_t * timestamp,
181 uint8_t * midi_data,
182 size_t * data_size);
183
188void
189windows_mme_device_print_info (WindowsMmeDevice * dev);
190
191void
192windows_mme_device_free (WindowsMmeDevice * dev);
193
198# endif
199#endif // _WIN32
The audio engine.
Definition engine.h:353
Timed MIDI event.
Definition midi_event.h:39