Java Code Examples for javax.sound.sampled.AudioFileFormat#Type

The following examples show how to use javax.sound.sampled.AudioFileFormat#Type . 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: WaveFileWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {

        AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length];
        System.arraycopy(types, 0, filetypes, 0, types.length);

        // make sure we can write this stream
        AudioFormat format = stream.getFormat();
        AudioFormat.Encoding encoding = format.getEncoding();

        if( AudioFormat.Encoding.ALAW.equals(encoding) ||
            AudioFormat.Encoding.ULAW.equals(encoding) ||
            AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ||
            AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding) ) {

            return filetypes;
        }

        return new AudioFileFormat.Type[0];
    }
 
Example 2
Source File: AiffFileWriter.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException {
    Objects.requireNonNull(stream);
    Objects.requireNonNull(fileType);
    Objects.requireNonNull(out);

    //$$fb the following check must come first ! Otherwise
    // the next frame length check may throw an IOException and
    // interrupt iterating File Writers. (see bug 4351296)

    // throws IllegalArgumentException if not supported
    AiffFileFormat aiffFileFormat = (AiffFileFormat)getAudioFileFormat(fileType, stream);

    // we must know the total data length to calculate the file length
    if( stream.getFrameLength() == AudioSystem.NOT_SPECIFIED ) {
        throw new IOException("stream length not specified");
    }

    return writeAiffFile(stream, aiffFileFormat, out);
}
 
Example 3
Source File: WaveFileFormat.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
WaveFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {

        super(type,lengthInBytes,format,lengthInFrames);

        AudioFormat.Encoding encoding = format.getEncoding();

        if( encoding.equals(AudioFormat.Encoding.ALAW) ) {
            waveType = WAVE_FORMAT_ALAW;
        } else if( encoding.equals(AudioFormat.Encoding.ULAW) ) {
            waveType = WAVE_FORMAT_MULAW;
        } else if( encoding.equals(AudioFormat.Encoding.PCM_SIGNED) ||
                   encoding.equals(AudioFormat.Encoding.PCM_UNSIGNED) ) {
            waveType = WAVE_FORMAT_PCM;
        } else {
            waveType = WAVE_FORMAT_UNKNOWN;
        }
    }
 
Example 4
Source File: AuFileFormat.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
AuFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {

        super(type,lengthInBytes,format,lengthInFrames);

        AudioFormat.Encoding encoding = format.getEncoding();

        auType = -1;

        if( AudioFormat.Encoding.ALAW.equals(encoding) ) {
            if( format.getSampleSizeInBits()==8 ) {
                auType = AU_ALAW_8;
            }
        } else if( AudioFormat.Encoding.ULAW.equals(encoding) ) {
            if( format.getSampleSizeInBits()==8 ) {
                auType = AU_ULAW_8;
            }
        } else if( AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ) {
            if( format.getSampleSizeInBits()==8 ) {
                auType = AU_LINEAR_8;
            } else if( format.getSampleSizeInBits()==16 ) {
                auType = AU_LINEAR_16;
            } else if( format.getSampleSizeInBits()==24 ) {
                auType = AU_LINEAR_24;
            } else if( format.getSampleSizeInBits()==32 ) {
                auType = AU_LINEAR_32;
            }
        }

    }
 
Example 5
Source File: AudioFileWriter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified file type is provided
 * by this audio file writer.
 * @param fileType the file type for which write capabilities are queried
 * @return <code>true</code> if the file type is supported,
 * otherwise <code>false</code>
 */
public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {

    AudioFileFormat.Type types[] = getAudioFileTypes();

    for(int i=0; i<types.length; i++) {
        if( fileType.equals( types[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 6
Source File: AudioFileWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified file type is provided
 * by this audio file writer.
 * @param fileType the file type for which write capabilities are queried
 * @return <code>true</code> if the file type is supported,
 * otherwise <code>false</code>
 */
public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {

    AudioFileFormat.Type types[] = getAudioFileTypes();

    for(int i=0; i<types.length; i++) {
        if( fileType.equals( types[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 7
Source File: AudioFileWriter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified file type is provided
 * by this audio file writer.
 * @param fileType the file type for which write capabilities are queried
 * @return <code>true</code> if the file type is supported,
 * otherwise <code>false</code>
 */
public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {

    AudioFileFormat.Type types[] = getAudioFileTypes();

    for(int i=0; i<types.length; i++) {
        if( fileType.equals( types[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 8
Source File: AudioFileWriter.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified file type is provided
 * by this audio file writer.
 * @param fileType the file type for which write capabilities are queried
 * @return <code>true</code> if the file type is supported,
 * otherwise <code>false</code>
 */
public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {

    AudioFileFormat.Type types[] = getAudioFileTypes();

    for(int i=0; i<types.length; i++) {
        if( fileType.equals( types[i] ) ) {
            return true;
        }
    }
    return false;
}
 
Example 9
Source File: AiffFileWriter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new AiffFileWriter object.
 */
public AiffFileWriter() {
    super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AIFF});
}
 
Example 10
Source File: SunFileWriter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Override
public final AudioFileFormat.Type[] getAudioFileTypes(){
    AudioFileFormat.Type[] localArray = new AudioFileFormat.Type[types.length];
    System.arraycopy(types, 0, localArray, 0, types.length);
    return localArray;
}
 
Example 11
Source File: AuFileWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new AuFileWriter object.
 */
public AuFileWriter() {
    super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AU});
}
 
Example 12
Source File: AuFileWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new AuFileWriter object.
 */
public AuFileWriter() {
    super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AU});
}
 
Example 13
Source File: SunFileWriter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new SunParser object.
 */
SunFileWriter(AudioFileFormat.Type types[]) {
    this.types = types;
}
 
Example 14
Source File: WriterCloseInput.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
static void test(AudioFileFormat.Type fileType) {
    test(fileType, frameLength);
    test(fileType, AudioSystem.NOT_SPECIFIED);
}
 
Example 15
Source File: AuFileWriter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new AuFileWriter object.
 */
public AuFileWriter() {
    super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AU});
}
 
Example 16
Source File: AudioFileWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains the file types for which file writing support is provided by this
 * audio file writer.
 * @return array of file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public abstract AudioFileFormat.Type[] getAudioFileTypes();
 
Example 17
Source File: AudioFileWriter.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Obtains the file types that this audio file writer can write from the
 * audio input stream specified.
 * @param stream the audio input stream for which audio file type support
 * is queried
 * @return array of file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream);
 
Example 18
Source File: AudioFileWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtains the file types for which file writing support is provided by this
 * audio file writer.
 * @return array of file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public abstract AudioFileFormat.Type[] getAudioFileTypes();
 
Example 19
Source File: SunFileWriter.java    From openjdk-8 with GNU General Public License v2.0 votes vote down vote up
public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException; 
Example 20
Source File: SunFileWriter.java    From openjdk-8-source with GNU General Public License v2.0 votes vote down vote up
public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream);