/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+
#+     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
#+
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

//	Nov 4, 2022

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

#define SLASH '/'

//-----------------------
//	vu style meters
//-----------------------

gboolean vu_draw2_draw (GtkDrawingArea *widget, cairo_t *cr) {

	double hor, ver, t1, len;

//----------------------------------------------
//	average the past X to dampen movement
//----------------------------------------------

#define ACOUNT 3

	if (which_meters == FAN_METER) {
		cairo_rectangle (cr, 0.0, 0.0, 640.0, 480.0);
		cairo_fill(cr);
		cairo_stroke(cr);
		}

	Lx = 0.0;
	for (int i=0; i < ACOUNT; i++) Lx = Lx + lchan[i];
	Rx = 0.0;
	for (int i=0; i < ACOUNT; i++) Rx = Rx + rchan[i];

	Lx = Lx / ACOUNT;
	Rx = Rx / ACOUNT;

	if (which_meters != BAR_METER) {

//--------------------------------
//	LEFT Channel meter
//--------------------------------

		if (Lx > ClipLevel) L_Clipping = 1;
		else                L_Clipping = 0;

		if (Lx > 0.0 ) t1 = (Lx / 100.0) * M_PI;
		else           t1 = 0.0;

//------------------------------------------------------
//	position of origin point and length of needle:
//------------------------------------------------------

#define MHOR 55.0
#define LEN 65.0

		hor = MHOR + 45.;
		ver = 62.0;
		len = LEN;

		vneedles(cr, hor, ver, len, t1, 1);

//--------------------------------
//	RIGHT Channel meter
//--------------------------------

		hor = MHOR + 248.;
		ver = 62.0;
		len = LEN;

		if (Rx > ClipLevel) R_Clipping = 1;
		else                R_Clipping = 0;

		if (Rx > 0.0) t1 = (Rx / 100.0) * M_PI;
		else          t1 = 0.0;

		vneedles(cr, hor, ver, len, t1, 2);

		return FALSE;

		}

//-----------------------------------------------------------------
//	not active in windows at present
//	t1 = (Balance / 100.0) * M_PI;
//      needles(cr, hor, ver, len, t1, 0, 4, 0.0);
//	cairo_move_to (cr, hor - 18., ver + 15.0 ); // top
//	cairo_show_text(cr, "Balance");
//	cairo_stroke (cr);
//-----------------------------------------------------------------

	return FALSE;

	}
