Save This Page
Home » openjdk-7 » com.sun.media » sound » [javadoc | source]
    1   /*
    2    * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   
   26   package com.sun.media.sound;
   27   
   28   
   29   import javax.sound.sampled.AudioFileFormat;
   30   import javax.sound.sampled.AudioFormat;
   31   
   32   
   33   /**
   34    * AU file format.
   35    *
   36    * @author Jan Borgersen
   37    */
   38   
   39   class AuFileFormat extends AudioFileFormat {
   40   
   41       // magic numbers
   42       static final int AU_SUN_MAGIC =     0x2e736e64;
   43       static final int AU_SUN_INV_MAGIC = 0x646e732e;
   44       static final int AU_DEC_MAGIC =         0x2e736400;
   45       static final int AU_DEC_INV_MAGIC = 0x0064732e;
   46   
   47       // encodings
   48       static final int AU_ULAW_8       = 1;  /* 8-bit ISDN u-law */
   49       static final int AU_LINEAR_8     = 2;  /* 8-bit linear PCM */
   50       static final int AU_LINEAR_16    = 3;  /* 16-bit linear PCM */
   51       static final int AU_LINEAR_24    = 4;  /* 24-bit linear PCM */
   52       static final int AU_LINEAR_32    = 5;  /* 32-bit linear PCM */
   53       static final int AU_FLOAT        = 6;  /* 32-bit IEEE floating point */
   54       static final int AU_DOUBLE       = 7;  /* 64-bit IEEE floating point */
   55       static final int AU_ADPCM_G721   = 23; /* 4-bit CCITT g.721 ADPCM */
   56       static final int AU_ADPCM_G722   = 24; /* CCITT g.722 ADPCM */
   57       static final int AU_ADPCM_G723_3 = 25; /* CCITT g.723 3-bit ADPCM */
   58       static final int AU_ADPCM_G723_5 = 26; /* CCITT g.723 5-bit ADPCM */
   59       static final int AU_ALAW_8       = 27; /* 8-bit ISDN A-law */
   60   
   61       static final int AU_HEADERSIZE       = 24;
   62   
   63       int auType;
   64   
   65       AuFileFormat( AudioFileFormat aff ) {
   66   
   67           this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
   68       }
   69   
   70       AuFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {
   71   
   72           super(type,lengthInBytes,format,lengthInFrames);
   73   
   74           AudioFormat.Encoding encoding = format.getEncoding();
   75   
   76           auType = -1;
   77   
   78           if( AudioFormat.Encoding.ALAW.equals(encoding) ) {
   79               if( format.getSampleSizeInBits()==8 ) {
   80                   auType = AU_ALAW_8;
   81               }
   82           } else if( AudioFormat.Encoding.ULAW.equals(encoding) ) {
   83               if( format.getSampleSizeInBits()==8 ) {
   84                   auType = AU_ULAW_8;
   85               }
   86           } else if( AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ) {
   87               if( format.getSampleSizeInBits()==8 ) {
   88                   auType = AU_LINEAR_8;
   89               } else if( format.getSampleSizeInBits()==16 ) {
   90                   auType = AU_LINEAR_16;
   91               } else if( format.getSampleSizeInBits()==24 ) {
   92                   auType = AU_LINEAR_24;
   93               } else if( format.getSampleSizeInBits()==32 ) {
   94                   auType = AU_LINEAR_32;
   95               }
   96           }
   97   
   98       }
   99   
  100       public int getAuType() {
  101   
  102           return auType;
  103       }
  104   
  105   }

Save This Page
Home » openjdk-7 » com.sun.media » sound » [javadoc | source]