예제 #1
0
        public static DirectSound8 Create8(Guid device)
        {
            IntPtr ptr;

            DirectSoundException.Try(NativeMethods.DirectSoundCreate8(ref device, out ptr, IntPtr.Zero), "DSInterop", "DirectSoundCreate8(ref Guid, out IntPtr, IntPtr)");
            return(new DirectSound8(ptr));
        }
예제 #2
0
        public IntPtr CreateSoundBuffer(DSBufferDescription bufferDesc, IntPtr pUnkOuter)
        {
            IntPtr soundBuffer;

            DirectSoundException.Try(CreateSoundBufferNative(bufferDesc, out soundBuffer, pUnkOuter),
                                     "IDirectSound8", "CreateSoundBuffer");
            return(soundBuffer);
        }
예제 #3
0
        public bool SupportsFormat(WaveFormat format)
        {
            DirectSoundCapabilities caps;

            DirectSoundException.Try(GetCaps(out caps), "IDirectSound", "GetCaps");
            bool result = true;

            if (format.Channels == 2)
            {
                result &= (caps.Flags & DSCapabilitiesFlags.SecondaryBufferStereo) == DSCapabilitiesFlags.SecondaryBufferStereo;
            }
            else if (format.Channels == 1)
            {
                result &= (caps.Flags & DSCapabilitiesFlags.SecondaryBufferMono) == DSCapabilitiesFlags.SecondaryBufferMono;
            }
            else
            {
                result &= false;
            }

            if (format.BitsPerSample == 8)
            {
                result &= (caps.Flags & DSCapabilitiesFlags.SecondaryBuffer8Bit) == DSCapabilitiesFlags.SecondaryBuffer8Bit;
            }
            else if (format.BitsPerSample == 16)
            {
                result &= (caps.Flags & DSCapabilitiesFlags.SecondaryBuffer16Bit) == DSCapabilitiesFlags.SecondaryBuffer16Bit;
            }
            else
            {
                result &= false;
            }

            result &= format.WaveFormatTag == AudioEncoding.Pcm;
            return(result);
        }
예제 #4
0
 public void Restore()
 {
     DirectSoundException.Try(RestoreNative(), c, "Restore");
 }
예제 #5
0
 public void Stop()
 {
     DirectSoundException.Try(StopNative(), c, "Stop");
 }
예제 #6
0
 public void Play(DSBPlayFlags flags)
 {
     DirectSoundException.Try(PlayNative(flags), c, "Play");
 }
예제 #7
0
 public void SetVolume(double volume)
 {
     DirectSoundException.Try(SetVolumeNative(volume), c, "SetVolume");
 }
예제 #8
0
 public void SetCurrentPosition(int playPosition)
 {
     DirectSoundException.Try(SetCurrentPositionNative(playPosition), c, "SetCurrentPosition");
 }
예제 #9
0
 public void SetCooperativeLevel(IntPtr hWnd, DSCooperativeLevelType level)
 {
     DirectSoundException.Try(SetCooperativeLevelNative(hWnd, level), "IDirectSound8", "SetCooperativeLevel");
 }
예제 #10
0
 public void SetNotificationPositions(DSBPositionNotify[] notifies)
 {
     DirectSoundException.Try(SetNotificationPositionsNative(notifies), "IDirectSoundNotify", "SetNotificationPositions");
 }