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++;
118 fIRFile = jcset.fIRFile;
119 fIRDir = jcset.fIRDir;
121 fOffset = jcset.fOffset;
122 fLength = jcset.fLength;
123 fDelay = jcset.fDelay;
124 gainline = jcset.gainline;
125 fGainCor = jcset.fGainCor;
130 if (fIRFile.empty()) {
133 return Glib::build_filename(fIRDir, fIRFile);
138 fIRDir = Glib::path_get_dirname(name);
139 fIRFile= Glib::path_get_basename(name);
144 w.
write_kv(
"jconv.IRFile", fIRFile);
147 w.
write_kv(
"jconv.GainCor", fGainCor);
148 w.
write_kv(
"jconv.Offset", fOffset);
149 w.
write_kv(
"jconv.Length", fLength);
153 for (
unsigned int i = 0; i < gainline.size(); i++) {
155 w.
write(gainline[i].i);
156 w.
write(gainline[i].g);
164 if (fIRFile != jcset.fIRFile || fIRDir != jcset.fIRDir) {
167 if (fOffset != jcset.fOffset || fLength != jcset.fLength || fDelay != jcset.fDelay) {
170 if (fGainCor != jcset.fGainCor) {
173 if (fGainCor && abs(fGain - jcset.fGain) > 1e-4 * (fGain + jcset.fGain)) {
176 if (gainline == jcset.gainline) {
193 gainline.push_back(p);
202 if (jp.
read_kv(
"jconv.IRFile", fIRFile) ||
203 jp.
read_kv(
"jconv.IRDir", fIRDir) ||
204 jp.
read_kv(
"jconv.Gain", fGain) ||
205 jp.
read_kv(
"jconv.GainCor", fGainCor) ||
206 jp.
read_kv(
"jconv.Offset", fOffset) ||
207 jp.
read_kv(
"jconv.Length", fLength) ||
208 jp.
read_kv(
"jconv.Delay", fDelay)) {
219 if (!fIRFile.empty()) {
220 if (fIRDir.empty()) {
234 :
Parameter(
id,
"", tp_special, None,
true,
false),
241 std_value.fGainCor =
true;
242 std_value.fGain = 0.598717;
243 const int ir_len = 112561;
244 std_value.fLength = ir_len;
245 static gain_points g[2] = {{0, 0}, {ir_len-1, 0}};
246 std_value.gainline = Gainline(g,
sizeof(g) /
sizeof(g[0]));
264 value(&value_storage),
271 std_value.readJSON(jp);
274 "JConvParameter", Glib::ustring::compose(
"%1: unknown key: %2",
_id, jp.
current_value()));
284 jw.
write_key(
"value"); value->writeJSON(jw);
285 jw.
write_key(
"std_value"); std_value.writeJSON(jw);
295 json_value = std_value;
300 value->writeJSON(jw);
304 json_value.readJSON(jp);
308 return json_value == *value;
329 #include "faust/jconv_post.cc" 330 #include "faust/jconv_post_mono.cc" 359 while (conv.is_runnable()) {
362 conv.set_buffersize(size);
367 conv.set_buffersize(size);
375 conv.set_not_runnable();
378 while (!conv.checkstate());
385 bool rc = conv.configure(
388 int policy, priority;
390 if (!rc || !conv.start(policy, priority)) {
396 if (!conv.get_buffersize() || !conv.get_samplerate()) {
405 while (!conv.checkstate());
406 if (conv.is_runnable()) {
420 int policy, priority;
422 return conv.start(policy, priority);
444 void ConvolverStereoAdapter::convolver(
int count,
float *input0,
float *input1,
447 if (
self.conv.is_runnable()) {
448 float conv_out0[count];
449 float conv_out1[count];
450 if (
self.conv.compute(count, input0, input1, conv_out0, conv_out1)) {
451 self.jc_post.compute(count, input0, input1,
452 conv_out0, conv_out1, output0, output1);
457 if (input0 != output0) {
458 memcpy(output0, input0, count *
sizeof(
float));
460 if (input1 != output1) {
461 memcpy(output1, input1, count *
sizeof(
float));
465 int ConvolverStereoAdapter::convolver_register(
const ParamReg& reg) {
468 self.jcp->signal_changed().connect(
471 return self.jc_post.register_par(reg);
474 void ConvolverStereoAdapter::convolver_init(
unsigned int samplingFreq,
PluginDef *p) {
478 self.conv.stop_process();
479 self.conv.set_samplerate(samplingFreq);
480 self.jc_post.init(samplingFreq);
481 while (
self.conv.is_runnable()) {
482 self.conv.checkstate();
486 self.conv.set_samplerate(samplingFreq);
487 self.jc_post.init(samplingFreq);
491 int ConvolverStereoAdapter::activate(
bool start,
PluginDef *p) {
495 if (
self.
activated &&
self.conv.is_runnable()) {
503 self.activated =
start;
505 if (
self.jc_post.activate(
true) != 0) {
513 self.conv.stop_process();
514 self.jc_post.activate(
false);
538 void ConvolverMonoAdapter::convolver(
int count,
float *input,
float *output,
PluginDef* plugin) {
540 if (
self.conv.is_runnable()) {
541 float conv_out[count];
542 if (
self.conv.compute(count, input, conv_out)) {
543 self.jc_post_mono.compute(count, output, conv_out, output);
548 if (input != output) {
549 memcpy(output, input, count *
sizeof(
float));
553 int ConvolverMonoAdapter::convolver_register(
const ParamReg& reg) {
556 self.jcp->signal_changed().connect(
559 return self.jc_post_mono.register_par(reg);;
562 void ConvolverMonoAdapter::convolver_init(
unsigned int samplingFreq,
PluginDef *p) {
566 self.conv.stop_process();
567 self.conv.set_samplerate(samplingFreq);
568 while (
self.conv.is_runnable()) {
569 self.conv.checkstate();
573 self.conv.set_samplerate(samplingFreq);
577 int ConvolverMonoAdapter::activate(
bool start,
PluginDef *p) {
581 if (
self.
activated &&
self.conv.is_runnable()) {
589 self.activated =
start;
595 self.conv.stop_process();
627 conv.set_buffersize(bufsize);
640 self.conv.set_samplerate(samplingFreq);
647 if (!
activated || !plugin.get_on_off()) {
658 if (!
self.conv.get_buffersize()) {
669 self.update_conn = Glib::signal_timeout().connect(
672 self.conv.stop_process();
674 self.activated =
start;
679 int policy, priority;
681 return conv.start(policy, priority);
694 template <
int tab_size>
698 float ir_data[tab_size];
709 {
"4x12",
N_(
"4x12"), &
static_cast<CabDesc&
>(cab_data_4x12) },
710 {
"2x12",
N_(
"2x12"), &
static_cast<CabDesc&
>(cab_data_2x12) },
711 {
"1x12",
N_(
"1x12"), &
static_cast<CabDesc&
>(cab_data_1x12) },
712 {
"4x10",
N_(
"4x10"), &
static_cast<CabDesc&
>(cab_data_4x10) },
713 {
"2x10",
N_(
"2x10"), &
static_cast<CabDesc&
>(cab_data_2x10) },
714 {
"HighGain",
N_(
"HighGain Style"), &
static_cast<CabDesc&
>(cab_data_HighGain) },
715 {
"Twin",
N_(
"Twin Style"), &
static_cast<CabDesc&
>(cab_data_Twin) },
716 {
"Bassman",
N_(
"Bassman Style"), &
static_cast<CabDesc&
>(cab_data_Bassman) },
717 {
"Marshall",
N_(
"Marshall Style"), &
static_cast<CabDesc&
>(cab_data_Marshall) },
718 {
"AC-30",
N_(
"AC-30 Style"), &
static_cast<CabDesc&
>(cab_data_AC30) },
719 {
"Princeton",
N_(
"Princeton Style"), &
static_cast<CabDesc&
>(cab_data_Princeton) },
720 {
"A2",
N_(
"A2 Style"), &
static_cast<CabDesc&
>(cab_data_A2) },
721 {
"1x15",
N_(
"1x15"), &
static_cast<CabDesc&
>(cab_data_1x15) },
722 {
"Mesa Boogie",
N_(
"Mesa Boogie Style"), &
static_cast<CabDesc&
>(cab_data_mesa) },
723 {
"Briliant",
N_(
"Briliant"), &
static_cast<CabDesc&
>(cab_data_briliant) },
724 {
"Vitalize",
N_(
"Vitalize"), &
static_cast<CabDesc&
>(cab_data_vitalize) },
725 {
"Charisma",
N_(
"Charisma"), &
static_cast<CabDesc&
>(cab_data_charisma) },
729 static CabEntry& getCabEntry(
unsigned int n) {
730 if (n >= cab_table_size) {
731 n = cab_table_size - 1;
736 static const float no_sum = 1e10;
738 #include "faust/cabinet_impulse_former.cc" 740 static int cab_load_ui(
const UiBuilder& builder,
int format) {
778 for (
unsigned int i = 0; i < cab_table_size; ++i) {
783 cab_names[cab_table_size].
value_id = 0;
797 bool CabinetConvolver::do_update() {
798 bool configure = cabinet_changed();
799 if (conv.is_runnable()) {
800 conv.set_not_runnable();
805 if (current_cab == -1) {
806 impf.init(cab.
ir_sr);
809 impf.clear_state_f();
811 while (!conv.checkstate());
813 if (!conv.configure(cab.
ir_count, cab_irdata_c, cab.
ir_sr)) {
826 bool CabinetConvolver::start(
bool force) {
830 if (cabinet_changed() || sum_changed()) {
833 while (!conv.checkstate());
834 if (!conv.is_runnable()) {
841 void CabinetConvolver::check_update() {
842 if (cabinet_changed() || sum_changed()) {
847 void CabinetConvolver::run_cab_conf(
int count,
float *input0,
float *output0,
PluginDef *p) {
849 if (!
self.conv.compute(count,output0)) {
854 int CabinetConvolver::register_cab(
const ParamReg& reg) {
856 reg.
registerIEnumVar(
"cab.select",
"select",
"B",
"", cab.cab_names, &cab.cabinet, 0);
857 reg.
registerVar(
"cab.Level",
N_(
"Level"),
"S",
N_(
"Level"), &cab.level, 1.0, 0.5, 5.0, 0.5);
858 reg.
registerVar(
"cab.bass",
N_(
"Bass"),
"S",
N_(
"Bass"), &cab.bass, 0.0, -10.0, 10.0, 0.5);
859 reg.
registerVar(
"cab.treble",
N_(
"Treble"),
"S",
N_(
"Treble"), &cab.treble, 0.0, -10.0, 10.0, 0.5);
860 cab.impf.register_par(reg);
866 static int cab_load_stereo_ui(
const UiBuilder& builder,
int format) {
904 for (
unsigned int i = 0; i < cab_table_size; ++i) {
909 cab_names[cab_table_size].
value_id = 0;
923 bool CabinetStereoConvolver::do_update() {
924 bool configure = cabinet_changed();
925 if (conv.is_runnable()) {
926 conv.set_not_runnable();
931 if (current_cab == -1) {
932 impf.init(cab.
ir_sr);
935 impf.clear_state_f();
937 while (!conv.checkstate());
939 if (!conv.configure_stereo(cab.
ir_count, cab_irdata_c, cab.
ir_sr)) {
943 if (!conv.update_stereo(cab.
ir_count, cab_irdata_c, cab.
ir_sr)) {
952 bool CabinetStereoConvolver::start(
bool force) {
956 if (cabinet_changed() || sum_changed()) {
959 while (!conv.checkstate());
960 if (!conv.is_runnable()) {
967 void CabinetStereoConvolver::check_update() {
968 if (cabinet_changed() || sum_changed()) {
973 void CabinetStereoConvolver::run_cab_conf(
int count,
float *input0,
float *input1,
float *output0,
float *output1,
PluginDef *p) {
975 if (!
self.conv.compute_stereo(count,output0,output1)) {
980 int CabinetStereoConvolver::register_cab(
const ParamReg& reg) {
982 reg.
registerIEnumVar(
"cab_st.select",
"select",
"B",
"", cab.cab_names, &cab.cabinet, 0);
983 reg.
registerVar(
"cab_st.Level",
N_(
"Level"),
"S",
N_(
"Level"), &cab.level, 1.0, 0.5, 5.0, 0.5);
984 reg.
registerVar(
"cab_st.bass",
N_(
"Bass"),
"S",
N_(
"Bass"), &cab.bass, 0.0, -10.0, 10.0, 0.5);
985 reg.
registerVar(
"cab_st.treble",
N_(
"Treble"),
"S",
N_(
"Treble"), &cab.treble, 0.0, -10.0, 10.0, 0.5);
986 cab.impf.register_par(reg);
1000 template <
int tab_size>
1004 float ir_data[tab_size];
1015 {
"AC30",
N_(
"AC30 Style"), &
static_cast<PreDesc&
>(pre_data_ac30) },
1016 {
"Bassman",
N_(
"Bassman Style"), &
static_cast<PreDesc&
>(pre_data_bassman) },
1017 {
"Tube",
N_(
"Tube Style"), &
static_cast<PreDesc&
>(pre_data_tube) },
1018 {
"Fender",
N_(
"Fender Style"), &
static_cast<PreDesc&
>(pre_data_fender) },
1019 {
"JCM800",
N_(
"JCM800 Style"), &
static_cast<PreDesc&
>(pre_data_jcm800) },
1020 {
"JTM45",
N_(
"JTM45 Style"), &
static_cast<PreDesc&
>(pre_data_jtm45) },
1021 {
"Mesa Boogie",
N_(
"Mesa Boogie Style"), &
static_cast<PreDesc&
>(pre_data_mesaboogie) },
1022 {
"Boutique",
N_(
"Boutique Style"), &
static_cast<PreDesc&
>(pre_data_boutique) },
1023 {
"Ampeg",
N_(
"Ampeg Style"), &
static_cast<PreDesc&
>(pre_data_ampeg) },
1024 {
"Rectifier",
N_(
"Rectifier Style"), &
static_cast<PreDesc&
>(pre_data_rectifier) },
1028 static PreEntry& getPreEntry(
unsigned int n) {
1029 if (n >= pre_table_size) {
1030 n = pre_table_size - 1;
1035 #include "faust/preamp_impulse_former.cc" 1037 static int pre_load_ui(
const UiBuilder& builder,
int format) {
1075 for (
unsigned int i = 0; i < pre_table_size; ++i) {
1080 pre_names[pre_table_size].
value_id = 0;
1083 name =
N_(
"Amp Impulse");
1094 bool PreampConvolver::do_update() {
1095 bool configure = preamp_changed();
1096 if (conv.is_runnable()) {
1097 conv.set_not_runnable();
1099 conv.stop_process();
1102 if (current_pre == -1) {
1103 impf.init(pre.
ir_sr);
1106 impf.clear_state_f();
1108 while (!conv.checkstate());
1110 if (!conv.configure(pre.
ir_count, pre_irdata_c, pre.
ir_sr)) {
1123 bool PreampConvolver::start(
bool force) {
1127 if (preamp_changed() || sum_changed()) {
1130 while (!conv.checkstate());
1131 if (!conv.is_runnable()) {
1138 void PreampConvolver::check_update() {
1139 if (preamp_changed() || sum_changed()) {
1144 void PreampConvolver::run_pre_conf(
int count,
float *input0,
float *output0,
PluginDef *p) {
1146 if (!
self.conv.compute(count, output0)) {
1151 int PreampConvolver::register_pre(
const ParamReg& reg) {
1153 reg.
registerIEnumVar(
"pre.select",
"select",
"B",
"", pre.pre_names, &pre.preamp, 0);
1154 reg.
registerVar(
"pre.Level",
N_(
"Level"),
"S",
N_(
"Level"), &pre.level, 1.0, 0.1, 2.1, 0.1);
1155 reg.
registerVar(
"pre.bass",
N_(
"Bass"),
"S",
N_(
"Bass"), &pre.bass, 0.0, -10.0, 10.0, 0.5);
1156 reg.
registerVar(
"pre.treble",
N_(
"Treble"),
"S",
N_(
"Treble"), &pre.treble, 0.0, -10.0, 10.0, 0.5);
1157 pre.impf.register_par(reg);
1165 #include "faust/presence_level.cc" 1173 name =
N_(
"Contrast convolver");
1181 bool ContrastConvolver::do_update() {
1182 bool configure = (sum == no_sum);
1183 if (conv.is_runnable()) {
1184 conv.set_not_runnable();
1186 conv.stop_process();
1189 presl.init(contrast_ir_desc.ir_sr);
1191 float contrast_irdata_c[contrast_ir_desc.ir_count];
1192 presl.compute(contrast_ir_desc.ir_count,contrast_ir_desc.ir_data,contrast_irdata_c);
1193 while (!conv.checkstate());
1195 if (!conv.configure(contrast_ir_desc.ir_count, contrast_irdata_c, contrast_ir_desc.ir_sr)) {
1199 if (!conv.update(contrast_ir_desc.ir_count, contrast_irdata_c, contrast_ir_desc.ir_sr)) {
1207 bool ContrastConvolver::start(
bool force) {
1211 if (sum_changed()) {
1214 while (!conv.checkstate());
1215 if (!conv.is_runnable()) {
1222 void ContrastConvolver::check_update() {
1223 if (sum_changed()) {
1228 int ContrastConvolver::register_con(
const ParamReg& reg) {
1230 reg.
registerVar(
"con.Level",
"",
"S",
"", &
self.level, 1.0, 0.5, 5.0, 0.5);
1231 self.presl.register_par(reg);
1235 void ContrastConvolver::run_contrast(
int count,
float *input0,
float *output0,
PluginDef *p) {
1237 if (!
self.conv.compute(count,output0)) {
1277 bool smbPitchShift::setParameters(
int sampleRate_)
1280 fftFrameSize = numSampsToProcess/4;
1281 sampleRate = int(sampleRate_);
1282 assert(sampleRate>0);
1285 osamp2 = 2.*
M_PI*osamp1;
1286 mpi = (1./(2.*
M_PI)) * osamp;
1295 resamp.setup(sampleRate,4);
1296 gRover = inFifoLatency;
1303 mem_allocated(false),
1318 id =
"smbPitchShift";
1332 sigc::mem_fun(*
this, &smbPitchShift::change_buffersize));
1335 void smbPitchShift::init(
unsigned int samplingFreq,
PluginDef *plugin) {
1340 void smbPitchShift::clear_state()
1342 stepSize = fftFrameSize/osamp;
1343 freqPerBin = (double)(sampleRate/4)/(double)fftFrameSize;
1344 freqPerBin1 = (1/freqPerBin)*osamp2;
1345 freqPerBin2 = freqPerBin*mpi;
1346 expct = 2.*
M_PI*(double)stepSize/(
double)fftFrameSize;
1347 inFifoLatency = fftFrameSize-stepSize;
1348 fftFrameSize3 = 2. * (1./ ((double)(fftFrameSize2)*osamp));
1349 fftFrameSize4 = 1./(double)fftFrameSize;
1361 for (k = 0; k < fftFrameSize2;k++) {
1362 fpb[k] = (double)k*freqPerBin;
1364 for (k = 0; k < fftFrameSize2;k++) {
1365 expect[k] = (double)k*expct;
1367 for (k = 0; k < fftFrameSize;k++) {
1368 hanning[k] = 0.5*(1-cos(2.*
M_PI*(
double)k/((
double)fftFrameSize)));
1370 for (k = 0; k < fftFrameSize;k++) {
1371 hanningd[k] = 0.5*(1-cos(2.*
M_PI*(
double)k * fftFrameSize4)) * fftFrameSize3;
1373 for (k = 0; k < fftFrameSize;k++) {
1376 for (k = 0; k < fftFrameSize;k++) {
1379 for (k = 0; k < fftFrameSize*4;k++) {
1382 for (k = 0; k < fftFrameSize*4;k++) {
1385 gRover = inFifoLatency;
1386 mem_allocated =
true;
1390 void smbPitchShift::mem_alloc()
1393 assert(numSampsToProcess>0);
1394 numSampsToResamp = numSampsToProcess/4;
1396 assert(sampleRate>0);
1400 if (numSampsToProcess <= 2048) {
1401 fftFrameSize = 512 ;
1403 fftFrameSize = numSampsToProcess*0.25 ;
1407 fftFrameSize = numSampsToProcess;
1410 fftFrameSize = numSampsToProcess*0.25;
1413 if (numSampsToProcess <= 2048) {
1414 fftFrameSize = 512 ;
1416 fftFrameSize = numSampsToProcess*0.25 ;
1420 fftFrameSize2 = fftFrameSize/2;
1424 ftPlanForward = fftwf_plan_dft_1d(fftFrameSize, fftw_in, fftw_out, FFTW_FORWARD, FFTW_ESTIMATE);
1425 ftPlanInverse = fftwf_plan_dft_1d(fftFrameSize, fftw_in, fftw_out, FFTW_BACKWARD, FFTW_ESTIMATE);
1427 fpb =
new float[fftFrameSize2];
1428 expect =
new float[fftFrameSize2];
1429 hanning =
new float[fftFrameSize];
1430 hanningd =
new float[fftFrameSize];
1431 resampin =
new float[fftFrameSize];
1432 resampin2 =
new float[fftFrameSize];
1433 resampout =
new float[fftFrameSize*4];
1434 indata2 =
new float[fftFrameSize*4];
1442 void smbPitchShift::mem_free()
1445 mem_allocated =
false;
1446 if (fpb) {
delete fpb; fpb = 0; }
1447 if (expect) {
delete expect; expect = 0; }
1448 if (hanning) {
delete hanning; hanning = 0; }
1449 if (hanningd) {
delete hanningd; hanningd = 0; }
1450 if (resampin) {
delete resampin; resampin = 0; }
1451 if (resampin2) {
delete resampin2; resampin2 = 0; }
1452 if (resampout) {
delete resampout; resampout = 0; }
1453 if (indata2) {
delete indata2; indata2 = 0; }
1455 {fftwf_destroy_plan(ftPlanForward);ftPlanForward = 0; }
1457 { fftwf_destroy_plan(ftPlanInverse);ftPlanInverse = 0; }
1460 int smbPitchShift::activate(
bool start)
1463 if (!mem_allocated) {
1466 }
else if (mem_allocated) {
1472 void smbPitchShift::change_buffersize(
unsigned int size)
1476 if (mem_allocated) {
1482 void smbPitchShift::change_latency()
1486 if (mem_allocated) {
1494 if (mem_allocated) {
1500 void __rt_func smbPitchShift::compute_static(
int count,
float *input0,
float *output0,
PluginDef *p)
1502 static_cast<smbPitchShift*
>(p)->PitchShift(count, input0, output0);
1506 void always_inline smbPitchShift::PitchShift(
int count,
float *indata,
float *outdata)
1509 if (!ready || count != numSampsToProcess) {
1510 if (indata != outdata)
1512 memcpy(outdata,indata,count*
sizeof(
float));
1517 resamp.
down(numSampsToResamp,indata,resampin);
1518 double fSlow0 = (0.01 * wet);
1519 double fSlow1 = (0.01 * dry);
1522 for (i = 0; i < count; i++){
1523 indata2[ii] = indata[i];
1527 for (i = 0; i < numSampsToResamp; i++){
1528 resampin2[ai] = resampin[i];
1532 if (ai>=fftFrameSize) {
1549 float pitchShift = pow(2., (semitones+tone)*0.0833333333);
1551 for (i = 0; i < fftFrameSize; i++){
1554 float fTemp = resampin2[i];
1555 gInFIFO[gRover] = fTemp;
1556 resampin2[i] = gOutFIFO[gRover-inFifoLatency];
1560 if (gRover >= fftFrameSize) {
1561 gRover = inFifoLatency;
1564 for (k = 0; k < fftFrameSize;k++) {
1565 fftw_in[k][0] = gInFIFO[k] * hanning[k];
1566 fftw_in[k][1] = 0.0;
1572 fftwf_execute(ftPlanForward);
1575 for (k = 0; k < fftFrameSize2; k++) {
1578 real = fftw_out[k][0];
1579 imag = fftw_out[k][1];
1582 magn = 2.*sqrt(real*real + imag*imag);
1583 phase = atan2(imag,real);
1586 tmp = phase - gLastPhase[k];
1587 gLastPhase[k] = phase;
1594 if (qpd >= 0) qpd += qpd&1;
1596 tmp -=
M_PI*(double)qpd;
1600 tmp = fpb[k] + tmp*freqPerBin2;
1610 memset(gSynMagn, 0, fftFrameSize*
sizeof(
float));
1611 memset(gSynFreq, 0, fftFrameSize*
sizeof(
float));
1612 for (k = 1; k < fftFrameSize2-2; k++) {
1613 index = k*pitchShift;
1614 if (index < fftFrameSize2) {
1615 if (index < fftFrameSize2*0.20)
1616 gSynMagn[index] += gAnaMagn[k]*a;
1617 else if (index < fftFrameSize2*0.45)
1618 gSynMagn[index] += gAnaMagn[k]*b;
1619 else if (index < fftFrameSize2*0.667)
1620 gSynMagn[index] += gAnaMagn[k]*c;
1622 gSynMagn[index] += gAnaMagn[k]*d;
1623 gSynFreq[index] = gAnaFreq[k] * pitchShift;
1629 for (k = 0; k < fftFrameSize2; k++) {
1639 tmp = ((gSynFreq[k] - fpb[k]) * freqPerBin1) + expect[k];
1642 gSumPhase[k] += tmp;
1643 phase = gSumPhase[k];
1644 if (magn == 0.0)
continue;
1647 fftw_in[k][0] = magn * cos (phase);
1648 fftw_in[k][1] = magn * sin (phase);
1652 fftwf_execute(ftPlanInverse);
1654 for(k=0; k < fftFrameSize; k++) {
1655 gOutputAccum[k] += hanningd[k] * fftw_out[ k][0] ;
1657 for (k = 0; k < stepSize; k++) gOutFIFO[k] = gOutputAccum[k];
1660 memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameSize*
sizeof(
float));
1663 for (k = 0; k < inFifoLatency; k++) gInFIFO[k] = gInFIFO[k+stepSize];
1666 resamp.
up(fftFrameSize,resampin2,resampout);
1670 for (i = 0; i < count; i++){
1671 outdata[i] = ((fSlow0 * resampout[aio]) + (fSlow1 *indata2[aio]));
1675 for (i = 0; i < count; i++){
1676 outdata[i] = ((fSlow0 * resampout[aio]) + (fSlow1 *indata[i]));
1682 int smbPitchShift::register_par(
const ParamReg& reg)
1684 reg.
registerVar(
"smbPitchShift.semitone",
N_(
"Detune"),
"S",
"", &semitones, 0.0, -12., 12., 0.1);
1685 static const value_pair octave_values[] = {{
"unison"},{
"octave up"},{
"octave down"},{0}};
1686 reg.
registerIEnumVar(
"smbPitchShift.octave",
N_(
"add harmonics"),
"B",
N_(
"add harmonics"),octave_values,&octave, 0);
1687 static const value_pair latency_values[] = {{
"latency "},{
"compensate"},{0}};
1688 reg.
registerEnumVar(
"smbPitchShift.l",
N_(
"compensate latency"),
"S",
N_(
"compensate latency"),latency_values,&l, 0.0f, 0.0f, 1.0f, 1.0f);
1689 static const value_pair latency_set[] = {{
"high quality"},{
"low quality"},{
"realtime"},{0}};
1690 reg.
registerIEnumVar(
"smbPitchShift.latency",
N_(
"latency settings"),
"B",
N_(
"latency settings"),latency_set,&latency, 0);
1691 reg.
registerVar(
"smbPitchShift.wet",
N_(
"Wet"),
"S",
N_(
"Wet amount"), &wet, 50.0, 0.0, 100.0, 1);
1692 reg.
registerVar(
"smbPitchShift.dry",
N_(
"Dry"),
"S",
N_(
"Dry amount"), &dry, 50.0, 0.0, 100.0, 1);
1693 reg.
registerVar(
"smbPitchShift.a",
N_(
"low"),
"S",
N_(
"Sub"), &a, 1.0, 0.0, 2.0, 0.01);
1694 reg.
registerVar(
"smbPitchShift.b",
N_(
"middle low"),
"S",
N_(
"Low"), &b, 1.0, 0.0, 2.0, 0.01);
1695 reg.
registerVar(
"smbPitchShift.c",
N_(
"middle treble"),
"S",
N_(
"Mid"), &c, 1.0, 0.0, 2.0, 0.01);
1696 reg.
registerVar(
"smbPitchShift.d",
N_(
"treble"),
"S",
N_(
"Hi"), &d, 1.0, 0.0, 2.0, 0.01);
1697 param[
"smbPitchShift.latency"].signal_changed_int().connect(
1698 sigc::hide(sigc::mem_fun(
this, &smbPitchShift::change_latency)));
1702 int smbPitchShift::registerparam(
const ParamReg& reg)
1707 int smbPitchShift::load_ui_f(
const UiBuilder& b,
int form)
1757 int smbPitchShift::activate_static(
bool start,
PluginDef *p)
1762 int smbPitchShift::load_ui_f_static(
const UiBuilder& b,
int form)
1767 void smbPitchShift::del_instance(
PluginDef *p)
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)
bool set(const GxJConvSettings &val) const
virtual bool on_off_value()
BasicOptions & get_options()
ParameterV< GxJConvSettings > JConvParameter
void end_array(bool nl=false)
static int activate(bool start, PluginDef *pdef)
virtual void overload(OverloadType tp, const char *reason)=0
virtual void writeJSON(gx_system::JsonWriter &jw) const
struct gx_engine::CabEntry cab_table[]
void set_pdef(PluginDef *p)
const PrefixConverter & get_IR_prefixmap() 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)
void change_buffersize(unsigned int)
void write_key(const char *p, bool nl=false)
void set_on_off(bool v) const
void(* load_glade_file)(const char *fname)
bool find_dir(std::string *d, const std::string &filename) const
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
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)
std::string getFullIRPath() const
CabinetConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
#define PLUGINDEF_VERSION
void(* openHorizontalBox)(const char *label)
registerfunc register_params
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
const PathList & get_IR_pathlist() const
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)
std::string replace_symbol(const std::string &dir) const
void(* create_mid_rackknob)(const char *id, const char *label)
boost::mutex activate_mutex
void setFullIRPath(string name)
const Gainline & getGainline() const
ContrastConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
unsigned int get_samplerate()
void gx_print_warning(const char *, const std::string &)
void(* openHorizontalhideBox)(const char *label)
ConvolverAdapter(EngineControl &engine, sigc::slot< void > sync, ParamMap ¶m)
virtual void stdJSON_value()
activatefunc activate_plugin
virtual void check_update()=0
process_stereo_audio stereo_audio
void readJSON(gx_system::JsonParser &jp)
void(* set_next_flags)(int flags)
process_mono_audio mono_audio
virtual void serializeJSON(gx_system::JsonWriter &jw)
GxJConvSettings & operator=(GxJConvSettings const &jcset)
string current_value() const
unsigned int get_buffersize()
~ConvolverStereoAdapter()
float current_value_float()
bool operator==(const GxJConvSettings &jcset) const
void writeJSON(gx_system::JsonWriter &w) const
token next(token expect=no_token)
void write(float v, bool nl=false)
struct gx_engine::PreEntry pre_table[]
virtual bool compareJSON_value()
static ParameterV< GxJConvSettings > * insert_param(ParamMap &pmap, const string &id, ConvolverAdapter &conv, GxJConvSettings *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)
sigc::signal< void, unsigned int > & signal_buffersize_change()