Permalink
Browse files

Fix FlacPacker

  • Loading branch information...
kc7bfi
kc7bfi committed Aug 9, 2004
1 parent 0be6f86 commit 28af0f523d162c915a7ca87df5a9f8a379082dee
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.0.0">
<fileset name="Source" enabled="true" check-config-name="ORCI Standard">
<file-match-pattern match-pattern=".java$" include-pattern="true"/>
</fileset>
</fileset-config>
@@ -1,18 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jflac</name>
<comment>&lt;p&gt;Java FLAC Codec&lt;/p&gt; &lt;p&gt;jFLAC is a port of the Free Lossless Audio Codec (FLAC) library to Java. This library allows java developers to experiment and write programs that use the FLAC algorithms.&lt;/p&gt; &lt;p&gt;The &lt;a href="http://sourceforge.net/projects/jflac"&gt;jFLAC project&lt;/a&gt; is hosted by &lt;a href="http://sourceforge.net"&gt;SourceForge&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;You may want to explore the Java &lt;a href="xref/index.html"&gt;source code&lt;/a&gt; and the &lt;a href="apidocs/index.html"&gt;javadoc&lt;/a&gt;.&lt;/p&gt; &lt;hr/&gt; &lt;A href="http://sourceforge.net"&gt; &lt;IMG src="http://sourceforge.net/sflogo.php?group_id=106536" border="0" alt="SourceForge.net Logo" /&gt;&lt;/A&gt;</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<name>SourceForge - jFLAC</name>
<comment>&lt;p&gt;Java FLAC Codec&lt;/p&gt; &lt;p&gt;jFLAC is a port of the Free Lossless Audio Codec (FLAC) library to Java. This library allows java developers to experiment and write programs that use the FLAC algorithms.&lt;/p&gt; &lt;p&gt;The &lt;a href=&quot;http://sourceforge.net/projects/jflac&quot;&gt;jFLAC project&lt;/a&gt; is hosted by &lt;a href=&quot;http://sourceforge.net&quot;&gt;SourceForge&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;You may want to explore the Java &lt;a href=&quot;xref/index.html&quot;&gt;source code&lt;/a&gt; and the &lt;a href=&quot;apidocs/index.html&quot;&gt;javadoc&lt;/a&gt;.&lt;/p&gt; &lt;hr/&gt; &lt;A href=&quot;http://sourceforge.net&quot;&gt; &lt;IMG src=&quot;http://sourceforge.net/sflogo.php?group_id=106536&quot; border=&quot;0&quot; alt=&quot;SourceForge.net Logo&quot; /&gt;&lt;/A&gt;</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
</natures>
</projectDescription>
@@ -59,7 +59,7 @@
private int outputCapacity = 0;
private int outputChannels = 0;
private int lastFrameNumber;
private long samplesDecoded;
private long samplesDecoded = 0;
private StreamInfo streamInfo;
private Frame frame = new Frame();
private byte[] headerWarmup = new byte[2]; // contains the sync code and reserved bits
@@ -571,7 +571,8 @@ public Metadata readNextMetadata() throws IOException {
int length = bitStream.readRawUInt(Metadata.STREAM_METADATA_LENGTH_LEN);
if (type == Metadata.METADATA_TYPE_STREAMINFO) {
metadata = streamInfo = new StreamInfo(bitStream, length, isLast);
streamInfo = new StreamInfo(bitStream, length, isLast);
metadata = streamInfo;
pcmProcessors.processStreamInfo((StreamInfo)metadata);
} else if (type == Metadata.METADATA_TYPE_SEEKTABLE) {
metadata = new SeekTable(bitStream, length, isLast);
@@ -764,7 +765,9 @@ public void readFrame() throws IOException, FrameDecodeException {
sampleRate = frame.header.sampleRate;
blockSize = frame.header.blockSize;
samplesDecoded = frame.header.sampleNumber + frame.header.blockSize;
//samplesDecoded = frame.header.sampleNumber + frame.header.blockSize;
samplesDecoded += frame.header.blockSize;
//System.out.println(samplesDecoded+" "+frame.header.sampleNumber + " "+frame.header.blockSize);
//state = DECODER_SEARCH_FOR_FRAME_SYNC;
//return;
@@ -61,6 +61,7 @@ public FlacPacker(String title) {
// text area
textArea.setText("");
textArea.setAutoscrolls(true);
this.getContentPane().add(textArea, BorderLayout.CENTER);
// button pannel
@@ -92,6 +93,7 @@ public void actionPerformed(ActionEvent event) {
private void appendMsg(String msg) {
textArea.setText(textArea.getText() + msg + "\n");
textArea.repaint();
}
private void addFilesToList() {
@@ -148,9 +150,15 @@ private SeekTable makeSeekTable() {
long frameStartOffs = decoder.getTotalBytesRead();
PackerFile aFile = new PackerFile(file, seekPoint, frameStartOffs);
albumFiles.add(aFile);
decoder.decode();
//System.out.println("Do decode " +i);
try {
decoder.decodeFrames();
} catch (EOFException e) {
//appendMsg("File " + file + ": " + e);
}
//System.out.println("Done decode");
long frameEndOffs = decoder.getTotalBytesRead();
appendMsg(frameStartOffs + " " + frameEndOffs);
//appendMsg(frameStartOffs + " " + frameEndOffs + " " + decoder.getSamplesDecoded());
lastSampleNumber += decoder.getSamplesDecoded();
lastStreamOffset += frameEndOffs - frameStartOffs;
} catch (FileNotFoundException e) {
@@ -20,6 +20,7 @@
*/
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -57,7 +58,11 @@ public void decode(String inFileName) throws IOException, LineUnavailableExcepti
FLACDecoder decoder = new FLACDecoder(is);
decoder.addPCMProcessor(this);
decoder.decode();
try {
decoder.decode();
} catch (EOFException e) {
// skip
}
line.drain();
line.close();
@@ -225,7 +225,7 @@ public int getSampleRate() {
* @return the Java Sound AudioFormat for this stream info.
*/
public AudioFormat getAudioFormat() {
return new AudioFormat(sampleRate, bitsPerSample, channels, true, false);
return new AudioFormat(sampleRate, bitsPerSample, channels, (bitsPerSample <= 8) ? false : true, false);
}
/**

0 comments on commit 28af0f5

Please sign in to comment.