* @since 0.0.5\r
*/\r
\r
-\r
public class Decoder implements DecoderErrors {\r
\r
static private final Params DEFAULT_PARAMS = new Params();\r
/**\r
* The Bistream from which the MPEG audio frames are read.\r
*/\r
- // \r
+ //\r
// private Bitstream stream;\r
\r
/**\r
* The Obuffer instance that will receive the decoded PCM samples.\r
*/\r
- // \r
+ //\r
// private Obuffer output;\r
\r
/**\r
* Synthesis filter for the left channel.\r
*/\r
- // \r
+ //\r
// private SynthesisFilter filter1;\r
\r
/**\r
* Sythesis filter for the right channel.\r
*/\r
- // \r
+ //\r
// private SynthesisFilter filter2;\r
\r
/**\r
* The decoder used to decode layer III frames.\r
*/\r
- \r
+\r
private LayerIIIDecoder l3decoder;\r
- // \r
+ //\r
// private LayerIIDecoder l2decoder;\r
- // \r
+ //\r
// private LayerIDecoder l1decoder;\r
\r
- \r
private int outputFrequency;\r
- \r
+\r
private int outputChannels;\r
\r
- \r
private Equalizer equalizer = new Equalizer();\r
\r
- \r
private Params params;\r
\r
- \r
private boolean initialized;\r
\r
/**\r
// if (filter2 != null)\r
// filter2.setEQ(factors);\r
// }\r
- \r
- public void init( Header header) {\r
- float scalefactor = 32700.0f;\r
\r
- int mode = header.mode();\r
- int layer = header.layer();\r
- int channels = mode == Header.SINGLE_CHANNEL ? 1 : 2;\r
+ public void init(Header header) {\r
+ float scalefactor = 32700.0f;\r
+\r
+ int mode = header.mode();\r
+ int layer = header.layer();\r
+ int channels = mode == Header.SINGLE_CHANNEL ? 1 : 2;\r
\r
// set up output buffer if not set up by client.\r
// if (output == null)\r
// output = new SampleBuffer(header.frequency(), channels);\r
SampleBufferWrapper.init(header.frequency(), channels);\r
\r
- float[] factors = equalizer.getBandFactors();\r
- SynthesisFilter filter1 =\r
- new SynthesisFilter(0, scalefactor, factors);\r
+ float[] factors = equalizer.getBandFactors();\r
+ SynthesisFilter filter1 = new SynthesisFilter(0, scalefactor, factors);\r
\r
// REVIEW: allow mono output for stereo\r
- SynthesisFilter filter2 = null;\r
+ SynthesisFilter filter2 = null;\r
if (channels == 2) {\r
filter2 = new SynthesisFilter(1, scalefactor, factors);\r
}\r
outputChannels = channels;\r
outputFrequency = header.frequency();\r
\r
- l3decoder = new LayerIIIDecoder(header,filter1, filter2, OutputChannels.BOTH_CHANNELS);\r
+ l3decoder = new LayerIIIDecoder(header, filter1, filter2, OutputChannels.BOTH_CHANNELS);\r
\r
}\r
\r
* \r
* @return A SampleBuffer containing the decoded samples.\r
*/\r
- \r
- public void decodeFrame( Header header) throws DecoderException {\r
+\r
+ public void decodeFrame(Header header) throws DecoderException {\r
\r
SampleBufferWrapper.clear_buffer();\r
l3decoder.decode(header);\r
}\r
}\r
\r
+/**\r
+ * The <code>Params</code> class presents the customizable aspects of the\r
+ * decoder.\r
+ * <p>\r
+ * Instances of this class are not thread safe.\r
+ */\r
+public class Params implements Cloneable {\r
\r
+ // private OutputChannels outputChannels = OutputChannels.BOTH;\r
+ private OutputChannels outputChannels = new OutputChannels(0);\r
\r
+ private Equalizer equalizer = new Equalizer();\r
\r
+ public Params() {\r
+ }\r
\r
- /**\r
- * The <code>Params</code> class presents the customizable aspects of the\r
- * decoder.\r
- * <p>\r
- * Instances of this class are not thread safe.\r
- */\r
- public class Params implements Cloneable {\r
-\r
- // private OutputChannels outputChannels = OutputChannels.BOTH;\r
- private OutputChannels outputChannels = new OutputChannels(0);\r
-\r
- private Equalizer equalizer = new Equalizer();\r
-\r
- public Params() {\r
- }\r
-\r
- public Object clone() {\r
- // TODO: need to have better clone method\r
- Params clone = new Params();\r
- clone.outputChannels = new OutputChannels(outputChannels.getChannelsOutputCode());\r
- clone.equalizer = new Equalizer();\r
- return clone;\r
- // try\r
- // {\r
- // return super.clone();\r
- // }\r
- // catch (CloneNotSupportedException ex)\r
- // {\r
- // throw new InternalError(this+": "+ex);\r
- // }\r
- }\r
+ public Object clone() {\r
+ // TODO: need to have better clone method\r
+ Params clone = new Params();\r
+ clone.outputChannels = new OutputChannels(outputChannels.getChannelsOutputCode());\r
+ clone.equalizer = new Equalizer();\r
+ return clone;\r
+ // try\r
+ // {\r
+ // return super.clone();\r
+ // }\r
+ // catch (CloneNotSupportedException ex)\r
+ // {\r
+ // throw new InternalError(this+": "+ex);\r
+ // }\r
+ }\r
\r
- public void setOutputChannels(OutputChannels out) {\r
- if (out == null)\r
- throw new NullPointerException("out");\r
+ public void setOutputChannels(OutputChannels out) {\r
+ if (out == null)\r
+ throw new NullPointerException("out");\r
\r
- outputChannels = out;\r
- }\r
+ outputChannels = out;\r
+ }\r
\r
- public OutputChannels getOutputChannels() {\r
- return outputChannels;\r
- }\r
+ public OutputChannels getOutputChannels() {\r
+ return outputChannels;\r
+ }\r
\r
- /**\r
- * Retrieves the equalizer settings that the decoder's equalizer will be\r
- * initialized from.\r
- * <p>\r
- * The <code>Equalizer</code> instance returned cannot be changed in real\r
- * time to affect the decoder output as it is used only to initialize the\r
- * decoders EQ settings. To affect the decoder's output in realtime, use the\r
- * Equalizer returned from the getEqualizer() method on the decoder.\r
- * \r
- * @return The <code>Equalizer</code> used to initialize the EQ settings of\r
- * the decoder.\r
- */\r
- public Equalizer getInitialEqualizerSettings() {\r
- return equalizer;\r
- }\r
+ /**\r
+ * Retrieves the equalizer settings that the decoder's equalizer will be\r
+ * initialized from.\r
+ * <p>\r
+ * The <code>Equalizer</code> instance returned cannot be changed in real time\r
+ * to affect the decoder output as it is used only to initialize the decoders\r
+ * EQ settings. To affect the decoder's output in realtime, use the Equalizer\r
+ * returned from the getEqualizer() method on the decoder.\r
+ * \r
+ * @return The <code>Equalizer</code> used to initialize the EQ settings of\r
+ * the decoder.\r
+ */\r
+ public Equalizer getInitialEqualizerSettings() {\r
+ return equalizer;\r
+ }\r
\r
- }
\ No newline at end of file
+}
\ No newline at end of file