Audio Format To JMF - Java javax.media

Java examples for javax.media:Format

Description

Audio Format To JMF

Demo Code

//  Copyright (c) 2010 MC Cubed, Inc. All rights reserved.
import java.awt.Dimension;
import java.util.Collection;
import java.util.LinkedList;
import javax.media.Format;
import javax.media.format.VideoFormat;
import javax.media.format.IndexedColorFormat;
import javax.media.format.*;
import javax.media.protocol.ContentDescriptor;
import java.util.Map.Entry;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.LinkedList;

public class Main{
    public static AudioFormat AudioFormatToJMF(
            QTCompressionFormat compressionFormat, int sampleRate,
            int bitsPerSample, int channels, boolean big_endian,
            boolean signed) {
        AudioFormat retval = null;
        switch (compressionFormat) {
        case LinearPCM: {
            retval = new AudioFormat(AudioFormat.LINEAR,
                    (double) sampleRate, bitsPerSample, channels,
                    (big_endian ? AudioFormat.BIG_ENDIAN
                            : AudioFormat.LITTLE_ENDIAN),
                    (signed ? AudioFormat.SIGNED : AudioFormat.UNSIGNED));
            break;
        }/*from  w w  w  .  j a va2  s . co m*/
        }

        return retval;
    }
}

Related Tutorials