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


Java TAudioFormat类代码示例

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


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

示例1: determineProperties

import org.tritonus.share.sampled.TAudioFormat; //导入依赖的package包/类
/**
 * Determines Properties when the File/URL/InputStream is opened.
 */
private void determineProperties() {
	logger.info("Entered determineProperties()!\n");
	
	// Add AudioFileFormat properties.
	// Expect if it is null(something bad happened).
	if (audioFileFormat == null)
		return;
	
	if (! ( audioFileFormat instanceof TAudioFileFormat ))
		audioProperties = new HashMap<>();
	else {
		// Tritonus SPI compliant audio file format.
		audioProperties = ( (TAudioFileFormat) audioFileFormat ).properties();
		
		// Clone the Map because it is not mutable.
		audioProperties = deepCopy(audioProperties);
		
	}
	
	// Add JavaSound properties.
	if (audioFileFormat.getByteLength() > 0)
		audioProperties.put("audio.length.bytes", audioFileFormat.getByteLength());
	if (audioFileFormat.getFrameLength() > 0)
		audioProperties.put("audio.length.frames", audioFileFormat.getFrameLength());
	if (audioFileFormat.getType() != null)
		audioProperties.put("audio.type", audioFileFormat.getType());
	
	// AudioFormat properties.
	AudioFormat audioFormat = audioFileFormat.getFormat();
	if (audioFormat.getFrameRate() > 0)
		audioProperties.put("audio.framerate.fps", audioFormat.getFrameRate());
	if (audioFormat.getFrameSize() > 0)
		audioProperties.put("audio.framesize.bytes", audioFormat.getFrameSize());
	if (audioFormat.getSampleRate() > 0)
		audioProperties.put("audio.samplerate.hz", audioFormat.getSampleRate());
	if (audioFormat.getSampleSizeInBits() > 0)
		audioProperties.put("audio.samplesize.bits", audioFormat.getSampleSizeInBits());
	if (audioFormat.getChannels() > 0)
		audioProperties.put("audio.channels", audioFormat.getChannels());
	// Tritonus SPI compliant audio format.
	if (audioFormat instanceof TAudioFormat)
		audioProperties.putAll( ( (TAudioFormat) audioFormat ).properties());
	
	// Add SourceDataLine
	audioProperties.put("basicplayer.sourcedataline", sourceDataLine);
	
	// Keep this final reference for the lambda expression
	final Map<String,Object> audioPropertiesCopy = audioProperties;
	
	// Notify all registered StreamPlayerListeners
	listeners.forEach(listener -> listener.opened(dataSource, audioPropertiesCopy));
	
	logger.info("Exited determineProperties()!\n");
	
}
 
开发者ID:goxr3plus,项目名称:java-stream-player,代码行数:59,代码来源:StreamPlayer.java


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