Example #1
0
 public static extern int acmStreamOpen(out IntPtr phas, IntPtr had, ref MPEGLayer3WaveFormat pwfxSrc, ref WaveFormatEx pwfxDst, IntPtr pwfltr, IntPtr dwCallback, IntPtr dwInstance, uint fdwOpen);
Example #2
0
 public static extern int acmFormatSuggest(IntPtr had, ref MPEGLayer3WaveFormat pwfxSrc, ref WaveFormatEx pwfxDst, uint cbwfxDst, uint fdwSuggest);
Example #3
0
 public static extern int acmStreamOpen(out IntPtr phas, IntPtr had, ref MPEGLayer3WaveFormat pwfxSrc, ref WaveFormatEx pwfxDst, IntPtr pwfltr, IntPtr dwCallback, IntPtr dwInstance, uint fdwOpen);
Example #4
0
        /// <summary> </summary>
        internal static void LoadMP3_ReadFrameData(WzSound sound, BinaryReader reader, int cbData)
        {
            uint dwFrameFormat = (uint)(reader.ReadByte() << 24 | reader.ReadByte() << 16 | reader.ReadByte() << 08 | reader.ReadByte());

            reader.BaseStream.Seek(-4, SeekOrigin.Current);

            WaveFormatEx wf = new WaveFormatEx();

            if ((dwFrameFormat >> 21) != 0x7FF)
            {
                throw new Exception();
            }

            while ((dwFrameFormat >> 21) == 0x7FF)
            {
                // ---vv--- (0 = mpeg2.5, 1 = reserved, 2 = mpeg2, 3 = mpeg1)
                int version = (int)(dwFrameFormat >> 19) & 3;
                // -----ll- (0 = reserved, 1 = layer3, 2 = layer2, 3 = layer1)
                int layer          = 3 - (int)((dwFrameFormat >> 17) & 3);
                int crc            = (int)(dwFrameFormat >> 16) & 1;
                int bitrate        = (int)(dwFrameFormat >> 12) & 15;
                int frequency      = (int)(dwFrameFormat >> 10) & 3;
                int padding        = (int)(dwFrameFormat >> 9) & 1;
                int private_bit    = (int)(dwFrameFormat >> 8) & 1;
                int channel        = 1 + (int)(dwFrameFormat >> 6) & 3;
                int mode_extension = (int)(dwFrameFormat >> 4) & 3;
                int copyright      = (int)(dwFrameFormat >> 3) & 1;
                int original       = (int)(dwFrameFormat >> 2) & 1;
                int emphasis       = (int)(dwFrameFormat) & 3;

                int bitrate_ = MpegBitRate[version == 3 ? 0 : 1, layer, bitrate];
                int length   = (int)((cbData / bitrate_) * 8.0);

                if (version == 1 || layer == 3 || bitrate == 0 || frequency == 3)
                {
                    break;
                }

                wf.wFormatTag      = SoundDX8Constants.WAVE_FORMAT_MPEGLAYER3;
                wf.nChannels       = (ushort)channel;
                wf.nSamplesPerSec  = MpegSamplesPerSec[version, frequency];
                wf.nAvgBytesPerSec = (uint)(cbData / (length / 1000.0));
                wf.nBlockAlign     = 1;
                wf.wBitsPerSample  = 0;
                wf.cbSize          = 12;

                // 目前不處理 extra 的部份

                sound.Duration = length;
                break;
            }

            MPEGLayer3WaveFormat mpegwf = new MPEGLayer3WaveFormat();

            mpegwf.wfx             = wf;
            mpegwf.wID             = SoundDX8Constants.MPEGLAYER3_ID_MPEG;
            mpegwf.fdwFlags        = SoundDX8Constants.MPEGLAYER3_FLAG_PADDING_OFF; // (default)
            mpegwf.nBlockSize      = 522;                                           //144 * 4 (default)
            mpegwf.nFramesPerBlock = 1;                                             // (default)
            mpegwf.nCodecDelay     = 0;

            WzMediaType wzmt = new WzMediaType();

            wzmt.majortype    = SoundDX8Constants.MEDIATYPE_Stream;
            wzmt.subtype      = SoundDX8Constants.MEDIASUBTYPE_WAVE;
            wzmt.Unknow1_Byte = 0;
            wzmt.Unknow2_Byte = 1;
            wzmt.formattype   = SoundDX8Constants.WMFORMAT_WaveFormatEx;
            wzmt.cbFormat     = MPEGLayer3WaveFormat.StructureSize;
            wzmt.pbFormat     = mpegwf.ToArray();

            sound.MediaType = wzmt;
            sound.DataSize  = cbData;
            sound.SoundData = reader.ReadBytes(cbData);
        }
Example #5
0
 public static extern int acmFormatSuggest(IntPtr had, ref MPEGLayer3WaveFormat pwfxSrc, ref WaveFormatEx pwfxDst, uint cbwfxDst, uint fdwSuggest);