FileDocCategorySizeDatePackage
AudioFormat.javaAPI DocAndroid 1.5 API6279Wed May 06 22:41:02 BST 2009javax.sound.sampled

AudioFormat

public class AudioFormat extends Object

Fields Summary
protected boolean
bigEndian
protected int
channels
protected Encoding
encoding
protected float
frameRate
protected int
frameSize
protected float
sampleRate
protected int
sampleSizeInBits
private HashMap
prop
Constructors Summary
public AudioFormat(Encoding encoding, float sampleRate, int sampleSizeInBits, int channels, int frameSize, float frameRate, boolean bigEndian)


        this.encoding = encoding;
        this.sampleRate = sampleRate;
        this.sampleSizeInBits = sampleSizeInBits;
        this.channels = channels;
        this.frameSize = frameSize;
        this.frameRate = frameRate;
        this.bigEndian = bigEndian;

    
public AudioFormat(Encoding encoding, float sampleRate, int sampleSizeInBits, int channels, int frameSize, float frameRate, boolean bigEndian, Map properties)


        this.encoding = encoding;
        this.sampleRate = sampleRate;
        this.sampleSizeInBits = sampleSizeInBits;
        this.channels = channels;
        this.frameSize = frameSize;
        this.frameRate = frameRate;
        this.bigEndian = bigEndian;
        prop = new HashMap<String, Object>();
        prop.putAll(properties);

    
public AudioFormat(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian)


        this.encoding = (signed?  Encoding.PCM_SIGNED : Encoding.PCM_UNSIGNED);
        this.sampleRate = sampleRate;
        this.sampleSizeInBits = sampleSizeInBits;
        this.channels = channels;
        this.frameSize = sampleSizeInBits >> 3;
        if ((sampleSizeInBits & 0x7) != 0) {
            this.frameSize++;
        }
        this.frameSize *= channels;
        this.frameRate = sampleRate;
        this.bigEndian = bigEndian;

    
Methods Summary
public intgetChannels()

        return channels;
    
public javax.sound.sampled.AudioFormat$EncodinggetEncoding()

        return encoding;
    
public floatgetFrameRate()

        return frameRate;
    
public intgetFrameSize()

        return frameSize;
    
public java.lang.ObjectgetProperty(java.lang.String key)

        if (prop == null) {
            return null;
        }
        return prop.get(key);
    
public floatgetSampleRate()

        return sampleRate;
    
public intgetSampleSizeInBits()

        return sampleSizeInBits;
    
public booleanisBigEndian()

        return bigEndian;
    
public booleanmatches(javax.sound.sampled.AudioFormat format)

        if (!encoding.equals(format.getEncoding()) ||
                channels != format.getChannels() ||
                sampleSizeInBits != format.getSampleSizeInBits() ||
                frameSize != format.getFrameSize()) {
            return false;
        }
        if (format.getSampleRate() != AudioSystem.NOT_SPECIFIED &&
                sampleRate != format.getSampleRate()) {
            return false;
        }
        
        if (format.getFrameRate() != AudioSystem.NOT_SPECIFIED &&
                frameRate != format.getFrameRate()) {
            return false;
        }
        
        if ((sampleSizeInBits > 8) 
                && (bigEndian != format.isBigEndian())) {
            return false;
        }
        return true;
        
    
public java.util.Mapproperties()

        if (prop != null) {
            return Collections.unmodifiableMap(prop);
        } else {
            return Collections.emptyMap();
        }
    
public java.lang.StringtoString()


        String ch;
        switch (channels) {
        case 1:
            ch = "mono,"; //$NON-NLS-1$
            break;
        case 2:
            ch = "stereo,"; //$NON-NLS-1$
        default:
            ch = channels + " channels, "; //$NON-NLS-1$
        }       

        return encoding + " " + sampleRate + " Hz, " + sampleSizeInBits + " bit, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            + ch + frameSize + " bytes/frame, " + frameRate + " frames/second"; //$NON-NLS-1$ //$NON-NLS-2$