当前位置: 首页>>代码示例>>C#>>正文


C# AudioClientShareMode类代码示例

本文整理汇总了C#中AudioClientShareMode的典型用法代码示例。如果您正苦于以下问题:C# AudioClientShareMode类的具体用法?C# AudioClientShareMode怎么用?C# AudioClientShareMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AudioClientShareMode类属于命名空间,在下文中一共展示了AudioClientShareMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WasapiOut

		/// <summary>
		/// Creates a new WASAPI Output
		/// </summary>
		/// <param name="device">Device to use</param>
		/// <param name="shareMode"></param>
		/// <param name="useEventSync">true if sync is done with event. false use sleep.</param>
		/// <param name="latency"></param>
		public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency)
		{
			audioClient = device.AudioClient;
			this.shareMode = shareMode;
			isUsingEventSync = useEventSync;
			latencyMilliseconds = latency;
		}
开发者ID:teetow,项目名称:teevegas,代码行数:14,代码来源:WasapiOut.cs

示例2: WasapiOutRT

 /// <summary>
 /// Creates a new WASAPI Output
 /// </summary>
 /// <param name="device">Device to use</param>
 /// <param name="shareMode"></param>
 /// <param name="latency"></param>
 public WasapiOutRT(string device, AudioClientShareMode shareMode, int latency)
 {
     this.device = device;
     this.shareMode = shareMode;
     this.latencyMilliseconds = latency;
     this.syncContext = SynchronizationContext.Current;
 }
开发者ID:KarimLUCCIN,项目名称:NAudioCustom,代码行数:13,代码来源:WasapiOutRT.cs

示例3: WasapiOut

 /// <summary>
 /// Creates a new WASAPI Output
 /// </summary>
 /// <param name="device">Device to use</param>
 /// <param name="shareMode"></param>
 /// <param name="useEventSync">true if sync is done with event. false use sleep.</param>
 /// <param name="latency"></param>
 public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency)
 {
     this.audioClient = device.AudioClient;
     this.shareMode = shareMode;
     this.isUsingEventSync = useEventSync;
     this.latencyMilliseconds = latency;
     this.syncContext = SynchronizationContext.Current;
 }
开发者ID:NoOnes2,项目名称:scharfrichter,代码行数:15,代码来源:WasapiOut.cs

示例4: WasapiOutRT

 /// <summary>
 /// Creates a new WASAPI Output
 /// </summary>
 /// <param name="device">Device to use</param>
 /// <param name="shareMode"></param>
 /// <param name="latency"></param>
 public WasapiOutRT(string device, AudioClientShareMode shareMode, int latency)
 {
     this.device = device;
     this.shareMode = shareMode;
     this.latencyMilliseconds = latency;
     this.syncContext = SynchronizationContext.Current;
     playThreadEvent = new AutoResetEvent(false);
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:14,代码来源:WasapiOutRT.cs

示例5: WasapiOut

 /// <summary>
 /// Creates a new WASAPI Output
 /// </summary>
 /// <param name="device">Device to use</param>
 /// <param name="shareMode"></param>
 /// <param name="useEventSync">true if sync is done with event. false use sleep.</param>
 /// <param name="latency">Desired latency in milliseconds</param>
 public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency)
 {
     audioClient = device.AudioClient;
     mmDevice = device;
     this.shareMode = shareMode;
     isUsingEventSync = useEventSync;
     latencyMilliseconds = latency;
     syncContext = SynchronizationContext.Current;
     outputFormat = audioClient.MixFormat; // allow the user to query the default format for shared mode streams
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:17,代码来源:WasapiOut.cs

示例6: WasapiOutGuiThread

 /// <summary>
 /// Creates a new WASAPI Output device
 /// </summary>
 /// <param name="device">Device to use</param>
 /// <param name="shareMode">Share mode to use</param>
 /// <param name="latency">Latency in milliseconds</param>
 public WasapiOutGuiThread(MMDevice device, AudioClientShareMode shareMode, int latency)
 {
     audioClient = device.AudioClient;
     outputFormat = audioClient.MixFormat;
     this.shareMode = shareMode;
     latencyMilliseconds = latency;
     timer = new Timer();
     timer.Tick += TimerOnTick;
     timer.Interval = latency/2;
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:16,代码来源:WasapiOutGuiThread.cs

示例7: Initialize

 /// <summary>
 /// Initialize the Audio Client
 /// </summary>
 /// <param name="shareMode">Share Mode</param>
 /// <param name="streamFlags">Stream Flags</param>
 /// <param name="bufferDuration">Buffer Duration</param>
 /// <param name="periodicity">Periodicity</param>
 /// <param name="waveFormat">Wave Format</param>
 /// <param name="audioSessionGuid">Audio Session GUID (can be null)</param>
 public void Initialize(AudioClientShareMode shareMode,
     AudioClientStreamFlags streamFlags,
     long bufferDuration,
     long periodicity,
     WaveFormat waveFormat,
     Guid audioSessionGuid)
 {
     audioClientInterface.Initialize(shareMode, streamFlags, bufferDuration, periodicity, waveFormat, ref audioSessionGuid);
     // may have changed the mix format so reset it
     mixFormat = null;
 }
开发者ID:androidhacker,项目名称:DotNetProjs,代码行数:20,代码来源:AudioClient.cs

示例8: Initialize

 /// <summary>
 /// Initializes the Audio Client
 /// </summary>
 /// <param name="shareMode">Share Mode</param>
 /// <param name="streamFlags">Stream Flags</param>
 /// <param name="bufferDuration">Buffer Duration</param>
 /// <param name="periodicity">Periodicity</param>
 /// <param name="waveFormat">Wave Format</param>
 /// <param name="audioSessionGuid">Audio Session GUID (can be null)</param>
 public void Initialize(AudioClientShareMode shareMode,
     AudioClientStreamFlags streamFlags,
     long bufferDuration,
     long periodicity,
     WaveFormat waveFormat,
     Guid audioSessionGuid)
 {
     this.shareMode = shareMode;
     int hresult = audioClientInterface.Initialize(shareMode, streamFlags, bufferDuration, periodicity, waveFormat, ref audioSessionGuid);
     Marshal.ThrowExceptionForHR(hresult);
     // may have changed the mix format so reset it
     mixFormat = null;
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:22,代码来源:AudioClient.cs

示例9: WasapiOut

        /// <summary>
        /// Creates a new WASAPI Output
        /// </summary>
        /// <param name="device">Device to use</param>
        /// <param name="shareMode"></param>
        /// <param name="useEventSync">true if sync is done with event. false use sleep.</param>
        /// <param name="latency"></param>
		public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency, AudioPCMConfig pcm)
        {
            this.audioClient = device.AudioClient;
            this.shareMode = shareMode;
            this.isUsingEventSync = useEventSync;
            this.latencyMilliseconds = latency;
			this.pcm = pcm;
			this.outputFormat = new NAudio.Wave.WaveFormatExtensible(pcm.SampleRate, pcm.BitsPerSample, pcm.ChannelCount);
			NAudio.Wave.WaveFormatExtensible closestSampleRateFormat;
            if (!audioClient.IsFormatSupported(shareMode, outputFormat, out closestSampleRateFormat))
				throw new NotSupportedException("PCM format mismatch");
			Init();
			bufferFrameCount = audioClient.BufferSize;
			readBuffers = new AudioBuffer[2];
			readBuffers[0] = new AudioBuffer(pcm, bufferFrameCount);
			readBuffers[1] = new AudioBuffer(pcm, bufferFrameCount);
			//if (this.shareMode == AudioClientShareMode.Exclusive)
			//    this.latencyMilliseconds = (int)(this.audioClient.DefaultDevicePeriod / 10000);
        }
开发者ID:androidhacker,项目名称:DotNetProjs,代码行数:26,代码来源:WasapiOut.cs

示例10: InitializeClient

 private AudioClient InitializeClient(AudioClientShareMode shareMode)
 {
     AudioClient audioClient = GetAudioClient();
     WaveFormat waveFormat = audioClient.MixFormat;
     long refTimesPerSecond = 10000000;
     audioClient.Initialize(shareMode,
         AudioClientStreamFlags.None,
         refTimesPerSecond,
         0,
         waveFormat,
         Guid.Empty);
     return audioClient;
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:13,代码来源:AudioClientTests.cs

示例11: IsFormatSupported

 public bool IsFormatSupported(AudioClientShareMode shareMode, WAVEFORMATEXTENSIBLE format, ref WAVEFORMATEXTENSIBLE closestMatch)
 {
     int hr = _RealClient.IsFormatSupported(shareMode, format, out closestMatch);
     bool ret = false;
     if (hr == 0) ret = true;
     else if (hr == 1) ret = false;
     else Marshal.ThrowExceptionForHR(hr);
     
     return ret;
 }
开发者ID:davinx,项目名称:PitchPitch,代码行数:10,代码来源:AudioClient.cs

示例12: WasapiCapture

        /// <summary>
        /// Initializes a new instance of the <see cref="WasapiCapture"/> class.
        /// </summary>
        /// <param name="eventSync">True, to use eventsynchronization instead of a simple loop and sleep behavior. Don't use this in combination with exclusive mode.</param>
        /// <param name="shareMode">Specifies how to open the audio device. Note that if exclusive mode is used, the device can only be used once on the whole system. Don't use exclusive mode in combination with eventSync.</param>
        /// <param name="latency">Latency of the capture specified in milliseconds.</param>
        /// <param name="captureThreadPriority">ThreadPriority of the capturethread which runs in background and provides the audiocapture itself.</param>
        /// <param name="defaultFormat">The default WaveFormat to use for the capture. If this parameter is set to null, the best available format will be chosen automatically.</param>
        /// <param name="synchronizationContext">The <see cref="SynchronizationContext"/> to use to fire events on.</param>
        /// <exception cref="PlatformNotSupportedException">The current platform does not support Wasapi. For more details see: <see cref="IsSupportedOnCurrentPlatform"/>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="eventSync"/> parameter is set to true while the <paramref name="shareMode"/> is set to <see cref="AudioClientShareMode.Exclusive"/>.</exception>
        public WasapiCapture(bool eventSync, AudioClientShareMode shareMode, int latency, WaveFormat defaultFormat,
            ThreadPriority captureThreadPriority, SynchronizationContext synchronizationContext)
        {
            if (!IsSupportedOnCurrentPlatform)
                throw new PlatformNotSupportedException("Wasapi is only supported on Windows Vista and above.");
            if (eventSync && shareMode == AudioClientShareMode.Exclusive)
                throw new ArgumentException("Don't use eventSync in combination with exclusive mode.");

            _eventSync = eventSync;
            _shareMode = shareMode;
            _waveFormat = defaultFormat;

            _latency = latency;
            _captureThreadPriority = captureThreadPriority;
            _synchronizationContext = synchronizationContext;

            _recordingState = RecordingState.Stopped;
        }
开发者ID:EQ4,项目名称:cscore,代码行数:29,代码来源:WasapiCapture.cs

示例13: IsFormatSupported

        /// <summary>
        /// Checks whether the audio endpoint device supports a particular stream format.
        /// </summary>
        public bool IsFormatSupported(AudioClientShareMode shareMode, WaveFormat waveFormat, out WaveFormatExtensible closestMatch)
        {
            int result = IsFormatSupportedNative(shareMode, waveFormat, out closestMatch);
            switch (result)
            {
                case 0x0:
                    return true;

                case 0x1:
                case unchecked((int)0x88890008):
                    return false;

                default:
                    CoreAudioAPIException.Try(result, c, "IsFormatSupported");
                    return false;
            }
        }
开发者ID:CheViana,项目名称:AudioLab,代码行数:20,代码来源:AudioClient.cs

示例14: Initialize

        public void Initialize(
            AudioClientShareMode shareMode,
            AudioClientStreamFlags streamFlags,
            long bufferDuration, long periodicity,
            WAVEFORMATEXTENSIBLE format, Guid audioSessionGuid)
        {
            int hr = _RealClient.Initialize(shareMode, streamFlags, bufferDuration, periodicity, format, ref audioSessionGuid);
            Marshal.ThrowExceptionForHR(hr);

            if ((streamFlags & AudioClientStreamFlags.EventCallback) != 0)
            {
                _audioSampleReady = new AutoResetEvent(false);
                IntPtr eventHandle = CreateEventEx(IntPtr.Zero, "audioSampleReady", CreateEventFlags.None, AccessRight.Synchronize | AccessRight.EventModifyState);
                _audioSampleReady.SafeWaitHandle = new Microsoft.Win32.SafeHandles.SafeWaitHandle(eventHandle, true);

                hr = _RealClient.SetEventHandle(eventHandle);
                Marshal.ThrowExceptionForHR(hr);

                _audioSampleReadyRegistered = ThreadPool.RegisterWaitForSingleObject(
                    _audioSampleReady, new WaitOrTimerCallback(sampleReady), null, -1, false);
            }
            _isInitialized = true;
        }
开发者ID:davinx,项目名称:PitchPitch,代码行数:23,代码来源:AudioClient.cs

示例15: WasapiOut

 /// <summary>
 ///     Initializes an new instance of <see cref="WasapiOut" /> class.
 ///     EventSyncContext = SynchronizationContext.Current.
 ///     PlaybackThreadPriority = AboveNormal.
 /// </summary>
 /// <param name="eventSync">True, to use eventsynchronization instead of a simple loop and sleep behavior.</param>
 /// <param name="shareMode">
 ///     Specifies how to open the audio device. Note that if exclusive mode is used, only one single
 ///     playback for the specified device is possible at once.
 /// </param>
 /// <param name="latency">Latency of the playback specified in milliseconds.</param>
 public WasapiOut(bool eventSync, AudioClientShareMode shareMode, int latency)
     : this(eventSync, shareMode, latency, ThreadPriority.AboveNormal)
 {
 }
开发者ID:opcon,项目名称:cscore,代码行数:15,代码来源:WasapiOut.cs


注:本文中的AudioClientShareMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。