示例#1
0
 private unsafe void __MarshalTo(ref WaveFormatAdpcm.__Native @ref)
 {
     if (this.Coefficients1.Length > 7)
     {
         throw new InvalidOperationException("Unable to encode Adpcm format. Too may coefficients (max 7)");
     }
     this.extraSize = (short)(4 + 4 * this.Coefficients1.Length);
     base.__MarshalTo(ref @ref.waveFormat);
     @ref.samplesPerBlock      = this.SamplesPerBlock;
     @ref.numberOfCoefficients = (ushort)this.Coefficients1.Length;
     fixed(short *ptr = & @ref.coefficients)
     {
         for (int i = 0; i < (int)@ref.numberOfCoefficients; i++)
         {
             ptr[i * 2]     = this.Coefficients1[i];
             ptr[i * 2 + 1] = this.Coefficients2[i];
         }
     }
 }
示例#2
0
        internal unsafe void __MarshalFrom(ref WaveFormatAdpcm.__Native @ref)
        {
            base.__MarshalFrom(ref @ref.waveFormat);
            this.SamplesPerBlock = @ref.samplesPerBlock;
            this.Coefficients1   = new short[(int)@ref.numberOfCoefficients];
            this.Coefficients2   = new short[(int)@ref.numberOfCoefficients];
            if (@ref.numberOfCoefficients > 7)
            {
                throw new InvalidOperationException("Unable to read Adpcm format. Too may coefficients (max 7)");
            }

            fixed(short *ptr = & @ref.coefficients)
            {
                for (int i = 0; i < (int)@ref.numberOfCoefficients; i++)
                {
                    this.Coefficients1[i] = ptr[i * 2];
                    this.Coefficients2[i] = ptr[i * 2 + 1];
                }
            }

            this.extraSize = (short)(4 + 4 * @ref.numberOfCoefficients);
        }