JLayer 1.0.1
- PlayerApplet Sample -
To play any MP3 file (e.g. : 44Khz, 128Kbps) , you need a browser JavaSound
1.0 compliant.
e.g : Mozilla, Netscape 6+, or Internet
Explorer + JDK1.3 plugin (or higher).
Playing : test.mp3
© JavaZOOM 1999-2008
DecoderException
represents the class of
* errors that can occur when decoding MPEG audio.
*
* @author MDM
*/
public class DecoderException extends JavaLayerException
implements DecoderErrors
{
private int errorcode = UNKNOWN_ERROR;
public DecoderException(String msg, Throwable t)
{
super(msg, t);
}
public DecoderException(int errorcode, Throwable t)
{
this(getErrorString(errorcode), t);
this.errorcode = errorcode;
}
public int getErrorCode()
{
return errorcode;
}
static public String getErrorString(int errorcode)
{
// REVIEW: use resource file to map error codes
// to locale-sensitive strings.
return "Decoder errorcode "+Integer.toHexString(errorcode);
}
}
libjlayer-java-2.orig/src/javazoom/jl/decoder/Control.java 0000644 0001750 0001750 00000002725 11110045576 023664 0 ustar drazzib drazzib /*
* 11/19/04 1.0 moved to LGPL.
*-----------------------------------------------------------------------
* 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;
/**
* Work in progress.
*/
public interface Control
{
/**
* Starts playback of the media presented by this control.
*/
public void start();
/**
* Stops playback of the media presented by this control.
*/
public void stop();
public boolean isPlaying();
public void pause();
public boolean isRandomAccess();
/**
* Retrieves the current position.
*/
public double getPosition();
/**
*
*/
public void setPosition(double d);
}
libjlayer-java-2.orig/src/javazoom/jl/decoder/InputStreamSource.java 0000644 0001750 0001750 00000003751 11110045576 025700 0 ustar drazzib drazzib /*
* 11/19/04 1.0 moved to LGPL.
* 12/12/99 Initial version. mdm@techie.com
*-----------------------------------------------------------------------
* 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;
import java.io.IOException;
import java.io.InputStream;
/**
* Work In Progress.
*
* An instance of InputStreamSource
implements a
* Source
that provides data from an InputStream
*
. Seeking functionality is not supported.
*
* @author MDM
*/
public class InputStreamSource implements Source
{
private final InputStream in;
public InputStreamSource(InputStream in)
{
if (in==null)
throw new NullPointerException("in");
this.in = in;
}
public int read(byte[] b, int offs, int len)
throws IOException
{
int read = in.read(b, offs, len);
return read;
}
public boolean willReadBlock()
{
return true;
//boolean block = (in.available()==0);
//return block;
}
public boolean isSeekable()
{
return false;
}
public long tell()
{
return -1;
}
public long seek(long to)
{
return -1;
}
public long length()
{
return -1;
}
}
libjlayer-java-2.orig/src/javazoom/jl/decoder/SampleBuffer.java 0000644 0001750 0001750 00000005720 11110045577 024616 0 ustar drazzib drazzib /*
* 11/19/04 1.0 moved to LGPL.
*
* 12/12/99 Initial Version based on FileObuffer. mdm@techie.com.
*
* FileObuffer:
* 15/02/99 Java Conversion by E.B ,javalayer@javazoom.net
*
*-----------------------------------------------------------------------
* 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 SampleBuffer
class implements an output buffer
* that provides storage for a fixed size block of samples.
*/
public class SampleBuffer extends Obuffer
{
private short[] buffer;
private int[] bufferp;
private int channels;
private int frequency;
/**
* Constructor
*/
public SampleBuffer(int sample_frequency, int number_of_channels)
{
buffer = new short[OBUFFERSIZE];
bufferp = new int[MAXCHANNELS];
channels = number_of_channels;
frequency = sample_frequency;
for (int i = 0; i < number_of_channels; ++i)
bufferp[i] = (short)i;
}
public int getChannelCount()
{
return this.channels;
}
public int getSampleFrequency()
{
return this.frequency;
}
public short[] getBuffer()
{
return this.buffer;
}
public int getBufferLength()
{
return bufferp[0];
}
/**
* Takes a 16 Bit PCM sample.
*/
public void append(int channel, short value)
{
buffer[bufferp[channel]] = value;
bufferp[channel] += channels;
}
public void appendSamples(int channel, float[] f)
{
int pos = bufferp[channel];
short s;
float fs;
for (int i=0; i<32;)
{
fs = f[i++];
fs = (fs>32767.0f ? 32767.0f
: (fs < -32767.0f ? -32767.0f : fs));
s = (short)fs;
buffer[pos] = s;
pos += channels;
}
bufferp[channel] = pos;
}
/**
* Write the samples to the file (Random Acces).
*/
public void write_buffer(int val)
{
//for (int i = 0; i < channels; ++i)
// bufferp[i] = (short)i;
}
public void close()
{}
/**
*
*/
public void clear_buffer()
{
for (int i = 0; i < channels; ++i)
bufferp[i] = (short)i;
}
/**
*
*/
public void set_stop_flag()
{}
}
libjlayer-java-2.orig/src/javazoom/jl/decoder/Equalizer.java 0000644 0001750 0001750 00000011676 11110045576 024212 0 ustar drazzib drazzib /*
* 11/19/04 1.0 moved to LGPL.
* 12/12/99 Initial version. mdm@techie.com
*-----------------------------------------------------------------------
* 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