38 float NoiseGate::fnglevel = 0;
39 float NoiseGate::ngate = 1;
40 bool NoiseGate::off =
true;
48 inputdef.
id =
"noise_gate";
49 inputdef.
name =
N_(
"Noise Gate");
63 inline float sqrf(
float x) {
67 void NoiseGate::inputlevel_compute(
int count,
float *input,
float *output,
PluginDef*) {
69 for (
int i = 0; i < count; i++) {
70 sumnoise +=
sqrf(input[i]);
72 if (sumnoise/count >
sqrf(fnglevel * 0.01)) {
74 }
else if (ngate > 0.01) {
79 int NoiseGate::noisegate_register(
const ParamReg& reg) {
80 reg.
registerVar(
"noise_gate.threshold",
N_(
"Threshold"),
"S",
"", &fnglevel,
81 0.017f, 0.01f, 0.31f, 0.001f);
85 void NoiseGate::outputgate_compute(
int count,
float *input,
float *output,
PluginDef*) {
90 *output++ = ngate * *input++;
110 seqline = seqset.seqline;
118 for (
unsigned int i = 0; i < seqline.size(); i++) {
126 if (seqline != seqset.seqline) {
138 seqline.push_back(p);
162 :
Parameter(
id,
"", tp_special, None,
true,
false),
168 std_value.seqline = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
184 value(&value_storage),
191 std_value.readJSON(jp);
194 "SeqParameter", Glib::ustring::compose(
"%1: unknown key: %2",
_id, jp.
current_value()));
204 jw.
write_key(
"value"); value->writeJSON(jw);
205 jw.
write_key(
"std_value"); std_value.writeJSON(jw);
215 json_value = std_value;
220 value->writeJSON(jw);
224 json_value.readJSON(jp);
228 return json_value == *value;
260 fIRFile = jcset.fIRFile;
261 fIRDir = jcset.fIRDir;
263 fOffset = jcset.fOffset;
264 fLength = jcset.fLength;
265 fDelay = jcset.fDelay;
266 gainline = jcset.gainline;
267 fGainCor = jcset.fGainCor;
272 if (fIRFile.empty()) {
275 return Glib::build_filename(fIRDir, fIRFile);
280 fIRDir = Glib::path_get_dirname(name);
281 fIRFile= Glib::path_get_basename(name);
286 w.
write_kv(
"jconv.IRFile", fIRFile);
289 w.
write_kv(
"jconv.GainCor", fGainCor);
290 w.
write_kv(
"jconv.Offset", fOffset);
291 w.
write_kv(
"jconv.Length", fLength);
295 for (
unsigned int i = 0; i < gainline.size(); i++) {
297 w.
write(gainline[i].i);
298 w.
write(gainline[i].g);
306 if (fIRFile != jcset.fIRFile || fIRDir != jcset.fIRDir) {
309 if (fOffset != jcset.fOffset || fLength != jcset.fLength || fDelay != jcset.fDelay) {
312 if (fGainCor != jcset.fGainCor) {
315 if (fGainCor && std::abs(fGain - jcset.fGain) > 1e-4 * (fGain + jcset.fGain)) {
318 if (gainline == jcset.gainline) {
335 gainline.push_back(p);
344 if (jp.
read_kv(
"jconv.IRFile", fIRFile) ||
345 jp.
read_kv(
"jconv.IRDir", fIRDir) ||
346 jp.
read_kv(
"jconv.Gain", fGain) ||
347 jp.
read_kv(
"jconv.GainCor", fGainCor) ||
348 jp.
read_kv(
"jconv.Offset", fOffset) ||
349 jp.
read_kv(
"jconv.Length", fLength) ||
350 jp.
read_kv(
"jconv.Delay", fDelay)) {
361 if (!fIRFile.empty()) {
362 if (fIRDir.empty()) {
376 :
Parameter(
id,
"", tp_special, None,
true,
false),
383 std_value.fGainCor =
true;
384 std_value.fGain = 0.598717;
385 const int ir_len = 112561;
386 std_value.fLength = ir_len;
387 static gain_points g[2] = {{0, 0}, {ir_len-1, 0}};
388 std_value.gainline = Gainline(g,
sizeof(g) /
sizeof(g[0]));
406 value(&value_storage),
413 std_value.readJSON(jp);
416 "JConvParameter", Glib::ustring::compose(
"%1: unknown key: %2",
_id, jp.
current_value()));
426 jw.
write_key(
"value"); value->writeJSON(jw);
427 jw.
write_key(
"std_value"); std_value.writeJSON(jw);
437 json_value = std_value;
442 value->writeJSON(jw);
446 json_value.readJSON(jp);
450 return json_value == *value;
471 #include "faust/jconv_post.cc" 472 #include "faust/jconv_post_mono.cc" 501 while (conv.is_runnable()) {
504 conv.set_buffersize(size);
509 conv.set_buffersize(size);
517 conv.set_not_runnable();
520 while (!conv.checkstate());
527 bool rc = conv.configure(
530 int policy, priority;
532 if (!rc || !conv.start(policy, priority)) {
538 if (!conv.get_buffersize() || !conv.get_samplerate()) {
547 while (!conv.checkstate());
548 if (conv.is_runnable()) {
562 int policy, priority;
564 return conv.start(policy, priority);
586 void ConvolverStereoAdapter::convolver(
int count,
float *input0,
float *input1,
589 if (
self.conv.is_runnable()) {
590 float conv_out0[count];
591 float conv_out1[count];
592 if (
self.conv.compute(count, input0, input1, conv_out0, conv_out1)) {
593 self.jc_post.compute(count, input0, input1,
594 conv_out0, conv_out1, output0, output1);
599 if (input0 != output0) {
600 memcpy(output0, input0, count *
sizeof(
float));
602 if (input1 != output1) {
603 memcpy(output1, input1, count *
sizeof(
float));
607 int ConvolverStereoAdapter::convolver_register(
const ParamReg& reg) {
610 self.jcp->signal_changed().connect(
613 return self.jc_post.register_par(reg);
616 void ConvolverStereoAdapter::convolver_init(
unsigned int samplingFreq,
PluginDef *p) {
620 self.conv.stop_process();
621 self.conv.set_samplerate(samplingFreq);
622 self.jc_post.init(samplingFreq);
623 while (
self.conv.is_runnable()) {
624 self.conv.checkstate();
628 self.conv.set_samplerate(samplingFreq);
629 self.jc_post.init(samplingFreq);
633 int ConvolverStereoAdapter::activate(
bool start,
PluginDef *p) {
637 if (
self.
activated &&
self.conv.is_runnable()) {
645 self.activated =
start;
647 if (
self.jc_post.activate(
true) != 0) {
655 self.conv.stop_process();
656 self.jc_post.activate(
false);
680 void ConvolverMonoAdapter::convolver(
int count,
float *input,
float *output,
PluginDef* plugin) {
682 if (
self.conv.is_runnable()) {
683 float conv_out[count];
684 if (
self.conv.compute(count, input, conv_out)) {
685 self.jc_post_mono.compute(count, output, conv_out, output);
690 if (input != output) {
691 memcpy(output, input, count *
sizeof(
float));
695 int ConvolverMonoAdapter::convolver_register(
const ParamReg& reg) {
698 self.jcp->signal_changed().connect(
701 return self.jc_post_mono.register_par(reg);;
704 void ConvolverMonoAdapter::convolver_init(
unsigned int samplingFreq,
PluginDef *p) {
708 self.conv.stop_process();
709 self.conv.set_samplerate(samplingFreq);
710 while (
self.conv.is_runnable()) {
711 self.conv.checkstate();
715 self.conv.set_samplerate(samplingFreq);
719 int ConvolverMonoAdapter::activate(
bool start,
PluginDef *p) {
723 if (
self.
activated &&
self.conv.is_runnable()) {
731 self.activated =
start;
737 self.conv.stop_process();
769 conv.set_buffersize(bufsize);
782 self.conv.set_samplerate(samplingFreq);
789 if (!
activated || !plugin.get_on_off()) {
800 if (!
self.conv.get_buffersize()) {
811 self.update_conn = Glib::signal_timeout().connect(
814 self.conv.stop_process();
816 self.activated =
start;
821 int policy, priority;
823 return conv.start(policy, priority);
857 conv.set_buffersize(static_cast<int>(ceil((bufsize*
bz))));
870 self.SamplingFreq = samplingFreq;
871 self.bz = 96000/samplingFreq;
872 self.conv.set_buffersize(static_cast<int>(ceil((
self.
buffersize*
self.
bz))));
880 if (!
activated || !plugin.get_on_off()) {
891 if (!
self.conv.get_buffersize()) {
902 self.update_conn = Glib::signal_timeout().connect(
905 self.conv.stop_process();
907 self.activated =
start;
912 int policy, priority;
914 return conv.start(policy, priority);
927 template <
int tab_size>
931 float ir_data[tab_size];
942 {
"4x12",
N_(
"4x12"), &
static_cast<CabDesc&
>(cab_data_4x12) },
943 {
"2x12",
N_(
"2x12"), &
static_cast<CabDesc&
>(cab_data_2x12) },
944 {
"1x12",
N_(
"1x12"), &
static_cast<CabDesc&
>(cab_data_1x12) },
945 {
"4x10",
N_(
"4x10"), &
static_cast<CabDesc&
>(cab_data_4x10) },
946 {
"2x10",
N_(
"2x10"), &
static_cast<CabDesc&
>(cab_data_2x10) },
947 {
"HighGain",
N_(
"HighGain Style"), &
static_cast<CabDesc&
>(cab_data_HighGain) },
948 {
"Twin",
N_(
"Twin Style"), &
static_cast<CabDesc&
>(cab_data_Twin) },
949 {
"Bassman",
N_(
"Bassman Style"), &
static_cast<CabDesc&
>(cab_data_Bassman) },
950 {
"Marshall",
N_(
"Marshall Style"), &
static_cast<CabDesc&
>(cab_data_Marshall) },
951 {
"AC-30",
N_(
"AC-30 Style"), &
static_cast<CabDesc&
>(cab_data_AC30) },
952 {
"Princeton",
N_(
"Princeton Style"), &
static_cast<CabDesc&
>(cab_data_Princeton) },
953 {
"A2",
N_(
"A2 Style"), &
static_cast<CabDesc&
>(cab_data_A2) },
954 {
"1x15",
N_(
"1x15"), &
static_cast<CabDesc&
>(cab_data_1x15) },
955 {
"Mesa Boogie",
N_(
"Mesa Boogie Style"), &
static_cast<CabDesc&
>(cab_data_mesa) },
956 {
"Briliant",
N_(
"Briliant"), &
static_cast<CabDesc&
>(cab_data_briliant) },
957 {
"Vitalize",
N_(
"Vitalize"), &
static_cast<CabDesc&
>(cab_data_vitalize) },
958 {
"Charisma",
N_(
"Charisma"), &
static_cast<CabDesc&
>(cab_data_charisma) },
962 static CabEntry& getCabEntry(
unsigned int n) {
963 if (n >= cab_table_size) {
964 n = cab_table_size - 1;
969 static const float no_sum = 1e10;
971 #include "faust/cabinet_impulse_former.cc" 973 static int cab_load_ui(
const UiBuilder& builder,
int format) {
1013 for (
unsigned int i = 0; i < cab_table_size; ++i) {
1018 cab_names[cab_table_size].
value_id = 0;
1032 bool CabinetConvolver::do_update() {
1033 bool configure = cabinet_changed();
1034 if (conv.is_runnable()) {
1035 conv.set_not_runnable();
1037 conv.stop_process();
1040 if (current_cab == -1) {
1042 unsigned int sru = 96000;
1043 unsigned int fact = sru/sr;
1045 smp.
setup(sr, fact*sr);
1046 impf.init(cab.
ir_sr);
1049 impf.clear_state_f();
1051 while (!conv.checkstate());
1053 if (!conv.configure(cab.
ir_count, cab_irdata_c, cab.
ir_sr)) {
1066 bool CabinetConvolver::start(
bool force) {
1070 if (cabinet_changed() || sum_changed()) {
1073 while (!conv.checkstate());
1074 if (!conv.is_runnable()) {
1081 void CabinetConvolver::check_update() {
1082 if (cabinet_changed() || sum_changed()) {
1087 void CabinetConvolver::run_cab_conf(
int count,
float *input0,
float *output0,
PluginDef *p) {
1089 FAUSTFLOAT buf[
self.smp.max_out_count(count)];
1090 int ReCount =
self.smp.up(count, output0, buf);
1091 if (!
self.conv.compute(ReCount,buf)) {
1094 self.smp.down(buf, output0);
1097 int CabinetConvolver::register_cab(
const ParamReg& reg) {
1099 reg.
registerIEnumVar(
"cab.select",
"select",
"B",
"", cab.cab_names, &cab.cabinet, 0);
1100 reg.
registerVar(
"cab.Level",
N_(
"Level"),
"S",
N_(
"Level"), &cab.level, 1.0, 0.5, 5.0, 0.5);
1101 reg.
registerVar(
"cab.bass",
N_(
"Bass"),
"S",
N_(
"Bass"), &cab.bass, 0.0, -10.0, 10.0, 0.5);
1102 reg.
registerVar(
"cab.treble",
N_(
"Treble"),
"S",
N_(
"Treble"), &cab.treble, 0.0, -10.0, 10.0, 0.5);
1103 cab.impf.register_par(reg);
1108 #include "faust/cabinet_impulse_former_st.cc" 1110 static int cab_load_stereo_ui(
const UiBuilder& builder,
int format) {
1151 for (
unsigned int i = 0; i < cab_table_size; ++i) {
1156 cab_names[cab_table_size].
value_id = 0;
1170 bool CabinetStereoConvolver::do_update() {
1171 bool configure = cabinet_changed();
1172 if (conv.is_runnable()) {
1173 conv.set_not_runnable();
1175 conv.stop_process();
1178 if (current_cab == -1) {
1180 unsigned int sru = 96000;
1181 unsigned int fact = sru/sr;
1183 smp.
setup(sr, fact*sr);
1184 smps.
setup(sr, fact*sr);
1185 impf.init(cab.
ir_sr);
1188 impf.clear_state_f();
1190 while (!conv.checkstate());
1192 if (!conv.configure_stereo(cab.
ir_count, cab_irdata_c, cab.
ir_sr)) {
1196 if (!conv.update_stereo(cab.
ir_count, cab_irdata_c, cab.
ir_sr)) {
1205 bool CabinetStereoConvolver::start(
bool force) {
1209 if (cabinet_changed() || sum_changed()) {
1212 while (!conv.checkstate());
1213 if (!conv.is_runnable()) {
1220 void CabinetStereoConvolver::check_update() {
1221 if (cabinet_changed() || sum_changed()) {
1226 void CabinetStereoConvolver::run_cab_conf(
int count,
float *input0,
float *input1,
float *output0,
float *output1,
PluginDef *p) {
1228 FAUSTFLOAT buf[
self.smp.max_out_count(count)];
1229 FAUSTFLOAT buf1[
self.smps.max_out_count(count)];
1230 int ReCount =
self.smp.up(count, output0, buf);
1231 self.smps.up(count, output1, buf1);
1232 if (!
self.conv.compute_stereo(ReCount,buf,buf1)) {
1235 self.smp.down(buf, output0);
1236 self.smps.down(buf1, output1);
1239 int CabinetStereoConvolver::register_cab(
const ParamReg& reg) {
1241 reg.
registerIEnumVar(
"cab_st.select",
"select",
"B",
"", cab.cab_names, &cab.cabinet, 0);
1242 reg.
registerVar(
"cab_st.Level",
N_(
"Level"),
"S",
N_(
"Level"), &cab.level, 1.0, 0.5, 5.0, 0.5);
1243 reg.
registerVar(
"cab_st.bass",
N_(
"Bass"),
"S",
N_(
"Bass"), &cab.bass, 0.0, -10.0, 10.0, 0.5);
1244 reg.
registerVar(
"cab_st.treble",
N_(
"Treble"),
"S",
N_(
"Treble"), &cab.treble, 0.0, -10.0, 10.0, 0.5);
1245 cab.impf.register_par(reg);
1259 template <
int tab_size>
1263 float ir_data[tab_size];
1274 {
"AC30",
N_(
"AC30 Style"), &
static_cast<PreDesc&
>(pre_data_ac30) },
1275 {
"Bassman",
N_(
"Bassman Style"), &
static_cast<PreDesc&
>(pre_data_bassman) },
1276 {
"Tube",
N_(
"Tube Style"), &
static_cast<PreDesc&
>(pre_data_tube) },
1277 {
"Fender",
N_(
"Fender Style"), &
static_cast<PreDesc&
>(pre_data_fender) },
1278 {
"JCM800",
N_(
"JCM800 Style"), &
static_cast<PreDesc&
>(pre_data_jcm800) },
1279 {
"JTM45",
N_(
"JTM45 Style"), &
static_cast<PreDesc&
>(pre_data_jtm45) },
1280 {
"Mesa Boogie",
N_(
"Mesa Boogie Style"), &
static_cast<PreDesc&
>(pre_data_mesaboogie) },
1281 {
"Boutique",
N_(
"Boutique Style"), &
static_cast<PreDesc&
>(pre_data_boutique) },
1282 {
"Ampeg",
N_(
"Ampeg Style"), &
static_cast<PreDesc&
>(pre_data_ampeg) },
1283 {
"Rectifier",
N_(
"Rectifier Style"), &
static_cast<PreDesc&
>(pre_data_rectifier) },
1287 static PreEntry& getPreEntry(
unsigned int n) {
1288 if (n >= pre_table_size) {
1289 n = pre_table_size - 1;
1294 #include "faust/preamp_impulse_former.cc" 1296 static int pre_load_ui(
const UiBuilder& builder,
int format) {
1336 for (
unsigned int i = 0; i < pre_table_size; ++i) {
1341 pre_names[pre_table_size].
value_id = 0;
1344 name =
N_(
"Amp Impulse");
1355 bool PreampConvolver::do_update() {
1356 bool configure = preamp_changed();
1357 if (conv.is_runnable()) {
1358 conv.set_not_runnable();
1360 conv.stop_process();
1363 if (current_pre == -1) {
1365 unsigned int sru = 96000;
1366 unsigned int fact = sru/sr;
1368 smp.
setup(sr, fact*sr);
1369 impf.init(pre.
ir_sr);
1372 impf.clear_state_f();
1374 while (!conv.checkstate());
1376 if (!conv.configure(pre.
ir_count, pre_irdata_c, pre.
ir_sr)) {
1389 bool PreampConvolver::start(
bool force) {
1393 if (preamp_changed() || sum_changed()) {
1396 while (!conv.checkstate());
1397 if (!conv.is_runnable()) {
1404 void PreampConvolver::check_update() {
1405 if (preamp_changed() || sum_changed()) {
1410 void PreampConvolver::run_pre_conf(
int count,
float *input0,
float *output0,
PluginDef *p) {
1412 FAUSTFLOAT buf[
self.smp.max_out_count(count)];
1413 int ReCount =
self.smp.up(count, output0, buf);
1414 if (!
self.conv.compute(ReCount, buf)) {
1417 self.smp.down(buf, output0);
1420 int PreampConvolver::register_pre(
const ParamReg& reg) {
1422 reg.
registerIEnumVar(
"pre.select",
"select",
"B",
"", pre.pre_names, &pre.preamp, 0);
1423 reg.
registerVar(
"pre.Level",
N_(
"Level"),
"S",
N_(
"Level"), &pre.level, 1.0, 0.1, 2.1, 0.1);
1424 reg.
registerVar(
"pre.bass",
N_(
"Bass"),
"S",
N_(
"Bass"), &pre.bass, 0.0, -10.0, 10.0, 0.5);
1425 reg.
registerVar(
"pre.treble",
N_(
"Treble"),
"S",
N_(
"Treble"), &pre.treble, 0.0, -10.0, 10.0, 0.5);
1426 pre.impf.register_par(reg);
1434 #include "faust/presence_level.cc" 1444 name =
N_(
"Contrast convolver");
1452 bool ContrastConvolver::do_update() {
1453 bool configure = (sum == no_sum);
1454 if (conv.is_runnable()) {
1455 conv.set_not_runnable();
1457 conv.stop_process();
1461 unsigned int sru = 96000;
1462 unsigned int fact = sru/sr;
1464 smp.
setup(sr, fact*sr);
1465 presl.init(contrast_ir_desc.ir_sr);
1467 float contrast_irdata_c[contrast_ir_desc.ir_count];
1468 presl.compute(contrast_ir_desc.ir_count,contrast_ir_desc.ir_data,contrast_irdata_c);
1469 while (!conv.checkstate());
1471 if (!conv.configure(contrast_ir_desc.ir_count, contrast_irdata_c, contrast_ir_desc.ir_sr)) {
1475 if (!conv.update(contrast_ir_desc.ir_count, contrast_irdata_c, contrast_ir_desc.ir_sr)) {
1483 bool ContrastConvolver::start(
bool force) {
1487 if (sum_changed()) {
1490 while (!conv.checkstate());
1491 if (!conv.is_runnable()) {
1498 void ContrastConvolver::check_update() {
1499 if (sum_changed()) {
1504 int ContrastConvolver::register_con(
const ParamReg& reg) {
1506 reg.
registerVar(
"con.Level",
"",
"S",
"", &
self.level, 1.0, 0.5, 5.0, 0.5);
1507 self.presl.register_par(reg);
1511 void ContrastConvolver::run_contrast(
int count,
float *input0,
float *output0,
PluginDef *p) {
1513 FAUSTFLOAT buf[
self.smp.max_out_count(count)];
1514 int ReCount =
self.smp.up(count, output0, buf);
1515 if (!
self.conv.compute(ReCount,buf)) {
1518 self.smp.down(buf, output0);
1563 bool smbPitchShift::setParameters(
int sampleRate_)
1566 fftFrameSize = numSampsToProcess/4;
1567 sampleRate = int(sampleRate_);
1568 assert(sampleRate>0);
1571 osamp2 = 2.*
M_PI*osamp1;
1572 mpi = (1./(2.*
M_PI)) * osamp;
1581 resamp.setup(sampleRate,4);
1582 gRover = inFifoLatency;
1589 mem_allocated(false),
1604 id =
"smbPitchShift";
1618 sigc::mem_fun(*
this, &smbPitchShift::change_buffersize));
1621 void smbPitchShift::init(
unsigned int samplingFreq,
PluginDef *plugin) {
1626 void smbPitchShift::clear_state()
1628 stepSize = fftFrameSize/osamp;
1629 freqPerBin = (double)(sampleRate/4)/(double)fftFrameSize;
1630 freqPerBin1 = (1/freqPerBin)*osamp2;
1631 freqPerBin2 = freqPerBin*mpi;
1632 expct = 2.*
M_PI*(double)stepSize/(
double)fftFrameSize;
1633 inFifoLatency = fftFrameSize-stepSize;
1634 fftFrameSize3 = 2. * (1./ ((double)(fftFrameSize2)*osamp));
1635 fftFrameSize4 = 1./(double)fftFrameSize;
1647 for (k = 0; k < fftFrameSize2;k++) {
1648 fpb[k] = (double)k*freqPerBin;
1650 for (k = 0; k < fftFrameSize2;k++) {
1651 expect[k] = (double)k*expct;
1653 for (k = 0; k < fftFrameSize;k++) {
1654 hanning[k] = 0.5*(1-cos(2.*
M_PI*(
double)k/((
double)fftFrameSize)));
1656 for (k = 0; k < fftFrameSize;k++) {
1657 hanningd[k] = 0.5*(1-cos(2.*
M_PI*(
double)k * fftFrameSize4)) * fftFrameSize3;
1659 for (k = 0; k < fftFrameSize;k++) {
1662 for (k = 0; k < fftFrameSize;k++) {
1665 for (k = 0; k < fftFrameSize*4;k++) {
1668 for (k = 0; k < fftFrameSize*4;k++) {
1671 gRover = inFifoLatency;
1672 mem_allocated =
true;
1676 void smbPitchShift::mem_alloc()
1679 assert(numSampsToProcess>0);
1680 numSampsToResamp = numSampsToProcess/4;
1682 assert(sampleRate>0);
1686 if (numSampsToProcess <= 2048) {
1687 fftFrameSize = 512 ;
1689 fftFrameSize = numSampsToProcess*0.25 ;
1693 fftFrameSize = numSampsToProcess;
1696 fftFrameSize = numSampsToProcess*0.25;
1699 if (numSampsToProcess <= 2048) {
1700 fftFrameSize = 512 ;
1702 fftFrameSize = numSampsToProcess*0.25 ;
1706 fftFrameSize2 = fftFrameSize/2;
1710 ftPlanForward = fftwf_plan_dft_1d(fftFrameSize, fftw_in, fftw_out, FFTW_FORWARD, FFTW_ESTIMATE);
1711 ftPlanInverse = fftwf_plan_dft_1d(fftFrameSize, fftw_in, fftw_out, FFTW_BACKWARD, FFTW_ESTIMATE);
1713 fpb =
new float[fftFrameSize2];
1714 expect =
new float[fftFrameSize2];
1715 hanning =
new float[fftFrameSize];
1716 hanningd =
new float[fftFrameSize];
1717 resampin =
new float[fftFrameSize];
1718 resampin2 =
new float[fftFrameSize];
1719 resampout =
new float[fftFrameSize*4];
1720 indata2 =
new float[fftFrameSize*4];
1728 void smbPitchShift::mem_free()
1731 mem_allocated =
false;
1732 if (fpb) {
delete fpb; fpb = 0; }
1733 if (expect) {
delete expect; expect = 0; }
1734 if (hanning) {
delete hanning; hanning = 0; }
1735 if (hanningd) {
delete hanningd; hanningd = 0; }
1736 if (resampin) {
delete resampin; resampin = 0; }
1737 if (resampin2) {
delete resampin2; resampin2 = 0; }
1738 if (resampout) {
delete resampout; resampout = 0; }
1739 if (indata2) {
delete indata2; indata2 = 0; }
1741 {fftwf_destroy_plan(ftPlanForward);ftPlanForward = 0; }
1743 { fftwf_destroy_plan(ftPlanInverse);ftPlanInverse = 0; }
1746 int smbPitchShift::activate(
bool start)
1749 if (!mem_allocated) {
1752 }
else if (mem_allocated) {
1758 void smbPitchShift::change_buffersize(
unsigned int size)
1762 if (mem_allocated) {
1768 void smbPitchShift::change_latency()
1772 if (mem_allocated) {
1780 if (mem_allocated) {
1786 void __rt_func smbPitchShift::compute_static(
int count,
float *input0,
float *output0,
PluginDef *p)
1788 static_cast<smbPitchShift*
>(p)->PitchShift(count, input0, output0);
1792 void always_inline smbPitchShift::PitchShift(
int count,
float *indata,
float *outdata)
1795 if (!ready || count != numSampsToProcess) {
1796 if (indata != outdata)
1798 memcpy(outdata,indata,count*
sizeof(
float));
1803 resamp.
down(numSampsToResamp,indata,resampin);
1804 double fSlow0 = (0.01 * wet);
1805 double fSlow1 = (0.01 * dry);
1808 for (i = 0; i < count; i++){
1809 indata2[ii] = indata[i];
1813 for (i = 0; i < numSampsToResamp; i++){
1814 resampin2[ai] = resampin[i];
1818 if (ai>=fftFrameSize) {
1835 float pitchShift = pow(2., (semitones+tone)*0.0833333333);
1837 for (i = 0; i < fftFrameSize; i++){
1840 float fTemp = resampin2[i];
1841 gInFIFO[gRover] = fTemp;
1842 resampin2[i] = gOutFIFO[gRover-inFifoLatency];
1846 if (gRover >= fftFrameSize) {
1847 gRover = inFifoLatency;
1850 for (k = 0; k < fftFrameSize;k++) {
1851 fftw_in[k][0] = gInFIFO[k] * hanning[k];
1852 fftw_in[k][1] = 0.0;
1858 fftwf_execute(ftPlanForward);
1861 for (k = 0; k < fftFrameSize2; k++) {
1864 real = fftw_out[k][0];
1865 imag = fftw_out[k][1];
1868 magn = 2.*sqrt(real*real + imag*imag);
1869 phase = atan2(imag,real);
1872 tmp = phase - gLastPhase[k];
1873 gLastPhase[k] = phase;
1880 if (qpd >= 0) qpd += qpd&1;
1882 tmp -=
M_PI*(double)qpd;
1886 tmp = fpb[k] + tmp*freqPerBin2;
1896 memset(gSynMagn, 0, fftFrameSize*
sizeof(
float));
1897 memset(gSynFreq, 0, fftFrameSize*
sizeof(
float));
1898 for (k = 1; k < fftFrameSize2-2; k++) {
1899 index = k*pitchShift;
1900 if (index < fftFrameSize2) {
1901 if (index < fftFrameSize2*0.20)
1902 gSynMagn[index] += gAnaMagn[k]*a;
1903 else if (index < fftFrameSize2*0.45)
1904 gSynMagn[index] += gAnaMagn[k]*b;
1905 else if (index < fftFrameSize2*0.667)
1906 gSynMagn[index] += gAnaMagn[k]*c;
1908 gSynMagn[index] += gAnaMagn[k]*d;
1909 gSynFreq[index] = gAnaFreq[k] * pitchShift;
1915 for (k = 0; k < fftFrameSize2; k++) {
1925 tmp = ((gSynFreq[k] - fpb[k]) * freqPerBin1) + expect[k];
1928 gSumPhase[k] += tmp;
1929 phase = gSumPhase[k];
1930 if (magn == 0.0)
continue;
1933 fftw_in[k][0] = magn * cos (phase);
1934 fftw_in[k][1] = magn * sin (phase);
1938 fftwf_execute(ftPlanInverse);
1940 for(k=0; k < fftFrameSize; k++) {
1941 gOutputAccum[k] += hanningd[k] * fftw_out[ k][0] ;
1943 for (k = 0; k < stepSize; k++) gOutFIFO[k] = gOutputAccum[k];
1946 memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameSize*
sizeof(
float));
1949 for (k = 0; k < inFifoLatency; k++) gInFIFO[k] = gInFIFO[k+stepSize];
1952 resamp.
up(fftFrameSize,resampin2,resampout);
1956 for (i = 0; i < count; i++){
1957 outdata[i] = ((fSlow0 * resampout[aio]) + (fSlow1 *indata2[aio]));
1961 for (i = 0; i < count; i++){
1962 outdata[i] = ((fSlow0 * resampout[aio]) + (fSlow1 *indata[i]));
1968 int smbPitchShift::register_par(
const ParamReg& reg)
1970 reg.
registerVar(
"smbPitchShift.semitone",
N_(
"Detune"),
"S",
"", &semitones, 0.0, -12., 12., 0.1);
1971 static const value_pair octave_values[] = {{
"unison"},{
"octave up"},{
"octave down"},{0}};
1972 reg.
registerIEnumVar(
"smbPitchShift.octave",
N_(
"add harmonics"),
"B",
N_(
"add harmonics"),octave_values,&octave, 0);
1973 static const value_pair latency_values[] = {{
"latency "},{
"compensate"},{0}};
1974 reg.
registerEnumVar(
"smbPitchShift.l",
N_(
"compensate latency"),
"S",
N_(
"compensate latency"),latency_values,&l, 0.0f, 0.0f, 1.0f, 1.0f);
1975 static const value_pair latency_set[] = {{
"high quality"},{
"low quality"},{
"realtime"},{0}};
1976 reg.
registerIEnumVar(
"smbPitchShift.latency",
N_(
"latency settings"),
"B",
N_(
"latency settings"),latency_set,&latency, 0);
1977 reg.
registerVar(
"smbPitchShift.wet",
N_(
"Wet"),
"S",
N_(
"Wet amount"), &wet, 50.0, 0.0, 100.0, 1);
1978 reg.
registerVar(
"smbPitchShift.dry",
N_(
"Dry"),
"S",
N_(
"Dry amount"), &dry, 50.0, 0.0, 100.0, 1);
1979 reg.
registerVar(
"smbPitchShift.a",
N_(
"low"),
"S",
N_(
"Sub"), &a, 1.0, 0.0, 2.0, 0.01);
1980 reg.
registerVar(
"smbPitchShift.b",
N_(
"middle low"),
"S",
N_(
"Low"), &b, 1.0, 0.0, 2.0, 0.01);
1981 reg.
registerVar(
"smbPitchShift.c",
N_(
"middle treble"),
"S",
N_(
"Mid"), &c, 1.0, 0.0, 2.0, 0.01);
1982 reg.
registerVar(
"smbPitchShift.d",
N_(
"treble"),
"S",
N_(
"Hi"), &d, 1.0, 0.0, 2.0, 0.01);
1983 param[
"smbPitchShift.latency"].signal_changed_int().connect(
1984 sigc::hide(sigc::mem_fun(
this, &smbPitchShift::change_latency)));
1988 int smbPitchShift::registerparam(
const ParamReg& reg)
1993 int smbPitchShift::load_ui_f(
const UiBuilder& b,
int form)
2043 int smbPitchShift::activate_static(
bool start,
PluginDef *p)
2048 int smbPitchShift::load_ui_f_static(
const UiBuilder& b,
int form)
2053 void smbPitchShift::del_instance(
PluginDef *p)
bool operator==(const GxSeqSettings &seqset) const
ParameterV< GxSeqSettings > SeqParameter
void write_kv(const char *key, float v)
static void init(unsigned int samplingFreq, PluginDef *p)
CmdConnection::msg_type start
void begin_array(bool nl=false)
void get_sched_priority(int &policy, int &priority, int prio_dim=0)
void up(int count, float *input, float *output)
void readJSON(gx_system::JsonParser &jp)
virtual bool on_off_value()
virtual bool on_off_value()
BasicOptions & get_options()
ParameterV< GxJConvSettings > JConvParameter
const Gainline & getGainline() const
void end_array(bool nl=false)
bool operator==(const GxJConvSettings &jcset) const
static int activate(bool start, PluginDef *pdef)
struct gx_engine::CabEntry cab_table[]
virtual void check_update()=0
void set_pdef(PluginDef *p)
bool set(const GxJConvSettings &val) const
unsigned int getSamplingFreq()
std::string getFullIRPath() const
float *(* registerVar)(const char *id, const char *name, const char *tp, const char *tooltip, float *var, float val, float low, float up, float step)
void(* registerEnumVar)(const char *id, const char *name, const char *tp, const char *tooltip, const value_pair *values, float *var, float val, float low, float up, float step)
ParameterV(const string &id, ConvolverAdapter &conv, GxJConvSettings *v)
void change_buffersize(unsigned int size)
virtual void stdJSON_value()
void change_buffersize(unsigned int)
void write_key(const char *p, bool nl=false)
bool set(const GxSeqSettings &val) const
sigc::connection update_conn
void(* load_glade_file)(const char *fname)
virtual void setJSON_value()
virtual void readJSON_value(gx_system::JsonParser &jp)
boost::mutex activate_mutex
void(* registerIEnumVar)(const char *id, const char *name, const char *tp, const char *tooltip, const value_pair *values, int *var, int val)
deletefunc delete_instance
virtual bool start(bool force=false)=0
ParameterV(const string &id, GxSeqSettings *v)
void gx_print_error(const char *, const std::string &)
bool read_kv(const char *key, float &v)
ConvolverMonoAdapter(EngineControl &engine, sigc::slot< void > sync, ParamMap ¶m)
bool check_update_timeout()
smbPitchShift(ParamMap ¶m_, EngineControl &engine, sigc::slot< void > sync)
CabinetConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
int setup(int _inputRate, int _outputRate)
GxSeqSettings & operator=(GxSeqSettings const &seqset)
#define PLUGINDEF_VERSION
void(* openHorizontalBox)(const char *label)
registerfunc register_params
bool find_dir(std::string *d, const std::string &filename) const
PreampConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
static PluginDef outputgate
CabinetStereoConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
virtual void serializeJSON(gx_system::JsonWriter &jw)
sigc::connection update_conn
virtual void readJSON_value(gx_system::JsonParser &jp)
static void init(unsigned int samplingFreq, PluginDef *p)
BaseConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
void begin_object(bool nl=false)
void(* create_small_rackknobr)(const char *id, const char *label)
void down(int count, float *input, float *output)
bool check_update_timeout()
void(* create_mid_rackknob)(const char *id, const char *label)
void change_buffersize(unsigned int)
void writeJSON(gx_system::JsonWriter &w) const
boost::mutex activate_mutex
virtual void writeJSON(gx_system::JsonWriter &jw) const
void setFullIRPath(string name)
const PathList & get_IR_pathlist() const
ContrastConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
void writeJSON(gx_system::JsonWriter &w) const
FixedBaseConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
unsigned int get_samplerate()
virtual void setJSON_value()
void gx_print_warning(const char *, const std::string &)
void(* openHorizontalhideBox)(const char *label)
ConvolverAdapter(EngineControl &engine, sigc::slot< void > sync, ParamMap ¶m)
virtual ~FixedBaseConvolver()
virtual void stdJSON_value()
activatefunc activate_plugin
virtual void check_update()=0
boost::mutex activate_mutex
process_stereo_audio stereo_audio
std::string replace_symbol(const std::string &dir) const
void readJSON(gx_system::JsonParser &jp)
string current_value() const
void(* set_next_flags)(int flags)
process_mono_audio mono_audio
virtual void serializeJSON(gx_system::JsonWriter &jw)
void set_on_off(bool v) const
GxJConvSettings & operator=(GxJConvSettings const &jcset)
unsigned int SamplingFreq
unsigned int get_buffersize()
virtual bool compareJSON_value()
~ConvolverStereoAdapter()
float current_value_float()
virtual void serializeJSON(gx_system::JsonWriter &jw)
token next(token expect=no_token)
void write(float v, bool nl=false)
struct gx_engine::PreEntry pre_table[]
virtual bool compareJSON_value()
const PrefixConverter & get_IR_prefixmap() const
static ParameterV< GxJConvSettings > * insert_param(ParamMap &pmap, const string &id, ConvolverAdapter &conv, GxJConvSettings *v)
virtual bool start(bool force=false)=0
static ParameterV< GxSeqSettings > * insert_param(ParamMap &pmap, const string &id, GxSeqSettings *v)
void(* create_master_slider)(const char *id, const char *label)
void end_object(bool nl=false)
~CabinetStereoConvolver()
ConvolverStereoAdapter(EngineControl &engine, sigc::slot< void > sync, ParamMap ¶m)
void(* create_selector_no_caption)(const char *id)
void(* openVerticalBox)(const char *label)
virtual void writeJSON(gx_system::JsonWriter &jw) const
static int activate(bool start, PluginDef *pdef)
sigc::signal< void, unsigned int > & signal_buffersize_change()