• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java AL类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.jogamp.openal.AL的典型用法代码示例。如果您正苦于以下问题:Java AL类的具体用法?Java AL怎么用?Java AL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

AL类属于com.jogamp.openal包,在下文中一共展示了AL类的38个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: stop

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
public void stop() {
	if (initiated == false) return;
	Audio.al.alSourceStop(alSourceId);
	if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
		Console.println("Audio sound: '" + id + "': Could not stop");
	}

	// determine queued buffers
	int[] queuedBuffersArray = new int[1];
	Audio.al.alGetSourcei(alSourceId, AL.AL_BUFFERS_QUEUED, queuedBuffersArray, 0);
	if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
		Console.println("Audio stream: '" + id + "': Could not determine queued buffers");
	}
	int queuedBuffers = queuedBuffersArray[0];

	// unqueue buffers
	if (queuedBuffers > 0) {
		int[] removedBuffers = new int[queuedBuffers];
		Audio.al.alSourceUnqueueBuffers(alSourceId, queuedBuffers, removedBuffers, 0);
		if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
			Console.println("Audio stream: '" + id + "': Could not unqueue buffers");
		}
	}
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:25,
代码来源:AudioStream.java

示例2: updateProperties

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
 * Updates properties to Open AL
 */
private void updateProperties() {
	// update sound properties
	Audio.al.alSourcef (alSourceId, AL.AL_PITCH, pitch);
	Audio.al.alSourcef (alSourceId, AL.AL_GAIN, gain);
	Audio.al.alSourcefv (alSourceId, AL.AL_POSITION, sourcePosition.getArray(), 0);
	Audio.al.alSourcefv (alSourceId, AL.AL_DIRECTION, sourceDirection.getArray(), 0);
	Audio.al.alSourcefv (alSourceId, AL.AL_VELOCITY, sourceVelocity.getArray(), 0);
	if (fixed == true) {
		Audio.al.alSourcef(alSourceId, AL.AL_ROLLOFF_FACTOR,  0.0f);
		Audio.al.alSourcei(alSourceId, AL.AL_SOURCE_RELATIVE, AL.AL_TRUE);
	} else {
		Audio.al.alSourcef(alSourceId, AL.AL_ROLLOFF_FACTOR,  1.0f);
		Audio.al.alSourcei(alSourceId, AL.AL_SOURCE_RELATIVE, AL.AL_FALSE);			
	}
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:19,
代码来源:AudioStream.java

示例3: dispose

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
protected void dispose() {
	if (alSourceId != Audio.ALSOURCEID_NONE) {
		Audio.al.alDeleteSources(1, new int[]{alSourceId}, 0);
		if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
			Console.println("Audio sound: '" + id + "': Could not delete source");
		}
		alSourceId = Audio.ALSOURCEID_NONE;
	}
	if (alBufferIds != null) {
		//
		Audio.al.alDeleteBuffers(alBufferIds.length, alBufferIds, 0);
		if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
			Console.println("Audio sound: '" + id + "': Could not delete buffers");
		}
		alBufferIds = null;
	}
	if (decoder != null) decoder.close();
	initiated = false;
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:20,
代码来源:AudioStream.java

示例4: update

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
 * Update and transfer audio entity states to open AL
 */
public void update() {
	// update audio entities
	for (AudioEntity audioEntity: audioEntities.getValuesIterator()) {
		audioEntity.update();
	}

	// update listener position
	al.alListenerfv (AL.AL_POSITION, listenerPosition.getArray(), 0);
	al.alListenerfv (AL.AL_VELOCITY, listenerVelocity.getArray(), 0);
	float[] listenerOrientationAtArray = listenerOrientationAt.getArray();
	float[] listenerOrientationUpArray = listenerOrientationUp.getArray();
	float[] listenerOrientation = new float[] {
		listenerOrientationAtArray[0],
		listenerOrientationAtArray[1],
		listenerOrientationAtArray[2],
		listenerOrientationUpArray[0],
		listenerOrientationUpArray[1],
		listenerOrientationUpArray[2]
	};
	al.alListenerfv (AL.AL_ORIENTATION, listenerOrientation, 0);
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:25,
代码来源:Audio.java

示例5: update

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
protected void update() {
	// update sound properties
	Audio.al.alSourcef(alSourceId, AL.AL_PITCH, pitch);
	Audio.al.alSourcef(alSourceId, AL.AL_GAIN, gain);
	Audio.al.alSourcefv(alSourceId, AL.AL_POSITION, sourcePosition.getArray(), 0);
	Audio.al.alSourcefv(alSourceId, AL.AL_DIRECTION, sourceDirection.getArray(), 0);
	Audio.al.alSourcefv(alSourceId, AL.AL_VELOCITY, sourceVelocity.getArray(), 0);
	Audio.al.alSourcei(alSourceId, AL.AL_LOOPING, looping?AL.AL_TRUE:AL.AL_FALSE);
	if (fixed == true) {
		Audio.al.alSourcef(alSourceId, AL.AL_ROLLOFF_FACTOR,  0.0f);
		Audio.al.alSourcei(alSourceId, AL.AL_SOURCE_RELATIVE, AL.AL_TRUE);
	} else {
		Audio.al.alSourcef(alSourceId, AL.AL_ROLLOFF_FACTOR,  1.0f);
		Audio.al.alSourcei(alSourceId, AL.AL_SOURCE_RELATIVE, AL.AL_FALSE);			
	}
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:17,
代码来源:Sound.java

示例6: dispose

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
protected void dispose() {
	if (alSourceId != Audio.ALSOURCEID_NONE) {
		Audio.al.alDeleteSources(1, new int[]{alSourceId}, 0);
		if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
			Console.println("Audio sound: '" + id + "': Could not delete source");
		}
		alSourceId = Audio.ALSOURCEID_NONE;
	}
	if (alBufferId != Audio.ALBUFFERID_NONE &&
		Audio.instance.audioBufferManager.removeAudioBuffer(bufferId) == true) {
		//
		Audio.al.alDeleteBuffers(1, new int[]{alBufferId}, 0);
		if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
			Console.println("Audio sound: '" + id + "': Could not delete buffers");
		}
		alBufferId = Audio.ALBUFFERID_NONE;
	}
	initiated = false;
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:20,
代码来源:Sound.java

示例7: setPosition

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Moves the source to the specified position.
* @param x X coordinate to move to.
* @param y Y coordinate to move to.
* @param z Z coordinate to move to.
*/
   @Override
   public void setPosition( float x, float y, float z )
   {
       super.setPosition( x, y, z );
       
       positionChanged();
       
       // check if we are assigned to a channel.  If so, tell OpenAL where
       // this source is located:
       if( channel != null && channel.attachedSource == this &&
           channelOpenAL != null && channelOpenAL.ALSource != null )
       {
           // move the source:
           al.alSource3f( channelOpenAL.ALSource[0], AL.AL_POSITION,
                          x, y, z );
           checkALError();
       }
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:25,
代码来源:SourceJOAL.java

示例8: positionChanged

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Recalculates the distance from the listner and the gain.
*/
   @Override
   public void positionChanged()
   {
       calculateDistance();
       calculateGain();
       
       if( channel != null && channel.attachedSource == this &&
           channelOpenAL != null && channelOpenAL.ALSource != null )
       {
           al.alSourcef( channelOpenAL.ALSource[0], AL.AL_GAIN,
                         (gain * sourceVolume * (float) Math.abs( fadeOutGain )
                                              * fadeInGain) );
           checkALError();
       }
       checkPitch();
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:20,
代码来源:SourceJOAL.java

示例9: setLooping

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Sets whether this source should loop or only play once.
* @param lp True or false.
*/
   @Override
   public void setLooping( boolean lp )
   {
       super.setLooping( lp );
       
       // make sure we are assigned to a channel:
       if( channel != null && channel.attachedSource == this &&
           channelOpenAL != null && channelOpenAL.ALSource != null )
       {
           if( lp )
               al.alSourcei( channelOpenAL.ALSource[0], AL.AL_LOOPING,
                             AL.AL_TRUE );
           else
               al.alSourcei( channelOpenAL.ALSource[0], AL.AL_LOOPING,
                             AL.AL_FALSE );
           checkALError();
       }
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:23,
代码来源:SourceJOAL.java

示例10: setAttenuation

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Sets this source's attenuation model.
* @param model Attenuation model to use.
*/
   @Override
   public void setAttenuation( int model )
   {
       super.setAttenuation( model );
       // make sure we are assigned to a channel:
       if( channel != null && channel.attachedSource == this &&
           channelOpenAL != null && channelOpenAL.ALSource != null )
       {
           // attenuation changed, so update the rolloff factor accordingly
           if( model == SoundSystemConfig.ATTENUATION_ROLLOFF )
               al.alSourcef( channelOpenAL.ALSource[0], AL.AL_ROLLOFF_FACTOR,
                             distOrRoll );
           else
               al.alSourcef( channelOpenAL.ALSource[0], AL.AL_ROLLOFF_FACTOR,
                             0.0f );
           checkALError();
       }
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:23,
代码来源:SourceJOAL.java

示例11: setDistOrRoll

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Sets this source's fade distance or rolloff factor, depending on the 
* attenuation model.
* @param dr New value for fade distance or rolloff factor.
*/
   @Override
   public void setDistOrRoll( float dr)
   {
       super.setDistOrRoll( dr );
       // make sure we are assigned to a channel:
       if( channel != null && channel.attachedSource == this &&
           channelOpenAL != null && channelOpenAL.ALSource != null )
       {
           // if we are using rolloff attenuation, then dr is a rolloff factor:
           if( attModel == SoundSystemConfig.ATTENUATION_ROLLOFF )
               al.alSourcef( channelOpenAL.ALSource[0], AL.AL_ROLLOFF_FACTOR,
                             dr );
           else
               al.alSourcef( channelOpenAL.ALSource[0], AL.AL_ROLLOFF_FACTOR,
                             0.0f );
           checkALError();
       }
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:24,
代码来源:SourceJOAL.java

示例12: createChannel

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Creates a new channel of the specified type (normal or streaming).  Possible 
* values for channel type can be found in the 
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} class.
* @param type Type of channel.
*/
   @Override
   protected Channel createChannel( int type )
   {
       ChannelJOAL channel;

       int[] ALSource = new int[1];
       try
       {
           al.alGenSources( 1, ALSource, 0 );
       }
       catch( java.lang.Exception e )
       {
           al.alGetError();
           return null;  // no more voices left
       }

       if( al.alGetError() != AL.AL_NO_ERROR )
           return null;

       channel = new ChannelJOAL( type, ALSource );
       return channel;
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:29,
代码来源:LibraryJOAL.java

示例13: setListenerAngle

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Changes the listeners orientation to the specified 'angle' radians 
* counterclockwise around the y-Axis.
* @param angle Radians.
*/
   @Override
   public void setListenerAngle( float angle )
   {
       super.setListenerAngle( angle );
       
       // Update OpenAL listener orientation:
       al.alListenerfv( AL.AL_ORIENTATION, new float[]{ listener.lookAt.x,
                                                        listener.lookAt.y,
                                                        listener.lookAt.z,
                                                        listener.up.x,
                                                        listener.up.y,
                                                        listener.up.z }, 0 );
       // Check for errors:
       checkALError();
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:21,
代码来源:LibraryJOAL.java

示例14: setListenerOrientation

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Changes the listeners orientation using the specified coordinates.
* @param lookX X element of the look-at direction.
* @param lookY Y element of the look-at direction.
* @param lookZ Z element of the look-at direction.
* @param upX X element of the up direction.
* @param upY Y element of the up direction.
* @param upZ Z element of the up direction.
*/
   @Override
   public void setListenerOrientation( float lookX, float lookY, float lookZ,
                                       float upX, float upY, float upZ )
   {
       super.setListenerOrientation( lookX, lookY, lookZ, upX, upY, upZ );

       // Update OpenAL listener orientation:
       al.alListenerfv( AL.AL_ORIENTATION, new float[]{ listener.lookAt.x,
                                                        listener.lookAt.y,
                                                        listener.lookAt.z,
                                                        listener.up.x,
                                                        listener.up.y,
                                                        listener.up.z }, 0 );
       // Check for errors:
       checkALError();
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:26,
代码来源:LibraryJOAL.java

示例15: setListenerData

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Changes the listeners position and orientation using the specified listener 
* data.
* @param l Listener data to use.
*/
   @Override
   public void setListenerData( ListenerData l )
   {
       super.setListenerData( l );
       
       // Pass the listener info to the sound system, and check for errors:
       al.alListener3f( AL.AL_POSITION, listener.position.x,
                        listener.position.y, listener.position.z );
       checkALError();
       al.alListenerfv( AL.AL_ORIENTATION, new float[]{ listener.lookAt.x,
                                                        listener.lookAt.y,
                                                        listener.lookAt.z,
                                                        listener.up.x,
                                                        listener.up.y,
                                                        listener.up.z }, 0 );
       checkALError();
       al.alListener3f( AL.AL_VELOCITY, listener.velocity.x,
                        listener.velocity.y, listener.velocity.z );
       checkALError();
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:26,
代码来源:LibraryJOAL.java

示例16: attachBuffer

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Attaches an OpenAL sound-buffer identifier for the sound data to be played 
* back for a normal source.
* @param buf Identifier for the sound data to play.
* @return False if an error occurred.
*/
   public boolean attachBuffer( int[] buf )
   {
       // A sound buffer can only be attached to a normal source:
       if( errorCheck( channelType != SoundSystemConfig.TYPE_NORMAL,
                       "Sound buffers may only be attached to normal " +
                       "sources." ) )
           return false;
       
       // send the sound buffer to the channel:
       al.alSourcei( ALSource[0], AL.AL_BUFFER, buf[0] );
       
       // save the format for later, for determining milliseconds played
       if( attachedSource != null && attachedSource.soundBuffer != null &&
           attachedSource.soundBuffer.audioFormat != null )
           setAudioFormat( attachedSource.soundBuffer.audioFormat );
       
       // Check for errors and return:
       return checkALError();
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:26,
代码来源:ChannelJOAL.java

示例17: millisInBuffer

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Returns the number of milliseconds of audio contained in specified buffer.
* @return milliseconds, or 0 if unable to calculate.
*/
   public float millisInBuffer( int alBufferi )
   {
       int size[] = new int[1];
       int channels[] = new int[1];
       int bits[] = new int[1];
       al.alGetBufferi( alBufferi, AL.AL_SIZE, size, 0 );
       checkALError();
       al.alGetBufferi( alBufferi, AL.AL_CHANNELS, channels, 0 );
       checkALError();
       al.alGetBufferi( alBufferi, AL.AL_BITS, bits, 0 );
       checkALError();

       return( ( (float) size[0] / (float) channels[0] / ( (float) bits[0] /
                                        8.0f ) / (float) sampleRate ) * 1000 );
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:20,
代码来源:ChannelJOAL.java

示例18: buffersProcessed

点赞 3

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Returns the number of queued byte[] buffers that have finished playing.
* @return Number of buffers processed.
*/
   @Override
   public int buffersProcessed()
   {
       // Only streaming sources process buffers:
       if( channelType != SoundSystemConfig.TYPE_STREAMING )
           return 0;
       
       // determine how many have been processed:
       int[] processed = new int[1];
       al.alGetSourcei( ALSource[0], AL.AL_BUFFERS_PROCESSED, processed, 0 );
       
       // Check for errors:
       if( checkALError() )
           return 0;
       
       // Return how many were processed:
       return processed[0];
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:23,
代码来源:ChannelJOAL.java

示例19: bind

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
 * Loads Resources and binds sound to AL Context
 * @return AL_TRUE (success) or AL_FALSE (fail)
 */
public int bind(){
	al.alGenSources(1, src, 0);

	if (al.alGetError() != AL.AL_NO_ERROR) {
		return AL.AL_FALSE;
	}

	loadAttributes();
	return AL.AL_FALSE;
}
 

开发者ID:ZetzmannM,
项目名称:CGL,
代码行数:15,
代码来源:SoundFile.java

示例20: loadWAVResources

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
 * loads the WAV file into the buffer
 * @return AL_TRUE (success) or AL_FALSE (fail)
 */
public int loadWAVResources(){
	al.alGenBuffers(1, buffer, 0);
	if (al.alGetError() != AL.AL_NO_ERROR) {
		return AL.AL_FALSE;
	}

	ALut.alutLoadWAVFile(filePath, format, data, size, freq, loop);
	al.alBufferData(buffer[0], format[0], data[0], size[0], freq[0]);
	return AL.AL_TRUE;
}
 

开发者ID:ZetzmannM,
项目名称:CGL,
代码行数:15,
代码来源:SoundFile.java

示例21: play

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
 * Plays the sound
 * @param pos Sound source position
 * @param vel Sound source velocity
 */
public void play(PointF3 pos, VectorF3 vel){
	al.alSourcefv(src[0], AL.AL_POSITION, pos.array(), 0);
	al.alSourcefv(src[0], AL.AL_VELOCITY, vel.array(), 0);

	al.alSourcePlay(src[0]);
	for(ISoundPlayListener e  : list){
		e.onSoundPlay();
	}
	calcLength();
	thr = new Thread(this);
	thr.start();
}
 

开发者ID:ZetzmannM,
项目名称:CGL,
代码行数:18,
代码来源:SoundFile.java

示例22: formtSz

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
public static double formtSz(int[] format2) {
	switch(format2[0]){
	case AL.AL_FORMAT_MONO8:
		return 8;
	case AL.AL_FORMAT_MONO16:
		return 16;

	}
	System.out.println("UNSUPPORTED AUDIO FORMAT");
	return 0;
}
 

开发者ID:ZetzmannM,
项目名称:CGL,
代码行数:12,
代码来源:SoundFile.java

示例23: play

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
public void play() {
	if (initiated == false) return;

	if (isPlaying() == true) stop();

	// update AL properties
	updateProperties();

	//
	int buffersToPlay = 0;
	for (int i = 0; i < alBufferIds.length; i++) {
		data.clear();
		try {
			//
			int bytesDecoded = decoder.readFromStream(data);

			// skip if no more data is available
			if (bytesDecoded == 0) break;
		} catch (IOException ioe) {
			Console.println("Audio stream: '" + id + "': " + ioe.getMessage());
		} catch (AudioDecoderException ade) {
			Console.println("Audio stream: '" + id + "': " + ade.getMessage());
		}
		Audio.al.alBufferData(alBufferIds[i], format, data, data.remaining(), frequency);
		if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
			Console.println("Audio stream: '" + id + "': Could not upload buffer");
		}
		buffersToPlay++;
	}

	//
	Audio.al.alSourceQueueBuffers(alSourceId, buffersToPlay, alBufferIds, 0);
	if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
		Console.println("Audio stream: '" + id + "': Could not queue buffers");
	}
	Audio.al.alSourcePlay(alSourceId);
	if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
		Console.println("Audio stream: '" + id + "': Could not play source");
	}
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:41,
代码来源:AudioStream.java

示例24: pause

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
public void pause() {
	if (initiated == false) return;
	Audio.al.alSourcePause(alSourceId);
	if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
		Console.println("Audio sound: '" + id + "': Could not pause");
	}
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:8,
代码来源:AudioStream.java

示例25: rewind

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
public void rewind() {
	if (initiated == false) return;
	Audio.al.alSourceRewind(alSourceId);
	if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
		Console.println("Audio sound: '" + id + "': Could not rewind");
	}
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:8,
代码来源:Sound.java

示例26: play

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
public void play() {
	if (initiated == false) return;

	// update
	update();

	// play
	Audio.al.alSourcePlay(alSourceId);
	if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
		Console.println("Audio sound: '" + id + "': Could not play");
	}
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:13,
代码来源:Sound.java

示例27: stop

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
public void stop() {
	if (initiated == false) return;
	Audio.al.alSourceStop(alSourceId);
	if (Audio.al.alGetError() != AL.AL_NO_ERROR) {
		Console.println("Audio sound: '" + id + "': Could not stop");
	}
}
 

开发者ID:andreasdr,
项目名称:tdme,
代码行数:8,
代码来源:Sound.java

示例28: setMusic

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
public synchronized void setMusic(Music music){
    if(CObjects.equals(currentMusic,music)) return;
    currentMusic = music;
    
    stopAudio();
    
    if(music==null) return;
    
    //load new audio
    final byte[] all = music.createPCMBuffer();
    final AudioStreamMeta meta = music.getAudioStreamMeta();
    if(meta==null) return;

    //buffer which contains audio datas
    final ALBuffer data = new ALBuffer();
    data.setFormat(AL.AL_FORMAT_STEREO16);
    data.setFrequency((int) meta.getSampleRate());
    data.setSize(all.length);
    data.setData(ByteBuffer.wrap(all));
    data.load();

    audioSource.setBuffer(data);
    audioSource.setLoop(true);
    audioSource.load();
    audioSource.play();
    
    getEventManager().sendPropertyEvent(this, MusicSelector.PROPERTY_MUSIC, null, null);
}
 

开发者ID:silice-hf,
项目名称:3ddm,
代码行数:29,
代码来源:DefaultStage.java

示例29: setSound

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
public void setSound(Path path){
    try{
        final MediaStore store = Medias.open(path);

        //tranform audio in a supported byte buffer
        final AudioStreamMeta meta = (AudioStreamMeta) store.getStreamsMeta()[0];
        final MediaReader reader = store.createReader(null);

        //recode stream in a stereo 16 bits per sample.
        final ArrayOutputStream out = new ArrayOutputStream();
        final DataOutputStream ds = new DataOutputStream(out, NumberEncoding.LITTLE_ENDIAN);

        while(reader.hasNext()){
            reader.next();
            final AudioSamples samples = (AudioSamples) reader.getBuffers()[0];
            final int[] audiosamples = samples.asPCM(null, 16);
            ds.writeUShort(audiosamples[0]);
            ds.writeUShort(audiosamples[1]);
        }

        final byte[] all = out.getBuffer().toArray();

        //buffer which contains audio datas
        final ALBuffer data = new ALBuffer();
        data.setFormat(AL.AL_FORMAT_STEREO16);
        data.setFrequency((int) meta.getSampleRate());
        data.setSize(all.length);
        data.setData(ByteBuffer.wrap(all));
        data.load();

        //the audio source
        alsource = new ALSource();
        alsource.setLoop(false);
        alsource.setBuffer(data);
        alsource.load();
    }catch(Throwable ex){
        Game.LOGGER.warning(ex);
    }
}
 

开发者ID:silice-hf,
项目名称:3ddm,
代码行数:40,
代码来源:WeaponFireTask.java

示例30: checkPitch

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Checks the source's pitch.
*/
   private void checkPitch()
   {
       if( channel != null && channel.attachedSource == this &&
           LibraryJOAL.alPitchSupported() && channelOpenAL != null &&
           channelOpenAL.ALSource != null )
       {
           al.alSourcef( channelOpenAL.ALSource[0],
                         AL.AL_PITCH, pitch );
           checkALError();
       }
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:15,
代码来源:SourceJOAL.java

示例31: setVelocity

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Sets this source's velocity, for use in Doppler effect.
* @param x Velocity along world x-axis.
* @param y Velocity along world y-axis.
* @param z Velocity along world z-axis.
*/
   @Override
   public void setVelocity( float x, float y, float z )
   {
       super.setVelocity( x, y, z );

       // make sure we are assigned to a channel:
       if( channel != null && channel.attachedSource == this &&
           channelOpenAL != null && channelOpenAL.ALSource != null )
       {
           al.alSource3f( channelOpenAL.ALSource[0], AL.AL_VELOCITY,
                          x, y, z );
           checkALError();
       }
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:21,
代码来源:SourceJOAL.java

示例32: checkALError

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Checks for OpenAL errors, and prints a message if there is an error.
* @return True if there was an error, False if not.
*/
   private boolean checkALError()
   {
       switch( al.alGetError() )
       {
           case AL.AL_NO_ERROR:
               return false;
           case AL.AL_INVALID_NAME:
               errorMessage( "Invalid name parameter." );
               return true;
           case AL.AL_INVALID_ENUM:
               errorMessage( "Invalid parameter." );
               return true;
           case AL.AL_INVALID_VALUE:
               errorMessage( "Invalid enumerated parameter value." );
               return true;
           case AL.AL_INVALID_OPERATION:
               errorMessage( "Illegal call." );
               return true;
           case AL.AL_OUT_OF_MEMORY:
               errorMessage( "Unable to allocate memory." );
               return true;
           default:
               errorMessage( "An unrecognized error occurred." );
               return true;
       }
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:31,
代码来源:SourceJOAL.java

示例33: setMasterVolume

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Sets the overall volume to the specified value, affecting all sources.
* @param value New volume, float value ( 0.0f - 1.0f ).
*/ 
   @Override
   public void setMasterVolume( float value )
   {
       super.setMasterVolume( value );
       
       al.alListenerf( AL.AL_GAIN, value );
       checkALError();
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:13,
代码来源:LibraryJOAL.java

示例34: setListenerPosition

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Changes the listener's position. 
* @param x Destination X coordinate.
* @param y Destination Y coordinate.
* @param z Destination Z coordinate.
*/
   @Override
   public void setListenerPosition( float x, float y, float z )
   {
       super.setListenerPosition( x, y, z );
       
       // Update OpenAL listener position:
       al.alListener3f( AL.AL_POSITION, x, y, z );
       // Check for errors:
       checkALError();
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:17,
代码来源:LibraryJOAL.java

示例35: setListenerVelocity

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Sets the listener's velocity, for use in Doppler effect.
* @param x Velocity along world x-axis.
* @param y Velocity along world y-axis.
* @param z Velocity along world z-axis.
*/
   @Override
   public void setListenerVelocity( float x, float y, float z )
   {
       super.setListenerVelocity( x, y, z );

       al.alListener3f( AL.AL_VELOCITY, listener.velocity.x,
                        listener.velocity.y, listener.velocity.z );
       checkALError();
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:16,
代码来源:LibraryJOAL.java

示例36: millisecondsPlayed

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Calculates the number of milliseconds since the channel began playing.
* @return Milliseconds, or -1 if unable to calculate.
*/
   @Override
   public float millisecondsPlayed()
   {
       int byteOffset[] = new int[1];
       // get number of samples played in current buffer
       al.alGetSourcei( ALSource[0], AL.AL_BYTE_OFFSET, byteOffset, 0 );

       float bytesPerFrame = 1f;
       switch( ALformat )
       {
           case AL.AL_FORMAT_MONO8 :
               bytesPerFrame = 1f;
               break;
           case AL.AL_FORMAT_MONO16 :
               bytesPerFrame = 2f;
               break;
           case AL.AL_FORMAT_STEREO8 :
               bytesPerFrame = 2f;
               break;
           case AL.AL_FORMAT_STEREO16 :
               bytesPerFrame = 4f;
               break;
           default :
               break;
       }

       float offset = ( ( (float) byteOffset[0] / bytesPerFrame ) /
                                                   (float) sampleRate ) * 1000;

       // add the milliseconds from stream-buffers that played previously
       if( channelType == SoundSystemConfig.TYPE_STREAMING )
           offset += millisPreviouslyPlayed;

       // Return millis played:
       return( offset );
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:41,
代码来源:ChannelJOAL.java

示例37: flush

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Dequeues all previously queued data.
*/
   @Override
   public void flush()
   {
       // Only a streaming source can be flushed, because only streaming
       // sources have queued buffers:
       if( channelType != SoundSystemConfig.TYPE_STREAMING )
           return;
       
       // determine how many buffers have been queued:
       int[] queued = new int[1];
       al.alGetSourcei( ALSource[0], AL.AL_BUFFERS_QUEUED, queued, 0 );

       // Check for errors:
       if( checkALError() )
           return;
       
       IntBuffer intBuffer = IntBuffer.wrap( new int[1] );
       while( queued[0] > 0 )
       {
           try
           {
               al.alSourceUnqueueBuffers( ALSource[0], 1, intBuffer );
           }
           catch( Exception e )
           {
               return;
           }
           if( checkALError() )
               return;
           queued[0]--;
       }
      	millisPreviouslyPlayed = 0;
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:37,
代码来源:ChannelJOAL.java

示例38: playing

点赞 2

import com.jogamp.openal.AL; //导入依赖的package包/类
/**
* Used to determine if a channel is actively playing a source.  This method 
* will return false if the channel is paused or stopped and when no data is 
* queued to be streamed.
* @return True if this channel is playing a source.
*/
   @Override
   public boolean playing()
   {
       int[] state = new int[1];
       al.alGetSourcei( ALSource[0], AL.AL_SOURCE_STATE, state, 0 );
       if( checkALError() )
           return false;
       
       return( state[0] == AL.AL_PLAYING );
   }
 

开发者ID:yuripourre,
项目名称:htbm-v2,
代码行数:17,
代码来源:ChannelJOAL.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)