Example #1
0
        /// <summary>
        ///     Creates and configures a source voice. For more information see
        ///     http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.ixaudio2.ixaudio2.createsourcevoice(v=vs.85).aspx.
        /// </summary>
        /// <param name="sourceFormat">
        ///     Pointer to a <see cref="WaveFormat" />. The following formats are supported:
        ///     <ul>
        ///         <li>8-bit (unsigned) integer PCM</li><li>16-bit integer PCM (optimal format for XAudio2)</li>
        ///         <li>20-bit integer PCM (either in 24 or 32 bit containers)</li>
        ///         <li>24-bit integer PCM (either in 24 or 32 bit containers)</li><li>32-bit integer PCM</li>
        ///         <li>32-bit float PCM (preferred format after 16-bit integer)</li>
        ///     </ul>
        ///     The number of channels in a source voice must be less than or equal to <see cref="MaxAudioChannels" />. The
        ///     sample rate of a source voice must be between <see cref="MinimumSampleRate" /> and <see cref="MaximumSampleRate" />
        ///     .
        /// </param>
        /// <param name="flags">
        ///     <see cref="VoiceFlags" /> that specify the behavior of the source voice. A flag can be
        ///     <see cref="VoiceFlags.None" /> or a combination of one or more of the following.
        ///     Possible values are <see cref="VoiceFlags.NoPitch" />, <see cref="VoiceFlags.NoSampleRateConversition" /> and
        ///     <see cref="VoiceFlags.UseFilter" />. <see cref="VoiceFlags.Music" /> is not supported on Windows.
        /// </param>
        /// <param name="maxFrequencyRatio">
        ///     Highest allowable frequency ratio that can be set on this voice. The value for this
        ///     argument must be between <see cref="MinFrequencyRatio" /> and <see cref="MaxFrequencyRatio" />.
        /// </param>
        /// <param name="voiceCallback">
        ///     Client-provided callback interface, <see cref="IXAudio2VoiceCallback" />. This parameter is
        ///     optional and can be null.
        /// </param>
        /// <param name="sendList">
        ///     List of <see cref="VoiceSends" /> structures that describe the set of destination voices for the
        ///     source voice. If <paramref name="sendList" /> is NULL, the send list defaults to a single output to the first
        ///     mastering
        ///     voice created.
        /// </param>
        /// <param name="effectChain">
        ///     List of <see cref="EffectChain" /> structures that describe an effect chain to use in the
        ///     source voice. This parameter is optional and can be null.
        /// </param>
        /// <returns>If successful, returns a pointer to the new <see cref="XAudio2SourceVoice" /> object.</returns>
        public IntPtr CreateSourceVoicePtr(WaveFormat sourceFormat, VoiceFlags flags, float maxFrequencyRatio,
                                           IXAudio2VoiceCallback voiceCallback, VoiceSends?sendList, EffectChain?effectChain)
        {
            GCHandle hWaveFormat = GCHandle.Alloc(sourceFormat, GCHandleType.Pinned);

            //todo: do we really need to use GCHandle?
            try
            {
                IntPtr ptr;
                int    result = CreateSourceVoiceNative(
                    out ptr,
                    hWaveFormat.AddrOfPinnedObject(),
                    flags,
                    maxFrequencyRatio,
                    voiceCallback,
                    sendList,
                    effectChain);
                XAudio2Exception.Try(result, N, "CreateSourceVoice");

                return(ptr);
            }
            finally
            {
                if (hWaveFormat.IsAllocated)
                {
                    hWaveFormat.Free();
                }
            }
        }
Example #2
0
        /// <summary>
        ///     Returns the number of available audio output devices.
        /// </summary>
        /// <returns>Number of available audio output devices.</returns>
        public int GetDeviceCount()
        {
            int c;

            XAudio2Exception.Try(GetDeviceCountNative(out c), N, "GetDeviceCount");
            return(c);
        }
Example #3
0
        /// <summary>
        ///     Returns information about an audio output device.
        /// </summary>
        /// <param name="deviceIndex">
        ///     Index of the device to be queried. This value must be less than the count returned by
        ///     <see cref="GetDeviceCount" />.
        /// </param>
        /// <returns><see cref="DeviceDetails" /> structure.</returns>
        public DeviceDetails GetDeviceDetails(int deviceIndex)
        {
            DeviceDetails deviceDetails;

            XAudio2Exception.Try(GetDeviceDetailsNative(deviceIndex, out deviceDetails), N, "GetDeviceDetails");
            return(deviceDetails);
        }
Example #4
0
        /// <summary>
        ///     Gets the voice's filter parameters.
        /// </summary>
        /// <returns><see cref="AudioSharp.XAudio2.FilterParameters" /> structure containing the filter information.</returns>
        public FilterParameters GetFilterParameters()
        {
            FilterParameters r;

            XAudio2Exception.Try(GetFilterParametersNative(out r), InterfaceName, "GetFilterParameters");
            return(r);
        }
Example #5
0
        /// <summary>
        ///     Gets the current overall volume level of the voice.
        /// </summary>
        /// <returns>The current overall volume level of the voice. See Remarks for more information on volume levels.</returns>
        /// <remarks>
        ///     The master volume level is applied at different times depending on the type of voice.
        ///     For submix and mastering voices the volume level is applied just before the voice's built in filter and effect
        ///     chain is applied.
        ///     For source voices the master volume level is applied after the voice's filter and effect
        ///     chain is applied. Volume levels are expressed as floating-point amplitude multipliers
        ///     between -2^24 and 2^24, with a maximum
        ///     gain of 144.5 dB. A volume level of 1.0 means there is no attenuation or gain and 0 means silence.
        ///     Negative levels can be used to invert the audio's phase.
        /// </remarks>
        public float GetVolume()
        {
            float v;

            XAudio2Exception.Try(GetVolumeNative(out v), InterfaceName, "GetVolume");
            return(v);
        }
Example #6
0
        /// <summary>
        ///     Gets the volume level of each channel of the final output for the voice. These channels are mapped to the input
        ///     channels of a specified destination voice.
        /// </summary>
        /// <param name="destinationVoice">The destination <see cref="XAudio2Voice" /> to retrieve the output matrix for.</param>
        /// <param name="sourceChannels">
        ///     Confirms the output channel count of the voice. This is the number of channels that are
        ///     produced by the last effect in the chain.
        /// </param>
        /// <param name="destinationChannels">Confirms the input channel count of the destination voice.</param>
        /// <param name="levelMatrix">
        ///     Array of [SourceChannels ?DestinationChannels] volume levels sent to the destination voice.
        ///     The level sent from source channel S to destination channel D is specified in the form levelMatrix[SourceChannels ?        ///     D + S].
        ///     For more details see
        ///     http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.ixaudio2voice.ixaudio2voice.getoutputmatrix(v=vs.85).aspx.
        /// </param>
        public void GetOutputMatrix(XAudio2Voice destinationVoice, int sourceChannels,
                                    int destinationChannels, float[] levelMatrix)
        {
            int result = GetOutputMatrixNative(destinationVoice, sourceChannels, destinationChannels, levelMatrix);

            XAudio2Exception.Try(result, InterfaceName, "GetOutputMatrix");
        }
Example #7
0
        /// <summary>
        ///     Returns the filter parameters from one of this voice's sends.
        /// </summary>
        /// <param name="destinationVoice">The destination voice of the send whose filter parameters will be read.</param>
        /// <returns><see cref="AudioSharp.XAudio2.FilterParameters" /> structure containing the filter information.</returns>
        public FilterParameters GetOutputFilterParameters(XAudio2Voice destinationVoice)
        {
            FilterParameters value;

            XAudio2Exception.Try(GetOutputFilterParametersNative(destinationVoice, out value), InterfaceName,
                                 "GetOutputFilterParameters");
            return(value);
        }
Example #8
0
        private static unsafe IntPtr CreateXAudio2Instance(XAudio2Processor processor)
        {
            IntPtr ptr    = IntPtr.Zero;
            var    pptr   = new IntPtr(&ptr);
            int    result = NativeMethods.XAudio2Create(pptr, 0, processor);

            XAudio2Exception.Try(result, "Interop", "XAudio2Create");
            return(ptr);
        }
Example #9
0
        /// <summary>
        ///     Sets parameters for a given effect in the voice's effect chain.
        /// </summary>
        /// <typeparam name="T">Effect parameter.</typeparam>
        /// <param name="effectIndex">Zero-based index of an effect within the voice's effect chain.</param>
        /// <param name="effectParameters">New values of the effect-specific parameters.</param>
        /// <param name="operationSet">
        ///     Identifies this call as part of a deferred batch. For more information see
        ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
        /// </param>
        public unsafe void SetEffectParameters <T>(int effectIndex, T effectParameters, int operationSet)
            where T : struct
        {
            int   parameterSize = Utils.ILUtils.SizeOf <T>();
            void *ptr           = stackalloc byte[parameterSize];

            Utils.ILUtils.WriteToMemory(new IntPtr(ptr), ref effectParameters);
            XAudio2Exception.Try(SetEffectParametersNative(effectIndex, new IntPtr(ptr), parameterSize, operationSet),
                                 InterfaceName, "SetEffectParameters");
        }
Example #10
0
        /// <summary>
        ///     Returns the current effect-specific parameters of a given effect in the voice's effect chain.
        /// </summary>
        /// <typeparam name="T">Effect parameters.</typeparam>
        /// <param name="effectIndex">Zero-based index of an effect within the voice's effect chain.</param>
        /// <returns>Effect parameters value.</returns>
        public unsafe T GetEffectParameters <T>(int effectIndex) where T : struct
        {
            int   parameterSize = Utils.ILUtils.SizeOf <T>();
            void *ptr           = stackalloc byte[parameterSize];

            XAudio2Exception.Try(GetEffectParametersNative(effectIndex, (IntPtr)ptr, parameterSize),
                                 InterfaceName, "GetEffectParameters");

            return(Utils.ILUtils.Read <T>((IntPtr)ptr));
        }
Example #11
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);
        }
Example #12
0
        /// <summary>
        ///     Creates and configures a submix voice.
        /// </summary>
        /// <param name="inputChannels">
        ///     Number of channels in the input audio data of the submix voice. The
        ///     <paramref name="inputChannels" /> must be less than or equal to <see cref="MaxAudioChannels" />.
        /// </param>
        /// <param name="inputSampleRate">
        ///     Sample rate of the input audio data of submix voice. This rate must be a multiple of
        ///     <see cref="QuantumDenominator" />. InputSampleRate must be between <see cref="MinimumSampleRate" /> and
        ///     <see cref="MaximumSampleRate" />.
        /// </param>
        /// <param name="flags">
        ///     Flags that specify the behavior of the submix voice. It can be <see cref="VoiceFlags.None" /> or
        ///     <see cref="VoiceFlags.UseFilter" />.
        /// </param>
        /// <param name="processingStage">
        ///     An arbitrary number that specifies when this voice is processed with respect to other
        ///     submix voices, if the XAudio2 engine is running other submix voices. The voice is processed after all other voices
        ///     that include a smaller <paramref name="processingStage" /> value and before all other voices that include a larger
        ///     <paramref name="processingStage" /> value. Voices that include the same <paramref name="processingStage" /> value
        ///     are
        ///     processed in any order. A submix voice cannot send to another submix voice with a lower or equal
        ///     <paramref name="processingStage" /> value. This prevents audio being lost due to a submix cycle.
        /// </param>
        /// <param name="sendList">
        ///     List of <see cref="VoiceSends" /> structures that describe the set of destination voices for the
        ///     submix voice. If <paramref name="sendList" /> is NULL, the send list will default to a single output to the first
        ///     mastering voice created.
        /// </param>
        /// <param name="effectChain">
        ///     List of <see cref="EffectChain" /> structures that describe an effect chain to use in the
        ///     submix voice. This parameter is optional and can be null.
        /// </param>
        /// <returns>On success, returns a pointer to the new <see cref="XAudio2SubmixVoice" /> object.</returns>
        public IntPtr CreateSubmixVoicePtr(int inputChannels, int inputSampleRate, VoiceFlags flags,
                                           int processingStage, VoiceSends?sendList, EffectChain?effectChain)
        {
            IntPtr ptr;
            int    result = CreateSubmixVoiceNative(out ptr, inputChannels, inputSampleRate, flags, processingStage,
                                                    sendList,
                                                    effectChain);

            XAudio2Exception.Try(result, N, "CreateSubmixVoiceNative");
            return(ptr);
        }
Example #13
0
        /// <summary>
        ///     Returns the volume levels for the voice, per channel.
        ///     These settings are applied after the effect chain is applied.
        ///     This method is valid only for source and submix voices, because mastering voices do not specify volume per channel.
        /// </summary>
        /// <param name="channelCount">Confirms the channel count of the voice.</param>
        /// <returns>
        ///     Returns the current volume level of each channel in the voice. The has at least <paramref name="channelCount" />
        ///     elements.
        /// </returns>
        /// <remarks>
        ///     The master volume level is applied at different times depending on the type of voice.
        ///     For submix and mastering voices the volume level is applied just before the voice's built in filter and effect
        ///     chain is applied.
        ///     For source voices the master volume level is applied after the voice's filter and effect
        ///     chain is applied. Volume levels are expressed as floating-point amplitude multipliers
        ///     between -2^24 and 2^24, with a maximum
        ///     gain of 144.5 dB. A volume level of 1.0 means there is no attenuation or gain and 0 means silence.
        ///     Negative levels can be used to invert the audio's phase.
        /// </remarks>
        public float[] GetChannelVolumes(int channelCount)
        {
            if (channelCount <= 0)
            {
                throw new ArgumentOutOfRangeException("channelCount");
            }
            var volumes = new float[channelCount];

            XAudio2Exception.Try(GetChannelVolumesNative(channelCount, volumes), InterfaceName, "GetChannelVolumes");
            return(volumes);
        }
Example #14
0
 /// <summary>
 ///     Sets the volume levels for the voice, per channel. This method is valid only for source and submix voices, because
 ///     mastering voices do not specify volume per channel.
 /// </summary>
 /// <param name="channelCount">Number of channels in the voice.</param>
 /// <param name="volumes">
 ///     Array containing the new volumes of each channel in the voice. The array must have
 ///     <paramref name="channelCount" /> elements. See Remarks for more information on volume levels.
 /// </param>
 /// <param name="operationSet">
 ///     Identifies this call as part of a deferred batch. For more information see
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
 /// </param>
 /// <remarks>
 ///     The master volume level is applied at different times depending on the type of voice.
 ///     For submix and mastering voices the volume level is applied just before the voice's built in filter and effect
 ///     chain is applied.
 ///     For source voices the master volume level is applied after the voice's filter and effect
 ///     chain is applied. Volume levels are expressed as floating-point amplitude multipliers
 ///     between -2^24 and 2^24, with a maximum
 ///     gain of 144.5 dB. A volume level of 1.0 means there is no attenuation or gain and 0 means silence.
 ///     Negative levels can be used to invert the audio's phase.
 /// </remarks>
 public void SetChannelVolumes(int channelCount, float[] volumes, int operationSet)
 {
     if (volumes == null)
     {
         throw new ArgumentNullException("volumes");
     }
     if (volumes.Length != channelCount)
     {
         throw new ArgumentException(
                   "The length of the volumes argument has to be equal to the channelCount argument.");
     }
     XAudio2Exception.Try(SetChannelVolumesNative(volumes.Length, volumes, operationSet), InterfaceName, "SetChannelVolumes");
 }
Example #15
0
        /// <summary>
        ///     Designates a new set of submix or mastering voices to receive the output of the voice.
        /// </summary>
        /// <param name="voiceSendDescriptors">
        ///     Array of <see cref="VoiceSendDescriptor" />s. if <paramref name="voiceSendDescriptors" /> is null, the voice will send
        ///     its output to the current mastering voice.
        ///     All voices in the <paramref name="voiceSendDescriptors" /> must have the same input sample rate.
        /// </param>
        public unsafe void SetOutputVoices(VoiceSendDescriptor[] voiceSendDescriptors)
        {
            if (voiceSendDescriptors == null)
            {
                XAudio2Exception.Try(SetOutputVoicesNative(null), InterfaceName, "SetOutputVoices");
            }
            else
            {
                fixed(void *ptr = &voiceSendDescriptors[0])
                {
                    var p = new VoiceSends
                    {
                        SendCount = voiceSendDescriptors.Length,
                        SendsPtr  = new IntPtr(ptr)
                    };

                    XAudio2Exception.Try(SetOutputVoicesNative(p), InterfaceName, "SetOutputVoices");
                }
            }
        }
Example #16
0
 /// <summary>
 ///     Starts the audio processing thread.
 /// </summary>
 public void StartEngine()
 {
     XAudio2Exception.Try(StartEngineNative(), N, "StartEngine");
 }
Example #17
0
 /// <summary>
 ///     Notifies an XAudio2 voice that no more buffers are coming after the last one that is currently in its queue.
 /// </summary>
 public void Discontinuity()
 {
     XAudio2Exception.Try(DiscontinuityNative(), N, "Discontinuity");
 }
Example #18
0
 /// <summary>
 ///     Sets the overall volume level for the voice.
 /// </summary>
 /// <param name="volume">Overall volume level to use. See Remarks for more information on volume levels.</param>
 /// <param name="operationSet">
 ///     Identifies this call as part of a deferred batch. For more information see
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
 /// </param>
 /// <remarks>
 ///     The master volume level is applied at different times depending on the type of voice.
 ///     For submix and mastering voices the volume level is applied just before the voice's built in filter and effect
 ///     chain is applied.
 ///     For source voices the master volume level is applied after the voice's filter and effect
 ///     chain is applied. Volume levels are expressed as floating-point amplitude multipliers
 ///     between -2^24 and 2^24, with a maximum
 ///     gain of 144.5 dB. A volume level of 1.0 means there is no attenuation or gain and 0 means silence.
 ///     Negative levels can be used to invert the audio's phase.
 /// </remarks>
 public void SetVolume(float volume, int operationSet)
 {
     XAudio2Exception.Try(SetVolumeNative(volume, operationSet), InterfaceName, "SetVolume");
 }
Example #19
0
 /// <summary>
 ///     Stops looping the voice when it reaches the end of the current loop region.
 /// </summary>
 /// <param name="operationSet">
 ///     Identifies this call as part of a deferred batch. For more details see
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
 /// </param>
 public void ExitLoop(int operationSet)
 {
     XAudio2Exception.Try(ExitLoopNative(operationSet), N, "ExitLoop");
 }
Example #20
0
 /// <summary>
 ///     Sets the filter parameters on one of this voice's sends.
 /// </summary>
 /// <param name="destinationVoice">The destination voice of the send whose filter parameters will be set.</param>
 /// <param name="filterParameters">
 ///     <see cref="AudioSharp.XAudio2.FilterParameters" /> structure containing the filter
 ///     information.
 /// </param>
 /// <param name="operationSet">
 ///     Identifies this call as part of a deferred batch. For more information see
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
 /// </param>
 public void SetOutputFilterParameters(XAudio2Voice destinationVoice, FilterParameters filterParameters,
                                       int operationSet)
 {
     XAudio2Exception.Try(SetOutputFilterParametersNative(destinationVoice, filterParameters, operationSet), InterfaceName,
                          "SetOutputFilterParameters");
 }
Example #21
0
 /// <summary>
 ///     Sets the frequency adjustment ratio of the voice.
 /// </summary>
 /// <param name="ratio">
 ///     Frequency adjustment ratio. This value must be between <see cref="XAudio2.MinFrequencyRatio" /> and
 ///     the MaxFrequencyRatio parameter specified when the voice was created
 ///     <see
 ///         cref="XAudio2.CreateSourceVoice(AudioSharp.WaveFormat,AudioSharp.XAudio2.VoiceFlags,float,AudioSharp.XAudio2.IXAudio2VoiceCallback,System.Nullable{AudioSharp.XAudio2.VoiceSends},System.Nullable{AudioSharp.XAudio2.EffectChain})" />
 ///     .
 /// </param>
 /// <param name="operationSet">
 ///     Identifies this call as part of a deferred batch. For more details see
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
 /// </param>
 public void SetFrequencyRatio(float ratio, int operationSet)
 {
     XAudio2Exception.Try(SetFrequencyRatioNative(ratio, operationSet), N, "SetFrequencyRatio");
 }
Example #22
0
 /// <summary>
 ///     Sets the voice's filter parameters.
 /// </summary>
 /// <param name="filterParameters">
 ///     <see cref="AudioSharp.XAudio2.FilterParameters" /> structure containing the filter
 ///     information.
 /// </param>
 /// <param name="operationSet">
 ///     Identifies this call as part of a deferred batch. For more information see
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
 /// </param>
 public void SetFilterParameters(FilterParameters filterParameters, int operationSet)
 {
     XAudio2Exception.Try(SetFilterParametersNative(filterParameters, operationSet), InterfaceName, "SetFilterParameters");
 }
Example #23
0
 /// <summary>
 ///     Reconfigures the voice to consume source data at a different sample rate than the rate specified when the voice was
 ///     created.
 /// </summary>
 /// <param name="newSourceSampleRate">
 ///     The new sample rate the voice should process submitted data at. Valid sample rates
 ///     are 1kHz to 200kHz.
 /// </param>
 public void SetSourceSampleRate(int newSourceSampleRate)
 {
     XAudio2Exception.Try(SetSourceSampleRateNative(newSourceSampleRate), N, "SetSourceSampleRate");
 }
Example #24
0
 /// <summary>
 ///     Starts consumption and processing of audio by the voice. Delivers the result to any connected submix or mastering
 ///     voices, or to the output device.
 /// </summary>
 /// <param name="flags">Flags that control how the voice is started. Must be 0.</param>
 /// <param name="operationSet">
 ///     Identifies this call as part of a deferred batch. For more details see
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
 /// </param>
 public void Start(int flags, int operationSet)
 {
     XAudio2Exception.Try(StartNative(flags, operationSet), N, "Start");
 }
Example #25
0
 /// <summary>
 ///     Disables the effect at a given position in the effect chain of the voice.
 /// </summary>
 /// <param name="effectIndex">Zero-based index of an effect in the effect chain of the voice.</param>
 /// <param name="operationSet">
 ///     Identifies this call as part of a deferred batch. For more information see
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/ee415807(v=vs.85).aspx.
 /// </param>
 public void DisableEffect(int effectIndex, int operationSet)
 {
     XAudio2Exception.Try(DisableEffectNative(effectIndex, operationSet), InterfaceName, "DisableEffect");
 }
Example #26
0
 /// <summary>
 ///     Sets XAudio2 parameters and prepares XAudio2 for use.
 /// </summary>
 /// <param name="flags">Flags that specify the behavior of the XAudio2 object. This value must be 0.</param>
 /// <param name="processor">
 ///     Specifies which CPU to use. Use <see cref="XAudio2Processor.XAudio27DefaultProcessor" /> as default value.
 /// </param>
 public void Initialize(int flags, XAudio2Processor processor)
 {
     XAudio2Exception.Try(InitializeNative(flags, processor), N, "Initialize");
 }
Example #27
0
 /// <summary>
 ///     Removes all pending audio buffers from the voice queue. If the voice is started, the buffer that is currently
 ///     playing is not removed from the queue.
 /// </summary>
 /// <remarks>
 ///     See
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.ixaudio2sourcevoice.ixaudio2sourcevoice.flushsourcebuffers(v=vs.85).aspx.
 /// </remarks>
 public void FlushSourceBuffers()
 {
     XAudio2Exception.Try(FlushSourceBuffersNative(), N, "FlushSourceBuffers");
 }
Example #28
0
 /// <summary>
 ///     Adds an <see cref="IXAudio2EngineCallback" /> from the <see cref="XAudio2" /> engine callback list.
 /// </summary>
 /// <param name="callback">
 ///     <see cref="IXAudio2EngineCallback" /> object to add to the <see cref="XAudio2" /> engine
 ///     callback list.
 /// </param>
 public void RegisterForCallbacks(IXAudio2EngineCallback callback)
 {
     XAudio2Exception.Try(RegisterForCallbacksNative(callback), N, "RegisterForCallbacks");
 }
Example #29
0
 /// <summary>
 ///     Atomically applies a set of operations that are tagged with a given identifier.
 /// </summary>
 /// <param name="operationSet">
 ///     Identifier of the set of operations to be applied. To commit all pending operations, pass
 ///     <see cref="CommitAll" />.
 /// </param>
 public void CommitChanges(int operationSet)
 {
     XAudio2Exception.Try(CommitChangesNative(operationSet), N, "CommitChanges");
 }
Example #30
0
 /// <summary>
 ///     Adds a new audio buffer to the voice queue.
 /// </summary>
 /// <param name="buffer"><see cref="XAudio2Buffer" /> structure to queue.</param>
 /// <remarks>
 ///     See
 ///     http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.ixaudio2sourcevoice.ixaudio2sourcevoice.submitsourcebuffer(v=vs.85).aspx.
 /// </remarks>
 public unsafe void SubmitSourceBuffer(XAudio2Buffer buffer)
 {
     XAudio2Exception.Try(SubmitSourceBufferNative(new IntPtr(&buffer), IntPtr.Zero), N, "SubmitSourceBuffer");
 }