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


Java AudioFormat.getFrameRate方法代码示例

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


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

示例1: getSignOrEndianChangedFormat

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
protected static AudioFormat getSignOrEndianChangedFormat(AudioFormat format) {
    boolean isSigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
    boolean isUnsigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED);
    if (format.getSampleSizeInBits() > 8 && isSigned) {
        // if this is PCM_SIGNED and 16-bit or higher, then try with endian-ness magic
        return new AudioFormat(format.getEncoding(),
                               format.getSampleRate(), format.getSampleSizeInBits(), format.getChannels(),
                               format.getFrameSize(), format.getFrameRate(), !format.isBigEndian());
    }
    else if (format.getSampleSizeInBits() == 8 && (isSigned || isUnsigned)) {
        // if this is PCM and 8-bit, then try with signed-ness magic
        return new AudioFormat(isSigned?AudioFormat.Encoding.PCM_UNSIGNED:AudioFormat.Encoding.PCM_SIGNED,
                               format.getSampleRate(), format.getSampleSizeInBits(), format.getChannels(),
                               format.getFrameSize(), format.getFrameRate(), format.isBigEndian());
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DirectAudioDevice.java

示例2: getAudioInputStream

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
/**
 */
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream) {

    if( isConversionSupported(targetEncoding, sourceStream.getFormat()) ) {

        AudioFormat sourceFormat = sourceStream.getFormat();
        AudioFormat targetFormat = new AudioFormat( targetEncoding,
                                                    sourceFormat.getSampleRate(),
                                                    sourceFormat.getSampleSizeInBits(),
                                                    sourceFormat.getChannels(),
                                                    sourceFormat.getFrameSize(),
                                                    sourceFormat.getFrameRate(),
                                                    sourceFormat.isBigEndian() );

        return getAudioInputStream( targetFormat, sourceStream );

    } else {
        throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " + targetEncoding.toString() );
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:PCMtoPCMCodec.java

示例3: isFullySpecifiedAudioFormat

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
static void isFullySpecifiedAudioFormat(AudioFormat format) {
    if (!format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)
        && !format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED)
        && !format.getEncoding().equals(AudioFormat.Encoding.ULAW)
        && !format.getEncoding().equals(AudioFormat.Encoding.ALAW)) {
        // we don't know how to verify possibly non-linear encodings
        return;
    }
    if (format.getFrameRate() <= 0) {
        throw new IllegalArgumentException("invalid frame rate: "
                                           +((format.getFrameRate()==-1)?
                                             "NOT_SPECIFIED":String.valueOf(format.getFrameRate())));
    }
    if (format.getSampleRate() <= 0) {
        throw new IllegalArgumentException("invalid sample rate: "
                                           +((format.getSampleRate()==-1)?
                                             "NOT_SPECIFIED":String.valueOf(format.getSampleRate())));
    }
    if (format.getSampleSizeInBits() <= 0) {
        throw new IllegalArgumentException("invalid sample size in bits: "
                                           +((format.getSampleSizeInBits()==-1)?
                                             "NOT_SPECIFIED":String.valueOf(format.getSampleSizeInBits())));
    }
    if (format.getFrameSize() <= 0) {
        throw new IllegalArgumentException("invalid frame size: "
                                           +((format.getFrameSize()==-1)?
                                             "NOT_SPECIFIED":String.valueOf(format.getFrameSize())));
    }
    if (format.getChannels() <= 0) {
        throw new IllegalArgumentException("invalid number of channels: "
                                           +((format.getChannels()==-1)?
                                             "NOT_SPECIFIED":String.valueOf(format.getChannels())));
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:Toolkit.java

示例4: AudioFloatInputStreamChannelMixer

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
AudioFloatInputStreamChannelMixer(AudioFloatInputStream ais,
        int targetChannels) {
    this.sourceChannels = ais.getFormat().getChannels();
    this.targetChannels = targetChannels;
    this.ais = ais;
    AudioFormat format = ais.getFormat();
    targetFormat = new AudioFormat(format.getEncoding(), format
            .getSampleRate(), format.getSampleSizeInBits(),
            targetChannels, (format.getFrameSize() / sourceChannels)
                    * targetChannels, format.getFrameRate(), format
                    .isBigEndian());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:AudioFloatFormatConverter.java

示例5: isFullySpecifiedPCMFormat

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
static boolean isFullySpecifiedPCMFormat(AudioFormat format) {
    if (!format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)
        && !format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED)) {
        return false;
    }
    if ((format.getFrameRate() <= 0)
        || (format.getSampleRate() <= 0)
        || (format.getSampleSizeInBits() <= 0)
        || (format.getFrameSize() <= 0)
        || (format.getChannels() <= 0)) {
        return false;
    }
    return true;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:Toolkit.java

示例6: toLittleEndian

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
private AudioInputStream toLittleEndian(AudioInputStream ais) {
    AudioFormat format = ais.getFormat();
    AudioFormat targetFormat = new AudioFormat(format.getEncoding(), format
            .getSampleRate(), format.getSampleSizeInBits(), format
            .getChannels(), format.getFrameSize(), format.getFrameRate(),
            false);
    return AudioSystem.getAudioInputStream(targetFormat, ais);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:WaveFloatFileWriter.java

示例7: getOtherEndianOrSign

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static AudioFormat getOtherEndianOrSign(AudioFormat format) {
    AudioFormat.Encoding newEnc = null;
    boolean newEndian = format.isBigEndian();
    boolean isSigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
    boolean isUnsigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED);
    if ((isSigned || isUnsigned) && format.getSampleSizeInBits() > 0) {
        if (format.getSampleSizeInBits() == 8) {
            // return the other signed'ness
            if (isSigned) {
                newEnc = AudioFormat.Encoding.PCM_UNSIGNED;
            } else {
                newEnc = AudioFormat.Encoding.PCM_SIGNED;
            }
        } else {
            newEnc = format.getEncoding();
            newEndian = !newEndian;
        }
        if (newEnc != null) {
            return new AudioFormat(newEnc, format.getSampleRate(),
                                   format.getSampleSizeInBits(),
                                   format.getChannels(),
                                   format.getFrameSize(),
                                   format.getFrameRate(),
                                   newEndian);
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:BothEndiansAndSigns.java

示例8: getAudioFileFormat

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
/**
 * Returns the AudioFileFormat describing the file that will be written from this AudioInputStream.
 * Throws IllegalArgumentException if not supported.
 */
private AudioFileFormat getAudioFileFormat(Type type, AudioInputStream stream) {
    if (!isFileTypeSupported(type, stream)) {
        throw new IllegalArgumentException("File type " + type + " not supported.");
    }

    AudioFormat streamFormat = stream.getFormat();
    AudioFormat.Encoding encoding = streamFormat.getEncoding();

    if (AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)) {
        encoding = AudioFormat.Encoding.PCM_SIGNED;
    }

    // We always write big endian au files, this is by far the standard
    AudioFormat format = new AudioFormat(encoding,
                                         streamFormat.getSampleRate(),
                                         streamFormat.getSampleSizeInBits(),
                                         streamFormat.getChannels(),
                                         streamFormat.getFrameSize(),
                                         streamFormat.getFrameRate(), true);

    int fileSize;
    if (stream.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
        fileSize = (int)stream.getFrameLength()*streamFormat.getFrameSize() + AuFileFormat.AU_HEADERSIZE;
    } else {
        fileSize = AudioSystem.NOT_SPECIFIED;
    }

    return new AuFileFormat(Type.AU, fileSize, format,
                            (int) stream.getFrameLength());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:AuFileWriter.java

示例9: open

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public void open(AudioFormat format) throws LineUnavailableException {
    if (bufferSize == -1)
        bufferSize = ((int) (format.getFrameRate() / 2))
                * format.getFrameSize();
    open(format, bufferSize);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:DummySourceDataLine.java

示例10: determineProperties

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

示例11: bytes2Ms

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static long bytes2Ms(long bytes, AudioFormat format) {
    return (long) (bytes/format.getFrameRate()*1000/format.getFrameSize());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:SDLLinuxCrash.java

示例12: bytes2Ms

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static long bytes2Ms(long bytes, AudioFormat format) {
    return (long) (bytes / format.getFrameRate() * 1000
                           / format.getFrameSize());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ClipLinuxCrash.java

示例13: bytes2millis

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
static long bytes2millis(AudioFormat format, long bytes) {
    return (long) (bytes / format.getFrameRate() * 1000.0f / format.getFrameSize());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:4,代码来源:Toolkit.java

示例14: micros2bytes

import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
static long micros2bytes(AudioFormat format, long micros) {
    long result = (long) (micros * format.getFrameRate() / 1000000.0f * format.getFrameSize());
    return align(result, format.getFrameSize());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:Toolkit.java


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