Commit 39956a88 authored by Jaromír Mikeš's avatar Jaromír Mikeš

Imported Upstream version 20131119

parent 96db6d12
2013-11-19 (0.2.0) Robin Gareus <robin@gareus.org>
* include list of plugins & version with dist
* augment and submodules (see plugin.list)
* share robTK between meters.lv2 and sisco.lv2
2013-05-25 (0.1.1) Robin Gareus <robin@gareus.org>
* update submodules
2013-05-25 (0.1.0) Robin Gareus <robin@gareus.org>
* add midifilter.lv plugis
* add midifilter.lv2 plugins
2013-05-20 (0.0.1) Robin Gareus <robin@gareus.org>
* plugin collection
......
#!/usr/bin/make
VERSION ?=$(shell date +%Y%m%d)
SUBDIRS = balance.lv2 convoLV2 nodelay.lv2 xfade.lv2 midifilter.lv2 meters.lv2
SUBDIRS = balance.lv2 convoLV2 nodelay.lv2 xfade.lv2 \
midifilter.lv2 meters.lv2 sisco.lv2
all clean install uninstall: submodule_check $(SUBDIRS)
$(SUBDIRS)::
$(MAKE) -C $@ $(MAKECMDGOALS)
$(MAKE) -C $@ $(MAKECMDGOALS) RW=../robtk/
###############################################################################
......
......@@ -16,5 +16,5 @@ Installation on non-debian systems
```
make
sudo make install
sudo make install PREFIX=/usr
```
2013-11-19 (0.4.3) Robin Gareus <robin@gareus.org>
* explicit built-dep on openGL
2013-09-15 (0.4.2) Robin Gareus <robin@gareus.org>
* NaN protection
* align RMS to sine-wave (not square wave)
* implement GL-UI thread-synchronization
* fix possible memory-leak (when re-opening ui)
* update (C) and GPL (FSF address)
2013-06-12 (0.4.1) Robin Gareus <robin@gareus.org>
* resize-port sz:minimumSize (fix jack1 issue)
* do not include production-files (xcf) in tar dist
......
......@@ -64,7 +64,7 @@ endif
ifeq ($(IS_OSX), yes)
HAVE_UI=$(shell pkg-config --exists ftgl && echo $(FONT_FOUND))
else
HAVE_UI=$(shell pkg-config --exists glu ftgl && echo $(FONT_FOUND))
HAVE_UI=$(shell pkg-config --exists glu gl ftgl && echo $(FONT_FOUND))
endif
LV2UIREQ=
......@@ -86,8 +86,8 @@ ifeq ($(HAVE_UI), yes)
UI_TYPE=CocoaUI
else
UIDEPS+=pugl/pugl_x11.c
UICFLAGS+=`pkg-config --cflags glu`
UILIBS=pugl/pugl_x11.c -lX11 `pkg-config --libs glu`
UICFLAGS+=`pkg-config --cflags glu gl`
UILIBS=pugl/pugl_x11.c -lX11 `pkg-config --libs glu gl`
UI_TYPE=X11UI
endif
override CFLAGS+=`pkg-config --cflags ftgl`
......
This diff is collapsed.
......@@ -31,7 +31,7 @@
#define GM_GIRTH (ui->display_freq ? 8.0f : 12.0f)
#define GM_WIDTH (ui->display_freq ? 13.0f : 28.0f)
#define GM_HEIGHT (400.0f)
#define GM_HEIGHT (ui->display_freq ? 400.0f:460.0f)
#define GM_TXT (GM_HEIGHT - (ui->display_freq ? 52.0f : 8.0f))
#define GM_SCALE (GM_TXT - GM_TOP - GM_TOP + 2.0)
......@@ -339,7 +339,7 @@ static void alloc_annotations(SAUI* ui) {
cairo_t* cr;
if (ui->display_freq) {
/* frequecy table */
for (int i = 0; i < ui->num_meters; ++i) {
for (uint32_t i = 0; i < ui->num_meters; ++i) {
INIT_BLACK_BG(ui->an[i], 24, 64)
write_text(cr, freq_table[i], FONT_LBL, -1, 0, -M_PI/2, 7, c_g90);
cairo_destroy (cr);
......@@ -438,7 +438,7 @@ static void prepare_metersurface(SAUI* ui) {
cairo_stroke(cr); \
}
for (int i = 0; i < ui->num_meters; ++i) {
for (uint32_t i = 0; i < ui->num_meters; ++i) {
ALLOC_SF(ui->sf[i])
/* metric background */
......@@ -471,7 +471,7 @@ static void prepare_metersurface(SAUI* ui) {
}
}
static void render_meter(SAUI* ui, int i, int old, int new, int m_old, int m_new) {
static void render_meter(SAUI* ui, int i, int v_old, int v_new, int m_old, int m_new) {
cairo_t* cr = cairo_create (ui->sf[i]);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
......@@ -481,7 +481,7 @@ static void render_meter(SAUI* ui, int i, int old, int new, int m_old, int m_new
cairo_clip(cr);
cairo_set_source(cr, ui->mpat);
cairo_rectangle (cr, GM_LEFT, GM_TOP + GM_SCALE - new - 1, GM_GIRTH, new + 1);
cairo_rectangle (cr, GM_LEFT, GM_TOP + GM_SCALE - v_new - 1, GM_GIRTH, v_new + 1);
cairo_fill(cr);
/* peak hold */
......@@ -538,18 +538,18 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
cairo_set_source_surface(cr, ui->ma[1], MA_WIDTH + GM_WIDTH * ui->num_meters, 0);
cairo_paint (cr);
for (int i = 0; i < ui->num_meters ; ++i) {
for (uint32_t i = 0; i < ui->num_meters ; ++i) {
if (!rect_intersect_a(ev, MA_WIDTH + GM_WIDTH * i, 0, GM_WIDTH, GM_HEIGHT)) continue;
const int old = ui->val_vis[i];
const int new = ui->val_def[i];
const int v_old = ui->val_vis[i];
const int v_new = ui->val_def[i];
const int m_old = ui->peak_vis[i];
const int m_new = ui->peak_def[i];
if (old != new || m_old != m_new) {
ui->val_vis[i] = new;
if (v_old != v_new || m_old != m_new) {
ui->val_vis[i] = v_new;
ui->peak_vis[i] = m_new;
render_meter(ui, i, old, new, m_old, m_new);
render_meter(ui, i, v_old, v_new, m_old, m_new);
}
cairo_set_source_surface(cr, ui->sf[i], MA_WIDTH + GM_WIDTH * i, 0);
cairo_paint (cr);
......@@ -558,7 +558,7 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
/* numerical peak and value */
if (!ui->display_freq) {
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
for (int i = 0; i < ui->num_meters ; ++i) {
for (uint32_t i = 0; i < ui->num_meters ; ++i) {
char buf[24];
if (rect_intersect_a(ev, MA_WIDTH + GM_WIDTH * i + 2, GM_TOP/2 - 6, GM_WIDTH-4, 16)) {
cairo_save(cr);
......@@ -601,7 +601,7 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
/* labels */
if (ui->display_freq) {
cairo_set_operator (cr, CAIRO_OPERATOR_SCREEN);
for (int i = 0; i < ui->num_meters ; ++i) {
for (uint32_t i = 0; i < ui->num_meters ; ++i) {
if (!rect_intersect_a(ev, MA_WIDTH + GM_WIDTH * i, GM_TXT, 24, 64)) continue;
cairo_set_source_surface(cr, ui->an[i], MA_WIDTH + GM_WIDTH * i, GM_TXT);
cairo_paint (cr);
......@@ -609,7 +609,7 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
}
/* highlight */
if (ui->highlight >= 0 && ui->highlight < ui->num_meters &&
if (ui->highlight >= 0 && ui->highlight < (int) ui->num_meters &&
rect_intersect_a(ev, MA_WIDTH + GM_WIDTH * ui->highlight + GM_WIDTH/2 - 32, GM_TXT -4.5, 64, 46)) {
const float dboff = ui->gain > .1 ? 20.0 * log10f(ui->gain) : -20;
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
......@@ -650,7 +650,7 @@ static RobWidget* cb_reset_peak (RobWidget* handle, RobTkBtnEvent *event) {
float temp = ui->reset_toggle ? 1.0 : 0.0;
ui->write(ui->controller, 0, sizeof(float), 0, (const void*) &temp);
}
for (int i=0; i < ui->num_meters ; ++i) {
for (uint32_t i=0; i < ui->num_meters ; ++i) {
ui->peak_val[i] = -70;
ui->peak_def[i] = deflect(ui, -70);
}
......@@ -716,9 +716,9 @@ static RobWidget* mousemove(RobWidget* handle, RobTkBtnEvent *event) {
return NULL;
}
const int mtr = x / ((int) GM_WIDTH);
const uint32_t mtr = x / ((int) GM_WIDTH);
if (mtr >=0 && mtr < ui->num_meters) {
if (ui->highlight != mtr) { queue_draw(ui->m0); }
if (ui->highlight != (int) mtr) { queue_draw(ui->m0); }
ui->highlight = mtr;
} else {
if (ui->highlight != -1) { queue_draw(ui->m0); }
......@@ -868,7 +868,7 @@ instantiate(
alloc_annotations(ui);
create_meter_pattern(ui);
for (int i=0; i < ui->num_meters ; ++i) {
for (uint32_t i=0; i < ui->num_meters ; ++i) {
ui->val[i] = -70.0;
ui->val_def[i] = deflect(ui, -70);
ui->peak_val[i] = -70.0;
......@@ -904,7 +904,7 @@ static void
cleanup(LV2UI_Handle handle)
{
SAUI* ui = (SAUI*)handle;
for (int i=0; i < ui->num_meters ; ++i) {
for (uint32_t i=0; i < ui->num_meters ; ++i) {
cairo_surface_destroy(ui->sf[i]);
cairo_surface_destroy(ui->an[i]);
}
......@@ -940,10 +940,10 @@ extension_data(const char* uri)
* backend communication
*/
static void invalidate_meter(SAUI* ui, int mtr, float val, float peak) {
const int old = ui->val_def[mtr];
const int new = deflect(ui, val);
const int v_old = ui->val_def[mtr];
const int v_new = deflect(ui, val);
const int m_old = ui->peak_def[mtr];
const int m_new = deflect(ui, peak);
const int m_new = ceilf(deflect(ui, peak) / 2.0) * 2.0;
int t, h;
#define INVALIDATE_RECT(XX,YY,WW,HH) { \
......@@ -965,17 +965,17 @@ static void invalidate_meter(SAUI* ui, int mtr, float val, float peak) {
}
ui->val[mtr] = val;
ui->val_def[mtr] = new;
ui->val_def[mtr] = v_new;
ui->peak_val[mtr] = peak;
ui->peak_def[mtr] = m_new;
if (old != new) {
if (old > new) {
t = old;
h = old - new;
if (v_old != v_new) {
if (v_old > v_new) {
t = v_old;
h = v_old - v_new;
} else {
t = new;
h = new - old;
t = v_new;
h = v_new - v_old;
}
INVALIDATE_RECT(
......
......@@ -919,7 +919,7 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
write_text(cr, buf, FONT(FONT_M12), COORD_BINTG_W-7, COORD_BI_Y+50, 0, 4, c_wht);
}
if (rect_intersect_a(ev, COORD_BR_X, COORD_BI_Y+bottom_max_offset, 117, 19) && redraw_part != 1) {
if (rect_intersect_a(ev, COORD_BR_X+115-trw, COORD_BI_Y-50+bottom_max_offset, trw, 40) && redraw_part != 1) {
/* bottom level text display */
trw = lufs ? 117 : 105;
//printf("BOTTOM LVL @ %d+%d %dx%d\n", COORD_BR_X+115-trw, 305+bottom_max_offset, trw, 40);
......@@ -933,9 +933,9 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
ui->prev_lvl[2] = !rings ? ui->ls : ui->lm;
ui->prev_lvl[3] = !rings ? ui->ms : ui->mm;
write_text(cr, rings ? "Mom":"Short", FONT(FONT_S08), COORD_BR_X+85, COORD_BI_Y-45+bottom_max_offset, 0, 8, c_wht);
sprintf(buf, "%+5.1f %s", LUFS(ui->prev_lvl[3]), lufs ? "LUFS" : "LU");
sprintf(buf, "%+5.1f %s", LUFS(ui->prev_lvl[2]), lufs ? "LUFS" : "LU");
write_text(cr, buf, FONT(FONT_M09), COORD_BR_X+105, COORD_BI_Y-25+bottom_max_offset, 0, 7, c_wht);
sprintf(buf, "Max:%+5.1f %s", LUFS(ui->prev_lvl[4]), lufs ? "LUFS" : "LU");
sprintf(buf, "Max:%+5.1f %s", LUFS(ui->prev_lvl[3]), lufs ? "LUFS" : "LU");
write_text(cr, buf, FONT(FONT_M09), COORD_BR_X+105, COORD_BI_Y-10+bottom_max_offset, 0, 7, c_wht);
}
......@@ -1273,7 +1273,7 @@ instantiate(
ui->cbx_autoreset = robtk_cbtn_new("Reset on Start", GBT_LED_LEFT, true);
ui->spn_radartime = robtk_spin_new(30, 600, 15);
ui->lbl_radarinfo = robtk_lbl_new("History Length [s]:");
ui->lbl_ringinfo = robtk_lbl_new("Level Diplay");
ui->lbl_ringinfo = robtk_lbl_new("Level Display");
ui->cbx_truepeak = robtk_cbtn_new("Compute True-Peak", GBT_LED_LEFT, true);
ui->sep_h0 = robtk_sep_new(TRUE);
......
......@@ -138,11 +138,14 @@ typedef struct {
int w_width;
int w_height;
int xrundisplay;
} GMUI;
static bool cb_preferences(RobWidget *w, gpointer handle);
static void setup_src(GMUI* ui, float oversample, int hlen, float frel) {
LV2gm* self = (LV2gm*) ui->instance;
if (ui->src != 0) {
delete ui->src;
free(ui->scratch);
......@@ -150,6 +153,7 @@ static void setup_src(GMUI* ui, float oversample, int hlen, float frel) {
ui->src = 0;
ui->scratch = 0;
ui->resampl = 0;
ui->hpw = expf(-2.0 * M_PI * 20 / self->rate);
}
if (oversample <= 1) {
......@@ -157,9 +161,9 @@ static void setup_src(GMUI* ui, float oversample, int hlen, float frel) {
return;
}
LV2gm* self = (LV2gm*) ui->instance;
uint32_t bsiz = self->rate * 2;
ui->hpw = expf(-2.0 * M_PI * 20 / (self->rate * oversample));
ui->src_fact = oversample;
ui->src = new Resampler();
ui->src->setup(self->rate, self->rate * oversample, 2, hlen, frel);
......@@ -455,8 +459,8 @@ static void draw_rb(GMUI* ui, gmringbuf *rb) {
cairo_destroy(cr);
if (!finite(ui->lp0)) ui->lp0 = 0;
if (!finite(ui->lp1)) ui->lp1 = 0;
if (!isfinite(ui->lp0)) ui->lp0 = 0;
if (!isfinite(ui->lp1)) ui->lp1 = 0;
if (autogain) {
LV2gm* self = (LV2gm*) ui->instance;
......@@ -467,7 +471,7 @@ static void draw_rb(GMUI* ui, gmringbuf *rb) {
max *= .707;
if (rms_c > 0 && g_rms > 0 && finite(g_rms)) {
if (rms_c > 0 && g_rms > 0 && isfinite(g_rms)) {
const float rms = 5.436 /* 2e */ * (rms_0 > rms_1 ? sqrt(rms_0 / rms_c) : sqrt(rms_1 / rms_c));
//printf("max: %f <> rms %f (tgt:%f)\n", max, rms, g_target);
max = max * (1.0 - g_rms) + rms * g_rms;
......@@ -475,7 +479,7 @@ static void draw_rb(GMUI* ui, gmringbuf *rb) {
max *= g_target;
if (!finite(max)) max = 0;
if (!isfinite(max)) max = 0;
float gain;
if (max < .01) {
gain = 100.0;
......@@ -726,6 +730,44 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
}
}
draw_gm_labels(ui, cr);
if (ui->xrundisplay < 0) { ui->xrundisplay++; }
else if (self->rb_overrun) ui->xrundisplay = 36;
else if (ui->xrundisplay > 0) ui->xrundisplay--;
self->rb_overrun = false;
if (ui->xrundisplay > 0) {
cairo_save(cr);
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
float c_warn[4] = {1.0, 0.0, 0.0, 0.75};
if (ui->xrundisplay < 30) {
c_warn[3] = ui->xrundisplay * .025;
}
CairoSetSouerceRGBA(c_warn);
rounded_rectangle (cr, PC_BOUNDS + GM_BOUNDS - 175, GM_BOUNDS - 33, 170, 28, 6);
cairo_fill(cr);
write_text(cr, "Buffer Overflow\nYour system is not fast enough.",
FONT_LB, GM_BOUNDS - 102, GM_BOUNDS - 27,
0, c_g90);
CairoSetSouerceRGBA(c_blk);
cairo_set_line_width(cr, 1.5);
float tx,ty;
tx = PC_BOUNDS + GM_BOUNDS - 157.5;
ty = GM_BOUNDS - 27.5;
cairo_move_to(cr, tx, ty);
cairo_line_to(cr, tx-10, ty+17);
cairo_line_to(cr, tx+10, ty+17);
cairo_close_path (cr);
cairo_stroke(cr);
cairo_move_to(cr, tx, ty+6);
cairo_line_to(cr, tx, ty+11);
cairo_stroke(cr);
cairo_move_to(cr, tx, ty+14);
cairo_line_to(cr, tx, ty+14);
cairo_stroke(cr);
cairo_restore(cr);
}
}
if (rect_intersect_a(ev, 0, 0, PC_BOUNDS, GM_BOUNDS)) {
......@@ -901,7 +943,7 @@ static bool cb_vfreq(RobWidget *w, gpointer handle) {
static bool cb_src(RobWidget *w, gpointer handle) {
GMUI* ui = (GMUI*)handle;
if (robtk_cbtn_get_active(ui->cbn_src)) {
setup_src(ui, robtk_spin_get_value(ui->spn_src_fact), 8, .7);
setup_src(ui, robtk_spin_get_value(ui->spn_src_fact), 12, 1.0);
} else {
setup_src(ui, 0, 0, 0);
}
......@@ -949,6 +991,15 @@ static void restore_state(GMUI* ui) {
ui->disable_signals = false;
}
/* instance connection */
#if (!defined GTK_BACKEND && defined USE_GUI_THREAD && defined THREADSYNC)
static void expose_goniometer(void* ptr) {
GMUI* ui = (GMUI*) ptr;
ui->ntfy_b = (ui->ntfy_b + 1 )% 10000;
queue_draw_area(ui->m0, PC_BOUNDS, 0, GM_BOUNDS, GM_BOUNDS);
}
#endif
/******************************************************************************
* widget hackery
*/
......@@ -1233,7 +1284,16 @@ instantiate(
*widget = ui->box;
gmrb_read_clear(self->rb);
ui->xrundisplay = -100;
self->ui_active = true;
#if (!defined GTK_BACKEND && defined USE_GUI_THREAD && defined THREADSYNC)
GlMetersLV2UI *glui = (GlMetersLV2UI*) ui_toplevel;
self->msg_thread_lock = &glui->msg_thread_lock;
self->data_ready = &glui->data_ready;
self->queue_display = &expose_goniometer;
self->ui = ui;
#endif
return ui;
}
......@@ -1308,6 +1368,7 @@ cleanup(LV2UI_Handle handle)
free(ui->scratch);
free(ui->resampl);
i->msg_thread_lock = NULL;
free(ui);
}
......@@ -1316,6 +1377,7 @@ extension_data(const char* uri)
{
return NULL;
}
static void invalidate_gm(GMUI* ui) {
queue_draw_area(ui->m0, PC_BOUNDS, 0, GM_BOUNDS, GM_BOUNDS);
}
......
......@@ -27,7 +27,7 @@
#define MTR_GUI "kmeterui"
#define GM_TOP 25.5f
#define GM_BOTTOM 7.5f
#define GM_BOTTOM 9.5f
#define GM_LEFT 4.5f
#define GM_GIRTH 10.0f
#define GM_WIDTH (GM_GIRTH + GM_LEFT + GM_LEFT)
......@@ -75,7 +75,7 @@ typedef struct {
//bool reset_toggle;
bool metrics_changed;
float kstandard;
int kstandard;
bool initialized;
bool reset_toggle;
......@@ -94,7 +94,7 @@ typedef struct {
static inline float meter_deflect_k (float db, float krange) {
db+=krange;
if (db < -40.0f) {
return (db > -318.8f ? pow (10.0f, db * 0.05f) : 0.0f) * 500.0f / (krange + 45.0f);
return (db > -90.0f ? pow (10.0f, db * 0.05f) : 0.0f) * 500.0f / (krange + 45.0f);
} else {
const float rv = (db + 45.0f) / (krange + 45.0f);
if (rv < 1.0) {
......@@ -306,6 +306,11 @@ static void create_metrics(KMUI* ui) {
cairo_rectangle (cr, 0, 0, MA_WIDTH, GM_HEIGHT);
cairo_fill (cr);
DO_THE_METRICS
char kstd[6];
snprintf(kstd, 5, "K%d", ui->kstandard);
write_text(cr, kstd , font, MA_WIDTH - 3, GM_HEIGHT, 4, c_blk);
cairo_destroy (cr);
pango_font_description_free(font);
......@@ -326,7 +331,7 @@ static void create_metrics(KMUI* ui) {
cairo_stroke(cr); \
}
for (int i = 0; i < ui->num_meters; ++i) {
for (uint32_t i = 0; i < ui->num_meters; ++i) {
ALLOC_SF(ui->sf[i])
/* metric background */
......@@ -365,7 +370,7 @@ static void create_metrics(KMUI* ui) {
}
}
static void render_meter(KMUI* ui, int i, int old, int new, int m_old, int m_new) {
static void render_meter(KMUI* ui, int i, int v_old, int v_new, int m_old, int m_new) {
cairo_t* cr = cairo_create (ui->sf[i]);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
......@@ -376,7 +381,7 @@ static void render_meter(KMUI* ui, int i, int old, int new, int m_old, int m_new
/* rms value */
cairo_set_source(cr, ui->mpat);
cairo_rectangle (cr, GM_LEFT, GM_TOP + GM_SCALE - new - 1, GM_GIRTH, new + 1);
cairo_rectangle (cr, GM_LEFT, GM_TOP + GM_SCALE - v_new - 1, GM_GIRTH, v_new + 1);
cairo_fill(cr);
/* peak */
......@@ -432,18 +437,18 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
cairo_set_source_surface(cr, ui->ma[1], MA_WIDTH + GM_WIDTH * ui->num_meters, 0);
cairo_paint (cr);
for (int i = 0; i < ui->num_meters ; ++i) {
for (uint32_t i = 0; i < ui->num_meters ; ++i) {
if (!rect_intersect_a(ev, MA_WIDTH + GM_WIDTH * i, 0, GM_WIDTH, GM_HEIGHT)) continue;
const int old = ui->val_vis[i];
const int new = ui->val_def[i];
const int v_old = ui->val_vis[i];
const int v_new = ui->val_def[i];
const int m_old = ui->peak_vis[i];
const int m_new = ui->peak_def[i];
if (old != new || m_old != m_new) {
ui->val_vis[i] = new;
if (v_old != v_new || m_old != m_new) {
ui->val_vis[i] = v_new;
ui->peak_vis[i] = m_new;
render_meter(ui, i, old, new, m_old, m_new);
render_meter(ui, i, v_old, v_new, m_old, m_new);
}
cairo_set_source_surface(cr, ui->sf[i], MA_WIDTH + GM_WIDTH * i, 0);
......@@ -451,31 +456,35 @@ static bool expose_event(RobWidget* handle, cairo_t* cr, cairo_rectangle_t *ev)
}
/* numerical peak */
if (ui->peak_max > -90) {
if (rect_intersect_a(ev, (ui->width - PK_WIDTH) / 2.0f, GM_TOP/2 - 8, PK_WIDTH, 16)) {
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
char buf[24];
if (rect_intersect_a(ev, (ui->width - PK_WIDTH) / 2.0f, GM_TOP/2 - 8, PK_WIDTH, 16)) {
cairo_save(cr);
rounded_rectangle (cr, (ui->width - PK_WIDTH)/2.0f, GM_TOP/2 - 8, PK_WIDTH, 16, 4);
if (ui->peak_max >= -1.0) {
CairoSetSouerceRGBA(c_ptr);
} else {
CairoSetSouerceRGBA(c_blk);
}
cairo_fill_preserve (cr);
cairo_set_line_width(cr, 0.75);
CairoSetSouerceRGBA(c_g60);
cairo_stroke_preserve (cr);
cairo_clip (cr);
cairo_save(cr);
rounded_rectangle (cr, (ui->width - PK_WIDTH)/2.0f, GM_TOP/2 - 8, PK_WIDTH, 16, 4);
if (ui->peak_max >= -1.0) {
CairoSetSouerceRGBA(c_ptr);
} else if (ui->peak_max > -90.0) {
CairoSetSouerceRGBA(c_blk);
} else {
CairoSetSouerceRGBA(c_g30);
}
cairo_fill_preserve (cr);
cairo_set_line_width(cr, 0.75);
CairoSetSouerceRGBA(c_g60);
cairo_stroke_preserve (cr);
cairo_clip (cr);
if (ui->peak_max > -90) {
char buf[24];
if (ui->peak_max <= -10.0) {
sprintf(buf, "%.0f ", ui->peak_max);
} else {
sprintf(buf, "%+.1f", ui->peak_max);
}
write_text(cr, buf, ui->font, (ui->width + PK_WIDTH) / 2.0f - 4, GM_TOP/2, 1, c_g90);
cairo_restore(cr);
}
cairo_restore(cr);
}
return TRUE;
......@@ -491,9 +500,6 @@ static RobWidget* cb_reset_peak (RobWidget* handle, RobTkBtnEvent *event) {
ui->reset_toggle = !ui->reset_toggle;
float temp = ui->reset_toggle ? 1.0 : 0.0;
ui->write(ui->controller, 0, sizeof(float), 0, (const void*) &temp);
ui->peak_max = -90;
queue_draw(ui->m0);
return NULL;
}
......@@ -571,7 +577,7 @@ instantiate(
create_meter_pattern(ui);
ui->font = pango_font_description_from_string("Mono 7");
for (int i=0; i < ui->num_meters ; ++i) {
for (uint32_t i=0; i < ui->num_meters ; ++i) {
ui->val[i] = -90.0;
ui->val_def[i] = deflect(ui, -90);
ui->peak_val[i] = -90.0;
......@@ -600,7 +606,7 @@ static void
cleanup(LV2UI_Handle handle)
{
KMUI* ui = (KMUI*)handle;
for (int i=0; i < ui->num_meters ; ++i) {
for (uint32_t i=0; i < ui->num_meters ; ++i) {
cairo_surface_destroy(ui->sf[i]);
cairo_surface_destroy(ui->an[i]);
}
......@@ -628,20 +634,20 @@ extension_data(const char* uri)
#define INVALIDATE_RECT(XX,YY,WW,HH) queue_tiny_area(ui->m0, XX, YY, WW, HH);
static void invalidate_meter(KMUI* ui, int mtr, float val) {
const int old = ui->val_def[mtr];
const int new = deflect(ui, val);
int t, h;
const int v_old = ui->val_def[mtr];
const int v_new = deflect(ui, val);
ui->val[mtr] = val;
ui->val_def[mtr] = new;
ui->val_def[mtr] = v_new;
if (old != new) {
if (old > new) {
t = old;
h = old - new;
if (v_old != v_new) {
int t, h;
if (v_old > v_new) {
t = v_old;
h = v_old - v_new;
} else {
t = new;
h = new - old;
t = v_new;
h = v_new - v_old;
}
INVALIDATE_RECT(
......@@ -652,20 +658,20 @@ static void invalidate_meter(KMUI* ui, int mtr, float val) {
}
static void invalidate_peak(KMUI* ui, int mtr, float val) {
const int old = ui->peak_def[mtr];
const int new = deflect(ui, val);
int t, h;
const int v_old = ui->peak_def[mtr];
const int v_new = deflect(ui, val);
ui->peak_val[mtr] = val;
ui->peak_def[mtr] = new;
ui->peak_def[mtr] = v_new;
if (old != new) {
if (old > new) {
t = old;
h = old - new;
if (v_old != v_new) {
int t, h;
if (v_old > v_new) {
t = v_old;
h = v_old - v_new;
} else {
t = new;
h = new - old;
t = v_new;
h = v_new - v_old;
}
INVALIDATE_RECT(
......@@ -724,7 +730,7 @@ port_event(LV2UI_Handle handle,
float temp = -1;
ui->write(ui->controller, 0, sizeof(float), 0, (const void*) &temp);
}
if (!ui->initialized && port_index != 0) {
else if (!ui->initialized && port_index != 0) {
ui->initialized = true;
float temp = -2;
ui->write(ui->controller, 0, sizeof(float), 0, (const void*) &temp);
......
......@@ -96,10 +96,10 @@ struct MyGimpImage {
/* load gimp-exported .c image into cairo surface */
static void img2surf (struct MyGimpImage const * img, cairo_surface_t **s, unsigned char **d)