Exemplo n.º 1
0
 public IXAudio2MasteringVoice CreateMasteringVoice(
     int inputChannels            = DefaultChannels,
     int inputSampleRate          = DefaultSampleRate,
     AudioStreamCategory category = AudioStreamCategory.GameEffects)
 {
     return(CreateMasteringVoice(inputChannels, inputSampleRate, 0, null, null, category));
 }
Exemplo n.º 2
0
 public static extern unsafe HRESULT CreateMasteringVoice_(
     [In] IntPtr ppXAudio2Handle,
     [Out] out IntPtr ppMasteringVoice,
     [In] uint inputChannels,
     [In] uint inputSampleRate,
     [In] uint flags,
     [In] string szDeviceId,
     [In] Xaudio2EffectChain *pEffectChain,
     [In] AudioStreamCategory streamCategory);
Exemplo n.º 3
0
 /// <summary>
 /// Sets the parameters that describe the properties of the client's audio stream.
 /// </summary>
 /// <param name="useHardwareOffload">Boolean value to indicate whether or not the audio stream is hardware-offloaded.</param>
 /// <param name="category">An enumeration that is used to specify the category of the audio stream.</param>
 /// <param name="options">A bit-field describing the characteristics of the stream. Supported in Windows 8.1 and later.</param>
 public void SetClientProperties(bool useHardwareOffload, AudioStreamCategory category, AudioClientStreamOptions options)
 {
     audioClientProperties = new AudioClientProperties()
     {
         cbSize     = (uint)Marshal.SizeOf <AudioClientProperties>(),
         bIsOffload = Convert.ToInt32(useHardwareOffload),
         eCategory  = category,
         Options    = options
     };
 }
Exemplo n.º 4
0
 public IXAudio2MasteringVoice CreateMasteringVoice(
     int inputChannels            = DefaultChannels,
     int inputSampleRate          = DefaultSampleRate,
     AudioStreamCategory category = AudioStreamCategory.GameEffects)
 {
     if (Version == XAudio2Version.Version27)
     {
         return(CreateMasteringVoice27(inputChannels, inputSampleRate, 0, 0, null));
     }
     else
     {
         return(CreateMasteringVoice(inputChannels, inputSampleRate, 0, null, null, category));
     }
 }
Exemplo n.º 5
0
    public unsafe IXAudio2MasteringVoice CreateMasteringVoice(
        int inputChannels            = DefaultChannels,
        int inputSampleRate          = DefaultSampleRate,
        AudioStreamCategory category = AudioStreamCategory.GameEffects,
        string deviceId = "",
        EffectDescriptor[]?effectDescriptors = null)
    {
        if (effectDescriptors != null)
        {
            var effectChain             = new EffectChain();
            var effectDescriptorNatives = new EffectDescriptor.__Native[effectDescriptors.Length];
            for (int i = 0; i < effectDescriptorNatives.Length; i++)
            {
                effectDescriptors[i].__MarshalTo(ref effectDescriptorNatives[i]);
            }

            effectChain.EffectCount = effectDescriptorNatives.Length;
            fixed(void *pEffectDescriptors = &effectDescriptorNatives[0])
            {
                effectChain.EffectDescriptorPointer = (IntPtr)pEffectDescriptors;

                if (string.IsNullOrEmpty(deviceId))
                {
                    return(CreateMasteringVoice(inputChannels, inputSampleRate, 0, null, effectChain, category));
                }
                else
                {
                    return(CreateMasteringVoice(inputChannels, inputSampleRate, 0, deviceId, effectChain, category));
                }
            }
        }
        else
        {
            if (string.IsNullOrEmpty(deviceId))
            {
                return(CreateMasteringVoice(inputChannels, inputSampleRate, 0, null, null, category));
            }
            else
            {
                return(CreateMasteringVoice(inputChannels, inputSampleRate, 0, deviceId, null, category));
            }
        }
    }
Exemplo n.º 6
0
        /// <summary>
        ///     Creates and configures a mastering voice.
        /// </summary>
        /// <param name="pMasteringVoice">If successful, returns a pointer to the new <see cref="XAudio2MasteringVoice" /> object.</param>
        /// <param name="inputChannels">
        ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less than
        ///     or equal to <see cref="MaxAudioChannels" />.
        ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
        ///     speaker configuration setup.
        /// </param>
        /// <param name="inputSampleRate">
        ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
        ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between <see cref="MinimumSampleRate" />
        ///     and <see cref="MaximumSampleRate" />.
        ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
        ///     platform.
        /// </param>
        /// <param name="flags">Flags that specify the behavior of the mastering voice. Must be 0.</param>
        /// <param name="deviceId">
        ///     Identifier of the device to receive the output audio. Specifying the default value of 0 (zero)
        ///     causes XAudio2 to select the global default audio device.
        /// </param>
        /// <param name="effectChain">
        ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
        ///     voice, or NULL to use no effects.
        /// </param>
        /// <param name="streamCategory"><b>Not valid for XAudio 2.7.</b></param>
        /// <returns>HRESULT</returns>
        public override unsafe int CreateMasteringVoiceNative(out IntPtr pMasteringVoice, int inputChannels,
                                                              int inputSampleRate, int flags,
                                                              object deviceId, EffectChain?effectChain, AudioStreamCategory streamCategory)
        {
            if (!(deviceId is int))
            {
                throw new ArgumentException("DeviceId has to be an integer.", "deviceId");
            }
            var device = (int)deviceId;

            EffectChain value1 = effectChain.HasValue ? effectChain.Value : new EffectChain();

            fixed(void *ptr = &pMasteringVoice)
            {
                return(InteropCalls.CallI(
                           UnsafeBasePtr,
                           ptr,
                           inputChannels,
                           inputSampleRate,
                           flags,
                           device,
                           effectChain.HasValue ? &value1 : (void *)IntPtr.Zero,
                           //streamCategory,
                           ((void **)(*(void **)UnsafeBasePtr))[10]));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Creates and configures a mastering voice.
        /// </summary>
        /// <param name="pMasteringVoice">If successful, returns a pointer to the new <see cref="XAudio2MasteringVoice" /> object.</param>
        /// <param name="inputChannels">
        ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less than
        ///     or equal to <see cref="MaxAudioChannels" />.
        ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
        ///     speaker configuration setup.
        /// </param>
        /// <param name="inputSampleRate">
        ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
        ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between <see cref="MinimumSampleRate" />
        ///     and <see cref="MaximumSampleRate" />.
        ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
        ///     platform.
        /// </param>
        /// <param name="flags">Flags that specify the behavior of the mastering voice. Must be 0.</param>
        /// <param name="deviceId">
        ///     Identifier of the device to receive the output audio. Specifying the default value of NULL
        ///     causes XAudio2 to select the global default audio device.
        /// </param>
        /// <param name="effectChain">
        ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
        ///     voice, or NULL to use no effects.
        /// </param>
        /// <param name="streamCategory">The audio stream category to use for this mastering voice.</param>
        /// <returns>HRESULT</returns>
        public override unsafe int CreateMasteringVoiceNative(out IntPtr pMasteringVoice, int inputChannels,
                                                              int inputSampleRate, int flags,
                                                              object deviceId, EffectChain?effectChain, AudioStreamCategory streamCategory)
        {
            if (deviceId != null && !(deviceId is string))
            {
                throw new ArgumentException("DeviceId has to be a string.", "deviceId");
            }

            var    device    = deviceId as string;
            IntPtr pdeviceId = IntPtr.Zero;

            try
            {
                EffectChain value1 = effectChain ?? new EffectChain();
                if (device != null)
                {
                    pdeviceId = Marshal.StringToHGlobalUni(device);

                    fixed(void *ptr = &pMasteringVoice)
                    {
                        return(InteropCalls.CallI(
                                   UnsafeBasePtr,
                                   ptr,
                                   inputChannels,
                                   inputSampleRate,
                                   flags,
                                   (void *)pdeviceId,
                                   effectChain.HasValue ? &value1 : (void *)IntPtr.Zero,
                                   streamCategory,
                                   ((void **)(*(void **)UnsafeBasePtr))[7]));
                    }
            }
            finally
            {
                if (pdeviceId != IntPtr.Zero)
                    Marshal.FreeHGlobal(pdeviceId); }
            }
Exemplo n.º 8
0
 /// <summary>
 ///     Creates and configures a mastering voice.
 /// </summary>
 /// <param name="inputChannels">
 ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less
 ///     than
 ///     or equal to <see cref="MaxAudioChannels" />.
 ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
 ///     speaker configuration setup.
 /// </param>
 /// <param name="inputSampleRate">
 ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
 ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between
 ///     <see cref="MinimumSampleRate" />
 ///     and <see cref="MaximumSampleRate" />.
 ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
 ///     platform.
 /// </param>
 /// <param name="device">
 ///     Identifier of the device to receive the output audio.
 ///     Specifying the default value of NULL (for XAudio2.8) or 0 (for XAudio2.7) causes
 ///     XAudio2 to select the global default audio device.
 ///
 ///     On XAudio2.7: Use the <see cref="XAudio2_7.GetDeviceCount"/> and the <see cref="XAudio2_7.GetDeviceDetails"/> method to enumerate device. Pass its index (valid range from 0 to <see cref="XAudio2_7.GetDeviceCount"/>) to the <paramref name="device"/> argument.
 ///     On XAudio2.8: Use the <see cref="MMDeviceEnumerator"/> class to enumerate <see cref="MMDevice"/> objects. Pass its <see cref="MMDevice.DevicePath"/> to the <paramref name="device"/> argument.
 /// </param>
 /// <param name="effectChain">
 ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
 ///     voice, or NULL to use no effects.
 /// </param>
 /// <param name="streamCategory"><b>XAudio2.8 only:</b> The audio stream category to use for this mastering voice.</param>
 /// <returns>If successful, returns a new <see cref="XAudio2MasteringVoice" /> object.</returns>
 public XAudio2MasteringVoice CreateMasteringVoice(int inputChannels, int inputSampleRate,
                                                   object device, EffectChain?effectChain, AudioStreamCategory streamCategory)
 {
     return
         (new XAudio2MasteringVoice(CreateMasteringVoicePtr(inputChannels, inputSampleRate, 0, device, effectChain,
                                                            streamCategory), _version));
 }
Exemplo n.º 9
0
 /// <summary>
 ///     Creates and configures a mastering voice.
 /// </summary>
 /// <param name="pMasteringVoice">If successful, returns a pointer to the new <see cref="XAudio2MasteringVoice" /> object.</param>
 /// <param name="inputChannels">
 ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less
 ///     than
 ///     or equal to <see cref="MaxAudioChannels" />.
 ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
 ///     speaker configuration setup.
 /// </param>
 /// <param name="inputSampleRate">
 ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
 ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between
 ///     <see cref="MinimumSampleRate" />
 ///     and <see cref="MaximumSampleRate" />.
 ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
 ///     platform.
 /// </param>
 /// <param name="flags">Flags that specify the behavior of the mastering voice. Must be 0.</param>
 /// <param name="device">
 ///     Identifier of the device to receive the output audio.
 ///     Specifying the default value of NULL (for XAudio2.8) or 0 (for XAudio2.7) causes
 ///     XAudio2 to select the global default audio device.
 ///
 ///     On XAudio2.7: Use the <see cref="XAudio2_7.GetDeviceCount"/> and the <see cref="XAudio2_7.GetDeviceDetails"/> method to enumerate device. Pass its index (valid range from 0 to <see cref="XAudio2_7.GetDeviceCount"/>) to the <paramref name="device"/> argument.
 ///     On XAudio2.8: Use the <see cref="MMDeviceEnumerator"/> class to enumerate <see cref="MMDevice"/> objects. Pass its <see cref="MMDevice.DevicePath"/> to the <paramref name="device"/> argument.
 /// </param>
 /// <param name="effectChain">
 ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
 ///     voice, or NULL to use no effects.
 /// </param>
 /// <param name="streamCategory">The audio stream category to use for this mastering voice.</param>
 /// <returns>HRESULT</returns>
 public abstract int CreateMasteringVoiceNative(out IntPtr pMasteringVoice, int inputChannels,
                                                int inputSampleRate,
                                                int flags,
                                                object device, EffectChain?effectChain, AudioStreamCategory streamCategory);
Exemplo n.º 10
0
 /// <summary>
 ///     Creates and configures a mastering voice.
 /// </summary>
 /// <param name="inputChannels">
 ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less
 ///     than
 ///     or equal to <see cref="MaxAudioChannels" />.
 ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
 ///     speaker configuration setup.
 /// </param>
 /// <param name="inputSampleRate">
 ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
 ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between
 ///     <see cref="MinimumSampleRate" />
 ///     and <see cref="MaximumSampleRate" />.
 ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
 ///     platform.
 /// </param>
 /// <param name="flags">Flags that specify the behavior of the mastering voice. Must be 0.</param>
 /// <param name="device">
 ///     Identifier of the device to receive the output audio. Specifying the default value of NULL (for XAudio2.8) or 0 (for XAudio2.7) causes
 ///     XAudio2 to select the global default audio device.
 /// </param>
 /// <param name="effectChain">
 ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
 ///     voice, or NULL to use no effects.
 /// </param>
 /// <param name="streamCategory">The audio stream category to use for this mastering voice.</param>
 /// <returns>If successful, returns a pointer to the new <see cref="XAudio2MasteringVoice" /> object.</returns>
 public IntPtr CreateMasteringVoicePtr(int inputChannels, int inputSampleRate, int flags,
     object device, EffectChain? effectChain, AudioStreamCategory streamCategory)
 {
     IntPtr ptr;
     int result = CreateMasteringVoiceNative(out ptr, inputChannels, inputSampleRate, flags, device,
         effectChain, streamCategory);
     XAudio2Exception.Try(result, N, "CreateMasteringVoice");
     return ptr;
 }
Exemplo n.º 11
0
 /// <summary>
 ///     Creates and configures a mastering voice.
 /// </summary>
 /// <param name="pMasteringVoice">If successful, returns a pointer to the new <see cref="XAudio2MasteringVoice" /> object.</param>
 /// <param name="inputChannels">
 ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less
 ///     than
 ///     or equal to <see cref="MaxAudioChannels" />.
 ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
 ///     speaker configuration setup.
 /// </param>
 /// <param name="inputSampleRate">
 ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
 ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between
 ///     <see cref="MinimumSampleRate" />
 ///     and <see cref="MaximumSampleRate" />.
 ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
 ///     platform.
 /// </param>
 /// <param name="flags">Flags that specify the behavior of the mastering voice. Must be 0.</param>
 /// <param name="device">
 ///     Identifier of the device to receive the output audio. Specifying the default value of NULL (for XAudio2.8) or 0 (for XAudio2.7) causes
 ///     XAudio2 to select the global default audio device.
 /// </param>
 /// <param name="effectChain">
 ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
 ///     voice, or NULL to use no effects.
 /// </param>
 /// <param name="streamCategory">The audio stream category to use for this mastering voice.</param>
 /// <returns>HRESULT</returns>
 public abstract int CreateMasteringVoiceNative(out IntPtr pMasteringVoice, int inputChannels,
     int inputSampleRate,
     int flags,
     object device, EffectChain? effectChain, AudioStreamCategory streamCategory);
Exemplo n.º 12
0
 /// <summary>
 ///     Creates and configures a mastering voice.
 /// </summary>
 /// <param name="inputChannels">
 ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less
 ///     than
 ///     or equal to <see cref="MaxAudioChannels" />.
 ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
 ///     speaker configuration setup.
 /// </param>
 /// <param name="inputSampleRate">
 ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
 ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between
 ///     <see cref="MinimumSampleRate" />
 ///     and <see cref="MaximumSampleRate" />.
 ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
 ///     platform.
 /// </param>
 /// <param name="device">
 ///     Identifier of the device to receive the output audio. Specifying the default value of NULL (for XAudio2.8) or 0 (for XAudio2.7) causes
 ///     XAudio2 to select the global default audio device.
 /// </param>
 /// <param name="effectChain">
 ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
 ///     voice, or NULL to use no effects.
 /// </param>
 /// <param name="streamCategory"><b>XAudio2.8 only:</b> The audio stream category to use for this mastering voice.</param>
 /// <returns>If successful, returns a new <see cref="XAudio2MasteringVoice" /> object.</returns>
 public XAudio2MasteringVoice CreateMasteringVoice(int inputChannels, int inputSampleRate,
     object device, EffectChain? effectChain, AudioStreamCategory streamCategory)
 {
     return
         new XAudio2MasteringVoice(CreateMasteringVoicePtr(inputChannels, inputSampleRate, 0, device, effectChain,
             streamCategory), _version);
 }
Exemplo n.º 13
0
        /// <summary>
        ///     Creates and configures a mastering voice.
        /// </summary>
        /// <param name="pMasteringVoice">If successful, returns a pointer to the new <see cref="XAudio2MasteringVoice" /> object.</param>
        /// <param name="inputChannels">
        ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less than
        ///     or equal to <see cref="MaxAudioChannels" />.
        ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
        ///     speaker configuration setup.
        /// </param>
        /// <param name="inputSampleRate">
        ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
        ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between <see cref="MinimumSampleRate" />
        ///     and <see cref="MaximumSampleRate" />.
        ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
        ///     platform.
        /// </param>
        /// <param name="flags">Flags that specify the behavior of the mastering voice. Must be 0.</param>
        /// <param name="deviceId">
        ///     Identifier of the device to receive the output audio. Specifying the default value of NULL
        ///     causes XAudio2 to select the global default audio device.
        /// </param>
        /// <param name="effectChain">
        ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
        ///     voice, or NULL to use no effects.
        /// </param>
        /// <param name="streamCategory">The audio stream category to use for this mastering voice.</param>
        /// <returns>HRESULT</returns>
        public unsafe override int CreateMasteringVoiceNative(out IntPtr pMasteringVoice, int inputChannels,
            int inputSampleRate, int flags,
            object deviceId, EffectChain? effectChain, AudioStreamCategory streamCategory)
        {
            if (deviceId != null && !(deviceId is string))
                throw new ArgumentException("DeviceId has to be a string.", "deviceId");

            var device = deviceId as string;
            IntPtr pdeviceId = IntPtr.Zero;
            try
            {
                EffectChain value1 = effectChain.HasValue ? effectChain.Value : new EffectChain();
                if (device != null)
                    pdeviceId = Marshal.StringToHGlobalUni(device);

                fixed (void* ptr = &pMasteringVoice)
                {
                    return InteropCalls.CallI(
                        UnsafeBasePtr,
                        ptr,
                        inputChannels,
                        inputSampleRate,
                        flags,
                        (void*) pdeviceId,
                        effectChain.HasValue ? &value1 : (void*) IntPtr.Zero,
                        streamCategory,
                        ((void**) (*(void**) UnsafeBasePtr))[7]);
                }
            }
            finally
            {
                if (pdeviceId != IntPtr.Zero)
                    Marshal.FreeHGlobal(pdeviceId);
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Sets the parameters that describe the properties of the client's audio stream.
 /// </summary>
 /// <param name="useHardwareOffload">Boolean value to indicate whether or not the audio stream is hardware-offloaded.</param>
 /// <param name="category">An enumeration that is used to specify the category of the audio stream.</param>
 /// <param name="options">A bit-field describing the characteristics of the stream. Supported in Windows 8.1 and later.</param>
 public void SetClientProperties(bool useHardwareOffload, AudioStreamCategory category, AudioClientStreamOptions options)
 {
     audioClientProperties = new AudioClientProperties()
     {
         cbSize = (uint) Marshal.SizeOf(typeof (AudioClientProperties)),
         bIsOffload = Convert.ToInt32(useHardwareOffload),
         eCategory = category,
         Options = options
     };
 }
Exemplo n.º 15
0
        /// <summary>
        ///     Creates and configures a mastering voice.
        /// </summary>
        /// <param name="pMasteringVoice">If successful, returns a pointer to the new <see cref="XAudio2MasteringVoice" /> object.</param>
        /// <param name="inputChannels">
        ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less than
        ///     or equal to <see cref="MaxAudioChannels" />.
        ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
        ///     speaker configuration setup.
        /// </param>
        /// <param name="inputSampleRate">
        ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
        ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between <see cref="MinimumSampleRate" />
        ///     and <see cref="MaximumSampleRate" />.
        ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
        ///     platform.
        /// </param>
        /// <param name="flags">Flags that specify the behavior of the mastering voice. Must be 0.</param>
        /// <param name="deviceId">
        ///     Identifier of the device to receive the output audio. Specifying the default value of 0 (zero)
        ///     causes XAudio2 to select the global default audio device.
        /// </param>
        /// <param name="effectChain">
        ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
        ///     voice, or NULL to use no effects.
        /// </param>
        /// <param name="streamCategory"><b>Not valid for XAudio 2.7.</b></param>
        /// <returns>HRESULT</returns>
        public unsafe override int CreateMasteringVoiceNative(out IntPtr pMasteringVoice, int inputChannels,
            int inputSampleRate, int flags,
            object deviceId, EffectChain? effectChain, AudioStreamCategory streamCategory)
        {
            if (!(deviceId is int))
                throw new ArgumentException("DeviceId has to be an integer.", "deviceId");
            var device = (int) deviceId;

            EffectChain value1 = effectChain.HasValue ? effectChain.Value : new EffectChain();

            fixed (void* ptr = &pMasteringVoice)
            {
                return InteropCalls.CallI(
                    UnsafeBasePtr,
                    ptr,
                    inputChannels,
                    inputSampleRate,
                    flags,
                    device,
                    effectChain.HasValue ? &value1 : (void*) IntPtr.Zero,
                    //streamCategory,
                    ((void**) (*(void**) UnsafeBasePtr))[10]);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Creates and configures a mastering voice.
        /// </summary>
        /// <param name="inputChannels">
        ///     Number of channels the mastering voice expects in its input audio. <paramref name="inputChannels" /> must be less
        ///     than
        ///     or equal to <see cref="MaxAudioChannels" />.
        ///     You can set InputChannels to <see cref="DefaultChannels" />, which causes XAudio2 to try to detect the system
        ///     speaker configuration setup.
        /// </param>
        /// <param name="inputSampleRate">
        ///     Sample rate of the input audio data of the mastering voice. This rate must be a multiple of
        ///     <see cref="QuantumDenominator" />. <paramref name="inputSampleRate" /> must be between
        ///     <see cref="MinimumSampleRate" />
        ///     and <see cref="MaximumSampleRate" />.
        ///     You can set InputSampleRate to <see cref="DefaultSampleRate" />, with the default being determined by the current
        ///     platform.
        /// </param>
        /// <param name="flags">Flags that specify the behavior of the mastering voice. Must be 0.</param>
        /// <param name="device">
        ///     Identifier of the device to receive the output audio.
        ///     Specifying the default value of NULL (for XAudio2.8) or 0 (for XAudio2.7) causes
        ///     XAudio2 to select the global default audio device.
        ///
        ///     On XAudio2.7: Use the <see cref="XAudio2_7.GetDeviceCount"/> and the <see cref="XAudio2_7.GetDeviceDetails"/> method to enumerate device. Pass its index (valid range from 0 to <see cref="XAudio2_7.GetDeviceCount"/>) to the <paramref name="device"/> argument.
        ///     On XAudio2.8: Use the <see cref="MMDeviceEnumerator"/> class to enumerate <see cref="MMDevice"/> objects. Pass its <see cref="MMDevice.DevicePath"/> to the <paramref name="device"/> argument.
        /// </param>
        /// <param name="effectChain">
        ///     <see cref="EffectChain" /> structure that describes an effect chain to use in the mastering
        ///     voice, or NULL to use no effects.
        /// </param>
        /// <param name="streamCategory">The audio stream category to use for this mastering voice.</param>
        /// <returns>If successful, returns a pointer to the new <see cref="XAudio2MasteringVoice" /> object.</returns>
        public IntPtr CreateMasteringVoicePtr(int inputChannels, int inputSampleRate, int flags,
                                              object device, EffectChain?effectChain, AudioStreamCategory streamCategory)
        {
            IntPtr ptr;
            int    result = CreateMasteringVoiceNative(out ptr, inputChannels, inputSampleRate, flags, device,
                                                       effectChain, streamCategory);

            XAudio2Exception.Try(result, N, "CreateMasteringVoice");
            return(ptr);
        }
Exemplo n.º 17
0
 internal static unsafe int CallI(void *_basePtr, void *ptr, int inputChannels, int inputSampleRate, int flags,
                                  void *p1, void *p2, AudioStreamCategory streamCategory, void *p3)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 18
0
 internal static unsafe int CallI(void* _basePtr, void* ptr, int inputChannels, int inputSampleRate, int flags,
     void* p1, void* p2, AudioStreamCategory streamCategory, void* p3)
 {
     throw new NotImplementedException();
 }