Java 类com.sun.media.sound.WaveFileReader 实例源码
项目:gl3DGE
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(String path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
InputStream is = WaveData.class.getResourceAsStream(path);
if (is == null)
throw new IOException("File not found: " + path);
return create(wfr.getAudioInputStream(new BufferedInputStream(is)));
} catch (Exception e) {
//System.err.println("Unable to create from: " + path + ", " + e.getMessage());
e.printStackTrace();
return null;
}
}
项目:gl3DGE
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(String path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
InputStream is = WaveData.class.getResourceAsStream(path);
if (is == null)
throw new IOException("File not found: " + path);
return create(wfr.getAudioInputStream(new BufferedInputStream(is)));
} catch (Exception e) {
//System.err.println("Unable to create from: " + path + ", " + e.getMessage());
e.printStackTrace();
return null;
}
}
项目:TeamProject
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
//System.out.println("Path! :D : " + path);
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
System.out.println("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:warp
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
logger.error("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:PhET
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:Point-Engine
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
print("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:Wolf_game
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:Dwarf2D
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occurred
*/
public static WaveData create(URL path) throws DwarfException {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
return create(new WaveFileReader().getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (IOException | UnsupportedAudioFileException ex) {
throw new DwarfException(ex);
}
}
项目:GPVM
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:GPVM
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:SpaceStationAlpha
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:TeacherSmash
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:3d-Demo
文件:WaveData.java
/**
* Creates a WaveData container from the specified url
*
* @param path URL to file
* @return WaveData containing data, or null if a failure occured
*/
public static WaveData create(URL path) {
try {
// due to an issue with AudioSystem.getAudioInputStream
// and mixing unsigned and signed code
// we will use the reader directly
WaveFileReader wfr = new WaveFileReader();
return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
} catch (Exception e) {
org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
return null;
}
}
项目:OpenAargon
文件:WavCodec.java
@Override
public IAudioInfo decode(InputStream strIn) throws IOException {
WaveFileReader reader = new WaveFileReader();
try (AudioInputStream ais = reader.getAudioInputStream(strIn)) {
AudioFormat fmt = ais.getFormat();
int chanFmt = -1;
switch (fmt.getChannels()) {
case 1:
switch (fmt.getSampleSizeInBits()) {
case 8:
chanFmt = AL10.AL_FORMAT_MONO8;
break;
case 16:
chanFmt = AL10.AL_FORMAT_MONO16;
break;
}
break;
case 2:
switch (fmt.getSampleSizeInBits()) {
case 8:
chanFmt = AL10.AL_FORMAT_STEREO8;
break;
case 16:
chanFmt = AL10.AL_FORMAT_STEREO16;
break;
}
break;
}
if (chanFmt == -1)
throw new UnsupportedAudioFileException("Illegal audio format!");
byte[] data = new byte[ais.available()];
int read = 0, total = 0;
while ((read = ais.read(data, total, data.length - total)) != 1 && total < data.length)
total += read;
return new WavData(data, chanFmt, (int)fmt.getSampleRate(), fmt.getSampleSizeInBits() == 16, fmt.isBigEndian());
} catch (UnsupportedAudioFileException e) {
throw new IOException(e);
}
}