finished adding album cover for music selection, properly read different wav headers now
This commit is contained in:
@@ -6,8 +6,6 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
public class WavInfo {
|
||||
private int channels;
|
||||
private double sampleRate;
|
||||
@@ -59,18 +57,18 @@ public class WavInfo {
|
||||
|
||||
byteRate = littleEndianIntBytes(); //4
|
||||
|
||||
readStream.skip(4); //38
|
||||
readStream.skip(4);
|
||||
|
||||
// System.out.println(readBytesToString(4).equals("data"));
|
||||
|
||||
if (!readBytesToString(4).equals("data")) { // 4
|
||||
Gdx.app.debug("Audio", "sample rate: " + sampleRate);
|
||||
Gdx.app.debug("Audio", "Data chunk size: " + dataSize);
|
||||
Gdx.app.debug("Audio", "Channel count: " + channels);
|
||||
|
||||
throw new InvalidParameterException("initial data section tag not found on wav: " + fileName);
|
||||
String moreInfo = readBytesToString(4);
|
||||
if (moreInfo.equals("LIST")) { // 4
|
||||
readStream.skip(30);
|
||||
if (!readBytesToString(4).equals("data")) {
|
||||
throw new InvalidParameterException("failed to read data with extra info.");
|
||||
}
|
||||
} else if (!moreInfo.equals("data")) {
|
||||
throw new InvalidParameterException("failed to read data.");
|
||||
}
|
||||
|
||||
|
||||
readStream.skip(4);
|
||||
}
|
||||
|
||||
@@ -122,4 +120,8 @@ public class WavInfo {
|
||||
public long getDurationInSeconds() {
|
||||
return (long) (dataSize/byteRate);
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user