Skip to content

Commit

Permalink
Prepare for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer10 committed Jul 17, 2024
1 parent f1a5384 commit d6ec09c
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 35 deletions.
Binary file modified Ratatouille.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions Ratatouille/Ratatouille.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,19 +333,19 @@ void plugin_create_controller_widgets(X11_UI *ui, const char * plugin_uri) {
asprintf(&ps->ir1.filepicker->filter ,"%s", ".wav");
ps->ir1.filepicker->use_filter = 1;

ps->ma.filebutton = add_lv2_file_button (ps->ma.filebutton, ui->win, -1, "Neural Model", ui, 25, 254, 60, 30);
ps->ma.filebutton = add_lv2_file_button (ps->ma.filebutton, ui->win, -1, "Neural Model", ui, 40, 258, 25, 25);
ps->ma.filebutton->parent_struct = (void*)&ps->ma;
ps->ma.filebutton->func.user_callback = file_load_response;

ps->mb.filebutton = add_lv2_file_button (ps->mb.filebutton, ui->win, -2, "Neural Model", ui, 25, 294, 60, 30);
ps->mb.filebutton = add_lv2_file_button (ps->mb.filebutton, ui->win, -2, "Neural Model", ui, 40, 298, 25, 25);
ps->mb.filebutton->parent_struct = (void*)&ps->mb;
ps->mb.filebutton->func.user_callback = file_load_response;

ps->ir.filebutton = add_lv2_irfile_button (ps->ir.filebutton, ui->win, -3, "IR File", ui, 25, 334, 60, 30);
ps->ir.filebutton = add_lv2_irfile_button (ps->ir.filebutton, ui->win, -3, "IR File", ui, 40, 338, 25, 25);
ps->ir.filebutton->parent_struct = (void*)&ps->ir;
ps->ir.filebutton->func.user_callback = file_load_response;

ps->ir1.filebutton = add_lv2_irfile_button (ps->ir1.filebutton, ui->win, -4, "IR File", ui, 25, 374, 60, 30);
ps->ir1.filebutton = add_lv2_irfile_button (ps->ir1.filebutton, ui->win, -4, "IR File", ui, 40, 378, 25, 25);
ps->ir1.filebutton->parent_struct = (void*)&ps->ir1;
ps->ir1.filebutton->func.user_callback = file_load_response;

Expand Down Expand Up @@ -374,25 +374,25 @@ void plugin_create_controller_widgets(X11_UI *ui, const char * plugin_uri) {
set_widget_color(ui->widget[1], 0, 0, 0.259, 0.518, 0.894, 1.0);
set_widget_color(ui->widget[1], 0, 3, 0.686, 0.729, 0.773, 1.0);

ps->ma.fbutton = add_lv2_button(ps->ma.fbutton, ui->win, "", ui, 450, 254, 22, 30);
ps->ma.fbutton = add_lv2_button(ps->ma.fbutton, ui->win, "", ui, 435, 254, 22, 30);
ps->ma.fbutton->parent_struct = (void*)&ps->ma;
combobox_set_pop_position(ps->ma.fbutton, 0);
combobox_add_entry(ps->ma.fbutton, "None");
ps->ma.fbutton->func.value_changed_callback = file_menu_callback;

ps->mb.fbutton = add_lv2_button(ps->mb.fbutton, ui->win, "", ui, 450, 294, 22, 30);
ps->mb.fbutton = add_lv2_button(ps->mb.fbutton, ui->win, "", ui, 435, 294, 22, 30);
ps->mb.fbutton->parent_struct = (void*)&ps->mb;
combobox_set_pop_position(ps->mb.fbutton, 0);
combobox_add_entry(ps->mb.fbutton, "None");
ps->mb.fbutton->func.value_changed_callback = file_menu_callback;

ps->ir.fbutton = add_lv2_button(ps->ir.fbutton, ui->win, "", ui, 450, 334, 22, 30);
ps->ir.fbutton = add_lv2_button(ps->ir.fbutton, ui->win, "", ui, 435, 334, 22, 30);
ps->ir.fbutton->parent_struct = (void*)&ps->ir;
combobox_set_pop_position(ps->ir.fbutton, 0);
combobox_add_entry(ps->ir.fbutton, "None");
ps->ir.fbutton->func.value_changed_callback = file_menu_callback;

ps->ir1.fbutton = add_lv2_button(ps->ir1.fbutton, ui->win, "", ui, 450, 374, 22, 30);
ps->ir1.fbutton = add_lv2_button(ps->ir1.fbutton, ui->win, "", ui, 435, 374, 22, 30);
ps->ir1.fbutton->parent_struct = (void*)&ps->ir1;
combobox_set_pop_position(ps->ir1.fbutton, 0);
combobox_add_entry(ps->ir1.fbutton, "None");
Expand Down
20 changes: 12 additions & 8 deletions Ratatouille/gx_convolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void ConvolverWorker::set_priority() {
fprintf(stderr, "ConvolverWorker: fail to set priority\n");
}
#else
//system does not supports thread priority!
//system does not supports thread priority!
#endif
}

Expand Down Expand Up @@ -510,6 +510,7 @@ void ConvolverWorker::run() {
if (_execute.load(std::memory_order_acquire)) {
_xr.doBackgroundProcessing();
_xr.co.notify_one();
_xr.setWait.store(false, std::memory_order_release);
}
}
// when done
Expand All @@ -527,12 +528,10 @@ bool ConvolverWorker::is_running() const noexcept {

void DoubleThreadConvolver::startBackgroundProcessing()
{
//fprintf(stderr, "startBackgroundProcessing\n");
if (work.is_running()) {
timePoint = std::chrono::steady_clock::now() + timeoutPeriod;
setWait.store(true, std::memory_order_release);
work.cv.notify_one();
std::unique_lock<std::mutex> lk(mo);
if (co.wait_until(lk, timePoint) == std::cv_status::timeout)
fprintf(stderr, "Convolver: overrun, time out!!\n");
} else {
doBackgroundProcessing();
}
Expand All @@ -541,8 +540,13 @@ void DoubleThreadConvolver::startBackgroundProcessing()

void DoubleThreadConvolver::waitForBackgroundProcessing()
{
timePoint = std::chrono::steady_clock::now() + timeoutPeriod;
//fprintf(stderr, "waitForBackgroundProcessing\n");
if (setWait.load(std::memory_order_acquire)) {
if (work.is_running()) {
std::unique_lock<std::mutex> lk(mo);
if (co.wait_until(lk, timePoint) == std::cv_status::timeout)
fprintf(stderr, "Convolver: overrun, time out!!\n");
}
}
}

bool DoubleThreadConvolver::get_buffer(std::string fname, float **buffer, uint32_t *rate, int *asize)
Expand Down Expand Up @@ -600,7 +604,7 @@ bool DoubleThreadConvolver::get_buffer(std::string fname, float **buffer, uint32


bool DoubleThreadConvolver::configure(std::string fname, float gain, unsigned int delay, unsigned int offset,
unsigned int length, unsigned int size, unsigned int bufsize)
unsigned int length, unsigned int size, unsigned int bufsize)
{
float* abuf = NULL;
uint32_t arate = 0;
Expand Down
4 changes: 3 additions & 1 deletion Ratatouille/gx_convolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ class DoubleThreadConvolver: public ConvolverBase, public fftconvolver::TwoStage

DoubleThreadConvolver()
: resamp(), ready(false), samplerate(0), work(*this) {
timeoutPeriod = std::chrono::microseconds(2000);}
timeoutPeriod = std::chrono::microseconds(2000);
setWait.store(false, std::memory_order_release);}

~DoubleThreadConvolver() { reset(); work.stop();}

Expand All @@ -247,6 +248,7 @@ class DoubleThreadConvolver: public ConvolverBase, public fftconvolver::TwoStage
uint32_t buffersize;
uint32_t samplerate;
ConvolverWorker work;
std::atomic<bool> setWait;
std::chrono::time_point<std::chrono::steady_clock> timePoint;
std::chrono::microseconds timeoutPeriod;
bool get_buffer(std::string fname, float **buffer, uint32_t* rate, int* size);
Expand Down
84 changes: 66 additions & 18 deletions Ratatouille/lv2_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,35 +152,35 @@ static void draw_window(void *w_, void* user_data) {
cairo_stroke (w->crb);

cairo_set_source_rgba(w->crb, 0.1, 0.1, 0.1, 1);
round_rectangle(w->crb, 90 * w->app->hdpi, 254 * w->app->hdpi,
350 * w->app->hdpi, 30 * w->app->hdpi, 0.5);
round_rectangle(w->crb, 30 * w->app->hdpi, 254 * w->app->hdpi,
440 * w->app->hdpi, 30 * w->app->hdpi, 0.5);
cairo_fill_preserve (w->crb);
boxShadowInset(w->crb,90 * w->app->hdpi,254 * w->app->hdpi,
350 * w->app->hdpi, 30 * w->app->hdpi, true);
boxShadowInset(w->crb,30 * w->app->hdpi,254 * w->app->hdpi,
440 * w->app->hdpi, 30 * w->app->hdpi, true);
cairo_fill (w->crb);

cairo_set_source_rgba(w->crb, 0.1, 0.1, 0.1, 1);
round_rectangle(w->crb, 90 * w->app->hdpi, 294 * w->app->hdpi,
350 * w->app->hdpi, 30 * w->app->hdpi, 0.5);
round_rectangle(w->crb, 30 * w->app->hdpi, 294 * w->app->hdpi,
440 * w->app->hdpi, 30 * w->app->hdpi, 0.5);
cairo_fill_preserve (w->crb);
boxShadowInset(w->crb,90 * w->app->hdpi,294 * w->app->hdpi,
350 * w->app->hdpi, 30 * w->app->hdpi, true);
boxShadowInset(w->crb,30 * w->app->hdpi,294 * w->app->hdpi,
440 * w->app->hdpi, 30 * w->app->hdpi, true);
cairo_fill (w->crb);

cairo_set_source_rgba(w->crb, 0.1, 0.1, 0.1, 1);
round_rectangle(w->crb, 90 * w->app->hdpi, 334 * w->app->hdpi,
350 * w->app->hdpi, 30 * w->app->hdpi, 0.5);
round_rectangle(w->crb, 30 * w->app->hdpi, 334 * w->app->hdpi,
440 * w->app->hdpi, 30 * w->app->hdpi, 0.5);
cairo_fill_preserve (w->crb);
boxShadowInset(w->crb,90 * w->app->hdpi,334 * w->app->hdpi,
350 * w->app->hdpi, 30 * w->app->hdpi, true);
boxShadowInset(w->crb,30 * w->app->hdpi,334 * w->app->hdpi,
440 * w->app->hdpi, 30 * w->app->hdpi, true);
cairo_fill (w->crb);

cairo_set_source_rgba(w->crb, 0.1, 0.1, 0.1, 1);
round_rectangle(w->crb, 90 * w->app->hdpi, 374 * w->app->hdpi,
350 * w->app->hdpi, 30 * w->app->hdpi, 0.5);
round_rectangle(w->crb, 30 * w->app->hdpi, 374 * w->app->hdpi,
440 * w->app->hdpi, 30 * w->app->hdpi, 0.5);
cairo_fill_preserve (w->crb);
boxShadowInset(w->crb,90 * w->app->hdpi,374 * w->app->hdpi,
350 * w->app->hdpi, 30 * w->app->hdpi, true);
boxShadowInset(w->crb,30 * w->app->hdpi,374 * w->app->hdpi,
440 * w->app->hdpi, 30 * w->app->hdpi, true);
cairo_fill (w->crb);

use_text_color_scheme(w, NORMAL_);
Expand Down Expand Up @@ -590,7 +590,7 @@ void draw_my_button(void *w_, void* user_data) {
if (!w->state && (int)w->adj_y->value)
w->state = 3;

roundrec(w->crb,2.0, 4.0, width, height, height*0.33);
/* roundrec(w->crb,2.0, 4.0, width, height, height*0.33);
if(w->state==0) {
cairo_set_line_width(w->crb, 1.0);
Expand All @@ -615,7 +615,7 @@ void draw_my_button(void *w_, void* user_data) {
} else if (w->state==3) {
roundrec(w->crb,3.0, 4.0, width, height, height*0.33);
cairo_stroke(w->crb);
}
} */

float offset = 0.0;
if(w->state==0) {
Expand Down Expand Up @@ -677,6 +677,11 @@ static void my_fbutton_callback(void *w_, void* user_data) {
if (!filebutton->w) {
filebutton->w = open_file_dialog(w,filebutton->path,filebutton->filter);
filebutton->w->flags |= HIDE_ON_DELETE;
if (strcmp(filebutton->filter, ".wav") == 0) {
widget_set_title(filebutton->w, _("File Selector - Select Impulse Response"));
} else {
widget_set_title(filebutton->w, _("File Selector - Select Neural Model"));
}
#ifdef __linux__
Atom wmStateAbove = XInternAtom(w->app->dpy, "_NET_WM_STATE_ABOVE", 1 );
Atom wmNetWmState = XInternAtom(w->app->dpy, "_NET_WM_STATE", 1 );
Expand All @@ -703,6 +708,46 @@ static void my_fbutton_mem_free(void *w_, void* user_data) {
filebutton = NULL;
}

void draw_image_(Widget_t *w, int width_t, int height_t, float offset) {
int width, height;
os_get_surface_size(w->image, &width, &height);
//double half_width = (width/height >=2) ? width*0.5 : width;
double x = (double)width_t/(double)(width);
double y = (double)height_t/(double)height;
double x1 = (double)height/(double)height_t;
double y1 = (double)(width)/(double)width_t;
double off_set = offset*x1;
cairo_scale(w->crb, x,y);
cairo_set_source_surface (w->crb, w->image, off_set, off_set);
cairo_rectangle(w->crb,0, 0, height, height);
cairo_fill(w->crb);
cairo_scale(w->crb, x1,y1);
}

void draw_i_button(void *w_, void* user_data) {
Widget_t *w = (Widget_t*)w_;
if (!w) return;
Metrics_t metrics;
os_get_window_metrics(w, &metrics);
int width = metrics.width-5;
int height = metrics.height-5;
if (!metrics.visible) return;
if (w->image) {
float offset = 0.0;
if(w->state==1 && ! (int)w->adj_y->value) {
offset = 1.0;
} else if(w->state==1) {
offset = 2.0;
} else if(w->state==2) {
offset = 2.0;
} else if(w->state==3) {
offset = 1.0;
}

draw_image_(w, width, height,offset);
}
}

Widget_t *add_my_file_button(Widget_t *parent, int x, int y, int width, int height,
const char* label, const char *path, const char *filter) {
FileButton *filebutton = (FileButton*)malloc(sizeof(FileButton));
Expand All @@ -718,20 +763,23 @@ Widget_t *add_my_file_button(Widget_t *parent, int x, int y, int width, int heig
fbutton->func.mem_free_callback = my_fbutton_mem_free;
fbutton->func.value_changed_callback = my_fbutton_callback;
fbutton->func.dialog_callback = my_fdialog_response;
fbutton->func.expose_callback = draw_i_button;
return fbutton;
}


Widget_t* add_lv2_file_button(Widget_t *w, Widget_t *p, PortIndex index, const char * label,
X11_UI* ui, int x, int y, int width, int height) {
w = add_my_file_button(p, x, y, width, height, "neural", "", ".nam|.aidax|.json");
widget_get_png(w, LDVAR(neuraldir_png));
w->data = index;
return w;
}

Widget_t* add_lv2_irfile_button(Widget_t *w, Widget_t *p, PortIndex index, const char * label,
X11_UI* ui, int x, int y, int width, int height) {
w = add_my_file_button(p, x, y, width, height, "IR File", "", ".wav");
widget_get_png(w, LDVAR(wavdir_png));
w->data = index;
return w;
}
Expand Down
Binary file added Ratatouille/resources/neuraldir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ratatouille/resources/wavdir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ endif

clean:
@rm -f ./libxputty/xputty/resources/texture.png
@rm -f ./libxputty/xputty/resources/wavdir.png
@rm -f ./libxputty/xputty/resources/neuraldir.png

features:

0 comments on commit d6ec09c

Please sign in to comment.