本文整理汇总了Java中paulscode.sound.SoundBuffer类的典型用法代码示例。如果您正苦于以下问题:Java SoundBuffer类的具体用法?Java SoundBuffer怎么用?Java SoundBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SoundBuffer类属于paulscode.sound包,在下文中一共展示了SoundBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: read
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
@Override
public SoundBuffer read() {
if (!initialized || streamClosed)
return null;
final int limit = SoundSystemConfig.getStreamingBufferSize();
ByteArrayOutputStream output = new ByteArrayOutputStream(limit);
try {
do {
readBytes(output);
if (!updateBuffer())
break;
} while (!streamClosed && output.size() < limit);
} catch (Throwable t) {
Log.warn(t, "Error in stream decoding, aborting");
streamClosed = true;
}
return new SoundBuffer(output.toByteArray(), audioFormat);
}
开发者ID:OpenMods,项目名称:NotEnoughCodecs,代码行数:22,代码来源:CodecMP3.java
示例2: readAll
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
@Override
public SoundBuffer readAll() {
if (!initialized || streamClosed)
return null;
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
do {
readBytes(output);
if (!updateBuffer())
break;
} while (!streamClosed);
} catch (Throwable t) {
Log.warn(t, "Error in stream decoding, aborting");
streamClosed = true;
}
return new SoundBuffer(output.toByteArray(), audioFormat);
}
开发者ID:OpenMods,项目名称:NotEnoughCodecs,代码行数:21,代码来源:CodecMP3.java
示例3: read
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
@Override
public SoundBuffer read() {
if (!initialized || streamClosed)
return null;
final int limit = SoundSystemConfig.getStreamingBufferSize();
ByteArrayOutputStream output = new ByteArrayOutputStream(limit);
try {
do {
output.write(buffer.getData(), 0, buffer.getLen());
if (!updateBuffer())
break;
} while (!streamClosed && output.size() < limit);
} catch (Throwable t) {
Log.warn(t, "Error in stream decoding, aborting");
streamClosed = true;
}
return new SoundBuffer(output.toByteArray(), audioFormat);
}
开发者ID:OpenMods,项目名称:NotEnoughCodecs,代码行数:22,代码来源:CodecFLAC.java
示例4: readAll
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
@Override
public SoundBuffer readAll() {
if (!initialized || streamClosed)
return null;
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
do {
output.write(buffer.getData(), 0, buffer.getLen());
if (!updateBuffer())
break;
} while (!streamClosed);
} catch (Throwable t) {
Log.warn(t, "Error in stream decoding, aborting");
streamClosed = true;
}
return new SoundBuffer(output.toByteArray(), audioFormat);
}
开发者ID:OpenMods,项目名称:NotEnoughCodecs,代码行数:21,代码来源:CodecFLAC.java
示例5: cleanup
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Empties the streamBuffers list, shuts the channel down and removes
* references to all instantiated objects.
*/
@Override
public void cleanup()
{
if( streamBuffers != null )
{
SoundBuffer buf = null;
while( !streamBuffers.isEmpty() )
{
buf = streamBuffers.remove( 0 );
buf.cleanup();
buf = null;
}
streamBuffers.clear();
}
clip = null;
soundBuffer = null;
sourceDataLine = null;
streamBuffers.clear();
myMixer = null;
myFormat = null;
streamBuffers = null;
super.cleanup();
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:30,代码来源:ChannelJavaSound.java
示例6: feedRawAudioData
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Feeds raw data to the stream.
* @param buffer Buffer containing raw audio data to stream.
* @return Number of prior buffers that have been processed, or -1 if error.
*/
@Override
public int feedRawAudioData( byte[] buffer )
{
// Stream buffers can only be queued for streaming sources:
if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING,
"Raw audio data can only be processed by streaming sources." ) )
return -1;
if( errorCheck( streamBuffers == null,
"StreamBuffers queue null in method 'feedRawAudioData'." ) )
return -1;
streamBuffers.add( new SoundBuffer( buffer, myFormat ) );
return buffersProcessed();
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:21,代码来源:ChannelJavaSound.java
示例7: SourceLWJGLOpenAL
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Constructor: Creates a new source using the specified parameters.
* @param listenerPosition FloatBuffer containing the listener's 3D coordinates.
* @param myBuffer OpenAL IntBuffer sound-buffer identifier to use for a new normal source.
* @param priority Setting this to true will prevent other sounds from overriding this one.
* @param toStream Setting this to true will create a streaming source.
* @param toLoop Should this source loop, or play only once.
* @param sourcename A unique identifier for this source. Two sources may not use the same sourcename.
* @param filenameURL Filename/URL of the sound file to play at this source.
* @param soundBuffer Buffer containing audio data, or null if not loaded yet.
* @param x X position for this source.
* @param y Y position for this source.
* @param z Z position for this source.
* @param attModel Attenuation model to use.
* @param distOrRoll Either the fading distance or rolloff factor, depending on the value of 'att'.
* @param temporary Whether or not to remove this source after it finishes playing.
*/
public SourceLWJGLOpenAL( FloatBuffer listenerPosition, IntBuffer myBuffer,
boolean priority, boolean toStream,
boolean toLoop, String sourcename,
FilenameURL filenameURL, SoundBuffer soundBuffer,
float x, float y, float z, int attModel,
float distOrRoll, boolean temporary )
{
super( priority, toStream, toLoop, sourcename, filenameURL, soundBuffer,
x, y, z, attModel, distOrRoll, temporary );
if( codec != null )
codec.reverseByteOrder( true );
this.listenerPosition = listenerPosition;
this.myBuffer = myBuffer;
libraryType = LibraryLWJGLOpenAL.class;
pitch = 1.0f;
resetALInformation();
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:35,代码来源:SourceLWJGLOpenAL.java
示例8: read
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Reads in one stream buffer worth of audio data. See
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more
* information about accessing and changing default settings.
* @return The audio data wrapped into a SoundBuffer context.
*/
public SoundBuffer read()
{
byte[] returnBuffer = null;
while( !endOfStream( GET, XXX ) && ( returnBuffer == null ||
returnBuffer.length < SoundSystemConfig.getStreamingBufferSize() ) )
{
if( returnBuffer == null )
returnBuffer = readBytes();
else
returnBuffer = appendByteArrays( returnBuffer, readBytes() );
}
if( returnBuffer == null )
return null;
return new SoundBuffer( returnBuffer, audioFormat );
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:25,代码来源:CodecJOrbis.java
示例9: readAll
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Reads in all the audio data from the stream (up to the default
* "maximum file size". See
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more
* information about accessing and changing default settings.
* @return the audio data wrapped into a SoundBuffer context.
*/
public SoundBuffer readAll()
{
byte[] returnBuffer = null;
while( !endOfStream( GET, XXX ) )
{
if( returnBuffer == null )
returnBuffer = readBytes();
else
returnBuffer = appendByteArrays( returnBuffer, readBytes() );
}
if( returnBuffer == null )
return null;
return new SoundBuffer( returnBuffer, audioFormat );
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:25,代码来源:CodecJOrbis.java
示例10: SourceJavaSound
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Constructor: Creates a new source matching the specified source.
* @param listener Handle to information about the listener.
* @param old Source to copy information from.
* @param soundBuffer Sound buffer to use if creating a new normal source.
*/
public SourceJavaSound( ListenerData listener, Source old,
SoundBuffer soundBuffer )
{
super( old, soundBuffer );
libraryType = LibraryJavaSound.class;
// point handle to the listener information:
this.listener = listener;
positionChanged();
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:17,代码来源:SourceJavaSound.java
示例11: loadSound
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Saves the specified sample data, under the specified identifier. This
* identifier can be later used in place of 'filename' parameters to reference
* the sample data.
* @param buffer the sample data and audio format to save.
* @param identifier What to call the sample.
* @return True if there weren't any problems.
*/
@Override
public boolean loadSound( SoundBuffer buffer, String identifier )
{
// Make sure the buffer map exists:
if( bufferMap == null )
{
bufferMap = new HashMap<String, SoundBuffer>();
importantMessage( "Buffer Map was null in method 'loadSound'" );
}
// make sure they gave us an identifier:
if( errorCheck(identifier == null,
"Identifier not specified in method 'loadSound'" ) )
return false;
// check if it is already loaded:
if( bufferMap.get( identifier ) != null )
return true;
// save it for later:
if( buffer != null )
bufferMap.put( identifier, buffer );
else
errorMessage( "Sound buffer null in method 'loadSound'" );
return true;
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:36,代码来源:LibraryJavaSound.java
示例12: ChannelJavaSound
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Constructor: takes channelType identifier and a handle to the Mixer as
* paramaters. Possible values for channel type can be found in the
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} class.
* @param type Type of channel (normal or streaming).
* @param mixer Handle to the JavaSound Mixer.
*/
public ChannelJavaSound( int type, Mixer mixer )
{
super( type );
libraryType = LibraryJavaSound.class;
myMixer = mixer;
clip = null;
sourceDataLine = null;
streamBuffers = new LinkedList<SoundBuffer>();
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:18,代码来源:ChannelJavaSound.java
示例13: queueBuffer
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Queues up a byte[] buffer of data to be streamed.
* @param buffer The next buffer to be played for a streaming source.
* @return False if an error occurred or if the channel is shutting down.
*/
@Override
public boolean queueBuffer( byte[] buffer )
{
// Stream buffers can only be queued for streaming sources:
if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING,
"Buffers may only be queued for streaming sources." ) )
return false;
// Make sure we have a SourceDataLine:
if( errorCheck( sourceDataLine == null,
"SourceDataLine null in method 'queueBuffer'." ) )
return false;
// make sure a format was specified:
if( errorCheck( myFormat == null,
"AudioFormat null in method 'queueBuffer'" ) )
return false;
// Queue a new buffer:
streamBuffers.add( new SoundBuffer( buffer, myFormat ) );
// Dequeue a buffer and process it:
processBuffer();
processed = 0;
return true;
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:33,代码来源:ChannelJavaSound.java
示例14: processBuffer
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Plays the next queued byte[] buffer. This method is run from the seperate
* {@link paulscode.sound.StreamThread StreamThread}.
* @return False when no more buffers are left to process.
*/
@Override
public boolean processBuffer()
{
// Stream buffers can only be queued for streaming sources:
if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING,
"Buffers are only processed for streaming sources." ) )
return false;
// Make sure we have a SourceDataLine:
if( errorCheck( sourceDataLine == null,
"SourceDataLine null in method 'processBuffer'." ) )
return false;
if( streamBuffers == null || streamBuffers.isEmpty() )
return false;
// Dequeue a buffer and feed it to the SourceDataLine:
SoundBuffer nextBuffer = streamBuffers.remove( 0 );
sourceDataLine.write( nextBuffer.audioData, 0,
nextBuffer.audioData.length );
if( !sourceDataLine.isActive() )
sourceDataLine.start();
nextBuffer.cleanup();
nextBuffer = null;
return true;
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:34,代码来源:ChannelJavaSound.java
示例15: read
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Reads in one stream buffer worth of audio data. See
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more
* information about accessing and changing default settings.
* @return The audio data wrapped into a SoundBuffer context.
*/
@Override
public SoundBuffer read()
{
if( endOfStream( GET, XXX ) )
return null;
if( module == null )
{
errorMessage( "Module null in method 'read'" );
return null;
}
// Check to make sure there is an audio format:
if( myAudioFormat == null )
{
errorMessage( "Audio Format null in method 'read'" );
return null;
}
int bufferFrameSize = (int) SoundSystemConfig.getStreamingBufferSize()
/ 4;
int frames = songDuration - playPosition;
if( frames > bufferFrameSize )
frames = bufferFrameSize;
if( frames <= 0 )
{
endOfStream( SET, true );
return null;
}
byte[] outputBuffer = new byte[ frames * 4 ];
ibxm.get_audio( outputBuffer, frames );
playPosition += frames;
if( playPosition >= songDuration )
{
endOfStream( SET, true );
}
// Reverse the byte order if necessary:
if( reverseBytes )
reverseBytes( outputBuffer, 0, frames * 4 );
// Wrap the data into a SoundBuffer:
SoundBuffer buffer = new SoundBuffer( outputBuffer, myAudioFormat );
return buffer;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:57,代码来源:CodecIBXM.java
示例16: readAll
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Reads in all the audio data from the stream (up to the default
* "maximum file size". See
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more
* information about accessing and changing default settings.
* @return the audio data wrapped into a SoundBuffer context.
*/
@Override
public SoundBuffer readAll()
{
if( module == null )
{
errorMessage( "Module null in method 'readAll'" );
return null;
}
// Check to make sure there is an audio format:
if( myAudioFormat == null )
{
errorMessage( "Audio Format null in method 'readAll'" );
return null;
}
int bufferFrameSize = (int) SoundSystemConfig.getFileChunkSize()
/ 4;
byte[] outputBuffer = new byte[ bufferFrameSize * 4 ];
// Buffer to contain the audio data:
byte[] fullBuffer = null;
// frames of audio data:
int frames;
// bytes of audio data:
int totalBytes = 0;
while( (!endOfStream(GET, XXX)) &&
(totalBytes < SoundSystemConfig.getMaxFileSize()) )
{
frames = songDuration - playPosition;
if( frames > bufferFrameSize )
frames = bufferFrameSize;
ibxm.get_audio( outputBuffer, frames );
totalBytes += (frames * 4);
fullBuffer = appendByteArrays( fullBuffer, outputBuffer,
frames * 4 );
playPosition += frames;
if( playPosition >= songDuration )
{
endOfStream( SET, true );
}
}
// Reverse the byte order if necessary:
if( reverseBytes )
reverseBytes( fullBuffer, 0, totalBytes );
// Wrap the data into a SoundBuffer:
SoundBuffer buffer = new SoundBuffer( fullBuffer, myAudioFormat );
return buffer;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:64,代码来源:CodecIBXM.java
示例17: read
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
@Override
public SoundBuffer read()
{
if(myAudioInputStream == null)
{
endOfStream(SET, true);
return null;
}
// Get the format for the audio data:
AudioFormat audioFormat = myAudioInputStream.getFormat();
// Check to make sure there is an audio format:
if(audioFormat == null)
{
errorMessage("Audio Format null in method 'read'");
endOfStream(SET, true);
return null;
}
// Variables used when reading from the audio input stream:
int bytesRead = 0, cnt = 0;
// Allocate memory for the audio data:
byte[] streamBuffer = new byte[SoundSystemConfig.getStreamingBufferSize()];
try
{
// Read until buffer is full or end of stream is reached:
while((!endOfStream(GET, XXX)) && (bytesRead < streamBuffer.length))
{
myAudioInputStream.execute();
if((cnt = myAudioInputStream.read(streamBuffer, bytesRead, streamBuffer.length
- bytesRead)) <= 0)
{
endOfStream(SET, true);
break;
}
// keep track of how many bytes were read:
bytesRead += cnt;
}
} catch (IOException ioe)
{
/*
* errorMessage( "Exception thrown while reading from the " +
* "AudioInputStream (location #3)." ); printStackTrace( e ); return
* null;
*/// TODO: Figure out why this exceptions is being thrown at end of
// MP3 files!
endOfStream(SET, true);
return null;
} catch (ArrayIndexOutOfBoundsException e)
{
//this exception is thrown at the end of the mp3's
endOfStream(SET, true);
return null;
}
// Return null if no data was read:
if(bytesRead <= 0)
{
endOfStream(SET, true);
return null;
}
// Insert the converted data into a ByteBuffer:
// byte[] data = convertAudioBytes(streamBuffer,
// audioFormat.getSampleSizeInBits() == 16);
// Wrap the data into a SoundBuffer:
SoundBuffer buffer = new SoundBuffer(streamBuffer, audioFormat);
// Return the result:
return buffer;
}
开发者ID:Dynious,项目名称:SoundsCool,代码行数:77,代码来源:CodecJLayerMP3.java
示例18: read
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Reads in one stream buffer worth of audio data. See
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more
* information about accessing and changing default settings.
* @return The audio data wrapped into a SoundBuffer context.
*/
public SoundBuffer read()
{
if( endOfStream( GET, XXX ) )
return null;
if( module == null )
{
errorMessage( "Module null in method 'read'" );
return null;
}
// Check to make sure there is an audio format:
if( myAudioFormat == null )
{
errorMessage( "Audio Format null in method 'read'" );
return null;
}
int bufferFrameSize = (int) SoundSystemConfig.getStreamingBufferSize()
/ 4;
int frames = songDuration - playPosition;
if( frames > bufferFrameSize )
frames = bufferFrameSize;
if( frames <= 0 )
{
endOfStream( SET, true );
return null;
}
byte[] outputBuffer = new byte[ frames * 4 ];
ibxm.get_audio( outputBuffer, frames );
playPosition += frames;
if( playPosition >= songDuration )
{
endOfStream( SET, true );
}
// Reverse the byte order if necessary:
if( reverseBytes )
reverseBytes( outputBuffer, 0, frames * 4 );
// Wrap the data into a SoundBuffer:
SoundBuffer buffer = new SoundBuffer( outputBuffer, myAudioFormat );
return buffer;
}
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:56,代码来源:CodecIBXM.java
示例19: readAll
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Reads in all the audio data from the stream (up to the default
* "maximum file size". See
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more
* information about accessing and changing default settings.
* @return the audio data wrapped into a SoundBuffer context.
*/
public SoundBuffer readAll()
{
if( module == null )
{
errorMessage( "Module null in method 'readAll'" );
return null;
}
// Check to make sure there is an audio format:
if( myAudioFormat == null )
{
errorMessage( "Audio Format null in method 'readAll'" );
return null;
}
int bufferFrameSize = (int) SoundSystemConfig.getFileChunkSize()
/ 4;
byte[] outputBuffer = new byte[ bufferFrameSize * 4 ];
// Buffer to contain the audio data:
byte[] fullBuffer = null;
// frames of audio data:
int frames;
// bytes of audio data:
int totalBytes = 0;
while( (!endOfStream(GET, XXX)) &&
(totalBytes < SoundSystemConfig.getMaxFileSize()) )
{
frames = songDuration - playPosition;
if( frames > bufferFrameSize )
frames = bufferFrameSize;
ibxm.get_audio( outputBuffer, frames );
totalBytes += (frames * 4);
fullBuffer = appendByteArrays( fullBuffer, outputBuffer,
frames * 4 );
playPosition += frames;
if( playPosition >= songDuration )
{
endOfStream( SET, true );
}
}
// Reverse the byte order if necessary:
if( reverseBytes )
reverseBytes( fullBuffer, 0, totalBytes );
// Wrap the data into a SoundBuffer:
SoundBuffer buffer = new SoundBuffer( fullBuffer, myAudioFormat );
return buffer;
}
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:63,代码来源:CodecIBXM.java
示例20: newSource
import paulscode.sound.SoundBuffer; //导入依赖的package包/类
/**
* Creates a new source and places it into the source map.
* @param priority Setting this to true will prevent other sounds from overriding this one.
* @param toStream Setting this to true will load the sound in pieces rather than all at once.
* @param toLoop Should this source loop, or play only once.
* @param sourcename A unique identifier for this source. Two sources may not use the same sourcename.
* @param filenameURL Filename/URL of the sound file to play at this source.
* @param x X position for this source.
* @param y Y position for this source.
* @param z Z position for this source.
* @param attModel Attenuation model to use.
* @param distOrRoll Either the fading distance or rolloff factor, depending on the value of "attmodel".
*/
@Override
public void newSource( boolean priority, boolean toStream, boolean toLoop,
String sourcename, FilenameURL filenameURL, float x,
float y, float z, int attModel, float distOrRoll )
{
SoundBuffer buffer = null;
if( !toStream )
{
// Grab the audio data for this file:
buffer = bufferMap.get( filenameURL.getFilename() );
// if not found, try loading it:
if( buffer == null )
{
if( !loadSound( filenameURL ) )
{
errorMessage( "Source '" + sourcename + "' was not created "
+ "because an error occurred while loading "
+ filenameURL.getFilename() );
return;
}
}
// try and grab the sound buffer again:
buffer = bufferMap.get( filenameURL.getFilename() );
// see if it was there this time:
if( buffer == null )
{
errorMessage( "Source '" + sourcename + "' was not created "
+ "because audio data was not found for "
+ filenameURL.getFilename() );
return;
}
}
if( !toStream && buffer != null )
buffer.trimData( maxClipSize );
sourceMap.put( sourcename,
new SourceJavaSound( listener, priority, toStream,
toLoop, sourcename, filenameURL,
buffer, x, y, z, attModel,
distOrRoll, false ) );
}
开发者ID:kovertopz,项目名称:Paulscode-SoundSystem,代码行数:57,代码来源:LibraryJavaSound.java
注:本文中的paulscode.sound.SoundBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论