All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javazoom.jl.decoder.Equalizer Maven / Gradle / Ivy

The newest version!
/*
 * 11/19/04		1.0 moved to LGPL.
 * 12/12/99		Initial version.	[email protected]
 *-----------------------------------------------------------------------
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library 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 Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------
 */


package javazoom.jl.decoder;

/**
 * The Equalizer class can be used to specify
 * equalization settings for the MPEG audio decoder. 
 * 

* The equalizer consists of 32 band-pass filters. * Each band of the equalizer can take on a fractional value between * -1.0 and +1.0. * At -1.0, the input signal is attenuated by 6dB, at +1.0 the signal is * amplified by 6dB. * * @see Decoder * * @author MDM */ public final class Equalizer { /** * Equalizer setting to denote that a given band will not be * present in the output signal. */ static public final float BAND_NOT_PRESENT = Float.NEGATIVE_INFINITY; static public final Equalizer PASS_THRU_EQ = new Equalizer(); private static final int BANDS = 32; private final float[] settings = new float[BANDS]; /** * Creates a new Equalizer instance. */ public Equalizer() { } // private Equalizer(float b1, float b2, float b3, float b4, float b5, // float b6, float b7, float b8, float b9, float b10, float b11, // float b12, float b13, float b14, float b15, float b16, // float b17, float b18, float b19, float b20); public Equalizer(float[] settings) { setFrom(settings); } public Equalizer(EQFunction eq) { setFrom(eq); } public void setFrom(float[] eq) { reset(); int max = (eq.length > BANDS) ? BANDS : eq.length; for (int i=0; i=0) && (band=0) && (band 1.0f) return 1.0f; if (eq < -1.0f) return -1.0f; return eq; } /** * Retrieves an array of floats whose values represent a * scaling factor that can be applied to linear samples * in each band to provide the equalization represented by * this instance. * * @return an array of factors that can be applied to the * subbands. */ float[] getBandFactors() { float[] factors = new float[BANDS]; for (int i=0, maxCount=BANDS; i





© 2015 - 2024 Weber Informatics LLC | Privacy Policy