MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ generate_planes()

void MayaFlux::Buffers::LogicProcessor::generate_planes ( size_t  num_samples,
const std::vector< double > &  input_data 
)
private

Definition at line 102 of file LogicProcessor.cpp.

103{
104 const uint32_t bits = std::clamp(m_plane_bits, uint32_t { 1 }, uint32_t { 24 });
105
106 if (m_plane_nodes.size() != bits || m_plane_template != m_logic) {
107 m_plane_nodes.clear();
108 for (uint32_t plane = 0; plane < bits; ++plane) {
109 m_plane_nodes.push_back(m_logic->clone());
110 }
112 }
113
114 const bool parallel = m_logic->get_mode() == Nodes::Generator::LogicMode::MULTI_INPUT;
115
116 lock_keys();
117 const size_t key_count = parallel ? m_live_keys.size() : 0;
118 m_key_words.assign(key_count, 0);
119 m_slots.assign(key_count + 1, 0.0);
120
121 const size_t available = input_data.size();
122 const uint32_t silence = Kinesis::Discrete::to_word(0.0, bits);
123
124 for (size_t i = 0; i < num_samples; ++i) {
125 const uint32_t own = Kinesis::Discrete::to_word(i < available ? input_data[i] : 0.0, bits);
126 for (size_t k = 0; k < key_count; ++k) {
127 const auto& key = m_live_keys[k];
128 m_key_words[k] = (key && i < key->get_data().size())
129 ? Kinesis::Discrete::to_word(key->get_data()[i], bits)
130 : silence;
131 }
132
133 uint32_t word = 0;
134 for (uint32_t plane = 0; plane < bits; ++plane) {
135 const auto bit_of = [plane](uint32_t w) { return static_cast<double>((w >> plane) & 1U); };
136
137 double out = 0.0;
138 if (parallel) {
139 for (size_t k = 0; k < key_count; ++k) {
140 m_slots[k] = bit_of(m_key_words[k]);
141 }
142 m_slots.back() = bit_of(own);
143 out = m_plane_nodes[plane]->process_multi_input(m_slots);
144 } else {
145 out = m_plane_nodes[plane]->process_sample(bit_of(own));
146 }
147 word |= (out > 0.5 ? 1U : 0U) << plane;
148 }
149
151 }
152}
std::vector< float > * out
bool available
Definition VKDevice.cpp:41
std::vector< double > m_slots
Input slots handed to the node.
std::vector< std::shared_ptr< Nodes::Generator::Logic > > m_plane_nodes
One clone of the node per bit plane.
std::vector< double > m_logic_data
Stored logic processing results.
std::vector< uint32_t > m_key_words
Words of the keys at the current sample.
uint32_t m_plane_bits
Word width when processing bit planes, 0 when off.
std::shared_ptr< Nodes::Generator::Logic > m_logic
Logic node for processing.
std::shared_ptr< Nodes::Generator::Logic > m_plane_template
The node the plane clones were taken from.
std::vector< std::shared_ptr< AudioBuffer > > m_live_keys
Keys locked for the current block.
size_t key_count() noexcept
Returns the total number of keys.
Definition Keys.cpp:103
double from_word(uint32_t word, uint32_t bits) noexcept
The value of an offset binary word; bits above the width are ignored.
Definition Word.cpp:22
uint32_t to_word(double value, uint32_t bits) noexcept
The offset binary word of a value, clamped to [-1, 1].
Definition Word.cpp:16
@ MULTI_INPUT
Parallel evaluation of multiple input signals.

References available, MayaFlux::Kinesis::Discrete::from_word(), lock_keys(), m_key_words, m_live_keys, m_logic, m_logic_data, m_plane_bits, m_plane_nodes, m_plane_template, m_slots, MayaFlux::Nodes::Generator::MULTI_INPUT, out, and MayaFlux::Kinesis::Discrete::to_word().

Referenced by generate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: