Ejemplo n.º 1
0
        public override AudioBuffer CreateBuffer(IAudioStream target)
        {
            int size = AudioBuffer.DefaultBufferSpan * target.Frequency * target.Channels * target.BitsPerSample / 8;

            WaveFormatEx fmt = new WaveFormatEx(target.Format, target.Channels, target.Frequency, target.BitsPerSample);

            DS.DSBufferCapsFlags flags = DS.DSBufferCapsFlags.CtrlVolume | DS.DSBufferCapsFlags.LocDefer | DS.DSBufferCapsFlags.GlobalFocus | DS.DSBufferCapsFlags.GetCurrentPosition2;
            DS.DSBufferDesc      desc  = new DS.DSBufferDesc((uint)size, flags, &fmt, Guid.Empty);

            return(new wAudioBuffer(this, ref desc)
            {
                _source = target, _owner = this
            });
        }
Ejemplo n.º 2
0
        //internal wAudioBuffer(wAudioProvider parent, DS.IDirectSoundBuffer8 buffer) { _dsb8 = buffer; }
        internal wAudioBuffer(wAudioProvider parent, ref DS.DSBufferDesc desc)
        {
            _parent = parent;

            if (desc.dwBufferBytes == 0)
            {
                return;
            }

            _parent._ds8.CreateSoundBuffer(ref desc, out _dsb8, IntPtr.Zero);

            _format        = desc.lpwfxFormat->wFormatTag;
            _frequency     = (int)desc.lpwfxFormat->nSamplesPerSec;
            _channels      = desc.lpwfxFormat->nChannels;
            _bitsPerSample = desc.lpwfxFormat->wBitsPerSample;
            _dataLength    = (int)desc.dwBufferBytes;
            _blockAlign    = _bitsPerSample * _channels / 8;
            _sampleLength  = _dataLength / _blockAlign;
        }