Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
ext_port.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __AUDIO_EXT_PORT_H__
5#define __AUDIO_EXT_PORT_H__
6
13#include "zrythm-config.h"
14
15#include "dsp/fader.h"
16#include "plugins/plugin.h"
17#include "utils/audio.h"
18#include "utils/types.h"
19#include "utils/yaml.h"
20
21#include <gdk/gdk.h>
22
23#ifdef HAVE_JACK
24# include "weak_libjack.h"
25#endif
26
27#ifdef HAVE_RTMIDI
28# include <rtmidi_c.h>
29#endif
30
31typedef struct WindowsMmeDevice WindowsMmeDevice;
33
40#define EXT_PORT_SCHEMA_VERSION 1
41
47#define EXT_PORTS_MAX 1024
48
49#define ext_port_is_in_active_project(self) \
50 (self->hw_processor \
51 && hw_processor_is_in_active_project ((self)->hw_processor))
52
56typedef enum ExtPortType
57{
58 EXT_PORT_TYPE_JACK,
59 EXT_PORT_TYPE_ALSA,
60 EXT_PORT_TYPE_WINDOWS_MME,
61 EXT_PORT_TYPE_RTMIDI,
62 EXT_PORT_TYPE_RTAUDIO,
64
65static const cyaml_strval_t ext_port_type_strings[] = {
66 {"JACK", EXT_PORT_TYPE_JACK },
67 { "ALSA", EXT_PORT_TYPE_ALSA },
68 { "Windows MME", EXT_PORT_TYPE_WINDOWS_MME},
69 { "RtMidi", EXT_PORT_TYPE_RTMIDI },
70 { "RtAudio", EXT_PORT_TYPE_RTAUDIO },
71};
72
76typedef struct ExtPort
77{
78 int schema_version;
79
81#ifdef HAVE_JACK
82 jack_port_t * jport;
83#else
84 void * jport;
85#endif
86
88 char * full_name;
89
91 char * short_name;
92
94 char * alias1;
95
97 char * alias2;
98
99 int num_aliases;
100
101#ifdef _WOE32
108 WindowsMmeDevice * mme_dev;
109#else
110 void * mme_dev;
111#endif
112
115
118
120 unsigned int rtaudio_id;
121
124 bool rtaudio_is_duplex;
125
126#ifdef HAVE_RTAUDIO
127 RtAudioDevice * rtaudio_dev;
128#else
129 void * rtaudio_dev;
130#endif
131
133 unsigned int rtmidi_id;
134
135#ifdef HAVE_RTMIDI
136 RtMidiDevice * rtmidi_dev;
137#else
138 void * rtmidi_dev;
139#endif
140
141 ExtPortType type;
142
145
149
152
155 bool active;
156
165
170} ExtPort;
171
175COLD NONNULL_ARGS (1) void ext_port_init_loaded (
176 ExtPort * self,
177 HardwareProcessor * hw_processor);
178
182void
184
189bool
191
197MALLOC
198NONNULL char *
199ext_port_get_id (ExtPort * ext_port);
200
201NONNULL bool
202ext_ports_equal (const ExtPort * a, const ExtPort * b);
203
209NONNULL char *
210ext_port_get_friendly_name (ExtPort * self);
211
215float *
217
221void
223
224#if 0
233void
234ext_port_connect (
235 ExtPort * ext_port,
236 Port * port,
237 int src);
238#endif
239
240#ifdef HAVE_JACK
244ExtPort *
245ext_port_new_from_jack_port (jack_port_t * jport);
246#endif /* HAVE_JACK */
247
254void
255ext_port_disconnect (ExtPort * ext_port, Port * port, int src);
256
265int
266ext_port_activate (ExtPort * self, Port * port, bool activate);
267
276bool
278
286void
287ext_ports_get (PortType type, PortFlow flow, bool hw, GPtrArray * ports);
288
292ExtPort *
294
298void
299ext_ports_free (ExtPort ** ext_port, int size);
300
304void
306
311#endif
Audio utils.
Backend for faders or other volume/gain controls.
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
ExtPortType
External port type.
Definition ext_port.h:57
void ext_ports_free(ExtPort **ext_port, int size)
Frees an array of ExtPort pointers.
int ext_port_activate(ExtPort *self, Port *port, bool activate)
Activates the port (starts receiving data) or deactivates it.
bool ext_port_get_enabled(ExtPort *self)
Checks in the GSettings whether this port is marked as enabled by the user.
void ext_port_clear_buffer(ExtPort *ext_port, nframes_t nframes)
Clears the buffer of the external port.
ExtPort * ext_port_clone(ExtPort *ext_port)
Creates a shallow clone of the port.
void ext_port_disconnect(ExtPort *ext_port, Port *port, int src)
Disconnects the Port from the ExtPort.
PortType
Type of signals the Port handles.
PortFlow
Direction of the signal.
float * ext_port_get_buffer(ExtPort *ext_port, nframes_t nframes)
Returns the buffer of the external port.
void ext_port_print(ExtPort *self)
Prints the port info.
void ext_ports_get(PortType type, PortFlow flow, bool hw, GPtrArray *ports)
Collects external ports of the given type.
void ext_port_free(ExtPort *ext_port)
Frees the ext_port.
bool ext_port_matches_backend(ExtPort *self)
Returns if the ext port matches the current backend.
uint32_t nframes_t
Frame count.
Definition types.h:35
Base plugin.
External port.
Definition ext_port.h:77
bool is_midi
True if MIDI, false if audio.
Definition ext_port.h:144
int hw_processor_index
Index in the HW processor (cache for real-time use)
Definition ext_port.h:148
HardwareProcessor * hw_processor
Pointer to owner hardware processor, if any.
Definition ext_port.h:151
char * short_name
Short port name.
Definition ext_port.h:91
unsigned int rtaudio_id
RtAudio device ID (NOT index!!!).
Definition ext_port.h:120
unsigned int rtaudio_channel_idx
RtAudio channel index.
Definition ext_port.h:114
char * full_name
Full port name, used also as ID.
Definition ext_port.h:88
char * alias2
Alias #2 if any.
Definition ext_port.h:97
char * rtaudio_dev_name
RtAudio device name.
Definition ext_port.h:117
unsigned int rtmidi_id
RtMidi port index.
Definition ext_port.h:133
void * jport
JACK port.
Definition ext_port.h:84
char * alias1
Alias #1 if any.
Definition ext_port.h:94
bool active
Whether the port is active and receiving events (for use by hw processor).
Definition ext_port.h:155
bool rtaudio_is_input
Whether the channel is input.
Definition ext_port.h:123
bool pending_reconnect
Set to true when a hardware port is disconnected.
Definition ext_port.h:164
Port * port
Temporary port to receive data.
Definition ext_port.h:169
Hardware processor.
Must ONLY be created via port_new()
Definition port.h:138
Custom types.
YAML utils.