Exemple #1
0
        public GameMusic()
        {
            soundScript = new SoundEvent("GameMusic");
            SampleSoundEvent ev1 = new SampleSoundEvent("layers.ogg");

            soundScript.AddEvent(0.5, ev1);
        }
Exemple #2
0
        public GameMusic()
        {
            //track = TTengineMaster.ActiveGame.Content.Load<Song>("A01");
            soundScript = new SoundEvent("GameMusic");
            SampleSoundEvent ev1 = new SampleSoundEvent("quest.ogg");

            soundScript.AddEvent(0, ev1);
            soundScript.AddEvent(300, ev1);
            soundScript.AddEvent(600, ev1);
            soundScript.AddEvent(900, ev1);
        }
Exemple #3
0
        public GameMusic()
        {
            soundScript = new SoundEvent("GameMusic");
            SampleSoundEvent ev1 = new SampleSoundEvent("quest14_medley.ogg");

            soundScript.AddEvent(0.4, ev1);
            soundScript.AddEvent(1 * 630, ev1);
            soundScript.AddEvent(2 * 630, ev1);
            soundScript.AddEvent(3 * 630, ev1);
            soundScript.AddEvent(4 * 630, ev1);
        }
Exemple #4
0
        public GameSound()
        {
            MusicEngine.GetInstance();

            soundsBank[0] = new SampleSoundEvent("sword-unsheathe.wav");
            soundsBank[1] = new SampleSoundEvent("swing.wav");
            soundsBank[2] = new SampleSoundEvent("swing2.wav");
            soundsBank[3] = new SampleSoundEvent("swing3.wav");
            soundsBank[4] = new SampleSoundEvent("hit_1.wav");
            soundsBank[5] = new SampleSoundEvent("hit_2.wav");
            soundsBank[6] = new SampleSoundEvent("hit_3.wav");
        }
Exemple #5
0
        public GameMusic()
        {
            //track = TTengineMaster.ActiveGame.Content.Load<Song>("A01");
            soundScript = new SoundEvent("GameMusic");
            SampleSoundEvent ev1 = new SampleSoundEvent("ductia.ogg");

            soundScript.AddEvent(2, ev1);
            soundScript.AddEvent(166, ev1);
            soundScript.AddEvent(332, ev1);
            soundScript.AddEvent(498, ev1);
            soundScript.AddEvent(664, ev1);
        }
            protected override void StartInternal()
            {
                try
                {
                    if (isAbort)
                    {
                        status    = ITaskStatus.FAIL;
                        statusMsg = "Task aborted";
                        return;
                    }

                    // check file
                    if (!System.IO.File.Exists(musicFile))
                    {
                        status    = ITaskStatus.FAIL;
                        statusMsg = "File not found: " + musicFile;
                        return;
                    }

                    SampleSoundEvent ev = new SampleSoundEvent(musicFile);
                    ev.Amplitude = volume;
                    parent.soundScript.AddEvent(parent.rp.Time - musicStartTime, ev);
                    if (isAbort)
                    {
                        status    = ITaskStatus.FAIL;
                        statusMsg = "Task aborted";
                        return;
                    }

                    lock (parent.songChangeLock)
                    {
                        if (parent.currentSong != null)  // if needed, fade out a current playing song
                        {
                            parent.oldSongs.Add(parent.currentSong);
                        }
                        parent.currentSong           = ev;
                        parent.currentSong.Amplitude = 0;
                        parent.currentSongStartTime  = parent.rp.Time;
                        parent.FadeIn();
                    }

                    // if all ok, record this as last song played
                    parent.lastMusicFile = musicFile;
                }
                catch (Exception ex)
                {
                    status    = ITaskStatus.FAIL;
                    statusMsg = "Failed: " + ex.Message;
                }
            }
        public override SoundEvent CreateSoundScript()
        {
            SampleSoundEvent amb = new SampleSoundEvent("Broken_Packet5/5BrknAmbVamp.wav");
            SampleSoundEvent bass = new SampleSoundEvent("Broken_Packet5/5BrknBassVamp.wav");
            SampleSoundEvent drum = new SampleSoundEvent("Broken_Packet5/5BrknDrumVamp.wav");
            SampleSoundEvent vox = new SampleSoundEvent("Broken_Packet5/5BrknVoxVamp.wav");
            double durLoop = drum.Duration; // single loop duration
            amb.Repeat = 5;
            bass.Repeat = 7;
            drum.Repeat = 8;
            vox.Repeat = 1;
            script.AddEvent(5 /*durLoop*/, amb);
            script.AddEvent(0, bass);
            script.AddEvent(0, drum);
            //script.AddEvent(durLoop, vox);

            // add game event to 'amb'
            BallShape ballShape = new BallShape(0);
            Ball ballItem = new Ball(ballShape, new Vector2(1500f,300f),new Vector2(0f,300f), 400.0f);
            ItemCreateSoundEvent ice = new ItemCreateSoundEvent(ballItem);
            ice.AttachTo(amb);
            return script;
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            lock (songChangeLock)
            {
                List <SampleSoundEvent> songsToRemove = new List <SampleSoundEvent>();
                foreach (SampleSoundEvent ev in oldSongs)
                {
                    ev.Amplitude -= fadeSpeed * p.Dt;

                    // remove songs from list if completely faded out.
                    if (ev.Amplitude <= 0)
                    {
                        ev.Active = false;
                        songsToRemove.Add(ev);
                    }
                }
                foreach (SampleSoundEvent ev in songsToRemove)
                {
                    oldSongs.Remove(ev);
                }

                // check if current song is still on list
                if (currentSong != null)
                {
                    if (isFadeIn)
                    {
                        currentSong.Amplitude += fadeSpeed * p.Dt;
                        if (currentSong.Amplitude >= 1)
                        {
                            currentSong.Amplitude = 1;
                            isFadeIn = false;
                        }
                    }

                    if (isFadeOut)
                    {
                        currentSong.Amplitude -= fadeSpeed * p.Dt;
                        if (currentSong.Amplitude <= 0)
                        {
                            currentSong.Amplitude = 0;
                            isFadeOut             = false;
                        }
                    }

                    // advance time only if volume nonzero
                    if (currentSong.Amplitude > 0)
                    {
                        rp.Time += p.Dt;
                    }

                    // remove current song if done playing
                    if (rp.Time - currentSongStartTime > currentSong.Duration + 0.3)
                    {
                        currentSong = null;
                    }
                }
            }

            if (currentSong != null && currentSong.Amplitude > 0)
            {
                MusicEngine.GetInstance().Render(soundScript, rp);
            }
        }