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


Java Type类代码示例

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


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

示例1: writeDataToLine

import javax.sound.sampled.FloatControl.Type; //导入依赖的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

示例2: setPanning

import javax.sound.sampled.FloatControl.Type; //导入依赖的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

示例3: createDataLineForChannel

import javax.sound.sampled.FloatControl.Type; //导入依赖的package包/类
/** This one will only create datalines for common clip/audioline samples
 *  directly.
 * 
 * @param c
 * @param sfxid
 */
private final void  createDataLineForChannel(int c, int sfxid){
	
	// None? Make a new one.
	
	if (channels[c].auline == null) {
       	try {
       		DoomSound tmp=cachedSounds.get(sfxid);
       		// Sorry, Charlie. Gotta make a new one.
       		DataLine.Info info = new DataLine.Info(SourceDataLine.class, DoomSound.DEFAULT_SAMPLES_FORMAT);
			channels[c].auline = (SourceDataLine) AudioSystem.getLine(info);
			channels[c].auline.open(tmp.format);
		} catch (LineUnavailableException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
				boolean errors=false;
       			// Add individual volume control.
       			if (channels[c].auline.isControlSupported(Type.MASTER_GAIN))
       				channels[c].vc=(FloatControl) channels[c].auline
       				.getControl(Type.MASTER_GAIN);
       			else {
       			System.err.print("MASTER_GAIN, ");
       			errors=true;
       			if (channels[c].auline.isControlSupported(Type.VOLUME))
           				channels[c].vc=(FloatControl) channels[c].auline
           				.getControl(Type.VOLUME);
       			else 
       				System.err.print("VOLUME, ");
       			} 
       			

       			// Add individual pitch control.
       			if (channels[c].auline.isControlSupported(Type.SAMPLE_RATE)){
       				channels[c].pc=(FloatControl) channels[c].auline
       				.getControl(Type.SAMPLE_RATE);
       			} else {
       				errors=true;
       				System.err.print("SAMPLE_RATE, ");
       			} 
       			
       			// Add individual pan control
       			if (channels[c].auline.isControlSupported(Type.BALANCE)){
       				channels[c].bc=(FloatControl) channels[c].auline
       				.getControl(FloatControl.Type.BALANCE);
       			} else {
       				System.err.print("BALANCE, ");
       				errors=true;
       				if (channels[c].auline.isControlSupported(Type.PAN)){        					
       				channels[c].bc=(FloatControl) channels[c].auline
       				.getControl(FloatControl.Type.PAN);
       			} else {
       				System.err.print("PANNING ");
       				}
       			}

       			if (errors) System.err.printf("for channel %d NOT supported!\n",c);
       			
       			channels[c].auline.start();
       		}
}
 
开发者ID:AXDOOMER,项目名称:mochadoom,代码行数:67,代码来源:DavidSFXModule.java


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