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
56enum class 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,
63};
64
68typedef struct ExtPort
69{
70 int schema_version;
71
73#ifdef HAVE_JACK
74 jack_port_t * jport;
75#else
76 void * jport;
77#endif
78
80 char * full_name;
81
83 char * short_name;
84
86 char * alias1;
87
89 char * alias2;
90
91 int num_aliases;
92
93#ifdef _WIN32
100 WindowsMmeDevice * mme_dev;
101#else
102 void * mme_dev;
103#endif
104
107
110
112 unsigned int rtaudio_id;
113
116 bool rtaudio_is_duplex;
117
118#ifdef HAVE_RTAUDIO
119 RtAudioDevice * rtaudio_dev;
120#else
121 void * rtaudio_dev;
122#endif
123
125 unsigned int rtmidi_id;
126
127#ifdef HAVE_RTMIDI
128 RtMidiDevice * rtmidi_dev;
129#else
130 void * rtmidi_dev;
131#endif
132
133 ExtPortType type;
134
137
141
144
147 bool active;
148
157
162} ExtPort;
163
167COLD NONNULL_ARGS (1) void ext_port_init_loaded (
168 ExtPort * self,
169 HardwareProcessor * hw_processor);
170
174void
176
181bool
183
189MALLOC
190NONNULL char *
191ext_port_get_id (ExtPort * ext_port);
192
193NONNULL bool
194ext_ports_equal (const ExtPort * a, const ExtPort * b);
195
201NONNULL char *
202ext_port_get_friendly_name (ExtPort * self);
203
207float *
209
213void
215
216#if 0
225void
226ext_port_connect (
227 ExtPort * ext_port,
228 Port * port,
229 int src);
230#endif
231
232#ifdef HAVE_JACK
236ExtPort *
237ext_port_new_from_jack_port (jack_port_t * jport);
238#endif /* HAVE_JACK */
239
246void
247ext_port_disconnect (ExtPort * ext_port, Port * port, int src);
248
257int
258ext_port_activate (ExtPort * self, Port * port, bool activate);
259
268bool
270
279void
280ext_ports_get (ZPortType type, ZPortFlow flow, bool hw, GPtrArray * ports);
281
285ExtPort *
287
291void
292ext_ports_free (ExtPort ** ext_port, int size);
293
297void
299
304#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.
ZPortType
Type of signals the Port handles.
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.
void ext_ports_get(ZPortType type, ZPortFlow flow, bool hw, GPtrArray *ports)
Collects external ports of the given type.
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.
ZPortFlow
Direction of the signal.
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:39
Base plugin.
External port.
Definition ext_port.h:69
bool is_midi
True if MIDI, false if audio.
Definition ext_port.h:136
int hw_processor_index
Index in the HW processor (cache for real-time use)
Definition ext_port.h:140
HardwareProcessor * hw_processor
Pointer to owner hardware processor, if any.
Definition ext_port.h:143
char * short_name
Short port name.
Definition ext_port.h:83
unsigned int rtaudio_id
RtAudio device ID (NOT index!!!).
Definition ext_port.h:112
unsigned int rtaudio_channel_idx
RtAudio channel index.
Definition ext_port.h:106
char * full_name
Full port name, used also as ID.
Definition ext_port.h:80
char * alias2
Alias #2 if any.
Definition ext_port.h:89
char * rtaudio_dev_name
RtAudio device name.
Definition ext_port.h:109
unsigned int rtmidi_id
RtMidi port index.
Definition ext_port.h:125
void * jport
JACK port.
Definition ext_port.h:76
char * alias1
Alias #1 if any.
Definition ext_port.h:86
bool active
Whether the port is active and receiving events (for use by hw processor).
Definition ext_port.h:147
bool rtaudio_is_input
Whether the channel is input.
Definition ext_port.h:115
bool pending_reconnect
Set to true when a hardware port is disconnected.
Definition ext_port.h:156
Port * port
Temporary port to receive data.
Definition ext_port.h:161
Hardware processor.
Must ONLY be created via port_new()
Definition port.h:136
Custom types.
YAML utils.