Skip to content

Commit c90f733

Browse files
committed
Fix issue #28, implement option to move EQ to make it pre/post EQ
1 parent 0572a99 commit c90f733

File tree

12 files changed

+477
-7
lines changed

12 files changed

+477
-7
lines changed

NeuralRack/clap/NeuralRack.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class NeuralRack
4343
ui->setVerbose = false;
4444
ui->uiSampleRate = 0;
4545
ui->f_index = 0;
46+
ui->glowY = 0;
4647
title = "NeuralRack";
4748
firstLoop = true;
4849
p = 0;
@@ -195,7 +196,10 @@ class NeuralRack
195196

196197
// check output ports from engine
197198
void checkEngine() {
198-
199+
200+
vsg_update(&ui->g, 1.0f / 60.0f);
201+
if(ui->g.newIndex != engine.eqPos) engine.setEQPos(ui->g.newIndex);
202+
199203
if (workToDo.load(std::memory_order_acquire)) {
200204
if (engine.xrworker.getProcess()) {
201205
workToDo.store(false, std::memory_order_release);
@@ -479,6 +483,15 @@ class NeuralRack
479483
workToDo.store(true, std::memory_order_release);
480484
}
481485

486+
void setEQPos(int pos) {
487+
int oldPos = vsg_findDragIndex(&ui->g, ui->elem[3]);
488+
if (oldPos != pos) {
489+
ui->g.dragWidget = ui->elem[3];
490+
ui->g.oldIndex = oldPos;
491+
ui->g.newIndex = pos;
492+
vsg_endDrag(&ui->g);
493+
}
494+
}
482495

483496
float check_stod (const std::string& str) {
484497
char* point = localeconv()->decimal_point;
@@ -572,6 +585,9 @@ class NeuralRack
572585
} else if (key.compare("[IrFile1]") == 0) {
573586
engine.ir_file1 = remove_sub(line, "[IrFile1] ");
574587
engine._cd.fetch_add(2, std::memory_order_relaxed);
588+
} else if (key.compare("[EQPos]") == 0) {
589+
engine.eqPos = check_stod(remove_sub(line, "[EQPos] "));
590+
setEQPos(engine.eqPos);
575591
}
576592
key.clear();
577593
value.clear();
@@ -621,6 +637,7 @@ class NeuralRack
621637
buffer << "[Model1] " << engine.model_file1 << "|";
622638
buffer << "[IrFile] " << engine.ir_file << "|";
623639
buffer << "[IrFile1] " << engine.ir_file1 << "|";
640+
buffer << "[EQPos] " << engine.eqPos << "|";
624641
(*state) = buffer.str();
625642
}
626643

NeuralRack/engine/engine.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class Engine
119119
uint32_t s_rate;
120120
uint32_t bufsize;
121121
uint32_t buffersize;
122+
uint32_t eqPos;
122123
uint32_t eqOnOff;
123124
uint32_t ngOnOff;
124125
uint32_t IRmode;
@@ -142,6 +143,7 @@ class Engine
142143
inline ~Engine();
143144

144145
inline void init(uint32_t rate, int32_t rt_prio_, int32_t rt_policy_);
146+
inline void setEQPos(uint32_t _eqPos);
145147
inline void clean_up();
146148
inline void do_work_mono();
147149
inline void process(uint32_t n_samples, float* output, float* output1);
@@ -171,6 +173,7 @@ class Engine
171173
inline void processConv1();
172174
inline void processBuffer();
173175
inline void processSlotB(float* output);
176+
inline void processEQ(uint32_t n_samples, float* output);
174177
inline void processBufferedSlotB();
175178
inline void processDsp(uint32_t n_samples, float* output, float* output1);
176179

@@ -199,6 +202,7 @@ inline Engine::Engine() :
199202
buffersize = 0;
200203
phaseOffset = 0;
201204
bypass = 0;
205+
eqPos = 1;
202206
eqOnOff = 0;
203207
ngOnOff = 0;
204208
IRmode = 0;
@@ -301,6 +305,11 @@ void Engine::clean_up()
301305
// delete the internal DSP mem
302306
}
303307

308+
inline void Engine::setEQPos(uint32_t _eqPos) {
309+
peq->clear_state_f();
310+
eqPos = _eqPos;
311+
}
312+
304313
inline void Engine::setModel(NeuralModelLoader *slot,
305314
std::string *file, std::atomic<bool> *set) {
306315
if ((*file).compare(slot->getModelFile()) != 0) {
@@ -428,6 +437,10 @@ inline void Engine::processBufferedSlotB() {
428437
processSlotB(bufferoutput0);
429438
}
430439

440+
inline void Engine::processEQ(uint32_t n_samples, float* output) {
441+
peq->compute(n_samples, output, output);
442+
}
443+
431444
inline void Engine::processDsp(uint32_t n_samples, float* output, float* output1)
432445
{
433446
if(n_samples<1) return;
@@ -449,6 +462,9 @@ inline void Engine::processDsp(uint32_t n_samples, float* output, float* output1
449462
if (ngOnOff)
450463
ngate->compute(n_samples, output);
451464

465+
// run eq
466+
if (eqOnOff && eqPos == 0) processEQ(n_samples, output);
467+
452468
// process input volume slot A
453469
if (_neuralA.load(std::memory_order_acquire)) {
454470
for (uint32_t i0 = 0; i0 < n_samples; i0 = i0 + 1) {
@@ -474,8 +490,7 @@ inline void Engine::processDsp(uint32_t n_samples, float* output, float* output1
474490
}
475491

476492
// run eq
477-
if (eqOnOff)
478-
peq->compute(n_samples, output, output);
493+
if (eqOnOff && eqPos == 1) processEQ(n_samples, output);
479494

480495
if ((buffered == 1.0) && bufferIsInit.load(std::memory_order_acquire)) {
481496
// avoid buffer overflow on frame size change
@@ -513,6 +528,9 @@ inline void Engine::processDsp(uint32_t n_samples, float* output, float* output1
513528
if (!buffered) latency = 0.0;
514529
}
515530

531+
// run eq
532+
if (eqOnOff && eqPos == 2) processEQ(n_samples, output);
533+
516534
// run dcblocker
517535
dcb->compute(n_samples, output, output);
518536

NeuralRack/gui/NeuralRack.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ static void file_menu_callback(void *w_, void* user_data) {
133133
file_load_response(m->filebutton, (void*)&ps->fname);
134134
}
135135

136+
void setFrameCallbacks(Widget_t *frame) {
137+
frame->func.button_press_callback = drag_frame;
138+
frame->func.motion_callback = move_frame;;
139+
frame->func.button_release_callback = drop_frame;
140+
}
141+
136142
void plugin_set_window_size(int *w,int *h,const char * plugin_uri) {
137143
(*w) = 620; //set initial width of main window
138144
(*h) = 580; //set initial height of main window
@@ -184,6 +190,9 @@ void plugin_create_controller_widgets(X11_UI *ui, const char * plugin_uri) {
184190

185191
ui->widget[10] = add_lv2_switch (ui->widget[10], ui->win, 14, "Enable", ui, 505, 12, 50, 50);
186192

193+
ui->glowY = 0;
194+
vsg_init(&ui->g, ui->win, 10, 130, 0, &ui->glowY);
195+
187196
// noisegate
188197
ui->elem[4] = create_widget(&ui->main, ui->win, 10, 60, 600, 70);
189198
ui->elem[4]->parent_struct = ui;
@@ -210,10 +219,11 @@ void plugin_create_controller_widgets(X11_UI *ui, const char * plugin_uri) {
210219
set_widget_color(ui->widget[25], (Color_state)1, (Color_mod)0, 0.335, 0.315, 0.382, 1.0);
211220

212221
// slot A Pedal Profile
213-
ui->elem[0] = create_widget(&ui->main, ui->win, 10, 130, 600, 110);
222+
vsg_add(&ui->g, ui->elem[0] = create_widget(&ui->main, ui->win, 10, 60, 600, 110));
214223
ui->elem[0]->parent_struct = ui;
215224
ui->elem[0]->label = "Pedal Profile";
216225
ui->elem[0]->data = 1;
226+
//setFrameCallbacks(ui->elem[0]);
217227
// rack mount background colour
218228
set_widget_color(ui->elem[0], (Color_state)0, (Color_mod)1, 0.306, 0.510, 0.584, 1.0);
219229
// rack mount foreground colour
@@ -254,9 +264,10 @@ void plugin_create_controller_widgets(X11_UI *ui, const char * plugin_uri) {
254264
ui->widget[11] = add_lv2_erase_button (ui->widget[11], ui->elem[0], 15, "", ui, 390, 48, 25, 25);
255265

256266
// EQ
257-
ui->elem[3] = create_widget(&ui->main, ui->win, 10, 240, 600, 110);
267+
vsg_add(&ui->g, ui->elem[3] = create_widget(&ui->main, ui->win, 10, 60, 600, 110));
258268
ui->elem[3]->parent_struct = ui;
259269
ui->elem[3]->label = "6 Band EQ";
270+
setFrameCallbacks(ui->elem[3]);
260271
// rack mount background colour
261272
set_widget_color(ui->elem[3], (Color_state)0, (Color_mod)1, 0.569, 0.271, 0.310,1.0);
262273
// rack mount foreground colour
@@ -322,10 +333,11 @@ void plugin_create_controller_widgets(X11_UI *ui, const char * plugin_uri) {
322333
set_widget_color(ui->widget[23], (Color_state)1, (Color_mod)0, 0.694, 0.714, 0.737, 1.0);
323334

324335
// sloat B Amp Profile
325-
ui->elem[1] = create_widget(&ui->main, ui->win, 10, 350, 600, 110);
336+
vsg_add(&ui->g, ui->elem[1] = create_widget(&ui->main, ui->win, 10, 60, 600, 110));
326337
ui->elem[1]->parent_struct = ui;
327338
ui->elem[1]->label = "Amp Profile";
328339
ui->elem[1]->data = 2;
340+
//setFrameCallbacks(ui->elem[1]);
329341
// rack mount background colour
330342
set_widget_color(ui->elem[1], (Color_state)0, (Color_mod)1, 0.725, 0.592, 0.388, 1.0);
331343
// rack mount foreground colour
@@ -465,6 +477,7 @@ void plugin_cleanup(X11_UI *ui) {
465477
free(ps->ir.filepicker);
466478
fp_free(ps->ir1.filepicker);
467479
free(ps->ir1.filepicker);
480+
vsg_destroy(&ui->g);
468481
// clean up used sources when needed
469482
}
470483

0 commit comments

Comments
 (0)