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 "dsp/port_connection.h"
16#include "utils/types.h"
17#include "utils/yaml.h"
18
19#include <glib.h>
20
21typedef struct Port Port;
22typedef struct PortIdentifier PortIdentifier;
23typedef struct PortConnection PortConnection;
24
31#define PORT_CONNECTIONS_MANAGER_SCHEMA_VERSION 1
32
33#define PORT_CONNECTIONS_MGR (PROJECT->port_connections_manager)
34
39{
42 int num_connections;
43 size_t connections_size;
44
52 GHashTable * src_ht;
53
61 GHashTable * dest_ht;
63
64NONNULL void
65port_connections_manager_init_loaded (PortConnectionsManager * self);
66
68port_connections_manager_new (void);
69
76void
78
93NONNULL_ARGS (1, 3)
95 const PortConnectionsManager * self,
96 GPtrArray * arr,
97 const PortIdentifier * id,
98 bool sources);
99
114NONNULL_ARGS (1, 3)
116 const PortConnectionsManager * self,
117 GPtrArray * arr,
118 const PortIdentifier * id,
119 bool sources);
120
132 const PortConnectionsManager * self,
133 const PortIdentifier * id,
134 bool sources);
135
137port_connections_manager_find_connection (
138 const PortConnectionsManager * self,
139 const PortIdentifier * src,
140 const PortIdentifier * dest);
141
146bool
148 const void * obj,
149 const void * user_data);
150
159int
161 const PortConnectionsManager * self,
162 GPtrArray * arr,
163 GenericPredicateFunc predicate);
164
172const PortConnection *
175 const PortIdentifier * src,
176 const PortIdentifier * dest,
177 float multiplier,
178 bool locked,
179 bool enabled);
180
181#define port_connections_manager_ensure_connect_from_connection(self, conn) \
182 port_connections_manager_ensure_connect ( \
183 self, conn->src_id, conn->dest_id, conn->multiplier, conn->locked, \
184 conn->enabled)
185
192bool
195 const PortIdentifier * src,
196 const PortIdentifier * dest);
197
202void
205 const PortIdentifier * pi);
206
213void
216 const PortConnectionsManager * src);
217
218bool
219port_connections_manager_contains_connection (
220 const PortConnectionsManager * self,
221 const PortConnection * const conn);
222
223void
224port_connections_manager_print_ht (GHashTable * ht);
225
226void
227port_connections_manager_print (const PortConnectionsManager * self);
228
234
238NONNULL void
240
245#endif /* __AUDIO_PORT_CONNECTIONS_MANAGER_H__ */
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
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.
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.
bool(* GenericPredicateFunc)(const void *object, const void *user_data)
Predicate function prototype.
Definition types.h:117
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:136
Custom types.
YAML utils.