/* * Copyright (C) 2003 Steve Harris * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * $Id: geq.c,v 1.32 2004/08/20 22:56:08 jdepner Exp $ */ /* code to control the graphic eq's, swh */ #include #include #include #include #include "geq.h" #include "hdeq.h" #include "process.h" #include "support.h" #include "main.h" #include "db.h" #include "state.h" #include "scenes.h" #include "callbacks.h" #include "help.h" GtkAdjustment *geqa[EQ_BANDS]; GtkRange *geqr[EQ_BANDS]; static int EQ_drawn = 0; static char *errstr = NULL; /* Linear gain of the 1/3rd octave EQ bands */ float geq_gains[EQ_BANDS + 1]; /* Frequency of each band of the EQ */ float geq_freqs[EQ_BANDS]; int bin_base[BINS]; float bin_delta[BINS]; gboolean eqb_changed(GtkAdjustment *adj, gpointer user_data); void geq_set_gains(); void bind_geq() { char name[16]; int i, bin; float last_bin, next_bin; const double hz_per_bin = sample_rate / (double)BINS; GtkTooltips *tooltips = gtk_tooltips_new(); char tip[255]; for (i=0; i x[i]) i++; value = y[i - 1] + (y[i] - y[i - 1]) * ((geq_freqs[j] - x[i - 1]) / (x[i] - x[i - 1])); gtk_adjustment_set_value (geqa[j], value / 0.05); } gtk_adjustment_set_value (geqa[EQ_BANDS - 1], y[length - 1] / 0.05); /* Release the restriction on the graphic EQ adjustments. */ EQ_drawn = 0; } } void geq_set_range(double min, double max) { int i; for (i = 0 ; i < EQ_BANDS ; i++) { gtk_range_set_range (geqr[i], min, max); } } void geq_get_freqs_and_gains(float *freqs, float *gains) { int i; for (i = 0 ; i < EQ_BANDS ; i++) { freqs[i] = geq_freqs[i]; gains[i] = geq_gains[i]; } } gboolean eqb_changed(GtkAdjustment *adj, gpointer user_data) { int band = (int)user_data; geq_gains[band-1] = db2lin(adj->value); geq_set_gains(); /* If the adjustment was made by hand set the scene warning. If it was set automatically by the set_EQ function we don't want to set it because this could just be a scene change. We are drawing the curve in order to set the state values. */ if (!EQ_drawn) { set_scene_warning_button (); draw_EQ_curve (); } return FALSE; } GtkAdjustment *geq_get_adjustment(int band) { if (band < 0 || band > EQ_BANDS) { fprintf(stderr, _("jam error: Adjustment from out-of-range band %d requested\n"), band); exit(1); } return geqa[band]; } /* vi:set ts=8 sts=4 sw=4: */