Beispiel #1
0
void
eq_refresh (void) {
    ddb_dsp_context_t *eq = get_supereq ();
    if (eq && eqwin) {
        char s[20];
        eq->plugin->get_param (eq, 0, s, sizeof (s));
        ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), atof(s));
        for (int i = 0; i < 18; i++) {
            eq->plugin->get_param (eq, i+1, s, sizeof (s));
            ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, atoi(s));
        }
        eq_redraw ();
    }
}
Beispiel #2
0
static void ddb_equalizer_finalize (GObject* obj) {
	DdbEqualizer * self;
	self = DDB_EQUALIZER (obj);
	self->priv->values = (g_free (self->priv->values), NULL);
	_gdk_cursor_unref0 (self->priv->pointer_cursor);
	G_OBJECT_CLASS (ddb_equalizer_parent_class)->finalize (obj);
}
Beispiel #3
0
void
on_zero_all_clicked                  (GtkButton       *button,
        gpointer         user_data) {
    if (eqwin) {
        ddb_dsp_context_t *eq = get_supereq ();
        if (eq) {
            ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), 0);
            set_param (eq, 0, 0);
            for (int i = 0; i < 18; i++) {
                // set gui
                ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, 0);

                // set dsp
                set_param (eq, i+1, 0);
            }
            gtk_widget_queue_draw (eqwin);
            deadbeef->streamer_dsp_chain_save ();
        }
    }
}
Beispiel #4
0
void
on_zero_preamp_clicked                  (GtkButton       *button,
        gpointer         user_data) {
    if (eqwin) {
        ddb_dsp_context_t *eq = get_supereq ();
        if (eq) {
            set_param (eq, 0, 0);
            ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), 0);
            gtk_widget_queue_draw (eqwin);
            deadbeef->streamer_dsp_chain_save ();
        }
    }
}
Beispiel #5
0
static GObject * ddb_equalizer_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	DdbEqualizer * self;
	parent_class = G_OBJECT_CLASS (ddb_equalizer_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = DDB_EQUALIZER (obj);
	{
		self->priv->margin_bottom = (gint) (((pango_units_to_double (pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc)) * gdk_screen_get_resolution (gdk_screen_get_default ())) / 72) + 4);
		self->priv->margin_left = self->priv->margin_bottom * 4;
	}
	return obj;
}
Beispiel #6
0
void
eq_window_show (void) {
    if (!eqcont) {
        eqcont = gtk_vbox_new (FALSE, 8);
        GtkWidget *parent= lookup_widget (mainwin, "plugins_bottom_vbox");
        gtk_box_pack_start (GTK_BOX (parent), eqcont, FALSE, FALSE, 0);

        GtkWidget *buttons = gtk_hbox_new (FALSE, 8);
        gtk_container_set_border_width (GTK_CONTAINER (buttons), 3);
        gtk_widget_show (buttons);
        gtk_box_pack_start (GTK_BOX (eqcont), buttons, FALSE, FALSE, 0);

        GtkWidget *button;

        eqenablebtn = button = gtk_check_button_new_with_label (_("Enable"));
        gtk_widget_show (button);
        gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
        ddb_dsp_context_t *eq = get_supereq ();
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (eqenablebtn), eq ? eq->enabled : 0);
        g_signal_connect ((gpointer) button, "toggled",
                G_CALLBACK (on_enable_toggled),
                NULL);

        button = gtk_button_new_with_label (_("Zero All"));
        gtk_widget_show (button);
        gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
        g_signal_connect ((gpointer) button, "clicked",
                G_CALLBACK (on_zero_all_clicked),
                NULL);

        button = gtk_button_new_with_label (_("Zero Preamp"));
        gtk_widget_show (button);
        gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
        g_signal_connect ((gpointer) button, "clicked",
                G_CALLBACK (on_zero_preamp_clicked),
                NULL);

        button = gtk_button_new_with_label (_("Zero Bands"));
        gtk_widget_show (button);
        gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
        g_signal_connect ((gpointer) button, "clicked",
                G_CALLBACK (on_zero_bands_clicked),
                NULL);

        button = gtk_button_new_with_label (_("Presets"));
        gtk_widget_show (button);
        gtk_box_pack_start (GTK_BOX (buttons), button, FALSE, FALSE, 0);
        g_signal_connect ((gpointer) button, "clicked",
                G_CALLBACK (on_presets_clicked),
                NULL);

        eqwin = GTK_WIDGET (ddb_equalizer_new());
        g_signal_connect (eqwin, "on_changed", G_CALLBACK (eq_value_changed), 0);
        gtk_widget_set_size_request (eqwin, -1, 200);

        if (eq) {
            char fv[100];
            float v;
            eq->plugin->get_param (eq, 0, fv, sizeof (fv));
            v = atof (fv);
            ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), v);
            for (int i = 0; i < 18; i++) {
                if (eq) {
                    eq->plugin->get_param (eq, i+1, fv, sizeof (fv));
                    v = atof (fv);
                    ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, v);
                }
            }
        }

        gtk_widget_show (eqwin);
        gtk_box_pack_start (GTK_BOX (eqcont), eqwin, TRUE, TRUE, 0);
    }
    gtk_widget_show (eqcont);
}
Beispiel #7
0
void
on_import_fb2k_preset_clicked                  (GtkButton       *button,
        gpointer         user_data) {
    GtkWidget *dlg = gtk_file_chooser_dialog_new (_("Import Foobar2000 EQ Preset..."), GTK_WINDOW (mainwin), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);

    GtkFileFilter* flt;
    flt = gtk_file_filter_new ();
    gtk_file_filter_set_name (flt, _("Foobar2000 EQ presets (*.feq)"));
    gtk_file_filter_add_pattern (flt, "*.feq");
    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dlg), flt);

    gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dlg), FALSE);
    // restore folder
    deadbeef->conf_lock ();
    gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dlg), deadbeef->conf_get_str_fast ("filechooser.lastdir", ""));
    deadbeef->conf_unlock ();

    int response = gtk_dialog_run (GTK_DIALOG (dlg));
    // store folder
    gchar *folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dlg));
    if (folder) {
        deadbeef->conf_set_str ("filechooser.lastdir", folder);
        g_free (folder);
    }
    if (response == GTK_RESPONSE_OK)
    {
        gchar *fname = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
        if (fname) {
            FILE *fp = fopen (fname, "rt");
            if (fp) {
                int vals[18]; // integer dBs
                int i = 0;
                while (i < 18) {
                    char tmp[20];
                    char *out = fgets (tmp, sizeof (tmp), fp);
                    if (!out) {
                        break;
                    }
                    vals[i] = atoi (tmp);
                    i++;
                }
                fclose (fp);
                if (i == 18) {
                    // apply and save config
                    ddb_dsp_context_t *eq = get_supereq ();
                    if (eq) {
                        set_param (eq, 0, 0);
                        ddb_equalizer_set_preamp (DDB_EQUALIZER (eqwin), 0);
                        for (int i = 0; i < 18; i++) {
                            ddb_equalizer_set_band (DDB_EQUALIZER (eqwin), i, vals[i]);
                            set_param (eq, i+1, vals[i]);
                        }
                        gtk_widget_queue_draw (eqwin);
                        deadbeef->streamer_dsp_chain_save ();
                    }
                }
                else {
                    fprintf (stderr, "[eq] corrupted Foobar2000 preset file, discarded\n");
                }
            }
            g_free (fname);
        }
    }
    gtk_widget_destroy (dlg);
}