Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
port_connections_manager.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2021 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __AUDIO_PORT_CONNECTIONS_MANAGER_H__
11#define __AUDIO_PORT_CONNECTIONS_MANAGER_H__
12
13#include "zrythm-config.h"
14
15#include <stdbool.h>
16
17#include "dsp/port_connection.h"
18#include "utils/types.h"
19#include "utils/yaml.h"
20
21#include <glib.h>
22
23typedef struct Port Port;
24typedef struct PortIdentifier PortIdentifier;
25typedef struct PortConnection PortConnection;
26
33#define PORT_CONNECTIONS_MANAGER_SCHEMA_VERSION 1
34
35#define PORT_CONNECTIONS_MGR \
36 (PROJECT->port_connections_manager)
37
42{
43 int schema_version;
44
47 int num_connections;
48 size_t connections_size;
49
57 GHashTable * src_ht;
58
66 GHashTable * dest_ht;
68
69static const cyaml_schema_field_t
70 port_connections_manager_fields_schema[] = {
71 YAML_FIELD_INT (PortConnectionsManager, schema_version),
74 connections,
75 port_connection_schema),
76
77 CYAML_FIELD_END
78 };
79
80static const cyaml_schema_value_t
81 port_connections_manager_schema = {
84 port_connections_manager_fields_schema),
85 };
86
87NONNULL void
88port_connections_manager_init_loaded (
90
92port_connections_manager_new (void);
93
100void
103
118NONNULL_ARGS (1, 3)
120 const PortConnectionsManager * self,
121 GPtrArray * arr,
122 const PortIdentifier * id,
123 bool sources);
124
139NONNULL_ARGS (1, 3)
141 const PortConnectionsManager * self,
142 GPtrArray * arr,
143 const PortIdentifier * id,
144 bool sources);
145
157 const PortConnectionsManager * self,
158 const PortIdentifier * id,
159 bool sources);
160
162port_connections_manager_find_connection (
163 const PortConnectionsManager * self,
164 const PortIdentifier * src,
165 const PortIdentifier * dest);
166
171bool
173 const void * obj,
174 const void * user_data);
175
184int
186 const PortConnectionsManager * self,
187 GPtrArray * arr,
188 GenericPredicateFunc predicate);
189
197const PortConnection *
200 const PortIdentifier * src,
201 const PortIdentifier * dest,
202 float multiplier,
203 bool locked,
204 bool enabled);
205
206#define port_connections_manager_ensure_connect_from_connection( \
207 self, conn) \
208 port_connections_manager_ensure_connect ( \
209 self, conn->src_id, conn->dest_id, conn->multiplier, \
210 conn->locked, conn->enabled)
211
218bool
221 const PortIdentifier * src,
222 const PortIdentifier * dest);
223
228void
231 const PortIdentifier * pi);
232
239void
242 const PortConnectionsManager * src);
243
244bool
245port_connections_manager_contains_connection (
246 const PortConnectionsManager * self,
247 const PortConnection * const conn);
248
249void
250port_connections_manager_print_ht (GHashTable * ht);
251
252void
253port_connections_manager_print (
254 const PortConnectionsManager * self);
255
261 const PortConnectionsManager * src);
262
266NONNULL void
268
273#endif /* __AUDIO_PORT_CONNECTIONS_MANAGER_H__ */
bool port_connections_manager_predicate_is_send_of(const void *obj, const void *user_data)
Returns whether the given connection is for the given send.
const PortConnection * port_connections_manager_ensure_connect(PortConnectionsManager *self, const PortIdentifier *src, const PortIdentifier *dest, float multiplier, bool locked, bool enabled)
Stores the connection for the given ports if it doesn't exist, otherwise updates the existing connect...
void port_connections_manager_regenerate_hashtables(PortConnectionsManager *self)
Regenerates the hash tables.
NONNULL PortConnectionsManager * port_connections_manager_clone(const PortConnectionsManager *src)
To be used during serialization.
PortConnection * port_connections_manager_get_source_or_dest(const PortConnectionsManager *self, const PortIdentifier *id, bool sources)
Wrapper over port_connections_manager_get_sources_or_dests() that returns the first connection.
int port_connections_manager_get_unlocked_sources_or_dests(const PortConnectionsManager *self, GPtrArray *arr, const PortIdentifier *id, bool sources)
Adds the sources/destinations of id in the given array.
void port_connections_manager_ensure_disconnect_all(PortConnectionsManager *self, const PortIdentifier *pi)
Disconnect all sources and dests of the given port identifier.
bool port_connections_manager_ensure_disconnect(PortConnectionsManager *self, const PortIdentifier *src, const PortIdentifier *dest)
Removes the connection for the given ports if it exists.
NONNULL void port_connections_manager_free(PortConnectionsManager *self)
Deletes port, doing required cleanup and updating counters.
int port_connections_manager_find(const PortConnectionsManager *self, GPtrArray *arr, GenericPredicateFunc predicate)
Adds the connections matching the given predicate to the given array (if given).
void port_connections_manager_reset(PortConnectionsManager *self, const PortConnectionsManager *src)
Removes all connections from self.
COLD NONNULL_ARGS(1) void automation_track_init_loaded(AutomationTrack *self
Inits a loaded AutomationTracklist.
int port_connections_manager_get_sources_or_dests(const PortConnectionsManager *self, GPtrArray *arr, const PortIdentifier *id, bool sources)
Adds the sources/destinations of id in the given array.
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
Definition yaml.h:221
#define YAML_FIELD_DYN_PTR_ARRAY_VAR_COUNT_OPT(owner, member, schema)
Dynamic-width (reallocated) array of pointers with variable count, nullable.
Definition yaml.h:138
bool(* GenericPredicateFunc)(const void *object, const void *user_data)
Predicate function prototype.
Definition types.h:113
Port connection.
A connection between two ports.
Port connections manager.
GHashTable * dest_ht
Hashtable to speedup lookup by destination port identifier.
PortConnection ** connections
Connections.
GHashTable * src_ht
Hashtable to speedup lookup by source port identifier.
Struct used to identify Ports in the project.
Must ONLY be created via port_new()
Definition port.h:150
Custom types.
YAML utils.