当前位置: 首页>>代码示例>>Java>>正文


Java FloatControl.getMaximum方法代码示例

本文整理汇总了Java中javax.sound.sampled.FloatControl.getMaximum方法的典型用法代码示例。如果您正苦于以下问题:Java FloatControl.getMaximum方法的具体用法?Java FloatControl.getMaximum怎么用?Java FloatControl.getMaximum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.sampled.FloatControl的用法示例。


在下文中一共展示了FloatControl.getMaximum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
private void init(AudioFormat baseFormat) throws LineUnavailableException {

		decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(),
				baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false);
		DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat);
		line = (SourceDataLine) AudioSystem.getLine(info);
		line.open(decodedFormat);

		volumeControl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);
		minGainDB = volumeControl.getMinimum();
		ampGainDB = ((10.0f / 20.0f) * volumeControl.getMaximum()) - volumeControl.getMinimum();
		cste = Math.log(10.0) / 20;

		//for stations we want to set the initial volume to 0
		volumeControl.setValue((float) minGainDB);
		
		line.start();

		//App.logger.d("prefix + WebPlayer SourceDataLine started!", null);
	}
 
开发者ID:WegFetZ,项目名称:SoundCenterClient,代码行数:21,代码来源:StationPlayer.java

示例2: init

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
private void init(AudioFormat baseFormat) throws LineUnavailableException {

		decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(),
				baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false);
		DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat);
		line = (SourceDataLine) AudioSystem.getLine(info);
		line.open(decodedFormat);

		volumeControl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);
		minGainDB = volumeControl.getMinimum();
		ampGainDB = ((10.0f / 20.0f) * volumeControl.getMaximum()) - volumeControl.getMinimum();
		cste = Math.log(10.0) / 20;
		
		line.start();

		//App.logger.d("prefix + WebPlayer SourceDataLine started!", null);
	}
 
开发者ID:WegFetZ,项目名称:SoundCenterClient,代码行数:18,代码来源:SingleSongPlayer.java

示例3: init

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
private void init() {
	AudioFormat speexFormat = new AudioFormat(16000, 16, 1, true, false);
	DataLine.Info sourceLineInfo = new DataLine.Info(SourceDataLine.class, speexFormat, bufferSize);
	speexDecoder.init(1, 16000, 1, false);
	try {
		line = (SourceDataLine) AudioSystem.getLine(sourceLineInfo);
		line.open(speexFormat, bufferSize);

		volumeControl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);
		minGainDB = volumeControl.getMinimum();
		ampGainDB = ((10.0f / 20.0f) * volumeControl.getMaximum()) - volumeControl.getMinimum();
		cste = Math.log(10.0) / 20;

		volumeControl.setValue((float) minGainDB);

		line.start();

	} catch (LineUnavailableException e) {
		App.logger.w("Failed to create voice player (type: " + type + " id: " + playerId + "):" , e);
		if (!exit)
			close(false);
	}
}
 
开发者ID:WegFetZ,项目名称:SoundCenterClient,代码行数:24,代码来源:VoicePlayer.java

示例4: start

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
/**
 * Plays the clip with the specified volume.
 * @param volume the volume the play at
 * @param listener the line listener
 * @throws LineUnavailableException if a clip object is not available or
 *         if the line cannot be opened due to resource restrictions
 */
public void start(float volume, LineListener listener) throws LineUnavailableException {
	Clip clip = getClip();
	if (clip == null)
		return;

	// PulseAudio does not support Master Gain
	if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
		// set volume
		FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
		float dB = (float) (Math.log(volume) / Math.log(10.0) * 20.0);
		gainControl.setValue(Utils.clamp(dB, gainControl.getMinimum(), gainControl.getMaximum()));
	} else if (clip.isControlSupported(FloatControl.Type.VOLUME)) {
		// The docs don't mention what unit "volume" is supposed to be,
		// but for PulseAudio it seems to be amplitude
		FloatControl volumeControl = (FloatControl) clip.getControl(FloatControl.Type.VOLUME);
		float amplitude = (float) Math.sqrt(volume) * volumeControl.getMaximum();
		volumeControl.setValue(Utils.clamp(amplitude, volumeControl.getMinimum(), volumeControl.getMaximum()));
	}

	if (listener != null)
		clip.addLineListener(listener);
	clip.setFramePosition(0);
	clip.start();
}
 
开发者ID:itdelatrisu,项目名称:opsu,代码行数:32,代码来源:MultiClip.java

示例5: setValue

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
private void setValue(FloatControl.Type type, float v)
{
  if (hasControl(type))
  {
    FloatControl c = (FloatControl) getControl(type);
    if (v > c.getMaximum())
      v = c.getMaximum();
    else if (v < c.getMinimum()) v = c.getMinimum();
    c.setValue(v);
  }
  else
  {
    Minim.error(type.toString() + " is not supported.");
  }
}
 
开发者ID:JacobRoth,项目名称:romanov,代码行数:16,代码来源:Controller.java

示例6: getVolume

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
final public float getVolume(int intPvolumePercentage) throws Throwable {

		if (this.objGclip != null && this.objGclip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
			final FloatControl objLvolumeFloatControl = (FloatControl) this.objGclip.getControl(FloatControl.Type.MASTER_GAIN);
			final float fltLrange = (objLvolumeFloatControl.getMaximum() - objLvolumeFloatControl.getMinimum()) * 1.2F;
			return Math.min(fltLrange * Math.max(0, intPvolumePercentage) / 100.0F + objLvolumeFloatControl.getMinimum(),
							objLvolumeFloatControl.getMaximum());
		}
		throw new Throwable();
	}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:11,代码来源:ExtendedClip.java

示例7: setVolume

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
@Override
public void setVolume(float volume) {
	
	FloatControl control = (FloatControl)this.controls.get("Master Gain");
	float min = control.getMinimum();
	float max = control.getMaximum();
	float oldVal = control.getValue();
	float newVal = volume < min ? min : (volume > max ? max : volume);
	control.setValue(newVal);
	this.trigger(AudioEvent.Type.VOLUME_CHANGED, oldVal, newVal);
}
 
开发者ID:RalleYTN,项目名称:SimpleAudio,代码行数:12,代码来源:AbstractAudio.java

示例8: setBalance

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
@Override
public void setBalance(float balance) {
	
	FloatControl balanceControl = (FloatControl)this.controls.get("Balance");
	float max = balanceControl.getMaximum();
	float min = balanceControl.getMinimum();
	balanceControl.setValue(balance < min ? min : (balance > max ? max : balance));
}
 
开发者ID:RalleYTN,项目名称:SimpleAudio,代码行数:9,代码来源:AbstractAudio.java

示例9: increaseSound

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
public static void increaseSound() {
    if (isTreadAlive()) {
        try {
            gain = (FloatControl) radioPLayer.line.getControl(FloatControl.Type.MASTER_GAIN);
            if (gain.getValue() < (gain.getMaximum() - 2.0F)) {
                gain.setValue(gain.getValue() + 1.0F);
            }

        } catch (NullPointerException e) {
            System.out.println("Sound System was still warming up");
        }
    }
}
 
开发者ID:Hoijima,项目名称:Fallout_Equestria,代码行数:14,代码来源:RadioThreadManager.java

示例10: writeDataToLine

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
private void writeDataToLine() throws LineUnavailableException {
	playing = true;
	line = AudioSystem.getSourceDataLine(format);
	
	if (line == null) {
		return;
	}
	
	line.open();
	
	line.start();
	
	for (int i = 0; i < data.length && playing; i += BUFFER_SIZE) {
		if (line.isControlSupported(Type.MASTER_GAIN)) {
			final FloatControl gainControl = (FloatControl)line.getControl(Type.MASTER_GAIN);
			final float minimum = gainControl.getMinimum();
			final float maximum = gainControl.getMaximum();
			final float actualGain = Math.max(minimum, Math.min(maximum, gain));
			
			gainControl.setValue(actualGain);
		}
		
		if (i + BUFFER_SIZE > data.length) {
			i = data.length - BUFFER_SIZE;
		}
		
		line.write(data, i, BUFFER_SIZE);
	}
	
	line.drain();
}
 
开发者ID:Sogomn,项目名称:spjgl,代码行数:32,代码来源:Sound.java

示例11: setPanning

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
public void setPanning(int chan,int sep){
Clip c=channels[chan];

if (c.isControlSupported(Type.PAN)){
	FloatControl bc=(FloatControl) c.getControl(Type.PAN);
	// Q: how does Doom's sep map to stereo panning?
	// A: Apparently it's 0-255 L-R.
	float pan= bc.getMinimum()+(bc.getMaximum()-bc.getMinimum())*(float)sep/ISoundDriver.PANNING_STEPS;
	bc.setValue(pan);
	}
}
 
开发者ID:AXDOOMER,项目名称:mochadoom,代码行数:12,代码来源:ClipSFXModule.java

示例12: rawplay

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
private void rawplay(AudioFormat trgFormat, AudioInputStream ain, float volume)
		throws IOException, LineUnavailableException {
	byte[] data = new byte[8192];
	try {
		clip = getLine(ain, trgFormat);
		if (clip == null) {
			return;
		}
		Control.Type vol1 = FloatControl.Type.VOLUME, vol2 = FloatControl.Type.MASTER_GAIN;
		FloatControl c = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
		float min = c.getMinimum();
		float v = volume * (c.getMaximum() - min) / 100f + min;
		if (this.clip.isControlSupported(vol1)) {
			FloatControl volumeControl = (FloatControl) this.clip.getControl(vol1);
			volumeControl.setValue(v);
		} else if (this.clip.isControlSupported(vol2)) {
			FloatControl gainControl = (FloatControl) this.clip.getControl(vol2);
			gainControl.setValue(v);
		}
		clip.start();
		int nBytesRead = 0;
		while (isRunning && (nBytesRead != -1)) {
			nBytesRead = ain.read(data, 0, data.length);
			if (nBytesRead != -1) {
				clip.write(data, 0, nBytesRead);
			}
		}
	} finally {
		clip.drain();
		clip.stop();
		clip.close();
		ain.close();
	}
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:35,代码来源:LWaveSound.java

示例13: updateVolume

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
public void updateVolume(int percent) {
	if (out != null && out.isOpen()) {
		try {
			FloatControl c = (FloatControl) out.getControl(FloatControl.Type.MASTER_GAIN);
			float min = c.getMinimum();
			float v = percent * (c.getMaximum() - min) / 100f + min;
			c.setValue(v);
		} catch (IllegalArgumentException e) {
		}
	}
	volume = percent;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:13,代码来源:JoggStreamer.java

示例14: setGain

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
/**
 * Attempt to set the global gain (volume ish) for the play back. If the
 * control is not supported this method has no effect. 1.0 will set maximum
 * gain, 0.0 minimum gain
 *
 * @param gain The gain value
 */
private void setGain(float gain) {
    if (gain != -1) {
        if ((gain < 0) || (gain > 1)) {
            throw new IllegalArgumentException("Volume must be between 0.0 and 1.0");
        }
    }

    this.gain = gain;

    if (outputLine == null) {
        return;
    }

    try {
        FloatControl control = (FloatControl) outputLine.getControl(FloatControl.Type.MASTER_GAIN);
        if (gain == -1) {
            control.setValue(0);
        } else {
            float max = control.getMaximum();
            float min = control.getMinimum(); // negative values all seem to be zero?
            float range = max - min;

            control.setValue(min + (range * gain));
        }
    } catch (IllegalArgumentException e) {
        // gain not supported
        e.printStackTrace();
    }
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:37,代码来源:OggClip.java

示例15: playSound

import javax.sound.sampled.FloatControl; //导入方法依赖的package包/类
/**
 * Starts playing a generated tone in a loop <br>
 * <br>
 * See also {@link #genTone()}
 */
void playSound() {
	try (SourceDataLine line = getSourceDataLine()) {
		if (line != null) {
			isPlaying.set(true);
			
			line.open(mAudioFormat, generatedSnd[currentTone].length);

			// decrease volume
			FloatControl control = (FloatControl) line
					.getControl(FloatControl.Type.MASTER_GAIN);
			// set to 3/5 of maximum dB
			float newValue = control.getMaximum()
					- (2 *(control.getMaximum() - control.getMinimum()) / 5);
			control.setValue(newValue);

			line.start();

			// loop playing
			while (isPlaying.get() && !Thread.currentThread().isInterrupted()) {
				line.write(generatedSnd[currentTone], 0,
						generatedSnd[currentTone].length);
			}
		}
	} catch (LineUnavailableException e) {
		e.printStackTrace();
	}
}
 
开发者ID:n0Live,项目名称:BrickGame,代码行数:33,代码来源:EngineSound.java


注:本文中的javax.sound.sampled.FloatControl.getMaximum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。