| @@ -31,24 +31,20 @@ static const int GENLIB_LOOPCOUNT_BAIL = 100000; | |||
| // The State struct contains all the state and procedures for the gendsp kernel | |||
| typedef struct State { | |||
| CommonState __commonstate; | |||
| DCBlock m_dcblock_15; | |||
| DCBlock m_dcblock_11; | |||
| Delay m_delay_2; | |||
| Delay m_delay_3; | |||
| Delay m_delay_4; | |||
| SineCycle m_cycle_16; | |||
| SineCycle m_cycle_12; | |||
| SineData __sinedata; | |||
| double m_repeats_10; | |||
| double m_mix_12; | |||
| double m_rate_13; | |||
| double m_depth_11; | |||
| double m_delay_14; | |||
| double m_time_9; | |||
| double m_cutoff_7; | |||
| double m_feedback_6; | |||
| double m_mix_9; | |||
| double m_rate_8; | |||
| double m_cutoff_10; | |||
| double m_morph_7; | |||
| double m_time_5; | |||
| double m_repeats_4; | |||
| double m_depth_6; | |||
| double samplerate; | |||
| double m_bleed_8; | |||
| double m_y_1; | |||
| double m_feedforward_5; | |||
| double m_history_2; | |||
| int vectorsize; | |||
| int __exception; | |||
| // re-initialize all member variables; | |||
| @@ -57,21 +53,17 @@ typedef struct State { | |||
| vectorsize = __vs; | |||
| samplerate = __sr; | |||
| m_y_1 = 0; | |||
| m_history_2 = 0; | |||
| m_delay_2.reset("m_delay_2", 48000); | |||
| m_delay_3.reset("m_delay_3", 48000); | |||
| m_delay_4.reset("m_delay_4", 48000); | |||
| m_feedforward_5 = 100; | |||
| m_feedback_6 = 0; | |||
| m_cutoff_7 = 2500; | |||
| m_bleed_8 = 0; | |||
| m_time_9 = 500; | |||
| m_repeats_10 = 75; | |||
| m_depth_11 = 1; | |||
| m_mix_12 = 100; | |||
| m_rate_13 = 2; | |||
| m_delay_14 = 0; | |||
| m_dcblock_15.reset(); | |||
| m_cycle_16.reset(samplerate, 0); | |||
| m_repeats_4 = 75; | |||
| m_time_5 = 500; | |||
| m_depth_6 = 1; | |||
| m_morph_7 = 50; | |||
| m_rate_8 = 2; | |||
| m_mix_9 = 100; | |||
| m_cutoff_10 = 2500; | |||
| m_dcblock_11.reset(); | |||
| m_cycle_12.reset(samplerate, 0); | |||
| genlib_reset_complete(this); | |||
| }; | |||
| @@ -88,50 +80,63 @@ typedef struct State { | |||
| return __exception; | |||
| }; | |||
| double mul_1738 = (m_mix_12 * 0.01); | |||
| double mstosamps_1764 = (m_time_9 * (samplerate * 0.001)); | |||
| double expr_1767 = safediv(((m_cutoff_7 * 2) * 3.1415926535898), 48000); | |||
| double sin_1745 = sin(expr_1767); | |||
| double clamp_1746 = ((sin_1745 <= 1e-05) ? 1e-05 : ((sin_1745 >= 0.99999) ? 0.99999 : sin_1745)); | |||
| double mul_1740 = (m_bleed_8 * 0.01); | |||
| double mul_1739 = (m_feedforward_5 * 0.01); | |||
| double mul_1742 = (m_repeats_10 * 0.01); | |||
| double mul_1741 = (m_feedback_6 * 0.01); | |||
| double mul_4216 = (m_mix_9 * 0.01); | |||
| double mstosamps_4241 = (m_time_5 * (samplerate * 0.001)); | |||
| double expr_4223 = safediv(((m_cutoff_10 * 2) * 3.1415926535898), 48000); | |||
| double sin_4224 = sin(expr_4223); | |||
| double clamp_4225 = ((sin_4224 <= 1e-05) ? 1e-05 : ((sin_4224 >= 0.99999) ? 0.99999 : sin_4224)); | |||
| double mul_4220 = (m_repeats_4 * 0.01); | |||
| double mul_4244 = (m_morph_7 * -1.4); | |||
| double add_4246 = (mul_4244 + 70); | |||
| double abs_4245 = fabs(add_4246); | |||
| double mul_4218 = (abs_4245 * 0.01); | |||
| double mul_4242 = (m_morph_7 * 1.4); | |||
| double sub_4243 = (mul_4242 - 70); | |||
| double mul_4219 = (sub_4243 * 0.01); | |||
| int gt_4248 = (m_morph_7 > 50); | |||
| double mul_4247 = (gt_4248 * m_morph_7); | |||
| double mul_4249 = (mul_4247 * -0.6); | |||
| double add_4250 = (mul_4249 + 130); | |||
| double clamp_4251 = ((add_4250 <= 70) ? 70 : ((add_4250 >= 100) ? 100 : add_4250)); | |||
| double mul_4217 = (clamp_4251 * 0.01); | |||
| int lt_4258 = (m_morph_7 < 50); | |||
| double mul_4253 = (lt_4258 * m_morph_7); | |||
| double mul_4252 = (mul_4253 * -1.2); | |||
| double add_4257 = (mul_4252 + 30); | |||
| double abs_4256 = fabs(add_4257); | |||
| double mul_4255 = (abs_4256 * -1); | |||
| double add_4254 = (mul_4255 + 30); | |||
| // the main sample loop; | |||
| while ((__n--)) { | |||
| const double in1 = (*(__in1++)); | |||
| double mix_1778 = (m_history_2 + (0.01 * (mstosamps_1764 - m_history_2))); | |||
| double mix_1765 = mix_1778; | |||
| double tap_1763 = m_delay_4.read_linear(mix_1765); | |||
| double mix_1779 = (m_y_1 + (clamp_1746 * (tap_1763 - m_y_1))); | |||
| double mix_1744 = mix_1779; | |||
| double mul_1760 = (mix_1744 * mul_1742); | |||
| double dcblock_1769 = m_dcblock_15(mul_1760); | |||
| double clamp_1768 = ((dcblock_1769 <= -1) ? -1 : ((dcblock_1769 >= 1) ? 1 : dcblock_1769)); | |||
| m_cycle_16.freq(m_rate_13); | |||
| double cycle_1749 = m_cycle_16(__sinedata); | |||
| double cycleindex_1750 = m_cycle_16.phase(); | |||
| double add_1748 = (cycle_1749 + 1); | |||
| double mul_1747 = (add_1748 * 0.5); | |||
| double mul_1752 = (m_depth_11 * mul_1747); | |||
| double add_1751 = (m_delay_14 + mul_1752); | |||
| double mstosamps_1743 = (add_1751 * (samplerate * 0.001)); | |||
| double tap_1757 = m_delay_3.read_linear(mstosamps_1743); | |||
| double mul_1755 = (tap_1757 * mul_1739); | |||
| double mul_1753 = (tap_1757 * mul_1741); | |||
| double add_1759 = (mix_1744 + mul_1753); | |||
| double mul_1754 = (add_1759 * mul_1740); | |||
| double add_1758 = (mul_1754 + mul_1755); | |||
| double mul_1761 = (add_1758 * mul_1738); | |||
| double out1 = (mul_1761 + in1); | |||
| double history_1766_next_1770 = mix_1765; | |||
| double y0_next_1771 = mix_1744; | |||
| m_delay_4.write((clamp_1768 + in1)); | |||
| m_delay_3.write(add_1759); | |||
| m_history_2 = history_1766_next_1770; | |||
| m_y_1 = y0_next_1771; | |||
| double tap_4240 = m_delay_3.read_cubic(mstosamps_4241); | |||
| double mix_4285 = (m_y_1 + (clamp_4225 * (tap_4240 - m_y_1))); | |||
| double mix_4222 = mix_4285; | |||
| double mul_4237 = (mix_4222 * mul_4220); | |||
| double dcblock_4214 = m_dcblock_11(mul_4237); | |||
| double clamp_4215 = ((dcblock_4214 <= -1) ? -1 : ((dcblock_4214 >= 1) ? 1 : dcblock_4214)); | |||
| m_cycle_12.freq(m_rate_8); | |||
| double cycle_4228 = m_cycle_12(__sinedata); | |||
| double cycleindex_4229 = m_cycle_12.phase(); | |||
| double add_4227 = (cycle_4228 + 1); | |||
| double mul_4226 = (add_4227 * 0.5); | |||
| double mul_4230 = (m_depth_6 * mul_4226); | |||
| double add_4259 = (add_4254 + mul_4230); | |||
| double mstosamps_4221 = (add_4259 * (samplerate * 0.001)); | |||
| double tap_4235 = m_delay_2.read_linear(mstosamps_4221); | |||
| double mul_4233 = (tap_4235 * mul_4217); | |||
| double mul_4231 = (tap_4235 * mul_4219); | |||
| double add_4236 = (mix_4222 + mul_4231); | |||
| double mul_4232 = (add_4236 * mul_4218); | |||
| double add_4213 = (mul_4232 + mul_4233); | |||
| double mul_4238 = (add_4213 * mul_4216); | |||
| double out1 = (mul_4238 + in1); | |||
| double y0_next_4260 = mix_4222; | |||
| m_delay_3.write((clamp_4215 + in1)); | |||
| m_delay_2.write(add_4236); | |||
| m_y_1 = y0_next_4260; | |||
| m_delay_2.step(); | |||
| m_delay_3.step(); | |||
| m_delay_4.step(); | |||
| // assign results to output buffer; | |||
| (*(__out1++)) = out1; | |||
| @@ -139,35 +144,26 @@ typedef struct State { | |||
| return __exception; | |||
| }; | |||
| inline void set_feedforward(double _value) { | |||
| m_feedforward_5 = (_value < 70 ? 70 : (_value > 100 ? 100 : _value)); | |||
| }; | |||
| inline void set_feedback(double _value) { | |||
| m_feedback_6 = (_value < -70 ? -70 : (_value > 70 ? 70 : _value)); | |||
| }; | |||
| inline void set_cutoff(double _value) { | |||
| m_cutoff_7 = (_value < 500 ? 500 : (_value > 6000 ? 6000 : _value)); | |||
| }; | |||
| inline void set_bleed(double _value) { | |||
| m_bleed_8 = (_value < 0 ? 0 : (_value > 70 ? 70 : _value)); | |||
| inline void set_repeats(double _value) { | |||
| m_repeats_4 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value)); | |||
| }; | |||
| inline void set_time(double _value) { | |||
| m_time_9 = (_value < 20 ? 20 : (_value > 1000 ? 1000 : _value)); | |||
| }; | |||
| inline void set_repeats(double _value) { | |||
| m_repeats_10 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value)); | |||
| m_time_5 = (_value < 20 ? 20 : (_value > 1000 ? 1000 : _value)); | |||
| }; | |||
| inline void set_depth(double _value) { | |||
| m_depth_11 = (_value < 0 ? 0 : (_value > 5 ? 5 : _value)); | |||
| m_depth_6 = (_value < 0 ? 0 : (_value > 5 ? 5 : _value)); | |||
| }; | |||
| inline void set_mix(double _value) { | |||
| m_mix_12 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value)); | |||
| inline void set_morph(double _value) { | |||
| m_morph_7 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value)); | |||
| }; | |||
| inline void set_rate(double _value) { | |||
| m_rate_13 = (_value < 0.1 ? 0.1 : (_value > 10 ? 10 : _value)); | |||
| m_rate_8 = (_value < 0.1 ? 0.1 : (_value > 10 ? 10 : _value)); | |||
| }; | |||
| inline void set_delay(double _value) { | |||
| m_delay_14 = (_value < 0 ? 0 : (_value > 30 ? 30 : _value)); | |||
| inline void set_mix(double _value) { | |||
| m_mix_9 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value)); | |||
| }; | |||
| inline void set_cutoff(double _value) { | |||
| m_cutoff_10 = (_value < 500 ? 500 : (_value > 6000 ? 6000 : _value)); | |||
| }; | |||
| } State; | |||
| @@ -184,7 +180,7 @@ int gen_kernel_numouts = 1; | |||
| int num_inputs() { return gen_kernel_numins; } | |||
| int num_outputs() { return gen_kernel_numouts; } | |||
| int num_params() { return 10; } | |||
| int num_params() { return 7; } | |||
| /// Assistive lables for the signal inputs and outputs | |||
| @@ -210,16 +206,13 @@ void reset(CommonState *cself) { | |||
| void setparameter(CommonState *cself, long index, double value, void *ref) { | |||
| State * self = (State *)cself; | |||
| switch (index) { | |||
| case 0: self->set_feedforward(value); break; | |||
| case 1: self->set_feedback(value); break; | |||
| case 2: self->set_cutoff(value); break; | |||
| case 3: self->set_bleed(value); break; | |||
| case 4: self->set_time(value); break; | |||
| case 5: self->set_repeats(value); break; | |||
| case 6: self->set_depth(value); break; | |||
| case 7: self->set_mix(value); break; | |||
| case 8: self->set_rate(value); break; | |||
| case 9: self->set_delay(value); break; | |||
| case 0: self->set_repeats(value); break; | |||
| case 1: self->set_time(value); break; | |||
| case 2: self->set_depth(value); break; | |||
| case 3: self->set_morph(value); break; | |||
| case 4: self->set_rate(value); break; | |||
| case 5: self->set_mix(value); break; | |||
| case 6: self->set_cutoff(value); break; | |||
| default: break; | |||
| } | |||
| @@ -230,16 +223,13 @@ void setparameter(CommonState *cself, long index, double value, void *ref) { | |||
| void getparameter(CommonState *cself, long index, double *value) { | |||
| State *self = (State *)cself; | |||
| switch (index) { | |||
| case 0: *value = self->m_feedforward_5; break; | |||
| case 1: *value = self->m_feedback_6; break; | |||
| case 2: *value = self->m_cutoff_7; break; | |||
| case 3: *value = self->m_bleed_8; break; | |||
| case 4: *value = self->m_time_9; break; | |||
| case 5: *value = self->m_repeats_10; break; | |||
| case 6: *value = self->m_depth_11; break; | |||
| case 7: *value = self->m_mix_12; break; | |||
| case 8: *value = self->m_rate_13; break; | |||
| case 9: *value = self->m_delay_14; break; | |||
| case 0: *value = self->m_repeats_4; break; | |||
| case 1: *value = self->m_time_5; break; | |||
| case 2: *value = self->m_depth_6; break; | |||
| case 3: *value = self->m_morph_7; break; | |||
| case 4: *value = self->m_rate_8; break; | |||
| case 5: *value = self->m_mix_9; break; | |||
| case 6: *value = self->m_cutoff_10; break; | |||
| default: break; | |||
| } | |||
| @@ -257,111 +247,83 @@ void * create(double sr, long vs) { | |||
| self->__commonstate.numouts = gen_kernel_numouts; | |||
| self->__commonstate.sr = sr; | |||
| self->__commonstate.vs = vs; | |||
| self->__commonstate.params = (ParamInfo *)genlib_sysmem_newptr(10 * sizeof(ParamInfo)); | |||
| self->__commonstate.numparams = 10; | |||
| // initialize parameter 0 ("m_feedforward_5") | |||
| self->__commonstate.params = (ParamInfo *)genlib_sysmem_newptr(7 * sizeof(ParamInfo)); | |||
| self->__commonstate.numparams = 7; | |||
| // initialize parameter 0 ("m_repeats_4") | |||
| pi = self->__commonstate.params + 0; | |||
| pi->name = "feedforward"; | |||
| pi->name = "repeats"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_feedforward_5; | |||
| pi->defaultvalue = self->m_repeats_4; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 70; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 100; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 1 ("m_feedback_6") | |||
| // initialize parameter 1 ("m_time_5") | |||
| pi = self->__commonstate.params + 1; | |||
| pi->name = "feedback"; | |||
| pi->name = "time"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_feedback_6; | |||
| pi->defaultvalue = self->m_time_5; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = -70; | |||
| pi->outputmax = 70; | |||
| pi->outputmin = 20; | |||
| pi->outputmax = 1000; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 2 ("m_cutoff_7") | |||
| // initialize parameter 2 ("m_depth_6") | |||
| pi = self->__commonstate.params + 2; | |||
| pi->name = "cutoff"; | |||
| pi->name = "depth"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_cutoff_7; | |||
| pi->defaultvalue = self->m_depth_6; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 500; | |||
| pi->outputmax = 6000; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 5; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 3 ("m_bleed_8") | |||
| // initialize parameter 3 ("m_morph_7") | |||
| pi = self->__commonstate.params + 3; | |||
| pi->name = "bleed"; | |||
| pi->name = "morph"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_bleed_8; | |||
| pi->defaultvalue = self->m_morph_7; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 70; | |||
| pi->outputmax = 100; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 4 ("m_time_9") | |||
| // initialize parameter 4 ("m_rate_8") | |||
| pi = self->__commonstate.params + 4; | |||
| pi->name = "time"; | |||
| pi->name = "rate"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_time_9; | |||
| pi->defaultvalue = self->m_rate_8; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 20; | |||
| pi->outputmax = 1000; | |||
| pi->outputmin = 0.1; | |||
| pi->outputmax = 10; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 5 ("m_repeats_10") | |||
| // initialize parameter 5 ("m_mix_9") | |||
| pi = self->__commonstate.params + 5; | |||
| pi->name = "repeats"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_repeats_10; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 100; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 6 ("m_depth_11") | |||
| pi = self->__commonstate.params + 6; | |||
| pi->name = "depth"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_depth_11; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 5; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 7 ("m_mix_12") | |||
| pi = self->__commonstate.params + 7; | |||
| pi->name = "mix"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_mix_12; | |||
| pi->defaultvalue = self->m_mix_9; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| @@ -371,32 +333,18 @@ void * create(double sr, long vs) { | |||
| pi->outputmax = 100; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 8 ("m_rate_13") | |||
| pi = self->__commonstate.params + 8; | |||
| pi->name = "rate"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_rate_13; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0.1; | |||
| pi->outputmax = 10; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 9 ("m_delay_14") | |||
| pi = self->__commonstate.params + 9; | |||
| pi->name = "delay"; | |||
| // initialize parameter 6 ("m_cutoff_10") | |||
| pi = self->__commonstate.params + 6; | |||
| pi->name = "cutoff"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_delay_14; | |||
| pi->defaultvalue = self->m_cutoff_10; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 30; | |||
| pi->outputmin = 500; | |||
| pi->outputmax = 6000; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||