当前位置: 首页>>代码示例>>C#>>正文


C# IAudioStream.ReadBuffer方法代码示例

本文整理汇总了C#中IAudioStream.ReadBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# IAudioStream.ReadBuffer方法的具体用法?C# IAudioStream.ReadBuffer怎么用?C# IAudioStream.ReadBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAudioStream的用法示例。


在下文中一共展示了IAudioStream.ReadBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Flow

        public int Flow(IAudioStream input, short[] obuf, int count, int volLeft, int volRight)
        {
            var obufPos = 0;
            var inPos = 0;
            var oend = count;

            while (obufPos < oend)
            {
                // read enough input samples so that opos < 0
                while (FRAC_ONE_LOW <= opos)
                {
                    // Check if we have to refill the buffer
                    if (inLen == 0)
                    {
                        inPos = 0;
                        inLen = input.ReadBuffer(inBuf, RateHelper.IntermediateBufferSize);
                        if (inLen <= 0)
                            return obufPos / 2;
                    }
                    inLen -= (stereo ? 2 : 1);
                    ilast0 = icur0;
                    icur0 = inBuf[inPos++];
                    if (stereo)
                    {
                        ilast1 = icur1;
                        icur1 = inBuf[inPos++];
                    }
                    opos -= FRAC_ONE_LOW;
                }

                // Loop as long as the outpos trails behind, and as long as there is
                // still space in the output buffer.
                while (opos < FRAC_ONE_LOW && obufPos < oend)
                {
                    // interpolate
                    int out0, out1;
                    out0 = (short)(ilast0 + (((icur0 - ilast0) * opos + FRAC_HALF_LOW) >> FRAC_BITS_LOW));
                    out1 = stereo ? (short)(ilast1 + (((icur1 - ilast1) * opos + FRAC_HALF_LOW) >> FRAC_BITS_LOW)) : out0;

                    // output left channel
                    RateHelper.ClampedAdd(ref obuf[obufPos + (reverseStereo ? 1 : 0)], (out0 * volLeft) / Mixer.MaxMixerVolume);

                    // output right channel
                    RateHelper.ClampedAdd(ref obuf[obufPos + (reverseStereo ? 0 : 1)], (out1 * volRight) / Mixer.MaxMixerVolume);

                    obufPos += 2;

                    // Increment output position
                    opos += oposInc;
                }
            }
            return obufPos / 2;

        }
开发者ID:scemino,项目名称:nscumm,代码行数:54,代码来源:LinearRateConverter.cs

示例2: Flow

        public int Flow(IAudioStream input, short[] obuf, int count, int volLeft, int volRight)
        {
            Debug.Assert(input.IsStereo == stereo);

            var osamp = count / 2;

            if (stereo)
                osamp *= 2;

            // Reallocate temp buffer, if necessary
            if (osamp > _bufferSize)
            {
                _buffer = new short[osamp];
                _bufferSize = osamp;
            }

            // Read up to 'osamp' samples into our temporary buffer
            var len = input.ReadBuffer(_buffer, _bufferSize);

            int iPos = 0;
            var oPos = 0;
            var inc = stereo ? 2 : 1;
            // Mix the data into the output buffer
            for (; iPos < len; iPos += inc)
            {
                var out0 = _buffer[iPos];
                var out1 = stereo ? _buffer[iPos + 1] : out0;

                // output left channel
                RateHelper.ClampedAdd(ref obuf[oPos + (reverseStereo ? 1 : 0)], (out0 * volLeft) / Mixer.MaxMixerVolume);

                // output right channel
                RateHelper.ClampedAdd(ref obuf[oPos + (reverseStereo ? 0 : 1)], (out1 * volRight) / Mixer.MaxMixerVolume);

                oPos += 2;
            }
            return oPos / 2;
        }
开发者ID:scemino,项目名称:nscumm,代码行数:38,代码来源:CopyRateConverter.cs

示例3: Flow

        public int Flow(IAudioStream input, short[] obuf, int count, int volLeft, int volRight)
        {
            int pos = 0;
            int oend = count * 2;

            while (pos < oend)
            {
                // read enough input samples so that opos >= 0
                do
                {
                    // Check if we have to refill the buffer
                    if (inLen == 0)
                    {
                        inPtr = 0;
                        inLen = input.ReadBuffer(inBuf, RateHelper.IntermediateBufferSize);
                        if (inLen <= 0)
                            return pos / 2;
                    }
                    inLen -= (stereo ? 2 : 1);
                    opos--;
                    if (opos >= 0)
                    {
                        inPtr += (stereo ? 2 : 1);
                    }
                } while (opos >= 0);

                short out0, out1;
                out0 = inBuf[inPtr++];
                out1 = (stereo ? inBuf[inPtr++] : out0);

                // Increment output position
                opos += oposInc;

                // output left channel
                RateHelper.ClampedAdd(ref obuf[reverseStereo ? 1 : 0], (out0 * (int)volLeft) / Mixer.MaxMixerVolume);

                // output right channel
                RateHelper.ClampedAdd(ref obuf[(reverseStereo ? 1 : 0) ^ 1], (out1 * (int)volRight) / Mixer.MaxMixerVolume);

                pos += 2;
            }
            return pos / 2;
        }
开发者ID:scemino,项目名称:nscumm,代码行数:43,代码来源:SimpleRateConverter.cs


注:本文中的IAudioStream.ReadBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。