Etterna 0.74.4
Loading...
Searching...
No Matches
Stream.h
1#pragma once
2#include "../../PatternModHelpers.h"
3#include "../HA_Sequencers/TrillSequencing.h"
4
5// since the calc skillset balance now operates on +- rather than
6// just - and then normalization, we will use this to depress the
7// stream rating for non-stream files.
8
13{
14 const CalcPatternMod _pmod = Stream;
15 const std::string name = "StreamMod";
16 const int _tap_size = single;
17
18#pragma region params
19 float base = 0.F;
20 float min_mod = 0.6F;
21 float max_mod = 1.0F;
22 float prop_buffer = 1.F;
23 float prop_scaler = 1.41F;
24
25 float jack_pool = 4.F;
26 float jack_comp_min = 0.5F;
27 float jack_comp_max = 1.F;
28
29 float vibro_flag = 1.F;
30
31 float tht_scaler = .0F;
32 float tht_cv_threshold = 0.5F;
33 float tht_trill_buffer = 1.4F;
34 float tht_trill_scaler = 1.F;
35 float tht_jump_buffer = 1.F;
36 float tht_jump_scaler = 0.5F;
37 float tht_jump_weight = 0.0F;
38 float tht_min_prop = 0.0F;
39 float tht_max_prop = 1.F;
40
41 const std::vector<std::pair<std::string, float*>> _params{
42 { "base", &base },
43 { "min_mod", &min_mod },
44 { "max_mod", &max_mod },
45 { "prop_buffer", &prop_buffer },
46 { "prop_scaler", &prop_scaler },
47
48 { "jack_pool", &jack_pool },
49 { "jack_comp_min", &jack_comp_min },
50 { "jack_comp_max", &jack_comp_max },
51
52 { "vibro_flag", &vibro_flag },
53
54 { "2ht_scaler", &tht_scaler },
55 { "2ht_cv_threshold", &tht_cv_threshold },
56 { "2ht_trill_buffer", &tht_trill_buffer },
57 { "2ht_trill_scaler", &tht_trill_scaler },
58 { "2ht_jump_buffer", &tht_jump_buffer },
59 { "2ht_jump_scaler", &tht_jump_scaler },
60 { "2ht_jump_weight", &tht_jump_weight },
61 { "2ht_min_prop", &tht_min_prop },
62 { "2ht_max_prop", &tht_max_prop },
63 };
64#pragma endregion params and param map
65
66 float prop_component = 0.F;
67 float jack_component = 0.F;
68 float pmod = min_mod;
69
70 THT_Sequencing trillsequencer;
71
72 void setup() {
73 trillsequencer.set_params(tht_cv_threshold,
74 tht_trill_buffer,
75 tht_trill_scaler,
76 tht_jump_buffer,
77 tht_jump_scaler,
78 tht_jump_weight,
79 tht_min_prop,
80 tht_max_prop);
81 }
82
83 void advance_sequencing(const float& ms_now, const unsigned& notes) {
84 trillsequencer(ms_now, notes);
85 }
86
87 void full_reset() {
88 trillsequencer.reset();
89 }
90
91 auto operator()(const metaItvInfo& mitvi) -> float
92 {
93 const auto& itvi = mitvi._itvi;
94
95 // 1 tap is by definition a single tap
96 if (itvi.total_taps < 2) {
97 return neutral;
98 }
99
100 if (itvi.taps_by_size.at(_tap_size) == 0) {
101 return min_mod;
102 }
103
104 /* we want very light js to register as stream, something like jumps on
105 * every other 4th, so 17/19 ratio should return full points, but maybe
106 * we should allow for some leeway in bad interval slicing this maybe
107 * doesn't need to be so severe, on the other hand, maybe it doesn'ting
108 * need to be not needing'nt to be so severe */
109
110 // we could make better use of sequencing here since now it's easy
111
112 prop_component =
113 static_cast<float>(itvi.taps_by_size.at(_tap_size) + prop_buffer) /
114 static_cast<float>(static_cast<float>(itvi.total_taps) -
115 prop_buffer) *
116 prop_scaler;
117
118 // allow for a mini/triple jack in streams.. but not more than that
119 jack_component = std::clamp(
120 jack_pool - mitvi.actual_jacks, jack_comp_min, jack_comp_max);
121 pmod = fastsqrt(prop_component * jack_component);
122
123 // water downing based on two hand trills
124 const auto tht_prop = trillsequencer.get(mitvi);
125 pmod *= (1 - (tht_prop * tht_scaler));
126 trillsequencer.reset();
127
128 pmod = std::clamp(base + pmod, min_mod, max_mod);
129
130 if (mitvi.basically_vibro) {
131 if (mitvi.num_var == 1) {
132 pmod *= 0.5F * vibro_flag;
133 } else if (mitvi.num_var == 2) {
134 pmod *= 0.9F * vibro_flag;
135 } else if (mitvi.num_var == 3) {
136 pmod *= 0.95F * vibro_flag;
137 }
138 }
139
140 // actual mod
141 return pmod;
142 }
143};
Definition Stream.h:13
Two Hand Trill Sequencing.
Definition TrillSequencing.h:217
float get(const metaItvInfo &mitvi)
numerical output (kind of like a proportion. 1 is "all trills")
Definition TrillSequencing.h:262
Definition MetaIntervalInfo.h:20