示例#1
0
        public DirectSoundSecondaryBuffer(DirectSoundBase directSound, WaveFormat waveFormat, int bufferSize)
        {
            if (directSound == null)
            {
                throw new ArgumentNullException("directSound");
            }

            DSBufferDescription secondaryBufferDesc = new DSBufferDescription()
            {
                dwBufferBytes = (uint)bufferSize * 2,
                dwFlags       = DSBufferCapsFlags.DSBCAPS_CTRLFREQUENCY | DSBufferCapsFlags.DSBCAPS_CTRLPAN |
                                DSBufferCapsFlags.DSBCAPS_CTRLVOLUME | DSBufferCapsFlags.DSBCAPS_CTRLPOSITIONNOTIFY |
                                DSBufferCapsFlags.DSBCAPS_GETCURRENTPOSITION2 | DSBufferCapsFlags.DSBCAPS_GLOBALFOCUS |
                                DSBufferCapsFlags.DSBCAPS_STICKYFOCUS,
                dwReserved      = 0,
                guid3DAlgorithm = Guid.Empty
            };

            secondaryBufferDesc.dwSize = Marshal.SizeOf(secondaryBufferDesc);
            GCHandle hWaveFormat = GCHandle.Alloc(waveFormat, GCHandleType.Pinned);

            secondaryBufferDesc.lpwfxFormat = hWaveFormat.AddrOfPinnedObject();

            Create(directSound, secondaryBufferDesc);

            hWaveFormat.Free();
        }
示例#2
0
        private void Create(DirectSoundBase directSound, DSBufferDescription bufferDesc)
        {
            if ((bufferDesc.dwFlags & DSBufferCapsFlags.DSBCAPS_PRIMARYBUFFER) == DSBufferCapsFlags.DSBCAPS_PRIMARYBUFFER)
            {
                throw new ArgumentException("Don t set the PRIMARYBUFFER flag for creating a secondarybuffer.", "bufferDesc");
            }

            _basePtr = directSound.CreateSoundBuffer(bufferDesc, IntPtr.Zero).ToPointer();
        }
        public DirectSoundPrimaryBuffer(DirectSoundBase directSound)
        {
            if (directSound == null)
            {
                throw new ArgumentNullException("directSound");
            }

            DSBufferDescription primaryBufferDesc = new DSBufferDescription()
            {
                dwBufferBytes   = 0,
                dwFlags         = DSBufferCapsFlags.DSBCAPS_PRIMARYBUFFER | DSBufferCapsFlags.DSBCAPS_CTRLVOLUME | DSBufferCapsFlags.DSBCAPS_CTRL3D,
                dwReserved      = 0,
                lpwfxFormat     = IntPtr.Zero,
                guid3DAlgorithm = Guid.Empty
            };

            primaryBufferDesc.dwSize = Marshal.SizeOf(primaryBufferDesc);

            _basePtr = directSound.CreateSoundBuffer(primaryBufferDesc, IntPtr.Zero).ToPointer();
        }
示例#4
0
 public DSResult Initialize(DirectSoundBase directSound, DSBufferDescription bufferDesc)
 {
     return(InteropCalls.CalliMethodPtr(_basePtr, directSound.BasePtr.ToPointer(), &bufferDesc, ((void **)(*(void **)_basePtr))[10]));
 }
示例#5
0
 public DirectSoundSecondaryBuffer(DirectSoundBase directSound, DSBufferDescription bufferDesc)
 {
     Create(directSound, bufferDesc);
 }