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

◆ generate_spectrum_ratios()

std::vector< double > MayaFlux::Nodes::Network::ModalNetwork::generate_spectrum_ratios ( Spectrum  spectrum,
size_t  count 
)
staticprivate

Generate frequency ratios for predefined spectra.

Definition at line 41 of file ModalNetwork.cpp.

43{
44 std::vector<double> ratios;
45 ratios.reserve(count);
46
47 switch (spectrum) {
49 // Perfect integer harmonics: 1, 2, 3, 4...
50 for (size_t i = 0; i < count; ++i) {
51 ratios.push_back(static_cast<double>(i + 1));
52 }
53 break;
54
56 // Free-free bar mode ratios, tabulated for the first eight, then constant spacing
57 ratios = { 1.0, 2.756, 5.404, 8.933, 13.344, 18.64, 24.81, 31.86 };
58 while (ratios.size() < count) {
59 double last = ratios.back();
60 ratios.push_back(last + 6.8);
61 }
62 ratios.resize(count);
63 break;
64
66 // f_n = n * f_0 * sqrt(1 + B * n^2)
67 // Using small B = 0.0001 for moderate stretching
68 {
69 constexpr double B = 0.0001;
70 for (size_t n = 1; n <= count; ++n) {
71 auto dn = static_cast<double>(n);
72 double ratio = dn * std::sqrt(1.0 + B * dn * dn);
73 ratios.push_back(ratio);
74 }
75 }
76 break;
77
79 for (size_t i = 0; i < count; ++i) {
80 ratios.push_back(static_cast<double>(i + 1));
81 }
82 break;
83 }
84
85 return ratios;
86}
size_t count
@ STRETCHED
Piano-like stiffness: f, 2.01f, 3.02f, 4.04f...
@ INHARMONIC
Bell-like: f, 2.76f, 5.40f, 8.93f, 13.34f...
@ CUSTOM
User-provided frequency ratios.
@ HARMONIC
Integer harmonics: f, 2f, 3f, 4f...

References count, CUSTOM, HARMONIC, INHARMONIC, and STRETCHED.

Referenced by ModalNetwork().

+ Here is the caller graph for this function: