本文整理匯總了Java中org.lwjgl.openal.AL10.alSourcef方法的典型用法代碼示例。如果您正苦於以下問題:Java AL10.alSourcef方法的具體用法?Java AL10.alSourcef怎麽用?Java AL10.alSourcef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.openal.AL10
的用法示例。
在下文中一共展示了AL10.alSourcef方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playAsMusic
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Play the specified buffer as music (i.e. use the music channel)
*
* @param buffer The buffer to be played
* @param pitch The pitch to play the music at
* @param gain The gaing to play the music at
* @param loop True if we should loop the music
*/
void playAsMusic(int buffer,float pitch,float gain, boolean loop) {
paused = false;
setMOD(null);
if (soundWorks) {
if (currentMusic != -1) {
AL10.alSourceStop(sources.get(0));
}
getMusicSource();
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffer);
AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch);
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE);
currentMusic = sources.get(0);
if (!music) {
pauseLoop();
} else {
AL10.alSourcePlay(sources.get(0));
}
}
}
示例2: playNewStream
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
@Override
public long playNewStream(double volume) {
int sourceID = audioFactory.obtainSource(false);
if (sourceID == -1) {
audioFactory.retain(this, true);
sourceID = audioFactory.obtainSource(false);
} else {
audioFactory.retain(this, false);
}
if (sourceID == -1) return -1;
long soundId = audioFactory.getSoundId(sourceID);
AL10.alSourcei(sourceID, AL10.AL_BUFFER, bufferID);
AL10.alSourcei(sourceID, AL10.AL_LOOPING, AL10.AL_FALSE);
AL10.alSourcef(sourceID, AL10.AL_GAIN, (float) volume);
AL10.alSourcePlay(sourceID);
return soundId;
}
示例3: setVolume
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
@Override
public void setVolume(double volume) {
this.volume = volume;
if (sourceID != -1) {
AL10.alSourcef(sourceID, AL10.AL_GAIN, (float) volume);
}
}
示例4: setPosition
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* @see org.newdawn.slick.openal.Audio#setPosition(float)
*/
public boolean setPosition(float position) {
position = position % length;
AL10.alSourcef(store.getSource(index), AL11.AL_SEC_OFFSET, position);
if (AL10.alGetError() != 0) {
return false;
}
return true;
}
示例5: setCurrentMusicVolume
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Set the music volume of the current playing music. Does NOT affect the global volume
*
* @param volume The volume for the current playing music
*/
public void setCurrentMusicVolume(float volume) {
if (volume < 0) {
volume = 0;
}
if (volume > 1) {
volume = 1;
}
if (soundWorks) {
lastCurrentMusicVolume = volume;
AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume);
}
}
示例6: playAsSoundAt
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Play the specified buffer as a sound effect with the specified
* pitch and gain.
*
* @param buffer The ID of the buffer to play
* @param pitch The pitch to play at
* @param gain The gain to play at
* @param loop True if the sound should loop
* @param x The x position to play the sound from
* @param y The y position to play the sound from
* @param z The z position to play the sound from
* @return source The source that will be used
*/
int playAsSoundAt(int buffer,float pitch,float gain,boolean loop,float x, float y, float z) {
gain *= soundVolume;
if (gain == 0) {
gain = 0.001f;
}
if (soundWorks) {
if (sounds) {
int nextSource = findFreeSource();
if (nextSource == -1) {
return -1;
}
AL10.alSourceStop(sources.get(nextSource));
AL10.alSourcei(sources.get(nextSource), AL10.AL_BUFFER, buffer);
AL10.alSourcef(sources.get(nextSource), AL10.AL_PITCH, pitch);
AL10.alSourcef(sources.get(nextSource), AL10.AL_GAIN, gain);
AL10.alSourcei(sources.get(nextSource), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE);
sourcePos.clear();
sourceVel.clear();
sourceVel.put(new float[] { 0, 0, 0 });
sourcePos.put(new float[] { x, y, z });
sourcePos.flip();
sourceVel.flip();
AL10.alSource(sources.get(nextSource), AL10.AL_POSITION, sourcePos);
AL10.alSource(sources.get(nextSource), AL10.AL_VELOCITY, sourceVel);
AL10.alSourcePlay(sources.get(nextSource));
return nextSource;
}
}
return -1;
}
示例7: startPlayback
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Starts the streaming.
*/
private void startPlayback() {
AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_FALSE);
AL10.alSourcef(source, AL10.AL_PITCH, pitch);
remainingBufferCount = BUFFER_COUNT;
for (int i = 0; i < BUFFER_COUNT; i++) {
stream(bufferNames.get(i));
}
AL10.alSourceQueueBuffers(source, bufferNames);
AL10.alSourcePlay(source);
}
示例8: play
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Play a mod or xm track streamed from the specified location
*
* @param module The moudle to play back
* @param source The OpenAL source to play the music on
* @param start True if the music should be started
* @param loop True if the track should be looped
*/
public void play(Module module, int source, boolean loop, boolean start) {
this.source = source;
this.loop = loop;
this.module = module;
done = false;
ibxm = new IBXM(48000);
ibxm.set_module(module);
songDuration = ibxm.calculate_song_duration();
if (bufferNames != null) {
AL10.alSourceStop(source);
bufferNames.flip();
AL10.alDeleteBuffers(bufferNames);
}
bufferNames = BufferUtils.createIntBuffer(2);
AL10.alGenBuffers(bufferNames);
remainingBufferCount = 2;
for (int i=0;i<2;i++) {
stream(bufferNames.get(i));
}
AL10.alSourceQueueBuffers(source, bufferNames);
AL10.alSourcef(source, AL10.AL_PITCH, 1.0f);
AL10.alSourcef(source, AL10.AL_GAIN, 1.0f);
if (start) {
AL10.alSourcePlay(source);
}
}
示例9: setMusicVolume
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Set the music volume
*
* @param volume The volume for music
*/
public void setMusicVolume(float volume) {
if (volume < 0) {
volume = 0;
}
if (volume > 1) {
volume = 1;
}
musicVolume = volume;
if (soundWorks) {
AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume);
}
}
示例10: playAsSoundAt
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
private int playAsSoundAt(int buffer, float pitch, float gain, float x,
float y)
{
// gain *= soundVolume;
if (gain == 0)
{
gain = 0.001f;
}
if (game.gameOptions.soundEnable == true)
{
int nextSource = findFreeSource();
if (nextSource == -1)
{
return -1;
}
AL10.alSourceStop(sources.get(nextSource));
AL10.alSourcei(sources.get(nextSource), AL10.AL_BUFFER, buffer);
AL10.alSourcef(sources.get(nextSource), AL10.AL_PITCH, pitch);
AL10.alSourcef(sources.get(nextSource), AL10.AL_GAIN, gain);
sourcePos.clear();
sourcePos.put(new float[]
{ x, y, 0.0f });
sourcePos.flip();
AL10.alSource(sources.get(nextSource), AL10.AL_POSITION, sourcePos);
AL10.alSourcePlay(sources.get(nextSource));
return nextSource;
}
return -1;
}
示例11: QueueSound
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
private void QueueSound(int sound)
{
if (game.gameOptions.soundEnable == false)
return;
intBuffer.clear();
intBuffer.put(sounds[sound]);
intBuffer.flip();
AL10.alSourceQueueBuffers(sources.get(0), intBuffer);
int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);
if (state != AL10.AL_PLAYING)
{
sourcePos.clear();
sourcePos.put(0).put(0).put(0);
sourcePos.flip();
int Source = sources.get(0);
AL10.alSourceStop(Source);
AL10.alSourcef(Source, AL10.AL_PITCH, 1.0f);
AL10.alSourcef(Source, AL10.AL_GAIN, 1.0f);
AL10.alSource(Source, AL10.AL_POSITION, sourcePos);
AL10.alSourcePlay(Source);
}
}
示例12: setMusicPitch
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Set the pitch at which the current music is being played
*
* @param pitch The pitch at which the current music is being played
*/
public void setMusicPitch(float pitch) {
if (soundWorks) {
AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch);
}
}
示例13: setGain
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
public void setGain(float gain){
this.gain = gain;
AL10.alSourcef(id, AL10.AL_GAIN, gain);
}
示例14: setRolloffFactor
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
public void setRolloffFactor(float rolloffFactor){
if(this.rolloffFactor == rolloffFactor)
return;
this.rolloffFactor = rolloffFactor;
AL10.alSourcef(id, AL10.AL_ROLLOFF_FACTOR, rolloffFactor);
}