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 (PROJECT->port_connections_manager)
36
41{
44 int num_connections;
45 size_t connections_size;
46
54 GHashTable * src_ht;
55
63 GHashTable * dest_ht;
65
66NONNULL void
67port_connections_manager_init_loaded (PortConnectionsManager * self);
68
70port_connections_manager_new (void);
71
78void
80
95NONNULL_ARGS (1, 3)
97 const PortConnectionsManager * self,
98 GPtrArray * arr,
99 const PortIdentifier * id,
100 bool sources);
101
116NONNULL_ARGS (1, 3)
118 const PortConnectionsManager * self,
119 GPtrArray * arr,
120 const PortIdentifier * id,
121 bool sources);
122
134 const PortConnectionsManager * self,
135 const PortIdentifier * id,
136 bool sources);
137
139port_connections_manager_find_connection (
140 const PortConnectionsManager * self,
141 const PortIdentifier * src,
142 const PortIdentifier * dest);
143
148bool
150 const void * obj,
151 const void * user_data);
152
161int
163 const PortConnectionsManager * self,
164 GPtrArray * arr,
165 GenericPredicateFunc predicate);
166
174const PortConnection *
177 const PortIdentifier * src,
178 const PortIdentifier * dest,
179 float multiplier,
180 bool locked,
181 bool enabled);
182
183#define port_connections_manager_ensure_connect_from_connection(self, conn) \
184 port_connections_manager_ensure_connect ( \
185 self, conn->src_id, conn->dest_id, conn->multiplier, conn->locked, \
186 conn->enabled)
187
194bool
197 const PortIdentifier * src,
198 const PortIdentifier * dest);
199
204void
207 const PortIdentifier * pi);
208
215void
218 const PortConnectionsManager * src);
219
220bool
221port_connections_manager_contains_connection (
222 const PortConnectionsManager * self,
223 const PortConnection * const conn);
224
225void
226port_connections_manager_print_ht (GHashTable * ht);
227
228void
229port_connections_manager_print (const PortConnectionsManager * self);
230
236
240NONNULL void
242
247#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: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:139
Custom types.
YAML utils.