/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+
#+     Internet Radio Automation & Encoding Toolkit
#+
#+     Copyright (C) 2018, 2019, 2020, 2021 by Kevin C. O'Kane
#+
#+     Kevin C. O'Kane
#+     kc.okane@gmail.com
#+     https://www.cs.uni.edu/~okane
#+     https://threadsafebooks.com/
#+
#+ 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.
#+
#+ You should have received a copy of the GNU General Public License
#+ along with this program; if not, write to the Free Software
#+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#+
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

//	Oct 25, 2022

#include "includes.h"
#include "common-externs.h"

#define SLASH '/'

void    on_eqReset_clicked(GtkWidget *b) {
	char cmd[128];
	gdouble x;

//-----------------------------------------------------------------------------
//      Fetch current values
//      SP->preSet[0] is the flat equalizer unless they change it in the future
//-----------------------------------------------------------------------------

	SP->x60         = SP->preSetBak[SP->currentPreset][0];
	SP->x170        = SP->preSetBak[SP->currentPreset][1];
	SP->x310        = SP->preSetBak[SP->currentPreset][2];
	SP->x600        = SP->preSetBak[SP->currentPreset][3];
	SP->x1000       = SP->preSetBak[SP->currentPreset][4];
	SP->x3000       = SP->preSetBak[SP->currentPreset][5];
	SP->x6000       = SP->preSetBak[SP->currentPreset][6];
	SP->x12000      = SP->preSetBak[SP->currentPreset][7];
	SP->x14000      = SP->preSetBak[SP->currentPreset][8];
	SP->x16000      = SP->preSetBak[SP->currentPreset][9];

	Eq_Vol = 0.0;
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment10), Eq_Vol); // preAmp
	SP->volumeLevel = 100;

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment35), 100.0);

	sprintf(cmd, "%+3.0f%%", SP->x60);
	gtk_label_set_text(GTK_LABEL(L60), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment11), SP->x60); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x60, 0);

	sprintf(cmd, "%+3.0f%%", SP->x170);
	gtk_label_set_text(GTK_LABEL(L170), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment12), SP->x170); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x170, 1);

	sprintf(cmd, "%+3.0f%%", SP->x310);
	gtk_label_set_text(GTK_LABEL(L310), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment13), SP->x310); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x310, 2);

	sprintf(cmd, "%+3.0f%%", SP->x600);
	gtk_label_set_text(GTK_LABEL(L600), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment14), SP->x600); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x600, 3);

	sprintf(cmd, "%+3.0f%%", SP->x1000);
	gtk_label_set_text(GTK_LABEL(L1000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment15), SP->x1000); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x1000, 4);

	sprintf(cmd, "%+3.0f%%", SP->x3000);
	gtk_label_set_text(GTK_LABEL(L3000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment16), SP->x3000); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x3000, 5);

	sprintf(cmd, "%+3.0f%%", SP->x6000);
	gtk_label_set_text(GTK_LABEL(L6000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment17), SP->x6000); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x6000, 6);

	sprintf(cmd, "%+3.0f%%", SP->x12000);
	gtk_label_set_text(GTK_LABEL(L12000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment18), SP->x12000); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x12000, 7);

	sprintf(cmd, "%+3.0f%%", SP->x14000);
	gtk_label_set_text(GTK_LABEL(L14000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment19), SP->x14000); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x14000, 8);

	sprintf(cmd, "%+3.0f%%", SP->x16000);
	gtk_label_set_text(GTK_LABEL(L16000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment20), SP->x16000); // set slider
	libvlc_audio_equalizer_set_amp_at_index (SP->preSet[0], SP->x16000, 9);
	}

//--------------------------------------------------
//      get levels for each freq for given equalizer
//--------------------------------------------------

void    getEqSettings(libvlc_equalizer_t* eq, int eqx ) {
	char cmd[128];
	gdouble x;

	x = SP->x60 = libvlc_audio_equalizer_get_amp_at_index(eq,0); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x60);
	gtk_label_set_text(GTK_LABEL(L60), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment11), x); // set slider

	x = SP->x170 = libvlc_audio_equalizer_get_amp_at_index(eq,1); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x170);
	gtk_label_set_text(GTK_LABEL(L170), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment12), x); // set slider

	x = SP->x310 = libvlc_audio_equalizer_get_amp_at_index(eq,2); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x310);
	gtk_label_set_text(GTK_LABEL(L310), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment13), x); // set slider

	x = SP->x600 = libvlc_audio_equalizer_get_amp_at_index(eq,3); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x600);
	gtk_label_set_text(GTK_LABEL(L600), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment14), x); // set slider

	x = SP->x1000 = libvlc_audio_equalizer_get_amp_at_index(eq,4); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x1000);
	gtk_label_set_text(GTK_LABEL(L1000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment15), x); // set slider

	x = SP->x3000 = libvlc_audio_equalizer_get_amp_at_index(eq,5); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x3000);
	gtk_label_set_text(GTK_LABEL(L3000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment16), x); // set slider

	x = SP->x6000 = libvlc_audio_equalizer_get_amp_at_index(eq,6); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x6000);
	gtk_label_set_text(GTK_LABEL(L6000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment17), x); // set slider

	x = SP->x12000 = libvlc_audio_equalizer_get_amp_at_index(eq,7); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x12000);
	gtk_label_set_text(GTK_LABEL(L12000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment18), x); // set slider

	x = SP->x14000 = libvlc_audio_equalizer_get_amp_at_index(eq,8); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x14000);
	gtk_label_set_text(GTK_LABEL(L14000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment19), x); // set slider

	x = SP->x16000 = libvlc_audio_equalizer_get_amp_at_index(eq,9); // value for freq
	sprintf(cmd, "%+3.0f%%", SP->x16000);
	gtk_label_set_text(GTK_LABEL(L16000), cmd);
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment20), x); // set slider

	if (SP->preSetBak[eqx][0] < 0) {
		SP->preSetBak[eqx][0] = SP->x60;
		SP->preSetBak[eqx][1] = SP->x170;
		SP->preSetBak[eqx][2] = SP->x310;
		SP->preSetBak[eqx][3] = SP->x600;
		SP->preSetBak[eqx][4] = SP->x1000;
		SP->preSetBak[eqx][5] = SP->x3000;
		SP->preSetBak[eqx][6] = SP->x6000;
		SP->preSetBak[eqx][7] = SP->x12000;
		SP->preSetBak[eqx][8] = SP->x14000;
		SP->preSetBak[eqx][9] = SP->x16000;
		}
	}


void	on_flat_toggled(GtkWidget *b) {
	if (!mediaPlayer) return;
	SP->currentPreset = 0;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[0]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[0], SP->currentPreset);
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_classical_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 1;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[1]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[1], SP->currentPreset);
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_club_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 2;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[2]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[2], SP->currentPreset);
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_dance_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 3;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[3]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[3], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_fullBass_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 4;
	libvlc_media_player_set_equalizer(mediaPlayer, NULL);
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[4]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[4], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_fullBassTreble_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 5;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[5]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[5], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_fullTreble_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 6;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[6]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[6], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_headphones_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 7;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[7]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[7], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_largeHall_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 8;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[8]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[8], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_live_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 9;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[9]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[9], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_party_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 10;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[10]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[10], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_pop_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 11;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[11]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[11], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_reggae_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 12;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[12]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[12], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_rock_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 13;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[13]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[13], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_ska_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 14;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[14]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[14], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_soft_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 15;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[15]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[15], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_softRock_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 16;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[16]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[16], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


void	on_techno_toggled(GtkWidget *b) {
	if (!mediaPlayer) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flat), TRUE);
		return;
		}
	SP->currentPreset = 17;
	int e=libvlc_media_player_set_equalizer(mediaPlayer, SP->preSet[17]);
	printf("*** equalizer change result %d\n", e);
	getEqSettings(SP->preSet[17], SP->currentPreset); // get the settings and set the sliders
	SetVlcEqualizerPreAmp() ;// attach preamp equalizer to media player if exists
	}


gboolean	on_h60_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//---------------------------
//	get current value
//---------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment11);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment11), x);

	return FALSE;
	}

gboolean	on_h170_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//---------------------------
//	get current value
//---------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment12);
	x = x - e->delta_y ; // opposite
	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment12), x);
	return FALSE;
	}

gboolean	on_h310_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//------------------------
//	get current value
//------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment13);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment13), x);

	return FALSE;
	}

gboolean	on_h600_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//-------------------------
//	get current value
//-------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment14);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment14), x);

	return FALSE;
	}


gboolean	on_h1000_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//----------------------------
//	get current value
//----------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment15);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment15), x);

	return FALSE;
	}


gboolean	on_h3000_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//---------------------------
//	get current value
//---------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment16);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment16), x);

	return FALSE;
	}


gboolean	on_h6000_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//---------------------------
//	get current value
//---------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment17);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment17), x);

	return FALSE;
	}

gboolean	on_h12000_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//---------------------------
//	get current value
//---------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment18);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment18), x);

	return FALSE;
	}

gboolean	on_h14000_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//---------------------------
//	get current value
//---------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment19);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment19), x);

	return FALSE;
	}

gboolean	on_h16000_scroll_event(GtkEntry *b, GdkEventScroll *e) {

	if (SP->currentPreset < 0 || ! mediaPlayer) return FALSE;

//---------------------------
//	get current value
//---------------------------

	gdouble x = (int) gtk_adjustment_get_value(adjustment20);

	x = x - e->delta_y ; // opposite

	gtk_adjustment_set_value (GTK_ADJUSTMENT(adjustment20), x);

	return FALSE;
	}

void	on_h60_value_changed(GtkRange *r) { // slider moved
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L60), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 0);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}

void	on_h170_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L170), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 1);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_h310_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L310), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 2);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_h600_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L600), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 3);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_h1000_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L1000), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 4);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_h3000_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L3000), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 5);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_h6000_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L6000), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 6);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_h12000_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L12000), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 7);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_h14000_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L14000), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 8);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_h16000_value_changed(GtkRange *r) {
	char tmp[128];

	if (!mediaPlayer) return;

	float lev = gtk_range_get_value (r);

	sprintf(tmp,"%+3.0f%%", lev);
	gtk_label_set_text(GTK_LABEL(L16000), tmp);    // update label

	if (SP->currentPreset < 0) {
		gtk_range_set_value(r,0.0);
		return;
		}

	libvlc_audio_equalizer_set_amp_at_index	(SP->preSet[SP->currentPreset], lev, 9);
	libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void	on_rmsPeak_value_changed(GtkRange *r) {
	}


void	on_attack_value_changed(GtkRange *r) {
	}


void	on_release_value_changed(GtkRange *r) {
	}


void	on_threshold_value_changed(GtkRange *r) {
	}


void	on_ratio_value_changed(GtkRange *r) {
	}


void	on_knee_value_changed(GtkRange *r) {
	}


void	on_makeup_value_changed(GtkRange *r) {
	}

void    SetVlcEqualizerPreAmp() { // attach preamp equalizer to media player if exists
	if (SP->currentPreset < 0) return;
	libvlc_audio_equalizer_set_preamp(SP->preSet[SP->currentPreset], Eq_Vol);
	if (mediaPlayer)
		libvlc_media_player_set_equalizer(mediaPlayer,  SP->preSet[SP->currentPreset]);
	}


void    createPresets() {

//----------------
//	presets
//----------------

	int i;
	printf("Equalizer preset count %d\n", i=libvlc_audio_equalizer_get_preset_count() );

	for(int j=0; j<i; j++) { // extract equilizer presets
		SP->preSet[j] = libvlc_audio_equalizer_new_from_preset((unsigned) j);
		}
	}

