Ejemplo n.º 1
0
        //public override AudioBuffer CreateBuffer(IAudioStream source)
        //{
        //    WaveFormatEx fmt = new WaveFormatEx(source.Format, source.Channels, source.Frequency, source.BitsPerSample);
        //    DS.DSBufferCapsFlags flags = DS.DSBufferCapsFlags.CtrlVolume | DS.DSBufferCapsFlags.LocDefer |DS.DSBufferCapsFlags.GlobalFocus | DS.DSBufferCapsFlags.GetCurrentPosition2;
        //    DS.DSBufferDesc desc = new DS.DSBufferDesc(AudioBuffer.DefaultBufferSpan * fmt.nAvgBytesPerSec, flags, &fmt, Guid.Empty);

        //    AudioBuffer buf = CreateBuffer(ref desc);
        //    buf._source = source;
        //    return buf;
        //}

        public override AudioBuffer CreateBuffer(WaveFormatTag format, int channels, int bps, int frequency, int size)
        {
            WaveFormatEx fmt = new WaveFormatEx(format, channels, frequency, bps);

            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));
        }
        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);

            return(new alAudioBuffer(this, fmt, target.Samples)
            {
                _source = target, _owner = this
            });
        }
        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.º 4
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.º 5
0
        internal alAudioBuffer(alAudioProvider parent, WaveFormatEx fmt)
        {
            _parent = parent;

            buffersToQueue = new List <int>();
            sourceLock     = new alSourceLock();

            int size = DefaultBufferSpan * (int)fmt.nSamplesPerSec * fmt.nChannels * fmt.wBitsPerSample / 8;

            if (size == 0)
            {
                return;
            }

            _format        = fmt.wFormatTag;
            _frequency     = (int)fmt.nSamplesPerSec;
            _channels      = fmt.nChannels;
            _bitsPerSample = fmt.wBitsPerSample;
            _dataLength    = size;
            _blockAlign    = _bitsPerSample * _channels / 8;
            _sampleLength  = _dataLength / _blockAlign;
        }
 public DSBufferDesc(uint bufferSize, DSBufferCapsFlags bufferCaps, WaveFormatEx* format, Guid algorithm)
 {
     dwSize = Size;
     dwFlags = bufferCaps;
     dwBufferBytes = bufferSize;
     dwReserved = 0;
     lpwfxFormat = format;
     guid3DAlgorithm = algorithm;
 }