Add Transmogrifier

This commit is contained in:
Aleks Rutins 2023-04-15 20:44:51 -04:00
parent 6c97eaf786
commit caaf19cf0e
3 changed files with 26 additions and 10 deletions

View file

@ -73,4 +73,13 @@
lv2:default 0.5 ;
lv2:minimum 0.0 ;
lv2:maximum 1.0 ;
] ,
[
a lv2:InputPort , lv2:ControlPort ;
lv2:index 6 ;
lv2:symbol "algorithm_mix" ;
lv2:name "Transmogrify" ;
lv2:default 0.5 ;
lv2:minimum 0.0 ;
lv2:maximum 1.0 ;
] .

21
gui.cc
View file

@ -24,9 +24,10 @@ namespace Dynamite {
Scale *threshold_scale;
Scale *gain_scale;
Scale *mix_scale;
Scale *create_vscale(p_port_enum nport) {
Scale *transmogrify_scale;
Scale *create_scale(p_port_enum nport, Orientation orient = ORIENTATION_VERTICAL) {
auto port = p_ports[nport];
auto result = manage(new VScale(port.min, port.max, 0.01));
Scale *result = manage(orient == ORIENTATION_VERTICAL ? (Scale *)new VScale(port.min, port.max, 0.01) : (Scale *)new HScale(port.min, port.max, 0.01));
auto scale_slot = bind<0>(bind<0>(bind<0>(&DriveGUI::write_control_ptr, this), (uint32_t)nport), result);
result->signal_value_changed().connect(scale_slot);
return result;
@ -38,20 +39,20 @@ namespace Dynamite {
vbox->add(*manage(new Label("Dynamite")));
drive_scale = create_vscale(p_drive);
drive_scale = create_scale(p_drive);
hbox->add(*manage(new LabeledWidget("Drive", *drive_scale)));
threshold_scale = create_vscale(p_threshold);
threshold_scale = create_scale(p_threshold);
hbox->add(*manage(new LabeledWidget("Threshold", *threshold_scale)));
gain_scale = create_vscale(p_gain);
gain_scale = create_scale(p_gain);
hbox->add(*manage(new LabeledWidget("Gain", *gain_scale)));
vbox->add(*hbox);
auto mix = p_ports[p_mix];
mix_scale = manage(new HScale(mix.min, mix.max, 0.01));
auto mix_slot = bind<0>(bind<0>(bind<0>(&DriveGUI::write_control_ptr, this), (uint32_t)p_mix), mix_scale);
mix_scale->signal_value_changed().connect(mix_slot);
transmogrify_scale = create_scale(p_algorithm_mix, ORIENTATION_HORIZONTAL);
vbox->add(*manage(new LabeledWidget("Transmogrify", *transmogrify_scale)));
mix_scale = create_scale(p_mix, ORIENTATION_HORIZONTAL);
vbox->add(*manage(new LabeledWidget("Mix", *mix_scale)));
add(*vbox);
}
@ -68,6 +69,8 @@ namespace Dynamite {
threshold_scale->set_value(value); break;
case p_gain:
gain_scale->set_value(value); break;
case p_algorithm_mix:
transmogrify_scale->set_value(value); break;
case p_mix:
mix_scale->set_value(value); break;

View file

@ -7,6 +7,7 @@ namespace Dynamite {
const float threshCoeff = dbCo(*p(p_threshold));
const float gainCoeff = dbCo(*p(p_gain));
const float mix = *p(p_mix);
const float algoMix = *p(p_algorithm_mix);
const float *input = p(p_audio_in);
float *output = p(p_audio_out);
@ -22,7 +23,10 @@ namespace Dynamite {
dist = dist * gainCoeff;
output[pos] = (mix * dist) + ((1.0 - mix) * input[pos] * gainCoeff);
float transmogrifier = threshCoeff * gainCoeff;
float transmogrified = (input[pos] < 0 ? -transmogrifier : transmogrifier);
output[pos] = (mix * ((algoMix * transmogrified) + ((1.0 - algoMix) * dist))) + ((1.0 - mix) * input[pos] * gainCoeff);
}
}
}