Наследование: IDisposable
 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
0
        public PlayWaveEvent(XactClip clip, float timeStamp, float randomOffset, SoundBank soundBank,
                             int[] waveBanks, int[] tracks, byte[] weights, int totalWeights,
                             VariationType variation, Vector2?volumeVar, Vector2?pitchVar, Vector4?filterVar,
                             int loopCount, bool newWaveOnLoop)
            : base(clip, timeStamp, randomOffset)
        {
            _soundBank    = soundBank;
            _waveBanks    = waveBanks;
            _tracks       = tracks;
            _weights      = weights;
            _totalWeights = totalWeights;
            _volumeVar    = volumeVar;
            _pitchVar     = pitchVar;
            _filterVar    = filterVar;
            _wavIndex     = -1;
            _loopIndex    = 0;

            _trackVolume          = 1.0f;
            _trackPitch           = 0;
            _trackFilterFrequency = 0;
            _trackFilterQFactor   = 0;

            _clipVolume    = 1.0f;
            _clipPitch     = 0;
            _clipReverbMix = 0;

            _variation     = variation;
            _loopCount     = loopCount;
            _newWaveOnLoop = newWaveOnLoop;
        }
Пример #3
0
        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
0
 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];
 }
Пример #5
0
        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
0
        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;
        }
Пример #7
0
        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;
        }
Пример #8
0
        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;
            }
        }
Пример #9
0
 public AudioManager(AudioEngine e, WaveBank wb, SoundBank sb)
 {
     Engine = e;
     WaveBank = wb;
     SoundBank = sb;
     singleton = this;
 }
Пример #10
0
        public static void PlaySound(String asset, String cueName)
        {
            if (!mSounds.ContainsKey(asset))
                mSounds[asset] = new SoundBank(AudioCore.Instance.Engine, asset);

            mSounds[asset].PlayCue(cueName);
        }
Пример #11
0
        /// <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
0
        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);
        }
Пример #13
0
        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;
            }
        }
Пример #14
0
 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");
 }
Пример #15
0
        /// <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();
        }
Пример #16
0
 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>();
 }
Пример #17
0
        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));
        }
Пример #18
0
        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();
        }
Пример #19
0
 private SoundEngine()
 {
     return;
     _engine = new AudioEngine("Content\\Sounds\\Sounds.xgs");
     _wavebank = new WaveBank(_engine, "Content\\Sounds\\Wave Bank.xwb");
     _soundbank = new SoundBank(_engine, "Content\\Sounds\\Sound Bank.xsb");
 }
Пример #20
0
 public GameOverScreen(Texture2D buttonTex, SpriteFont font, Color color, Rectangle window, SoundBank soundBack)
     : base(buttonTex, font, window, soundBack)
 {
     this.AddLabel("Game Over!! you've lost the battle!.But it's not too late,wanna try again?", new Vector2(100,window.Height/3f));
     this.AddButton("Try Again",color, new Vector2(window.Width/2f-buttonTex.Width,window.Height/2f+70));
     this.AddButton("Exit",color, new Vector2(window.Width / 2f+30f, window.Height / 2f + 70));
 }
Пример #21
0
 private AudioEngineManager()
 {
     //create and use appropriate XACT objects
     audioEngine = new AudioEngine("Content\\Audio\\datx02.xgs");
     soundBank = new SoundBank(audioEngine, "Content\\Audio\\SoundEffects.xsb");
     waveBank = new WaveBank(audioEngine, "Content\\Audio\\SoundEffectWaves.xwb");
 }
Пример #22
0
        public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset)
        {
            long oldPosition = soundReader.BaseStream.Position;

            soundReader.BaseStream.Seek(soundOffset, SeekOrigin.Begin);

            byte flags = soundReader.ReadByte();

            complexSound = (flags & 1) != 0;

            uint category = soundReader.ReadUInt16();

            soundReader.ReadByte();                 //unkn
            uint volume = soundReader.ReadUInt16(); //maybe pitch?

            soundReader.ReadByte();                 //unkn
            uint entryLength = soundReader.ReadUInt16();

            uint numClips = 0;

            if (complexSound)
            {
                numClips = (uint)soundReader.ReadByte();
            }
            else
            {
                uint trackIndex    = soundReader.ReadUInt16();
                byte waveBankIndex = soundReader.ReadByte();
                wave = soundBank.GetWave(waveBankIndex, trackIndex);
            }

            if ((flags & 0x1E) != 0)
            {
                uint extraDataLen = soundReader.ReadUInt16();
                //TODO: Parse RPC+DSP stuff

                // extraDataLen - 2, we need to account for extraDataLen itself!
                soundReader.BaseStream.Seek(extraDataLen - 2, SeekOrigin.Current);
            }

            if (complexSound)
            {
                soundClips = new XactClip[numClips];
                for (int i = 0; i < numClips; i++)
                {
                    soundReader.ReadByte();                      //unkn
                    uint clipOffset = soundReader.ReadUInt32();
                    soundReader.ReadUInt32();                    //unkn

                    soundClips[i] = new XactClip(soundBank, soundReader, clipOffset);
                }
            }

            var audioCategory = soundBank.AudioEngine.Categories[category];

            audioCategory.AddSound(this);

            soundReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
Пример #23
0
        public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset)
        {
            _soundBank = soundBank;

            var oldPosition = soundReader.BaseStream.Position;

            soundReader.BaseStream.Seek(soundOffset, SeekOrigin.Begin);

            byte flags = soundReader.ReadByte();

            _complexSound = (flags & 1) != 0;

            _categoryID = soundReader.ReadUInt16();
            var volume = XactHelpers.ParseVolumeFromDecibels(soundReader.ReadByte());
            var pitch  = soundReader.ReadInt16() / 1000.0f;

            soundReader.ReadByte();    //unkn
            soundReader.ReadUInt16();  // entryLength

            uint numClips = 0;

            if (_complexSound)
            {
                numClips = (uint)soundReader.ReadByte();
            }
            else
            {
                _trackIndex    = soundReader.ReadUInt16();
                _waveBankIndex = soundReader.ReadByte();
            }

            if ((flags & 0x1E) != 0)
            {
                uint extraDataLen = soundReader.ReadUInt16();
                //TODO: Parse RPC+DSP stuff

                // extraDataLen - 2, we need to account for extraDataLen itself!
                soundReader.BaseStream.Seek(extraDataLen - 2, SeekOrigin.Current);
            }

            if (_complexSound)
            {
                _soundClips = new XactClip[numClips];
                for (int i = 0; i < numClips; i++)
                {
                    soundReader.ReadByte();                      //unkn
                    uint clipOffset = soundReader.ReadUInt32();
                    soundReader.ReadUInt32();                    //unkn

                    _soundClips[i] = new XactClip(soundBank, soundReader, clipOffset);
                }
            }

            var category = soundBank.AudioEngine.Categories[_categoryID];

            category.AddSound(this);

            soundReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
Пример #24
0
 public Audio(Game game)
     : base(game)
 {
     // Load all the audio data
     audioEngine = new AudioEngine(@"Content\Audio\FinalProject.xgs");
     waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb");
     soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb");
 }
Пример #25
0
        public XactSound(SoundBank soundBank, int waveBankIndex, int trackIndex)
        {
            _complexSound = false;

            _soundBank = soundBank;
            _waveBankIndex = waveBankIndex;
            _trackIndex = trackIndex;
        }
Пример #26
0
		public DefenderMusic( SoundBank sounds, AudioEngine engine ) {
			mSounds = sounds;
			mEngine = engine;
			mMusic = sounds.GetCue( "stage_music" );
			mMusicName = mMusic.Name;
			mVolume = 1.0f;
			mMusic.Play();
		}
Пример #27
0
 protected override void LoadGraphicsContent(bool loadAllContent)
 {
     audio = new AudioEngine("Content/Audio/TOBam.xgs");
     waveBank = new WaveBank(audio, "Content/Audio/Wave Bank.xwb");
     soundBank = new SoundBank(audio, "Content/Audio/Sound Bank.xsb");
     TOBamGame.soundBank.PlayCue("required_ttc");
     base.LoadGraphicsContent(loadAllContent);
 }
Пример #28
0
        public override void Initialize()
        {
            engine = new AudioEngine("Content\\audio\\siegeAudio.xgs");
            waveBank = new WaveBank(engine, "Content\\audio\\Wave Bank.xwb");
            soundBank = new SoundBank(engine, "Content\\audio\\Sound Bank.xsb");

            base.Initialize();
        }
Пример #29
0
        public SoundManager()
        {
            audioEngine = new AudioEngine(@"Content/Sounds/GameSounds.xgs");
            waveBank = new WaveBank(audioEngine, @"Content/Sounds/Wave Bank.xwb");
            soundBank = new SoundBank(audioEngine, @"Content/Sounds/Sound Bank.xsb");

            Songs = new Dictionary<string, SoundEffectInstance>();
        }
Пример #30
0
        public XactSound(SoundBank soundBank, int waveBankIndex, int trackIndex)
        {
            _complexSound = false;

            _soundBank     = soundBank;
            _waveBankIndex = waveBankIndex;
            _trackIndex    = trackIndex;
        }
Пример #31
0
 /// <summary>
 /// Constructs the manager for audio playback of all cues.
 /// </summary>
 /// <param name="game">The game that this component will be attached to.</param>
 /// <param name="settingsFile">The filename of the XACT settings file.</param>
 /// <param name="waveBankFile">The filename of the XACT wavebank file.</param>
 /// <param name="soundBankFile">The filename of the XACT soundbank file.</param>
 public AudioManager(Game game, string settingsFile, string waveBankFile,
     string soundBankFile)
     : base(game)
 {
     engine = new AudioEngine(settingsFile);
     waves = new WaveBank(engine, waveBankFile);
     sounds = new SoundBank(engine, soundBankFile);
 }
Пример #32
0
        public AudioEM(Microsoft.Xna.Framework.Game game)
        {
            content = new ContentManager(game.Services, "main");

            audioEngine = new AudioEngine(@"main\audio\soundEngine.xgs");
            musicWaves = new WaveBank(audioEngine, @"main\audio\musicWaves.xwb");
            musicSounds = new SoundBank(audioEngine, @"main\audio\musicSounds.xsb");
        }
Пример #33
0
        public Ship(GameObjType _type, Sprite_Proxy _spriteRef)
        {
            type = _type;
            spriteRef = _spriteRef;

            waveBank = WaveBankManager.WaveBank();
            soundBank = SoundBankManager.SoundBank();
        }
Пример #34
0
        internal Cue(IntPtr cue, string name, SoundBank soundBank)
        {
            handle = cue;
            Name   = name;
            bank   = soundBank;

            selfReference = new WeakReference(this, true);
            bank.engine.RegisterCue(handle, selfReference);
        }
Пример #35
0
        public XactSound(SoundBank soundBank, BinaryReader soundReader)
        {
            _soundBank = soundBank;

            var flags = soundReader.ReadByte();

            _complexSound = (flags & 0x1) != 0;
            var hasRPCs    = (flags & 0x0E) != 0;
            var hasEffects = (flags & 0x10) != 0;

            _categoryID = soundReader.ReadUInt16();
            _volume     = XactHelpers.ParseVolumeFromDecibels(soundReader.ReadByte());
            _pitch      = soundReader.ReadInt16() / 1000.0f;
            var priority = soundReader.ReadByte();

            soundReader.ReadUInt16(); // filter stuff?

            uint numClips = 0;

            if (_complexSound)
            {
                numClips = soundReader.ReadByte();
            }
            else
            {
                _trackIndex    = soundReader.ReadUInt16();
                _waveBankIndex = soundReader.ReadByte();
            }

            if (hasRPCs)
            {
                var current    = soundReader.BaseStream.Position;
                var dataLength = soundReader.ReadUInt16();
                soundReader.BaseStream.Seek(current + dataLength, SeekOrigin.Begin);
            }

            if (hasEffects)
            {
                var current    = soundReader.BaseStream.Position;
                var dataLength = soundReader.ReadUInt16();
                soundReader.BaseStream.Seek(current + dataLength, SeekOrigin.Begin);
            }

            if (_complexSound)
            {
                _soundClips = new XactClip[numClips];
                for (int i = 0; i < numClips; i++)
                {
                    _soundClips[i] = new XactClip(soundBank, soundReader);
                }
            }

            var category = soundBank.AudioEngine.Categories[_categoryID];

            category.AddSound(this);
        }
Пример #36
0
 public PlayWaveEvent(XactClip clip, float timeStamp, float randomOffset, SoundBank soundBank,
                      int[] waveBanks, int[] tracks, VariationType variation, bool isLooped)
     : base(clip, timeStamp, randomOffset)
 {
     _soundBank = soundBank;
     _waveBanks = waveBanks;
     _tracks    = tracks;
     _wavIndex  = 0;
     _volume    = 1.0f;
     _variation = variation;
     _isLooped  = isLooped;
 }
Пример #37
0
        public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset)
        {
            long oldPosition = clipReader.BaseStream.Position;

            clipReader.BaseStream.Seek(clipOffset, SeekOrigin.Begin);

            byte numEvents = clipReader.ReadByte();

            events = new ClipEvent[numEvents];

            for (int i = 0; i < numEvents; i++)
            {
                uint eventInfo = clipReader.ReadUInt32();

                uint eventId = eventInfo & 0x1F;
                switch (eventId)
                {
                case 1:
                    EventPlayWave evnt = new EventPlayWave();


                    clipReader.ReadUInt32();                      //unkn
                    uint trackIndex    = clipReader.ReadUInt16();
                    byte waveBankIndex = clipReader.ReadByte();


                    var loopCount = clipReader.ReadByte();
                    // if loopCount == 255 its an infinite loop
                    // otherwise it loops n times..
                    // unknown
                    clipReader.ReadUInt16();
                    clipReader.ReadUInt16();

                    evnt.wave          = soundBank.GetWave(waveBankIndex, trackIndex);
                    evnt.wave.IsLooped = loopCount == 255;

                    events[i] = evnt;
                    break;

                default:
                    throw new NotSupportedException();
                }

                events[i].clip = this;
            }


            clipReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
Пример #38
0
        public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset)
        {
            long oldPosition = clipReader.BaseStream.Position;

            clipReader.BaseStream.Seek(clipOffset, SeekOrigin.Begin);

            byte numEvents = clipReader.ReadByte();

            events = new ClipEvent[numEvents];

            for (int i = 0; i < numEvents; i++)
            {
                uint eventInfo = clipReader.ReadUInt32();

                uint eventId = eventInfo & 0x1F;
                switch (eventId)
                {
                case 1:
                    EventPlayWave evnt = new EventPlayWave();


                    clipReader.ReadUInt32();                      //unkn
                    uint trackIndex    = clipReader.ReadUInt16();
                    byte waveBankIndex = clipReader.ReadByte();

                    //unkn
                    clipReader.ReadByte();
                    clipReader.ReadUInt16();
                    clipReader.ReadUInt16();

                    evnt.wave = soundBank.GetWave(waveBankIndex, trackIndex);

                    events[i] = evnt;
                    break;

                default:
                    throw new NotImplementedException();
                }

                events[i].clip = this;
            }


            clipReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
Пример #39
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="directoryToXwb"></param>
        /// <param name="pathToWaveBank"></param>
        /// <param name="pathToSoundBank"></param>
        public XACTMusicPack(string directoryToXwb, string pathToWaveBank, string pathToSoundBank)
        {
            this.directory     = directoryToXwb;
            this.WaveBankPath  = pathToWaveBank;
            this.SoundBankPath = pathToSoundBank;
            this.setModDirectoryFromFullDirectory();
            this.songInformation      = new SongSpecifics();
            this.currentCue           = null;
            this.musicPackInformation = MusicPackMetaData.readFromJson(Path.Combine(directoryToXwb, "MusicPackInformation.json"));
            if (this.musicPackInformation == null)
            {
                StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToXwb + ". Blank information will be put in place.", StardewModdingAPI.LogLevel.Warn);
                this.musicPackInformation = new MusicPackMetaData("???", "???", "", "0.0.0", "");
            }

            this.WaveBank  = new WaveBank(Game1.audioEngine, this.WaveBankPath);
            this.SoundBank = new SoundBank(Game1.audioEngine, this.SoundBankPath);
            this.loadMusicFiles();
        }
Пример #40
0
        public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset)
        {
            long position = soundReader.BaseStream.Position;

            soundReader.BaseStream.Seek((long)soundOffset, SeekOrigin.Begin);
            byte num1 = soundReader.ReadByte();

            this.complexSound = ((int)num1 & 1) != 0;
            int  num2 = (int)soundReader.ReadUInt16();
            int  num3 = (int)soundReader.ReadByte();
            int  num4 = (int)soundReader.ReadUInt16();
            int  num5 = (int)soundReader.ReadByte();
            int  num6 = (int)soundReader.ReadUInt16();
            uint num7 = 0U;

            if (this.complexSound)
            {
                num7 = (uint)soundReader.ReadByte();
            }
            else
            {
                uint trackIndex    = (uint)soundReader.ReadUInt16();
                byte waveBankIndex = soundReader.ReadByte();
                this.wave = soundBank.GetWave(waveBankIndex, trackIndex);
            }
            if (((int)num1 & 30) != 0)
            {
                uint num8 = (uint)soundReader.ReadUInt16();
                soundReader.BaseStream.Seek((long)(num8 - 2U), SeekOrigin.Current);
            }
            if (this.complexSound)
            {
                this.soundClips = new XactClip[(IntPtr)num7];
                for (int index = 0; (long)index < (long)num7; ++index)
                {
                    int  num8       = (int)soundReader.ReadByte();
                    uint clipOffset = soundReader.ReadUInt32();
                    int  num9       = (int)soundReader.ReadUInt32();
                    this.soundClips[index] = new XactClip(soundBank, soundReader, clipOffset);
                }
            }
            soundReader.BaseStream.Seek(position, SeekOrigin.Begin);
        }
Пример #41
0
        public XactClip(SoundBank soundBank, BinaryReader clipReader)
        {
            State = SoundState.Stopped;

            var volumeDb = XactHelpers.ParseDecibels(clipReader.ReadByte());

            _defaultVolume = XactHelpers.ParseVolumeFromDecibels(volumeDb);
            var clipOffset = clipReader.ReadUInt32();

            // Unknown!
            clipReader.ReadUInt32();

            var oldPosition = clipReader.BaseStream.Position;

            clipReader.BaseStream.Seek(clipOffset, SeekOrigin.Begin);

            var numEvents = clipReader.ReadByte();

            _events = new ClipEvent[numEvents];

            for (var i = 0; i < numEvents; i++)
            {
                var eventInfo    = clipReader.ReadUInt32();
                var randomOffset = clipReader.ReadUInt16() * 0.001f;

                // TODO: eventInfo still has 11 bits that are unknown!
                var eventId   = eventInfo & 0x1F;
                var timeStamp = ((eventInfo >> 5) & 0xFFFF) * 0.001f;
                var unknown   = eventInfo >> 21;

                switch (eventId)
                {
                case 0:
                    // Stop Event
                    throw new NotImplementedException("Stop event");

                case 1:
                {
                    // Unknown!
                    clipReader.ReadByte();

                    // Event flags
                    var eventFlags       = clipReader.ReadByte();
                    var playRelease      = (eventFlags & 0x01) == 0x01;
                    var panEnabled       = (eventFlags & 0x02) == 0x02;
                    var useCenterSpeaker = (eventFlags & 0x04) == 0x04;

                    int trackIndex    = clipReader.ReadUInt16();
                    int waveBankIndex = clipReader.ReadByte();
                    var loopCount     = clipReader.ReadByte();
                    var panAngle      = clipReader.ReadUInt16() / 100.0f;
                    var panArc        = clipReader.ReadUInt16() / 100.0f;

                    _events[i] = new PlayWaveEvent(
                        this,
                        timeStamp,
                        randomOffset,
                        soundBank,
                        new[] { waveBankIndex },
                        new[] { trackIndex },
                        null,
                        0,
                        VariationType.Ordered,
                        null,
                        null,
                        loopCount,
                        false);

                    break;
                }

                case 3:
                {
                    // Unknown!
                    clipReader.ReadByte();

                    // Event flags
                    var eventFlags       = clipReader.ReadByte();
                    var playRelease      = (eventFlags & 0x01) == 0x01;
                    var panEnabled       = (eventFlags & 0x02) == 0x02;
                    var useCenterSpeaker = (eventFlags & 0x04) == 0x04;

                    var loopCount = clipReader.ReadByte();
                    var panAngle  = clipReader.ReadUInt16() / 100.0f;
                    var panArc    = clipReader.ReadUInt16() / 100.0f;

                    // The number of tracks for the variations.
                    var numTracks = clipReader.ReadUInt16();

                    // Not sure what most of this is.
                    var moreFlags     = clipReader.ReadByte();
                    var newWaveOnLoop = (moreFlags & 0x40) == 0x40;

                    // The variation playlist type seems to be
                    // stored in the bottom 4bits only.
                    var variationType = (VariationType)(moreFlags & 0x0F);

                    // Unknown!
                    clipReader.ReadBytes(5);

                    // Read in the variation playlist.
                    var waveBanks    = new int[numTracks];
                    var tracks       = new int[numTracks];
                    var weights      = new byte[numTracks];
                    var totalWeights = 0;
                    for (var j = 0; j < numTracks; j++)
                    {
                        tracks[j]    = clipReader.ReadUInt16();
                        waveBanks[j] = clipReader.ReadByte();
                        var minWeight = clipReader.ReadByte();
                        var maxWeight = clipReader.ReadByte();
                        weights[j]    = (byte)(maxWeight - minWeight);
                        totalWeights += weights[j];
                    }

                    _events[i] = new PlayWaveEvent(
                        this,
                        timeStamp,
                        randomOffset,
                        soundBank,
                        waveBanks,
                        tracks,
                        weights,
                        totalWeights,
                        variationType,
                        null,
                        null,
                        loopCount,
                        newWaveOnLoop);

                    break;
                }

                case 4:
                {
                    // Unknown!
                    clipReader.ReadByte();

                    // Event flags
                    var eventFlags       = clipReader.ReadByte();
                    var playRelease      = (eventFlags & 0x01) == 0x01;
                    var panEnabled       = (eventFlags & 0x02) == 0x02;
                    var useCenterSpeaker = (eventFlags & 0x04) == 0x04;

                    int trackIndex    = clipReader.ReadUInt16();
                    int waveBankIndex = clipReader.ReadByte();
                    var loopCount     = clipReader.ReadByte();
                    var panAngle      = clipReader.ReadUInt16() / 100.0f;
                    var panArc        = clipReader.ReadUInt16() / 100.0f;

                    // Pitch variation range
                    var minPitch = clipReader.ReadInt16() / 1000.0f;
                    var maxPitch = clipReader.ReadInt16() / 1000.0f;

                    // Volume variation range
                    var minVolume = XactHelpers.ParseVolumeFromDecibels(clipReader.ReadByte());
                    var maxVolume = XactHelpers.ParseVolumeFromDecibels(clipReader.ReadByte());

                    // Filter variation
                    var minFrequency = clipReader.ReadSingle() / 1000.0f;
                    var maxFrequency = clipReader.ReadSingle() / 1000.0f;
                    var minQ         = clipReader.ReadSingle();
                    var maxQ         = clipReader.ReadSingle();

                    // Unknown!
                    clipReader.ReadByte();

                    _events[i] = new PlayWaveEvent(
                        this,
                        timeStamp,
                        randomOffset,
                        soundBank,
                        new[] { waveBankIndex },
                        new[] { trackIndex },
                        null,
                        0,
                        VariationType.Ordered,
                        new Vector2(minVolume, maxVolume - minVolume),
                        new Vector2(minPitch, maxPitch - minPitch),
                        loopCount,
                        false);

                    break;
                }

                case 6:
                {
                    // Unknown!
                    clipReader.ReadByte();

                    // Event flags
                    var eventFlags       = clipReader.ReadByte();
                    var playRelease      = (eventFlags & 0x01) == 0x01;
                    var panEnabled       = (eventFlags & 0x02) == 0x02;
                    var useCenterSpeaker = (eventFlags & 0x04) == 0x04;

                    var loopCount = clipReader.ReadByte();
                    var panAngle  = clipReader.ReadUInt16() / 100.0f;
                    var panArc    = clipReader.ReadUInt16() / 100.0f;

                    // Pitch variation range
                    var minPitch = clipReader.ReadInt16() / 1000.0f;
                    var maxPitch = clipReader.ReadInt16() / 1000.0f;

                    // Volume variation range
                    var minVolume = XactHelpers.ParseVolumeFromDecibels(clipReader.ReadByte());
                    var maxVolume = XactHelpers.ParseVolumeFromDecibels(clipReader.ReadByte());

                    // Filter variation range
                    var minFrequency = clipReader.ReadSingle() / 1000.0f;
                    var maxFrequency = clipReader.ReadSingle() / 1000.0f;
                    var minQ         = clipReader.ReadSingle();
                    var maxQ         = clipReader.ReadSingle();

                    // Unknown!
                    clipReader.ReadByte();

                    // TODO: Still has unknown bits!
                    var variationFlags = clipReader.ReadByte();

                    // Enable pitch variation
                    Vector2?pitchVar = null;
                    if ((variationFlags & 0x10) == 0x10)
                    {
                        pitchVar = new Vector2(minPitch, maxPitch - minPitch);
                    }

                    // Enable volume variation
                    Vector2?volumeVar = null;
                    if ((variationFlags & 0x20) == 0x20)
                    {
                        volumeVar = new Vector2(minVolume, maxVolume - minVolume);
                    }

                    // Enable filter variation
                    Vector4?filterVar = null;
                    if ((variationFlags & 0x40) == 0x40)
                    {
                        filterVar = new Vector4(minFrequency, maxFrequency - minFrequency, minQ, maxQ - minQ);
                    }

                    // The number of tracks for the variations.
                    var numTracks = clipReader.ReadUInt16();

                    // Not sure what most of this is.
                    var moreFlags     = clipReader.ReadByte();
                    var newWaveOnLoop = (moreFlags & 0x40) == 0x40;

                    // The variation playlist type seems to be
                    // stored in the bottom 4bits only.
                    var variationType = (VariationType)(moreFlags & 0x0F);

                    // Unknown!
                    clipReader.ReadBytes(5);

                    // Read in the variation playlist.
                    var waveBanks    = new int[numTracks];
                    var tracks       = new int[numTracks];
                    var weights      = new byte[numTracks];
                    var totalWeights = 0;
                    for (var j = 0; j < numTracks; j++)
                    {
                        tracks[j]    = clipReader.ReadUInt16();
                        waveBanks[j] = clipReader.ReadByte();
                        var minWeight = clipReader.ReadByte();
                        var maxWeight = clipReader.ReadByte();
                        weights[j]    = (byte)(maxWeight - minWeight);
                        totalWeights += weights[j];
                    }

                    _events[i] = new PlayWaveEvent(
                        this,
                        timeStamp,
                        randomOffset,
                        soundBank,
                        waveBanks,
                        tracks,
                        weights,
                        totalWeights,
                        variationType,
                        volumeVar,
                        pitchVar,
                        loopCount,
                        newWaveOnLoop);

                    break;
                }

                case 7:
                    // Pitch Event
                    throw new NotImplementedException("Pitch event");

                case 8:
                {
                    // Unknown!
                    clipReader.ReadBytes(2);

                    // Event flags
                    var eventFlags = clipReader.ReadByte();
                    var isAdd      = (eventFlags & 0x01) == 0x01;

                    // The replacement or additive volume.
                    var decibles = clipReader.ReadSingle() / 100.0f;
                    var volume   = XactHelpers.ParseVolumeFromDecibels(decibles + (isAdd ? volumeDb : 0));

                    // Unknown!
                    clipReader.ReadBytes(9);

                    _events[i] = new VolumeEvent(this,
                                                 timeStamp,
                                                 randomOffset,
                                                 volume);
                    break;
                }

                case 17:
                    // Volume Repeat Event
                    throw new NotImplementedException("Volume repeat event");

                case 9:
                    // Marker Event
                    throw new NotImplementedException("Marker event");

                default:
                    throw new NotSupportedException("Unknown event " + eventId);
                }
            }

            clipReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
Пример #42
0
        public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset)
        {
            long oldPosition = soundReader.BaseStream.Position;

            soundReader.BaseStream.Seek(soundOffset, SeekOrigin.Begin);

            byte flags = soundReader.ReadByte();

            complexSound = (flags & 1) != 0;

            category = soundReader.ReadUInt16();
            uint volume = soundReader.ReadByte();   // FIXME: Maybe wrong?
            uint pitch  = soundReader.ReadUInt16(); // FIXME: Maybe wrong?

            soundReader.ReadByte();                 //unkn
            uint entryLength = soundReader.ReadUInt16();

            uint numClips = 0;

            if (complexSound)
            {
                numClips = (uint)soundReader.ReadByte();
            }
            else
            {
                uint trackIndex    = soundReader.ReadUInt16();
                byte waveBankIndex = soundReader.ReadByte();
                soundClips    = new XactClip[1];
                soundClips[0] = new XactClip(soundBank.GetWave(waveBankIndex, trackIndex));
            }

            if ((flags & 0xE) != 0)                 // RPC Tables
            {
                uint extraDataLen = soundReader.ReadUInt16();

                if ((flags == 0x02) || (flags == 0x03))                   // FIXME: Verify this!

                // The number of RPC presets that affect this sound.
                {
                    uint numRPCPresets = soundReader.ReadByte();

                    rpcEffects = new byte[numRPCPresets];

                    for (uint i = 0; i < numRPCPresets; i++)
                    {
                        byte rpcTable = soundReader.ReadByte();

                        // !!! FIXME: Anyone know how these bytes work? -flibit

                        // System.Console.WriteLine(rpcTable);

                        // !!! HACK: Screw it, I need these working. -flibit

                        // Codename lolno has these RPC entries...
                        // All affect Volume, based on the Distance variable.
                        // 1 1 0 0 0 1 1 0 --- 198 - Attenuation
                        // 1 1 1 1 1 0 0 0 --- 248 - Attenuation_high
                        // 0 0 1 0 0 0 0 1 --- 033 - Attenuation_low
                        if (rpcTable == 198 || rpcTable == 218 || rpcTable == 050)
                        {
                            rpcEffects[i] = 0;
                        }
                        else if (rpcTable == 248 || rpcTable == 001)
                        {
                            rpcEffects[i] = 1;
                        }
                        else if (rpcTable == 033 || rpcTable == 150)
                        {
                            rpcEffects[i] = 2;
                        }
                        else if (rpcTable == 000)
                        {
                            rpcEffects[i] = 3;
                        }
                        else
                        {
                            throw new NotImplementedException("Check the XACT RPC parsing!");
                        }
                    }

                    // Create the variable table
                    for (int i = 0; i < rpcEffects.Length; i++)
                    {
                        rpcVariables.Add(
                            soundBank.audioengine.variables[soundBank.audioengine.rpcCurves[rpcEffects[i]].variable].name,
                            soundBank.audioengine.variables[soundBank.audioengine.rpcCurves[rpcEffects[i]].variable].initValue
                            );
                    }

                    // Seek to the end of this block.
                    soundReader.BaseStream.Seek(extraDataLen - 3 - numRPCPresets, SeekOrigin.Current);
                }
                else
                {
                    // Screw it, just skip the block.
                    soundReader.BaseStream.Seek(extraDataLen - 2, SeekOrigin.Current);
                }
            }

            if ((flags & 0x10) != 0)               // DSP Presets
            {
                uint   extraDataLen = soundReader.ReadUInt16();
                byte   numPresets   = soundReader.ReadByte();
                uint[] presets      = new uint[numPresets];
                for (int i = 0; i < numPresets; i++)
                {
                    presets[i] = soundReader.ReadUInt32();
                }
            }

            if (complexSound)
            {
                soundClips = new XactClip[numClips];
                for (int i = 0; i < numClips; i++)
                {
                    soundReader.ReadByte();                      //unkn
                    uint clipOffset = soundReader.ReadUInt32();
                    soundReader.ReadUInt32();                    //unkn

                    soundClips[i] = new XactClip(soundBank, soundReader, clipOffset);
                }
            }

            // FIXME: This is totally arbitrary. I dunno the exact ratio here.
            staticVolume = volume / 256.0f;
            Volume       = 1.0f;

            soundReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
Пример #43
0
        public XactSound(AudioEngine engine, SoundBank soundBank, BinaryReader soundReader)
        {
            _soundBank = soundBank;

            var flags = soundReader.ReadByte();

            _complexSound = (flags & 0x1) != 0;
            var hasRPCs = (flags & 0x0E) != 0;
            var hasDSPs = (flags & 0x10) != 0;

            _categoryID = soundReader.ReadUInt16();
            _volume     = XactHelpers.ParseVolumeFromDecibels(soundReader.ReadByte());
            _pitch      = soundReader.ReadInt16() / 1000.0f;
            soundReader.ReadByte();   //priority
            soundReader.ReadUInt16(); // filter stuff?

            var numClips = 0;

            if (_complexSound)
            {
                numClips = soundReader.ReadByte();
            }
            else
            {
                _trackIndex    = soundReader.ReadUInt16();
                _waveBankIndex = soundReader.ReadByte();
            }

            if (!hasRPCs)
            {
                RpcCurves = new int[0];
            }
            else
            {
                var current = soundReader.BaseStream.Position;

                // This doesn't seem to be used... might have been there
                // to allow for some future file format expansion.
                var dataLength = soundReader.ReadUInt16();

                var numPresets = soundReader.ReadByte();
                RpcCurves = new int[numPresets];
                for (var i = 0; i < numPresets; i++)
                {
                    RpcCurves[i] = engine.GetRpcIndex(soundReader.ReadUInt32());
                }

                // Just in case seek to the right spot.
                soundReader.BaseStream.Seek(current + dataLength, SeekOrigin.Begin);
            }

            if (!hasDSPs)
            {
                _useReverb = false;
            }
            else
            {
                // The file format for this seems to follow the pattern for
                // the RPC curves above, but in this case XACT only supports
                // a single effect...  Microsoft Reverb... so just set it.
                _useReverb = true;
                soundReader.BaseStream.Seek(7, SeekOrigin.Current);
            }

            if (_complexSound)
            {
                _soundClips = new XactClip[numClips];
                for (int i = 0; i < numClips; i++)
                {
                    _soundClips[i] = new XactClip(soundBank, soundReader, _useReverb);
                }
            }

            var category = engine.Categories[_categoryID];

            category.AddSound(this);
        }
Пример #44
0
        public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset)
        {
            var oldPosition = clipReader.BaseStream.Position;

            clipReader.BaseStream.Seek(clipOffset, SeekOrigin.Begin);

            byte numEvents = clipReader.ReadByte();

            _events = new ClipEvent[numEvents];

            for (int i = 0; i < numEvents; i++)
            {
                var eventInfo    = clipReader.ReadUInt32();
                var randomOffset = clipReader.ReadUInt16() * 0.001f;

                // TODO: eventInfo still has 11 bits that are unknown!
                var eventId   = eventInfo & 0x1F;
                var timeStamp = ((eventInfo >> 5) & 0xFFFF) * 0.001f;
                var unknown   = eventInfo >> 21;

                switch (eventId)
                {
                case 0:
                    // Stop Event
                    throw new NotImplementedException("Stop event");

                case 1:
                {
                    // Unknown!
                    clipReader.ReadUInt16();

                    int trackIndex    = clipReader.ReadUInt16();
                    int waveBankIndex = clipReader.ReadByte();

                    var loopCount = clipReader.ReadByte();
                    // if loopCount == 255 its an infinite loop
                    // otherwise it loops n times..

                    // Unknown!
                    clipReader.ReadUInt16();
                    clipReader.ReadUInt16();

                    _events[i] = new PlayWaveEvent(
                        this,
                        timeStamp,
                        randomOffset,
                        soundBank,
                        new[] { waveBankIndex },
                        new[] { trackIndex },
                        VariationType.Ordered,
                        loopCount == 255);

                    break;
                }

                case 3:
                {
                    // Unknown!
                    clipReader.ReadByte();

                    // Event flags
                    clipReader.ReadByte();

                    // Unknown!
                    clipReader.ReadBytes(5);

                    // The number of tracks for the variations.
                    int numTracks = clipReader.ReadUInt16();

                    // The variation playlist type seems to be
                    // stored in the bottom 4bits only.
                    var variationType = clipReader.ReadUInt16() & 0x000F;

                    // Unknown!
                    clipReader.ReadBytes(4);

                    // Read in the variation playlist.
                    var waveBanks = new int[numTracks];
                    var tracks    = new int[numTracks];
                    var weights   = new byte[numTracks];
                    for (var j = 0; j < numTracks; j++)
                    {
                        tracks[j]    = clipReader.ReadUInt16();
                        waveBanks[j] = clipReader.ReadByte();

                        var minWeight = clipReader.ReadByte();
                        var maxWeight = clipReader.ReadByte();
                        weights[j] = (byte)(maxWeight - minWeight);
                    }

                    _events[i] = new PlayWaveEvent(
                        this,
                        timeStamp,
                        randomOffset,
                        soundBank,
                        waveBanks,
                        tracks,
                        (VariationType)variationType,
                        false);

                    break;
                }

                case 7:
                    // Pitch Event
                    throw new NotImplementedException("Pitch event");

                case 8:
                    // Volume Event
                    throw new NotImplementedException("Volume event");

                case 9:
                    // Marker Event
                    throw new NotImplementedException("Marker event");

                default:
                    throw new NotSupportedException("Unknown event " + eventId);
                }
            }

            clipReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
Пример #45
0
        public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset)
        {
            long oldPosition = clipReader.BaseStream.Position;

            clipReader.BaseStream.Seek(clipOffset, SeekOrigin.Begin);

            byte numEvents = clipReader.ReadByte();

            events = new ClipEvent[numEvents];

            for (int i = 0; i < numEvents; i++)
            {
                uint eventInfo = clipReader.ReadUInt32();

                uint eventId = eventInfo & 0x1F;
                switch (eventId)
                {
                case 0:
                    // FIXME: SetVolumeEventInfo -flibit
                    EventSetVolume volEvnt = new EventSetVolume();
                    events[i] = volEvnt;
                    break;

                case 1:
                case 4:
                    EventPlayWave evnt = new EventPlayWave();


                    clipReader.ReadUInt32();                      //unkn
                    uint trackIndex    = clipReader.ReadUInt16();
                    byte waveBankIndex = clipReader.ReadByte();

                    var loopCount = clipReader.ReadByte();
                    // if loopCount == 255 its an infinite loop
                    // otherwise it loops n times..
                    // unknown
                    clipReader.ReadUInt16();
                    clipReader.ReadUInt16();

                    evnt.wave     = soundBank.GetWave(waveBankIndex, trackIndex);
                    evnt.IsLooped = loopCount == 255;

                    events[i] = evnt;
                    break;

                case 3:
                case 8: // FIXME: lolwuta
                    // FIXME: WavePlayVariationEventInfo -flibit
                    EventWavePlayVariation playVarEvt = new EventWavePlayVariation();
                    events[i] = playVarEvt;
                    break;

                case 6:
                    EventPlayMultiWave evt = new EventPlayMultiWave();

                    // A whole bunch of shit nobody cares about
                    clipReader.ReadBytes(33);
                    // u16 0    0
                    // u8 255   255
                    // u32 12   12
                    // u16 0    0
                    // u8 156   123
                    // u8 255   254
                    // u16 100  215
                    // u8 151   151
                    // u16 180  214

                    // u8 0
                    // u8 122
                    // u16 68

                    // u8 0
                    // u8 122
                    // u16 68

                    // u8 0
                    // u8 240
                    // u16 65

                    // u8 0
                    // u8 240
                    // u16 65

                    // u8 32    16

                    ushort numEntries = clipReader.ReadUInt16();
                    evt.waves = new SoundEffect[numEntries];
                    clipReader.ReadUInt16(); // 3
                    clipReader.ReadBytes(4); // 255 each
                    for (ushort j = 0; j < numEntries; j++)
                    {
                        ushort index     = clipReader.ReadUInt16();
                        byte   wavebank  = clipReader.ReadByte();
                        byte   minWeight = clipReader.ReadByte();
                        byte   weight    = clipReader.ReadByte();
                        evt.waves[j] = soundBank.GetWave(wavebank, index);
                    }
                    events[i] = evt;
                    break;

                default:
                    throw new NotImplementedException("eventInfo & 0x1F = " + eventId);
                }

                events[i].clip = this;
            }


            clipReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
 public static void Initialize()
 {
     // Initialize audio objects.
     engine = new AudioEngine(@"Content/sound/tglrf.xgs");
     soundBank = new SoundBank(engine, @"Content/sound/Sound Bank.xsb");
     waveBank = new WaveBank(engine, @"Content/sound/Wave Bank.xwb");
 }