Ejemplo n.º 1
0
        public AudioBuffer( IAudioDevice audioDevice, AudioInfo audioInfo )
        {
            this.audioInfo = audioInfo;

            SharpDX.DirectSound.SoundBufferDescription bufferDesc = new SharpDX.DirectSound.SoundBufferDescription ()
            {
                Flags = SharpDX.DirectSound.BufferFlags.ControlVolume | SharpDX.DirectSound.BufferFlags.ControlPan |
                SharpDX.DirectSound.BufferFlags.ControlPositionNotify | SharpDX.DirectSound.BufferFlags.StickyFocus |
                SharpDX.DirectSound.BufferFlags.Software | SharpDX.DirectSound.BufferFlags.GetCurrentPosition2 |
                SharpDX.DirectSound.BufferFlags.ControlFrequency | SharpDX.DirectSound.BufferFlags.GlobalFocus,
                Format = new SharpDX.Multimedia.WaveFormat ( audioInfo.SampleRate, audioInfo.BitsPerSample, audioInfo.AudioChannel ),
                BufferBytes = audioInfo.SampleRate
            };
            soundBuffer = new SharpDX.DirectSound.SecondarySoundBuffer ( audioDevice.Handle as SharpDX.DirectSound.DirectSound,
                bufferDesc );
        }
Ejemplo n.º 2
0
        public Audio( IAudioDevice audioDevice, AudioInfo audioInfo )
        {
            this.audioDevice = new WeakReference ( audioDevice );
            this.audioInfo = audioInfo;

            SharpDX.DirectSound.SoundBufferDescription bufferDesc = new SharpDX.DirectSound.SoundBufferDescription ()
            {
                Flags = SharpDX.DirectSound.BufferFlags.ControlVolume | SharpDX.DirectSound.BufferFlags.ControlPan |
                SharpDX.DirectSound.BufferFlags.ControlPositionNotify | SharpDX.DirectSound.BufferFlags.StickyFocus |
                SharpDX.DirectSound.BufferFlags.Software | SharpDX.DirectSound.BufferFlags.GetCurrentPosition2 |
                SharpDX.DirectSound.BufferFlags.ControlFrequency,
                Format = new SharpDX.Multimedia.WaveFormat ( audioInfo.SampleRate, audioInfo.BitPerSample * 8, ( int ) audioInfo.AudioChannel ),
                BufferBytes = totalLength = ( int ) ( audioInfo.Duration.TotalSeconds *
                    ( ( int ) audioInfo.AudioChannel * audioInfo.BitPerSample * audioInfo.SampleRate ) ),
            };
            soundBuffer = new SharpDX.DirectSound.SecondarySoundBuffer ( audioDevice.Handle as SharpDX.DirectSound.DirectSound,
                bufferDesc );

            ( audioDevice as AudioDevice ).audioList.Add ( this );

            offset = 0;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// <p>The <strong>DirectSoundFullDuplexCreate</strong> function is documented under a different name. For complete documentation of this function, see DirectSoundFullDuplexCreate8. </p>
 /// </summary>
 /// <param name="cGuidCaptureDeviceRef">No documentation.</param>
 /// <param name="cGuidRenderDeviceRef">No documentation.</param>
 /// <param name="cDSCBufferDescRef">No documentation.</param>
 /// <param name="cDSBufferDescRef">No documentation.</param>
 /// <param name="hWnd">No documentation.</param>
 /// <param name="dwLevel">No documentation.</param>
 /// <param name="dSFDOut">No documentation.</param>
 /// <param name="dSCBuffer8Out">No documentation.</param>
 /// <param name="dSBuffer8Out">No documentation.</param>
 /// <param name="unkOuterRef">No documentation.</param>
 /// <returns><p>If this function succeeds, it returns <strong><see cref="SharpDX.Result.Ok"/></strong>. Otherwise, it returns an <strong><see cref="SharpDX.Result"/></strong> error code.</p></returns>
 /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='DirectSoundFullDuplexCreate']/*"/>
 /// <msdn-id>bb432248</msdn-id>
 /// <unmanaged>HRESULT DirectSoundFullDuplexCreate([In, Optional] const GUID* pcGuidCaptureDevice,[In, Optional] const GUID* pcGuidRenderDevice,[In] const DSCBUFFERDESC* pcDSCBufferDesc,[In] const DSBUFFERDESC* pcDSBufferDesc,[In] HWND hWnd,[In] unsigned int dwLevel,[Out, Fast] IDirectSoundFullDuplex** ppDSFD,[Out] IDirectSoundCaptureBuffer8** ppDSCBuffer8,[Out] IDirectSoundBuffer8** ppDSBuffer8,[In] IUnknown* pUnkOuter)</unmanaged>
 /// <unmanaged-short>DirectSoundFullDuplexCreate</unmanaged-short>
 public static void FullDuplexCreate(System.Guid?cGuidCaptureDeviceRef, System.Guid?cGuidRenderDeviceRef, SharpDX.DirectSound.CaptureBufferDescription cDSCBufferDescRef, SharpDX.DirectSound.SoundBufferDescription cDSBufferDescRef, System.IntPtr hWnd, int dwLevel, SharpDX.DirectSound.FullDuplex dSFDOut, out SharpDX.DirectSound.CaptureBuffer dSCBuffer8Out, out SharpDX.DirectSound.SecondarySoundBuffer dSBuffer8Out, SharpDX.ComObject unkOuterRef)
 {
     unsafe {
         System.Guid cGuidCaptureDeviceRef_;
         if (cGuidCaptureDeviceRef.HasValue)
         {
             cGuidCaptureDeviceRef_ = cGuidCaptureDeviceRef.Value;
         }
         System.Guid cGuidRenderDeviceRef_;
         if (cGuidRenderDeviceRef.HasValue)
         {
             cGuidRenderDeviceRef_ = cGuidRenderDeviceRef.Value;
         }
         var cDSCBufferDescRef_ = SharpDX.DirectSound.CaptureBufferDescription.__NewNative();
         cDSCBufferDescRef.__MarshalTo(ref cDSCBufferDescRef_);
         var cDSBufferDescRef_ = SharpDX.DirectSound.SoundBufferDescription.__NewNative();
         cDSBufferDescRef.__MarshalTo(ref cDSBufferDescRef_);
         IntPtr         dSFDOut_       = IntPtr.Zero;
         IntPtr         dSCBuffer8Out_ = IntPtr.Zero;
         IntPtr         dSBuffer8Out_  = IntPtr.Zero;
         SharpDX.Result __result__;
         __result__ =
             DirectSoundFullDuplexCreate_((cGuidCaptureDeviceRef.HasValue)?&cGuidCaptureDeviceRef_:(void *)IntPtr.Zero, (cGuidRenderDeviceRef.HasValue)?&cGuidRenderDeviceRef_:(void *)IntPtr.Zero, &cDSCBufferDescRef_, &cDSBufferDescRef_, (void *)hWnd, dwLevel, &dSFDOut_, &dSCBuffer8Out_, &dSBuffer8Out_, (void *)((unkOuterRef == null)?IntPtr.Zero:unkOuterRef.NativePointer));
         cDSCBufferDescRef.__MarshalFree(ref cDSCBufferDescRef_);
         cDSBufferDescRef.__MarshalFree(ref cDSBufferDescRef_);
         ((SharpDX.DirectSound.FullDuplex)dSFDOut).NativePointer = dSFDOut_;
         dSCBuffer8Out = (dSCBuffer8Out_ == IntPtr.Zero)?null:new SharpDX.DirectSound.CaptureBuffer(dSCBuffer8Out_);
         dSBuffer8Out  = (dSBuffer8Out_ == IntPtr.Zero)?null:new SharpDX.DirectSound.SecondarySoundBuffer(dSBuffer8Out_);
         __result__.CheckError();
     }
 }