本文整理汇总了C#中SharpDX.XAudio2.XAudio2.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# XAudio2.Dispose方法的具体用法?C# XAudio2.Dispose怎么用?C# XAudio2.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpDX.XAudio2.XAudio2
的用法示例。
在下文中一共展示了XAudio2.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
/// <summary>
/// SharpDX XAudio2 sample. Plays wav/xwma/adpcm files from the disk.
/// </summary>
static void Main(string[] args)
{
var xaudio2 = new XAudio2();
var masteringVoice = new MasteringVoice(xaudio2);
PLaySoundFile(xaudio2, "1) Playing a standard WAV file", "ergon.wav");
PLaySoundFile(xaudio2, "2) Playing a XWMA file", "ergon.xwma");
PLaySoundFile(xaudio2, "3) Playing an ADPCM file", "ergon.adpcm.wav");
masteringVoice.Dispose();
xaudio2.Dispose();
}
示例2: Main
public static void Main(string[] args)
{
xaudio2 = new XAudio2();
xaudio2.StartEngine();
var masteringVoice = new MasteringVoice(xaudio2);
if (!string.IsNullOrEmpty(Properties.Settings.Default.BackgroundMusicPath) &&
Directory.Exists(Properties.Settings.Default.BackgroundMusicPath))
{
var musicFiles = Directory.GetFiles(Properties.Settings.Default.BackgroundMusicPath, "*.wav");
if(musicFiles.Length > 0)
backgroundPlayer = new TrackPlayer(xaudio2, musicFiles);
}
var listener = new UdpClient(10009);
listener.BeginReceive(new AsyncCallback(ReceiveCallback), listener);
effectManager = new EffectManager(xaudio2, 4, Properties.Settings.Default.FXPath);
// Wait until its done
int count = 1;
while (true)
{
Thread.Sleep(10);
if (Console.KeyAvailable)
{
var key = Console.ReadKey();
if (key.Key == ConsoleKey.Escape)
break;
switch (key.Key)
{
case ConsoleKey.A:
effectManager.Play("Scream.wav");
break;
case ConsoleKey.B:
effectManager.Play("Violin screech.wav");
break;
case ConsoleKey.N:
if(backgroundPlayer != null)
backgroundPlayer.NextTrack();
break;
case ConsoleKey.V:
if (key.Modifiers.HasFlag(ConsoleModifiers.Shift))
backgroundVolume -= 0.1f;
else
backgroundVolume += 0.1f;
if (backgroundVolume < 0f)
backgroundVolume = 0f;
if (backgroundVolume > 1f)
backgroundVolume = 1f;
break;
}
}
var muteMusic = effectManager.AreAnyPlaying && autoMuteBackground ? 0.2f : 0f;
if (backgroundPlayer != null)
backgroundPlayer.Volume = backgroundVolume - muteMusic;
if (count % 50 == 0)
{
Console.Write(".");
Console.Out.Flush();
}
Thread.Sleep(10);
count++;
}
listener.Close();
if (backgroundPlayer != null)
backgroundPlayer.Stop();
if (trackPlayer != null)
trackPlayer.Stop();
effectManager.Dispose();
Thread.Sleep(500);
masteringVoice.Dispose();
xaudio2.StopEngine();
xaudio2.Dispose();
}
示例3: SoundEffect
static SoundEffect()
{
var flags = XAudio2Flags.None;
#if !WINRT && DEBUG
flags |= XAudio2Flags.DebugEngine;
#endif
try
{
// This cannot fail.
Device = new XAudio2(flags, ProcessorSpecifier.DefaultProcessor);
Device.StartEngine();
// Just use the default device.
#if WINRT
string deviceId = null;
#else
const int deviceId = 0;
#endif
// Let windows autodetect number of channels and sample rate.
MasterVoice = new MasteringVoice(Device, XAudio2.DefaultChannels, XAudio2.DefaultSampleRate, deviceId);
MasterVoice.SetVolume(_masterVolume, 0);
// The autodetected value of MasterVoice.ChannelMask corresponds to the speaker layout.
#if WINRT
Speakers = (Speakers)MasterVoice.ChannelMask;
#else
var deviceDetails = Device.GetDeviceDetails(deviceId);
Speakers = deviceDetails.OutputFormat.ChannelMask;
#endif
}
catch
{
// Release the device and null it as
// we have no audio support.
if (Device != null)
{
Device.Dispose();
Device = null;
}
MasterVoice = null;
}
}
示例4: SoundEffect
static SoundEffect()
{
// This cannot fail.
Device = new XAudio2();
try
{
Device.StartEngine();
// Let windows autodetect number of channels and sample rate.
MasterVoice = new MasteringVoice(Device, XAudio2.DefaultChannels, XAudio2.DefaultSampleRate);
MasterVoice.SetVolume(_masterVolume, 0);
// The autodetected value of MasterVoice.ChannelMask corresponds to the speaker layout.
Speakers = (Speakers)MasterVoice.ChannelMask;
}
catch
{
// Release the device and null it as
// we have no audio support.
Device.Dispose();
Device = null;
MasterVoice = null;
}
}