コード例 #1
0
ファイル: Lame.cs プロジェクト: xiaomailong/CMS
 public BE_CONFIG(LameWaveFormat format)
     : this(format, 128)
 {
 }
コード例 #2
0
ファイル: Lame.cs プロジェクト: xiaomailong/CMS
 public Format(LameWaveFormat format, uint MpeBitRate)
 {
     lhv1 = new LHV1(format, MpeBitRate);
 }
コード例 #3
0
ファイル: Lame.cs プロジェクト: xiaomailong/CMS
 public BE_CONFIG(LameWaveFormat format, uint MpeBitRate)
 {
     this.dwConfig = BE_CONFIG_LAME;
     this.format   = new Format(format, MpeBitRate);
 }
コード例 #4
0
ファイル: Lame.cs プロジェクト: xiaomailong/CMS
        public ushort              nQuality;        // Quality Setting, HIGH BYTE should be NOT LOW byte, otherwhise quality=5
        // FUTURE USE, SET TO 0, align strucutre to 331 bytes
        //[ MarshalAs( UnmanagedType.ByValArray, SizeConst=255-4*4-2 )]
        //public byte[]   btReserved;//[255-4*sizeof(DWORD) - sizeof( WORD )];
        public LHV1(LameWaveFormat format, uint MpeBitRate)
        {
            if (format.wFormatTag != (short)WaveFormats.Pcm)
            {
                throw new ArgumentOutOfRangeException("format", "Only PCM format supported");
            }
            if (format.wBitsPerSample != 16)
            {
                throw new ArgumentOutOfRangeException("format", "Only 16 bits samples supported");
            }
            dwStructVersion = 1;
            dwStructSize    = (uint)Marshal.SizeOf(typeof(BE_CONFIG));
            switch (format.nSamplesPerSec)
            {
            case 8000:    //add by jonney
            case 16000:
            case 22050:
            case 24000:
                dwMpegVersion = MPEG2;
                break;

            case 32000:
            case 44100:
            case 48000:
                dwMpegVersion = MPEG1;
                break;

            default:
                throw new ArgumentOutOfRangeException("format", "Unsupported sample rate");
            }
            dwSampleRate   = (uint)format.nSamplesPerSec;       // INPUT FREQUENCY
            dwReSampleRate = 0;                                 // DON'T RESAMPLE
            switch (format.nChannels)
            {
            case 1:
                nMode = MpegMode.MONO;
                break;

            case 2:
                nMode = MpegMode.STEREO;
                break;

            default:
                throw new ArgumentOutOfRangeException("format", "Invalid number of channels");
            }
            switch (MpeBitRate)
            {
            case 32:
            case 40:
            case 48:
            case 56:
            case 64:
            case 80:
            case 96:
            case 112:
            case 128:
            case 160:     //Allowed bit rates in MPEG1 and MPEG2
                break;

            case 192:
            case 224:
            case 256:
            case 320:     //Allowed only in MPEG1
                if (dwMpegVersion != MPEG1)
                {
                    throw new ArgumentOutOfRangeException("MpsBitRate", "Bit rate not compatible with input format");
                }
                break;

            case 8:
            case 16:
            case 24:
            case 144:     //Allowed only in MPEG2
                if (dwMpegVersion != MPEG2)
                {
                    throw new ArgumentOutOfRangeException("MpsBitRate", "Bit rate not compatible with input format");
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("MpsBitRate", "Unsupported bit rate");
            }
            dwBitrate       = MpeBitRate;                             // MINIMUM BIT RATE
            nPreset         = LAME_QUALITY_PRESET.LQP_NORMAL_QUALITY; // QUALITY PRESET SETTING
            dwPsyModel      = 0;                                      // USE DEFAULT PSYCHOACOUSTIC MODEL
            dwEmphasis      = 0;                                      // NO EMPHASIS TURNED ON
            bOriginal       = 1;                                      // SET ORIGINAL FLAG
            bWriteVBRHeader = 0;
            bNoRes          = 0;                                      // No Bit resorvoir
            bCopyright      = 0;
            bCRC            = 0;
            bEnableVBR      = 0;
            bPrivate        = 0;
            bStrictIso      = 0;
            dwMaxBitrate    = 0;
            dwVbrAbr_bps    = 0;
            nQuality        = 0;
            nVbrMethod      = VBRMETHOD.VBR_METHOD_NONE;
            nVBRQuality     = 0;
        }