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


C# XAudio2.CreateSourceVoice_方法代码示例

本文整理汇总了C#中SharpDX.XAudio2.XAudio2.CreateSourceVoice_方法的典型用法代码示例。如果您正苦于以下问题:C# XAudio2.CreateSourceVoice_方法的具体用法?C# XAudio2.CreateSourceVoice_怎么用?C# XAudio2.CreateSourceVoice_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpDX.XAudio2.XAudio2的用法示例。


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

示例1: SourceVoice

 /// <summary>
 /// Creates and configures a source voice with callback through delegates.
 /// </summary>
 /// <param name="device">an instance of <see cref="SharpDX.XAudio2.XAudio2" /></param>
 /// <param name="sourceFormat">[in]  Pointer to a <see cref="SharpDX.Multimedia.WaveFormat" /> structure. This structure contains the expected format for all audio buffers submitted to the source voice. XAudio2 supports voice types of PCM, xWMA, ADPCM (Windows only), and XMA (Xbox 360 only). XAudio2 supports the following PCM formats.   8-bit (unsigned) integer PCM   16-bit integer PCM (Optimal format for XAudio2)   20-bit integer PCM (either in 24 or 32 bit containers)   24-bit integer PCM (either in 24 or 32 bit containers)   32-bit integer PCM   32-bit float PCM (Preferred format after 16-bit integer)   The number of channels in a source voice must be less than or equal to XAUDIO2_MAX_AUDIO_CHANNELS. The sample rate of a source voice must be between XAUDIO2_MIN_SAMPLE_RATE and XAUDIO2_MAX_SAMPLE_RATE. Note Data formats such as XMA, {{ADPCM}}, and {{xWMA}} that require more information than provided by <see cref="SharpDX.Multimedia.WaveFormat" /> have a <see cref="SharpDX.Multimedia.WaveFormat" /> structure as the first member in their format structure. When creating a source voice with one of those formats cast the format's structure as a <see cref="SharpDX.Multimedia.WaveFormat" /> structure and use it as the value for pSourceFormat.</param>
 /// <param name="flags">[in]  Flags that specify the behavior of the source voice. A flag can be 0 or a combination of one or more of the following: ValueDescriptionXAUDIO2_VOICE_NOPITCHNo pitch control is available on the voice.?XAUDIO2_VOICE_NOSRCNo sample rate conversion is available on the voice, the voice's  outputs must have the same sample rate.Note The XAUDIO2_VOICE_NOSRC flag causes the voice to behave as though the XAUDIO2_VOICE_NOPITCH flag also is specified. ?XAUDIO2_VOICE_USEFILTERThe filter effect should be available on this voice.?XAUDIO2_VOICE_MUSICThe voice is used to play background music. The system automatically  can replace the voice with music selected by the user.?</param>
 /// <param name="maxFrequencyRatio">[in]  Highest allowable frequency ratio that can be set on this voice. The value for this argument must be between XAUDIO2_MIN_FREQ_RATIO and XAUDIO2_MAX_FREQ_RATIO. Subsequent calls to <see cref="SharpDX.XAudio2.SourceVoice.SetFrequencyRatio" /> are clamped between XAUDIO2_MIN_FREQ_RATIO and MaxFrequencyRatio. The maximum value for this argument is defined as XAUDIO2_MAX_FREQ_RATIO, which allows pitch to be raised by up to 10 octaves. If MaxFrequencyRatio is less than 1.0, the voice will use that ratio immediately after being created (rather than the default of 1.0). Xbox 360  For XMA voices there is an additional restriction on the MaxFrequencyRatio argument and the voice's sample rate. The product of these two numbers cannot exceed XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MONO for one-channel voices or XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MULTICHANNEL for voices with any other number of channels. If the value specified for MaxFrequencyRatio is too high for the specified format, the call to CreateSourceVoice fails and produces a debug message.  Note XAudio2's memory usage can be reduced by using the lowest possible MaxFrequencyRatio value.</param>
 /// <param name="enableCallbackEvents">if set to <c>true</c> [enable callback events].</param>
 /// <returns>No enableCallbackEvents.</returns>
 ///   <unmanaged>HRESULT IXAudio2::CreateSourceVoice([Out] IXAudio2SourceVoice** ppSourceVoice,[In] const WAVEFORMATEX* pSourceFormat,[None] UINT32 Flags,[None] float MaxFrequencyRatio,[In, Optional] IXAudio2VoiceCallback* pCallback,[In, Optional] const XAUDIO2_VOICE_SENDS* pSendList,[In, Optional] const XAUDIO2_EFFECT_CHAIN* pEffectChain)</unmanaged>
 public SourceVoice(XAudio2 device, SharpDX.Multimedia.WaveFormat sourceFormat, SharpDX.XAudio2.VoiceFlags flags, float maxFrequencyRatio, bool enableCallbackEvents)
     : base(IntPtr.Zero)
 {
     var waveformatPtr = WaveFormat.MarshalToPtr(sourceFormat);
     try
     {
         device.CreateSourceVoice_(this, waveformatPtr, flags, maxFrequencyRatio, enableCallbackEvents ? VoiceShadow.ToIntPtr(voiceCallbackImpl = new VoiceCallbackImpl(this)) : IntPtr.Zero, null, null);
     } finally
     {
         Marshal.FreeHGlobal(waveformatPtr);                
     }
 }
开发者ID:GrafSeismo,项目名称:SharpDX,代码行数:22,代码来源:SourceVoice.cs

示例2: CreateSourceVoice

 private void CreateSourceVoice(XAudio2 device, SharpDX.Multimedia.WaveFormat sourceFormat, SharpDX.XAudio2.VoiceFlags flags, float maxFrequencyRatio, IntPtr callback, EffectDescriptor[] effectDescriptors)
 {
     var waveformatPtr = WaveFormat.MarshalToPtr(sourceFormat);
     try
     {
         if (effectDescriptors != null)
         {
             unsafe
             {
                 var tempSendDescriptor = new EffectChain();
                 var effectDescriptorNatives = new EffectDescriptor.__Native[effectDescriptors.Length];
                 for (int i = 0; i < effectDescriptorNatives.Length; i++)
                     effectDescriptors[i].__MarshalTo(ref effectDescriptorNatives[i]);
                 tempSendDescriptor.EffectCount = effectDescriptorNatives.Length;
                 fixed (void* pEffectDescriptors = &effectDescriptorNatives[0])
                 {
                     tempSendDescriptor.EffectDescriptorPointer = (IntPtr)pEffectDescriptors;
                     device.CreateSourceVoice_(this, waveformatPtr, flags, maxFrequencyRatio, callback, null, tempSendDescriptor);
                 }
             }
         }
         else
         {
             device.CreateSourceVoice_(this, waveformatPtr, flags, maxFrequencyRatio, callback, null, null);
         }
     }
     finally
     {
         Marshal.FreeHGlobal(waveformatPtr);
     }
 }
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:31,代码来源:SourceVoice.cs


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