Пример #1
0
 public void startWaveStream(WaveFormatEx waveHeader)
 {
     mWaveDataSerializer = new Serializer();
     byte[] riffByte = new byte[4] {
         (byte)'R', (byte)'I', (byte)'F', (byte)'F'
     };
     mRiffMark = BinaryUtility.bytesToInt(riffByte);
     mFileSize = 0;
     byte[] waveByte = new byte[4] {
         (byte)'W', (byte)'A', (byte)'V', (byte)'E'
     };
     mWaveMark = BinaryUtility.bytesToInt(waveByte);
     byte[] fmtByte = new byte[4] {
         (byte)'f', (byte)'m', (byte)'t', (byte)' '
     };
     mFmtMark        = BinaryUtility.bytesToInt(fmtByte);
     mFmtChunkSize   = 16;
     mFormatType     = waveHeader.wFormatTag;
     mSoundChannels  = waveHeader.nChannels;
     mSamplesPerSec  = waveHeader.nSamplesPerSec;
     mAvgBytesPerSec = waveHeader.nAvgBytesPerSec;
     mBlockAlign     = waveHeader.nBlockAlign;
     mBitsPerSample  = waveHeader.wBitsPerSample;
     mOtherSize      = waveHeader.cbSize;
     mDataMark       = new byte[4] {
         (byte)'d', (byte)'a', (byte)'t', (byte)'a'
     };
 }
Пример #2
0
    public void read(ref int value)
    {
        int readLen = sizeof(int);

        if (!readCheck(readLen))
        {
            return;
        }
        byte[] dest = BinaryUtility.toBytes(value);
        BinaryUtility.memcpy(dest, mBuffer, 0, mIndex, readLen);
        value   = BinaryUtility.bytesToInt(dest);
        mIndex += readLen;
    }