Java Code Examples for javax.sound.sampled.AudioFormat#getFrameRate()

The following examples show how to use javax.sound.sampled.AudioFormat#getFrameRate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WaveFloatFileWriter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: Toolkit.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: AudioFloatFormatConverter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 4
Source File: WaveFloatFileWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 5
Source File: AudioFloatFormatConverter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 6
Source File: Toolkit.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: AudioFloatFormatConverter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 8
Source File: Toolkit.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static long frames2micros(AudioFormat format, long frames) {
    return (long) (((double) frames) / format.getFrameRate() * 1000000.0d);
}
 
Example 9
Source File: DummySourceDataLine.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void open(AudioFormat format) throws LineUnavailableException {
    if (bufferSize == -1)
        bufferSize = ((int) (format.getFrameRate() / 2))
                * format.getFrameSize();
    open(format, bufferSize);
}
 
Example 10
Source File: DummySourceDataLine.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void open(AudioFormat format) throws LineUnavailableException {
    if (bufferSize == -1)
        bufferSize = ((int) (format.getFrameRate() / 2))
                * format.getFrameSize();
    open(format, bufferSize);
}
 
Example 11
Source File: SoftMixingSourceDataLine.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void open(AudioFormat format) throws LineUnavailableException {
    if (bufferSize == -1)
        bufferSize = ((int) (format.getFrameRate() / 2))
                * format.getFrameSize();
    open(format, bufferSize);
}
 
Example 12
Source File: Toolkit.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static long millis2bytes(AudioFormat format, long millis) {
    long result = (long) (millis * format.getFrameRate() / 1000.0f * format.getFrameSize());
    return align(result, format.getFrameSize());
}
 
Example 13
Source File: Toolkit.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static long bytes2millis(AudioFormat format, long bytes) {
    return (long) (bytes / format.getFrameRate() * 1000.0f / format.getFrameSize());
}
 
Example 14
Source File: Toolkit.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static long micros2frames(AudioFormat format, long micros) {
    return (long) (micros * format.getFrameRate() / 1000000.0f);
}
 
Example 15
Source File: Toolkit.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static long millis2bytes(AudioFormat format, long millis) {
    long result = (long) (millis * format.getFrameRate() / 1000.0f * format.getFrameSize());
    return align(result, format.getFrameSize());
}
 
Example 16
Source File: DummySourceDataLine.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void open(AudioFormat format) throws LineUnavailableException {
    if (bufferSize == -1)
        bufferSize = ((int) (format.getFrameRate() / 2))
                * format.getFrameSize();
    open(format, bufferSize);
}
 
Example 17
Source File: Toolkit.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static long micros2frames(AudioFormat format, long micros) {
    return (long) (micros * format.getFrameRate() / 1000000.0f);
}
 
Example 18
Source File: SoftMixingSourceDataLine.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void open(AudioFormat format) throws LineUnavailableException {
    if (bufferSize == -1)
        bufferSize = ((int) (format.getFrameRate() / 2))
                * format.getFrameSize();
    open(format, bufferSize);
}
 
Example 19
Source File: Toolkit.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static long frames2micros(AudioFormat format, long frames) {
    return (long) (((double) frames) / format.getFrameRate() * 1000000.0d);
}
 
Example 20
Source File: DummySourceDataLine.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void open(AudioFormat format) throws LineUnavailableException {
    if (bufferSize == -1)
        bufferSize = ((int) (format.getFrameRate() / 2))
                * format.getFrameSize();
    open(format, bufferSize);
}