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

◆ pluck()

void MayaFlux::Nodes::Network::WaveguideNetwork::pluck ( double  position = 0.5,
double  strength = 1.0 
)

Pluck the string at a normalized position.

Parameters
positionNormalized position along string (0.0 to 1.0)
strengthExcitation amplitude (0.0 to 1.0+)

Seeds the delay line with a triangle. A string seed has its average removed, because the lumped loop would otherwise hold it as a DC offset. Position affects spectral content: 0.5 = center (warm), near 0/1 = bridge (bright).

Definition at line 303 of file WaveguideNetwork.cpp.

304{
305 position = std::clamp(position, 0.01, 0.99);
306
307 if (m_segments.empty())
308 return;
309
310 auto& seg = m_segments[0];
311 const size_t len = m_delay_length_integer;
312 if (len < 2)
313 return;
314
315 const auto pluck_sample = std::clamp(
316 static_cast<size_t>(position * static_cast<double>(len)), size_t { 1 }, len - 1);
317 const double effective_strength = (m_exciter_type == ExciterType::CONTINUOUS)
318 ? std::max(strength, 1.0)
319 : strength;
320
321 seg.p_plus = Memory::HistoryBuffer<double>(seg.p_plus.capacity());
322 seg.p_minus = Memory::HistoryBuffer<double>(seg.p_minus.capacity());
323
324 std::vector<double> shape(len);
325 for (size_t s = 0; s < len; ++s) {
326 if (s <= pluck_sample) {
327 shape[s] = effective_strength * static_cast<double>(s)
328 / static_cast<double>(pluck_sample);
329 } else {
330 shape[s] = effective_strength * static_cast<double>(len - s)
331 / static_cast<double>(len - pluck_sample);
332 }
333 }
334
335 double offset = 0.0;
337 offset = std::accumulate(shape.begin(), shape.end(), 0.0) / static_cast<double>(len);
338 }
339
340 for (const double value : shape) {
341 seg.p_plus.push(value - offset);
342 }
343
345 m_exciter_active = false;
347 }
348}
uint64_t offset
Definition Composite.cpp:10
std::optional< glm::vec3 > position
Definition Decoder.cpp:93
glm::vec3 value
@ CONTINUOUS
External node as continuous exciter (bowing)
std::vector< WaveguideSegment > m_segments

References CONTINUOUS, m_delay_length_integer, m_exciter_active, m_exciter_samples_remaining, m_exciter_type, m_segments, offset, position, MayaFlux::Nodes::Network::WaveguideNetwork::WaveguideSegment::UNIDIRECTIONAL, and value.