18#ifndef SBL_DSP_DIAGRAM_GRAPH_HPP_
19#define SBL_DSP_DIAGRAM_GRAPH_HPP_
77 groups_[group_count_] =
Group{name, parent};
78 return group_count_++;
82 float value = 0.0f,
float value2 = 0.0f) {
84 nodes_[node_count_] =
Node{kind, name, value, value2,
group};
90 edges_[edge_count_++] =
Edge{from, to, wave};
96 const Node&
node(uint8_t i)
const {
return nodes_[i]; }
97 const Edge&
edge(uint8_t i)
const {
return edges_[i]; }
98 const Group&
group(uint8_t i)
const {
return groups_[i]; }
103 for (uint8_t i = 0; i < node_count_; ++i) {
104 if (nodes_[i].kind == kind) ++n;
123 uint8_t node_count_ = 0;
124 uint8_t edge_count_ = 0;
125 uint8_t group_count_ = 0;
126 bool dropped_ =
false;
147 void add(
const char* name, uint8_t node) {
153 uint8_t
find(
const char* name)
const {
156 const char* b = name;
157 while (*a !=
'\0' && *a == *b) { ++a; ++b; }
158 if (*a ==
'\0' && *b ==
'\0')
return named[i].
node;
uint8_t node_count() const
bool overflowed() const
True if a describe() lost something: a node, edge or group was refused.
static constexpr uint8_t MAX_GROUPS
static constexpr uint8_t MAX_EDGES
uint8_t add_group(const char *name, uint8_t parent=NO_GROUP)
Open a group (a component); returns its id. Nodes added with it belong to it.
uint8_t group_count() const
void add_edge(uint8_t from, uint8_t to, Wave wave)
const Group & group(uint8_t i) const
const Edge & edge(uint8_t i) const
uint8_t count(Kind kind) const
How many nodes of a kind the graph holds — the structural tests' question.
uint8_t edge_count() const
const Node & node(uint8_t i) const
static constexpr uint8_t MAX_NODES
a 32-mode bank and the string around it
uint8_t add_node(Kind kind, const char *name, uint8_t group, float value=0.0f, float value2=0.0f)
A model's wiring as data, for pictures.
Wave
What travels along an edge.
constexpr uint8_t NO_NODE
Kind
What a node is, in the paper's vocabulary.
@ Loss
value: cutoff in Hz
@ Bandpass
a banded-waveguide band; value: Hz, value2: Q
@ Component
a folded group, made by the renderer
@ DcBlock
value: corner in Hz
@ Junction
where waves scatter or a source meets the string
@ Resonator
a modal source; value: Hz, value2: Q
@ Reflection
value: coefficient (−1 wall, +1 free end)
@ DelayLine
value: length in samples
@ Load
a lumped body; value: Hz, value2: Q
@ Source
a driving signal (bow velocity, pluck)
@ Allpass
value: delay in samples
constexpr uint8_t NO_GROUP
const char * name
short label; string literals only, the graph does not own it
const char * name
string literal
The ports a component exposes after describing itself, so an owner can wire them.
static constexpr uint8_t MAX_NAMED
uint8_t find(const char *name) const
The node behind a name, or NO_NODE.
void add(const char *name, uint8_t node)
Add a named port; a ninth is refused and find() answers NO_NODE for it.
uint8_t in
where a wave enters (the junction, the load)
uint8_t out
where a wave leaves (the pickup, the reflection)