/**
* Loads the requested file into an {@link AudioPlayer} with the request
* buffer size.
*
* @param filename
* the file or URL you want to load
* @param bufferSize
* int: the sample buffer size you want, which determines the
* size of the left, right, and mix AudioBuffer fields of the
* returned AudioPlayer.
*
* @return an <code>AudioPlayer</code> with a sample buffer of the requested
* size, or null if we were unable to load the file
*/
public AudioPlayer loadFile(String filename, int bufferSize)
{
AudioPlayer player = null;
AudioRecordingStream rec = mimp.getAudioRecordingStream( filename, bufferSize, false );
if ( rec != null )
{
AudioFormat format = rec.getFormat();
AudioOut out = mimp.getAudioOutput( format.getChannels(),
bufferSize,
format.getSampleRate(),
format.getSampleSizeInBits() );
if ( out != null )
{
player = new AudioPlayer( rec, out );
}
else
{
rec.close();
}
}
if ( player != null )
{
addSource( player );
}
else
{
error( "Couldn't load the file " + filename );
}
return player;
}
Minim.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:romanov
作者:
评论列表
文章目录