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{
42 int schema_version;
43
46 int num_connections;
47 size_t connections_size;
48
56 GHashTable * src_ht;
57
65 GHashTable * dest_ht;
67
68static const cyaml_schema_field_t port_connections_manager_fields_schema[] = {
69 YAML_FIELD_INT (PortConnectionsManager, schema_version),
72 connections,
73 port_connection_schema),
74
75 CYAML_FIELD_END
76};
77
78static const cyaml_schema_value_t port_connections_manager_schema = {
79 YAML_VALUE_PTR (PortConnectionsManager, port_connections_manager_fields_schema),
80};
81
82NONNULL void
83port_connections_manager_init_loaded (PortConnectionsManager * self);
84
86port_connections_manager_new (void);
87
94void
96
111NONNULL_ARGS (1, 3)
113 const PortConnectionsManager * self,
114 GPtrArray * arr,
115 const PortIdentifier * id,
116 bool sources);
117
132NONNULL_ARGS (1, 3)
134 const PortConnectionsManager * self,
135 GPtrArray * arr,
136 const PortIdentifier * id,
137 bool sources);
138
150 const PortConnectionsManager * self,
151 const PortIdentifier * id,
152 bool sources);
153
155port_connections_manager_find_connection (
156 const PortConnectionsManager * self,
157 const PortIdentifier * src,
158 const PortIdentifier * dest);
159
164bool
166 const void * obj,
167 const void * user_data);
168
177int
179 const PortConnectionsManager * self,
180 GPtrArray * arr,
181 GenericPredicateFunc predicate);
182
190const PortConnection *
193 const PortIdentifier * src,
194 const PortIdentifier * dest,
195 float multiplier,
196 bool locked,
197 bool enabled);
198
199#define port_connections_manager_ensure_connect_from_connection(self, conn) \
200 port_connections_manager_ensure_connect ( \
201 self, conn->src_id, conn->dest_id, conn->multiplier, conn->locked, \
202 conn->enabled)
203
210bool
213 const PortIdentifier * src,
214 const PortIdentifier * dest);
215
220void
223 const PortIdentifier * pi);
224
231void
234 const PortConnectionsManager * src);
235
236bool
237port_connections_manager_contains_connection (
238 const PortConnectionsManager * self,
239 const PortConnection * const conn);
240
241void
242port_connections_manager_print_ht (GHashTable * ht);
243
244void
245port_connections_manager_print (const PortConnectionsManager * self);
246
252
256NONNULL void
258
263#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
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
Definition yaml.h:202
#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:127
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:140
Custom types.
YAML utils.