/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAS_GAIN_H_
#define __GDAS_GAIN_H_

typedef struct _GdasGain GdasGain;

#include "gdasfilter.h"


GtkType gdas_gain_get_type();
#define GDAS_TYPE_GAIN   gdas_gain_get_type()
#define GDAS_GAIN(ptr) ((GdasGain*) gtk_type_check_object_cast ((GtkTypeObject*) (ptr), GDAS_TYPE_GAIN))

/* This is a virtual function which changes the volume of a
 * block of audio data.  making this a virtual func lets us
 * swap highly optimized versions for special cases 0.0, 1.0, etc */
typedef void (*GdasGainAlterer)(GdamSample    *buffer,
                                int            buffer_length,
				GdamFixed      resampler_param);
struct _GdasGain {
	GdasFilter           	filter;
	GdasGainAlterer      	regainer;
	GdamFixed            	current_gain;
	GdamFixed		desired_gain;
	GdamFixed		max_delta_per_sample;

	/* don't bother fading unless we've output
	 * some sample. */
	gboolean		has_output;
};

void        gdas_gain_set_level        (GdasGain   *gain,
                                        GdamFixed   fixed);

#endif
