本文整理汇总了C#中Microsoft.Xna.Framework.Audio.SoundBank类的典型用法代码示例。如果您正苦于以下问题:C# SoundBank类的具体用法?C# SoundBank怎么用?C# SoundBank使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SoundBank类属于Microsoft.Xna.Framework.Audio命名空间,在下文中一共展示了SoundBank类的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: 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;
}
示例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: 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();
}
示例5: bolt
protected int timeTillNextRBolt = 4000; // Electricity bolt ( right )
#endregion Fields
#region Constructors
public FinalBoss(Texture2D textureImage, Texture2D pulseCannonTex, Texture2D boltCannonTex, Texture2D defendersPlatformTex, Texture2D defenderTex, Texture2D pulseTex, Texture2D boltTex, Player player, Rectangle window, ExplosionManager explosionManager, SoundBank soundBank)
: base(textureImage, new Point(1, 1), new Vector2(window.Width / 2f, window.Height + 400), Vector2.Zero, window, explosionManager, soundBank)
{
this.pulseCannonTex = pulseCannonTex;
this.boltCannonTex = boltCannonTex;
this.defendersPlatformTex = defendersPlatformTex;
this.defenderTex = defenderTex;
this.pulseTex = pulseTex;
this.boltTex = boltTex;
this.player = player;
this.explosionDamage = 200f;
this.explosionRadius = 300f;
this.scoreOnDeath = 3000;
this.health = 14000;
this.materialDensity = 10f;
this.rotation = (float)Math.PI;
boltR = new Bolt(boltTex, new Point(1, 4), position - new Vector2(230 + 105 + 10, 15), 60, false, window, explosionManager);
boltL = new Bolt(boltTex, new Point(1, 4), position + new Vector2(230 + 105 + 10, -15), 60, true, window, explosionManager);
this.side = Side.Aliens;
soundBank.PlayCue("FinalBossFlyBy");
}
示例6: WinningScreen
public WinningScreen(Texture2D background, Texture2D buttonTex, SpriteFont font, Color color, Difficulty difficulty,Texture2D control, Player player, bool superShipWasAvailable, bool superShipAvailable, TimeSpan TotalTime, Rectangle window, SoundBank soundBack)
: base(background, WallpaperType.Streched, buttonTex, font, window, soundBack)
{
this.playerTex = player.GetTexture;
this.control = control;
this.AddButton("Play Again", color, new Vector2(buttonTex.Width / 2f + buttonTex.Height / 3f, window.Height - buttonTex.Height / 3f));
this.AddButton("Exit", color, new Vector2(buttonTex.Width * 2f + buttonTex.Height / 3f, window.Height - buttonTex.Height / 3f));
this.AddLabel("Well Done! You have finished the game!", new Vector2(50));
float w = window.Width / 2f-150;
float h = window.Height / 14f;
float t = 100;
this.AddLabel("Bullets fired : " + player.GetBulletsFired,new Vector2(w,h+t));
this.AddLabel(" Accuracy: " + player.GetBulletsAccuracy + "%", new Vector2(w, h * 2 + t));
this.AddLabel("Missiles fired: " + player.GetMissilesFired, new Vector2(w, h * 3 + t));
this.AddLabel(" Accuracy: " + player.GetMissilesAccuracy + "%", new Vector2(w, h * 4 + t));
this.AddLabel("Total Accuracy: " + player.GetTotalAccuracy + "%", new Vector2(w, h * 5 + t));
this.AddLabel("MidKits Used : " + player.GetMidkitsUsed, new Vector2(w, h * 6 + t));
this.AddLabel("Player Score : " + player.GetPlayerScore , new Vector2(w, h * 7 + t));
this.AddLabel("Time played " + TotalTime.Hours +":" + TotalTime.Minutes + ":" + TotalTime.Seconds , new Vector2(w, h * 8 + t));
this.AddAnimation( new Animation(playerTex, new Point(4, 1),new Vector2(100,window.Height/2f),20,true,font,difficulty.ToString(),window));
this.AddAnimation( new Animation(control,new Point(1,3),new Vector2(150,window.Height/2f+100),700,false,font,"",window));
if (superShipAvailable && !superShipWasAvailable)
this.AddLabel("*Congratulations!! You've unlocked a new ship,The ultimate ship.", new Vector2(100, h * 9f + t));
}
示例7: 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);
}
示例8: GridMenu
public GridMenu(int xloc, int yloc, int cols, Texture2D texture, SoundBank soundbank)
{
m_xpos = xloc;
m_ypos = yloc;
m_columns = cols;
m_texture = texture;
m_soundbank = soundbank;
Console.WriteLine("Starting Drawing at [" + xloc + ", " + yloc + "]");
m_x = -1;
m_y = 0;
m_rows = 1;
m_num_items = 0;
m_selected_x = -1;
m_selected_y = -1;
m_list = new List<SelectionItem>();
m_grid = new GridItem[m_rows, m_columns];
for (int i = 0; i < m_columns; i++)
{
m_grid[m_rows-1, i] = new GridItem();
m_grid[m_rows-1, i].m_selectable = false;
}
}
示例9: 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();
}
示例10: AudioManager
public AudioManager(AudioEngine e, WaveBank wb, SoundBank sb)
{
Engine = e;
WaveBank = wb;
SoundBank = sb;
singleton = this;
}
示例11: 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");
}
示例12: 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;
}
}
示例13: 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;
}
示例14: 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
}
示例15: PlaySound
public static void PlaySound(String asset, String cueName)
{
if (!mSounds.ContainsKey(asset))
mSounds[asset] = new SoundBank(AudioCore.Instance.Engine, asset);
mSounds[asset].PlayCue(cueName);
}