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

◆ generate_spatial()

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

Definition at line 154 of file LogicProcessor.cpp.

155{
156 if (num_samples == 0) {
157 return;
158 }
159
160 const size_t available = input_data.size();
161 const size_t width = 2 * m_radius + 1;
162 const auto count = static_cast<std::ptrdiff_t>(num_samples);
163
164 m_cells.assign(num_samples, 0);
165 m_next_cells.assign(num_samples, 0);
166 m_slots.assign(width, 0.0);
167
168 for (size_t i = 0; i < num_samples; ++i) {
169 uint8_t cell = (i < available && input_data[i] > 0.0) ? 1 : 0;
170 if (m_memory && i < m_previous_cells.size()) {
171 cell ^= m_previous_cells[i];
172 }
173 m_cells[i] = cell;
174 }
175
176 for (size_t generation = 0; generation < m_generations; ++generation) {
177 for (std::ptrdiff_t i = 0; i < count; ++i) {
178 for (size_t k = 0; k < width; ++k) {
179 std::ptrdiff_t at = i + static_cast<std::ptrdiff_t>(m_radius) - static_cast<std::ptrdiff_t>(k);
180 double cell = 0.0;
181 if (at >= 0 && at < count) {
182 cell = m_cells[static_cast<size_t>(at)];
183 } else if (m_wrap) {
184 at = ((at % count) + count) % count;
185 cell = m_cells[static_cast<size_t>(at)];
186 }
187 m_slots[k] = cell;
188 }
189 m_next_cells[static_cast<size_t>(i)] = m_logic->process_multi_input(m_slots) > 0.5 ? 1 : 0;
190 }
191 m_cells.swap(m_next_cells);
192 }
193
194 for (size_t i = 0; i < num_samples; ++i) {
195 m_logic_data[i] = m_cells[i];
196 }
197 if (m_memory) {
199 }
200}
bool available
Definition VKDevice.cpp:41
size_t count
uint32_t width
std::vector< double > m_slots
Input slots handed to the node.
size_t m_generations
Automaton steps per block, 0 when off.
std::vector< double > m_logic_data
Stored logic processing results.
bool m_wrap
Whether the automaton's block ends meet.
std::vector< uint8_t > m_next_cells
Automaton cells of the next generation.
std::vector< uint8_t > m_previous_cells
Last automaton result, kept when memory is on.
std::vector< uint8_t > m_cells
Automaton cells.
size_t m_radius
Neighbourhood radius of the automaton.
std::shared_ptr< Nodes::Generator::Logic > m_logic
Logic node for processing.
bool m_memory
Whether blocks perturb the previous automaton result.
auto at(const B &anchor, F &&factory, Args &&... args) -> decltype(std::forward< F >(factory)(Kinesis::bounds_of(anchor), std::forward< Args >(args)...))
Call a bounds-taking factory with an anchor's region.
Definition Geometry.hpp:152

References available, count, m_cells, m_generations, m_logic, m_logic_data, m_memory, m_next_cells, m_previous_cells, m_radius, m_slots, m_wrap, and width.

Referenced by generate().

+ Here is the caller graph for this function: