本文整理汇总了C#中Microsoft.Xna.Framework.Audio.AudioEngine类的典型用法代码示例。如果您正苦于以下问题:C# AudioEngine类的具体用法?C# AudioEngine怎么用?C# AudioEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AudioEngine类属于Microsoft.Xna.Framework.Audio命名空间,在下文中一共展示了AudioEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AudioManager
private AudioManager(Microsoft.Xna.Framework.Game game, string settingsFile, string waveBankFile, string soundBankFile)
: base(game)
{
this.SoundEffectInstances = new List<SoundEffectInstance>();
try
{
this.audioEngine = new AudioEngine(settingsFile);
this.waveBank = new WaveBank(this.audioEngine, waveBankFile, 0, 16);
this.soundBank = new SoundBank(this.audioEngine, soundBankFile);
}
catch (NoAudioHardwareException)
{
this.audioEngine = null;
this.waveBank = null;
this.soundBank = null;
}
catch (InvalidOperationException)
{
this.audioEngine = null;
this.waveBank = null;
this.soundBank = null;
}
while (!this.waveBank.IsPrepared)
{
this.audioEngine.Update();
}
}
示例2: GameRoot
public GameRoot()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Instance = this;
//http://msdn.microsoft.com/en-us/library/dd231915%28v=xnagamestudio.31%29.aspx nores on how to load audio engine. had to add xact.dll reference located in programfiles/microsoftxna/.../win/xact.dll
//http://xboxforums.create.msdn.com/forums/p/102228/608489.aspx how to find other audio devices.
// Initialize audio objects.
engine = new AudioEngine(@"Content\Audio\Xact.xgs",TimeSpan.Zero,"{0.0.0.00000000}.{a26fe1c0-9b55-4670-a6fd-76d91685f704}");
soundBank = new SoundBank(engine, @"Content\Audio\Sound Bank.xsb");
waveBank = new WaveBank(engine, @"Content\Audio\Wave Bank.xwb");
//Console.WriteLine("SOUND ENGINE: " + engine.RendererDetails.ToString()); used to determine the redndererID
//foreach (var r in engine.RendererDetails)
//{
// Console.WriteLine(r.FriendlyName +","+ r.RendererId);
//}
graphics.PreferredBackBufferWidth = 1680;//(int)DisplaySize.X-150;
graphics.PreferredBackBufferHeight = 1050;//(int)DisplaySize.Y -350;
bloom = new BloomComponent(this);
Components.Add(bloom);
bloom.Settings = new BloomSettings(null, .25f, 4, 2, 1, 1.5f, 1);
IsFixedTimeStep = true;
//TargetElapsedTime = TimeSpan.FromSeconds(1.0 / 120);
}
示例3: Load
public override void Load()
{
try
{
m_AudioEngine = new AudioEngine(m_RootDirectory + "sounds.xgs");
if (m_AudioEngine != null)
{
m_WaveBank = new WaveBank(m_AudioEngine, (m_RootDirectory + "Wave Bank.xwb"));
m_SoundBank = new SoundBank(m_AudioEngine, (m_RootDirectory + "Sound Bank.xsb"));
// Get sound categories
AudioCategory soundCategory = m_AudioEngine.GetCategory("Sounds");
AudioCategory musicCategory = m_AudioEngine.GetCategory("Music");
// Set into the custom categories
m_SoundCategory = new CustomAudioCategory(soundCategory);
m_MusicCategory = new CustomAudioCategory(musicCategory);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
示例4: AudioManager
public AudioManager(AudioEngine e, WaveBank wb, SoundBank sb)
{
Engine = e;
WaveBank = wb;
SoundBank = sb;
singleton = this;
}
示例5: NunChuckEnemy
public NunChuckEnemy(Random rand, AudioEngine engine, SoundBank soundBank, WaveBank waveBank)
{
this.engine = engine;
this.soundBank = soundBank;
this.waveBank = waveBank;
int side = rand.Next(5);
if (side == 1)
{
position = new Vector2(rand.Next(GraphicsViewport.Width), 0f);
}
if (side == 2)
{
position = new Vector2(0f, rand.Next(GraphicsViewport.Height));
}
if (side == 3)
{
position = new Vector2(rand.Next(GraphicsViewport.Width), GraphicsViewport.Height);
}
if (side == 4)
{
position = new Vector2(GraphicsViewport.Width, rand.Next(GraphicsViewport.Height));
}
origin = new Vector2(0f, 0f);
rotation = 0;
velocity = 10;
boxSize = 25;
tint = new Color(255, 255, 255, 255);
collided = false;
fired = false;
}
示例6: WaveBank
public WaveBank(
AudioEngine audioEngine,
string streamingWaveBankFilename,
int offset,
short packetsize
)
{
/* Note that offset and packetsize go unused,
* because we're frauds and aren't actually streaming.
* -flibit
*/
if (audioEngine == null)
{
throw new ArgumentNullException("audioEngine");
}
if (String.IsNullOrEmpty(streamingWaveBankFilename))
{
throw new ArgumentNullException("streamingWaveBankFilename");
}
INTERNAL_waveBankReader = new BinaryReader(
TitleContainer.OpenStream(streamingWaveBankFilename)
);
LoadWaveBank(audioEngine, INTERNAL_waveBankReader, true);
}
示例7: World
/// <summary>
/// Create an empty world.
/// </summary>
/// <param name="parentScreen">The screen this world will be updated in.</param>
public World(Screen parentScreen, Player player)
: base(parentScreen)
{
this.worldObjects = new List<WorldObject>();
this.player = player;
ParentScreen.Components.Add(player);
this.interactiveLayers = new Dictionary<int, TileMapLayer>();
this.parallaxLayers = new Dictionary<int, TileMapLayer>();
batchService = (ISpriteBatchService)this.Game.Services.GetService(typeof(ISpriteBatchService));
otherMaps = new List<TileMap>();
//Set up Sound systems
audioEngine = new AudioEngine("Content\\System\\Sounds\\Win\\SoundFX.xgs");
soundBank = new SoundBank(audioEngine, "Content\\System\\Sounds\\Win\\GameSoundBank.xsb");
waveBank = new WaveBank(audioEngine, "Content\\System\\Sounds\\Win\\GameWavs.xwb");
// Set up our collision systems:
spriteCollisionManager = new SpriteSpriteCollisionManager(this.Game, batchService, 40, 40);
ParentScreen.Components.Add(spriteCollisionManager);
bgm = this.Game.Content.Load<Song>("System\\Music\\DesertBGM");
MediaPlayer.IsRepeating = true;
MediaPlayer.Play(bgm);
LoadCtorInfos();
}
示例8: FieldPong
public FieldPong()
{
graphics = new GraphicsDeviceManager(this);
content = new ContentManager(Services);
graphics.PreferredBackBufferWidth = 1024;
graphics.PreferredBackBufferHeight = 768;
graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0;
graphics.SynchronizeWithVerticalRetrace = true;
physicsSimulator = new PhysicsSimulator(new Vector2(0));
physicsSimulator.AllowedPenetration = 0.3f;
physicsSimulator.BiasFactor = 1.0f;
Services.AddService(typeof(PhysicsSimulator), physicsSimulator);
screenManager = new ScreenManager(this);
Components.Add(screenManager);
bloomProcessor = new BloomPostProcessor(this);
Components.Add(bloomProcessor);
// Uncomment this to monitor the FPS:
//fpsCounter = new FrameRateCounter(this);
//Components.Add(fpsCounter);
audioEngine = new AudioEngine("Content\\Audio\\FieldPongAudio.xgs");
waveBank = new WaveBank(audioEngine, "Content\\Audio\\Wave Bank.xwb");
soundBank = new SoundBank(audioEngine, "Content\\Audio\\Sound Bank.xsb");
backgroundMusic = soundBank.GetCue("GameSong0010 16 Bit");
backgroundMusic.Play();
}
示例9: SoundBank
public SoundBank(AudioEngine audioEngine, string filename)
{
audioengine = audioEngine;
// Check for windows-style directory separator character
filename = filename.Replace('\\',Path.DirectorySeparatorChar);
BinaryReader soundbankreader = new BinaryReader(new FileStream(filename, FileMode.Open));
//byte[] identifier = soundbankreader.ReadBytes(4);
soundbankreader.BaseStream.Seek(30, SeekOrigin.Begin);
int cuelength = soundbankreader.ReadInt32();
soundbankreader.BaseStream.Seek(42, SeekOrigin.Begin);
int cueoffset = soundbankreader.ReadInt32();
soundbankreader.BaseStream.Seek(74, SeekOrigin.Begin);
name = System.Text.Encoding.UTF8.GetString(soundbankreader.ReadBytes(64)).Replace("\0","");
targetname = System.Text.Encoding.UTF8.GetString(soundbankreader.ReadBytes(64)).Replace("\0", "");
soundbankreader.BaseStream.Seek(cueoffset, SeekOrigin.Begin);
cues = System.Text.Encoding.UTF8.GetString(soundbankreader.ReadBytes(cuelength)).Split('\0');
}
示例10: GameplayScreen
public GameplayScreen(GraphicsDevice g, byte _gameType)
{
audioEngine = new AudioEngine(@"Content\Audio\Sounds.xgs");
waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb");
soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb");
BGM = new Cue[9];
graphicsDevice = g;
graphicsDevice.RenderState.DepthBufferEnable = true;
spriteBatch = new SpriteBatch(g);
GameOverScreen = new MessageBoxScreen(" " + Score, false);
CongratulationsScreen = new MessageBoxScreen(" ", false);
PauseMenu = new PauseMenuScreen();
WorldMatrix = Matrix.Identity;
SwitchCue = false; PauseCue = false; GameOverState = false;
tmrVibrate = new TimeSpan();
tmrVibrate = TimeSpan.Zero;
sourceRect = new Rectangle(0, 0, 64, 16);
GameType = _gameType;
currentcue = 0;
if (GameType > 0)
{
timespan = 10;
Randomizer = new Random();
tmrTimer = new TimeSpan();
tmrTimer = TimeSpan.Zero;
}
}
示例11: Sound
/// <summary>
/// Create sound
/// </summary>
static Sound()
{
try
{
string dir = Directories.SoundsDirectory;
audioEngine = new AudioEngine(
Path.Combine(dir, "XnaShooter.xgs"));
waveBank = new WaveBank(audioEngine,
Path.Combine(dir, "Wave Bank.xwb"));
// Dummy wavebank call to get rid of the warning that waveBank is
// never used (well it is used, but only inside of XNA).
if (waveBank != null)
soundBank = new SoundBank(audioEngine,
Path.Combine(dir, "Sound Bank.xsb"));
// Get the music category to change the music volume and stop music
musicCategory = audioEngine.GetCategory("Music");
} // try
catch (Exception ex)
{
// Audio creation crashes in early xna versions, log it and ignore it!
Log.Write("Failed to create sound class: " + ex.ToString());
} // catch
}
示例12: Initialize
public static void Initialize()
{
audioEngine = new AudioEngine("Content/Sounds.xgs");
soundBank = new SoundBank(audioEngine, "Content/Sound Bank.xsb");
waveBank = new WaveBank(audioEngine, "Content/Wave Bank.xwb");
soundsPlaying = new List<Cue>();
}
示例13: cAudio
public cAudio()
{
_instance = this;
_engine = new AudioEngine("Resources/Audio/Portal2DSounds.xgs");
_waveBank = new WaveBank(_engine, "Resources/Audio/Wave Bank.xwb");
_soundBank = new SoundBank(_engine, "Resources/Audio/Sound Bank.xsb");
}
示例14: MoteurAudio
public MoteurAudio()
{
engine = new AudioEngine(@"Content\Sons\Ambiance sonore.xgs");
waveBank = new WaveBank(engine, @"Content\Sons\Wave Bank.xwb");
soundBank = new SoundBank(engine, @"Content\Sons\Sound Bank.xsb");
musiques = new Song[2];
}
示例15: InitializeAudioManager
public static void InitializeAudioManager(ContentManager cm)
{
audioEngine = new AudioEngine("Content//Music//music.xgs");
waveBank = new WaveBank(audioEngine, "Content//Music//Wave Bank.xwb");
soundBank = new SoundBank(audioEngine, "Content//Music//Sound Bank.xsb");
//TODO: initialize SoundEffects
worldShatter = cm.Load<SoundEffect>("SFX/DimensionShatter");
doorClose = cm.Load<SoundEffect>("SFX/DoorClose");
doorOpen = cm.Load<SoundEffect>("SFX/DoorOpen");
portal = cm.Load<SoundEffect>("SFX/EnterPortal");
bridgeBarrier = cm.Load<SoundEffect>("SFX/HitBarrier");
objectDestroyed = cm.Load<SoundEffect>("SFX/ObjectDestroyed");
playerDie = cm.Load<SoundEffect>("SFX/PlayerDie");
playerRevive = cm.Load<SoundEffect>("SFX/PlayerRevive");
portalItem = cm.Load<SoundEffect>("SFX/PortalItemGet");
switchActivate = cm.Load<SoundEffect>("SFX/SwitchActivate");
switchDeactivate = cm.Load<SoundEffect>("SFX/SwitchDeactivate");
bridgeBreaking = cm.Load<SoundEffect>("SFX/ObjectDestroyed"); //Change
playerJump = cm.Load<SoundEffect>("SFX/PlayerJump");
playerLand = cm.Load<SoundEffect>("SFX/PlayerLand");
playerPsyActivate = cm.Load<SoundEffect>("SFX/PsyActivate");
playerPsyDeactivate = cm.Load<SoundEffect>("SFX/PsyDeactivate");
checkpoint = worldShatter; //Change?
signal = bridgeBarrier; //Do -> Change?
pause = cm.Load<SoundEffect>("SFX/pause"); //Change
//menuMove = cm.Load<SoundEffect>("SFX/menuBlip");
menuMove = bridgeBarrier;
//menuSelect = cm.Load<SoundEffect>("SFX/menuSelect");
menuSelect = worldShatter;
}