Save/Load keyboard tuning freq

This commit is contained in:
Robin Gareus 2019-08-15 16:33:25 +02:00
parent 5027c1e267
commit 16243ee06b
No known key found for this signature in database
GPG Key ID: A090BCE02CF57F04
3 changed files with 34 additions and 4 deletions

View File

@ -785,6 +785,14 @@ static void update_filter_display (Fil4UI* ui) {
queue_draw(ui->m0);
}
static void update_grid (Fil4UI* ui) {
if (ui->m0_grid) {
cairo_surface_destroy (ui->m0_grid);
ui->m0_grid = NULL;
}
queue_draw(ui->m0);
}
///////////////////////////////////////////////////////////////////////////////
static double warp_freq (double w, double f)
@ -1365,6 +1373,9 @@ static void tx_state (Fil4UI* ui) {
lv2_atom_forge_property_head(&ui->forge, ui->uris.s_uiscale, 0);
lv2_atom_forge_float(&ui->forge, ui->rw->widget_scale);
lv2_atom_forge_property_head(&ui->forge, ui->uris.s_kbtuning, 0);
lv2_atom_forge_float(&ui->forge, ui->tuning_fq);
lv2_atom_forge_pop(&ui->forge, &frame);
ui->write(ui->controller, FIL_ATOM_CONTROL, lv2_atom_total_size(msg), ui->uris.atom_eventTransfer, msg);
}
@ -1905,10 +1916,7 @@ m0_size_allocate (RobWidget* handle, int w, int h) {
ui->m0_height = h;
robwidget_set_size(ui->m0, w, h);
if (ui->m0_grid) {
cairo_surface_destroy (ui->m0_grid);
ui->m0_grid = NULL;
}
update_grid (ui);
if (ui->m0_filters) {
cairo_surface_destroy (ui->m0_filters);
@ -3248,6 +3256,15 @@ port_event(LV2UI_Handle handle,
robtk_queue_scale_change (ui->rw, sc);
}
}
a0 = NULL;
if (1 == lv2_atom_object_get(obj, ui->uris.s_kbtuning, &a0, NULL) && a0) {
const float fq = ((LV2_Atom_Float*)a0)->body;
if (fq > 220 && fq < 880) {
ui->tuning_fq = fq;
update_grid (ui);
}
}
}
}
}

View File

@ -80,6 +80,7 @@ typedef struct {
float fft_gain;
float db_scale;
float ui_scale;
float kb_tuning;
bool need_expose;
bool enabled;
@ -165,6 +166,7 @@ instantiate(const LV2_Descriptor* descriptor,
self->resend_peak = 0;
self->db_scale = DEFAULT_YZOOM;
self->ui_scale = 1.0;
self->kb_tuning = 440.0;
if (options) {
LV2_URID atom_Float = self->map->map (self->map->handle, LV2_ATOM__Float);
@ -255,6 +257,9 @@ static void tx_state (Fil4* self)
lv2_atom_forge_property_head(&self->forge, self->uris.s_uiscale, 0);
lv2_atom_forge_float(&self->forge, self->ui_scale);
lv2_atom_forge_property_head(&self->forge, self->uris.s_kbtuning, 0);
lv2_atom_forge_float(&self->forge, self->kb_tuning);
lv2_atom_forge_pop(&self->forge, &frame);
}
@ -464,6 +469,10 @@ run(LV2_Handle instance, uint32_t n_samples)
v = NULL;
lv2_atom_object_get(obj, self->uris.s_uiscale, &v, 0);
if (v) { self->ui_scale = ((LV2_Atom_Float*)v)->body; }
v = NULL;
lv2_atom_object_get(obj, self->uris.s_kbtuning, &v, 0);
if (v) { self->kb_tuning = ((LV2_Atom_Float*)v)->body; }
}
}
ev = lv2_atom_sequence_next(ev);
@ -550,6 +559,7 @@ fil4_save(LV2_Handle instance,
STATESTORE(s_dbscale, Float, self->db_scale)
STATESTORE(s_fftgain, Float, self->fft_gain)
STATESTORE(s_uiscale, Float, self->ui_scale)
STATESTORE(s_uiscale, Float, self->kb_tuning)
STATESTORE(s_fftmode, Int, self->fft_mode)
STATESTORE(s_fftchan, Int, self->fft_chan)
@ -579,6 +589,7 @@ fil4_restore(LV2_Handle instance,
STATEREAD(s_dbscale, Float, float, self->db_scale)
STATEREAD(s_fftgain, Float, float, self->fft_gain)
STATEREAD(s_uiscale, Float, float, self->ui_scale)
STATEREAD(s_uiscale, Float, float, self->kb_tuning)
STATEREAD(s_fftmode, Int, int32_t, self->fft_mode)
STATEREAD(s_fftchan, Int, int32_t, self->fft_chan)

View File

@ -50,6 +50,7 @@ typedef struct {
LV2_URID s_fftgain;
LV2_URID s_fftchan;
LV2_URID s_uiscale;
LV2_URID s_kbtuning;
} Fil4LV2URIs;
static inline void
@ -72,6 +73,7 @@ map_fil4_uris(LV2_URID_Map* map, Fil4LV2URIs* uris) {
uris->s_fftmode = map->map(map->handle, FIL4_URI "fftmode");
uris->s_fftchan = map->map(map->handle, FIL4_URI "fftchannel");
uris->s_uiscale = map->map(map->handle, FIL4_URI "uiscale");
uris->s_kbtuning = map->map(map->handle, FIL4_URI "kbtuning");
}
/* common definitions UI and DSP */