Ejemplo n.º 1
0
        public void ReturnListOfNotes()
        {
            var result = _player.Play(_noNumberNotes);

            result.ShouldBeOfType <List <Note> >();
            result.Count().ShouldBe(3);
        }
Ejemplo n.º 2
0
    IEnumerator PlaySong(LoadedSong song)
    {
        //This will wait for songfile to load, if possible
        yield return(song.PrepForPlaying());

        if (song.song == null)
        {
            Abort();
            yield break;
        }

        this.song = song;
        AddCursor(loader);
        AddCursor(timing);
        actualOffset = -1 * (totalOffset + song.offset);
        if (actualOffset > 0)
        {
            player.Play(song, 0);
            StartCoroutine(StartAfterDelay(actualOffset / 1000.0f));
        }
        else
        {
            player.Play(song, (-1 * actualOffset) / 1000.0f);
            StartCoroutine(StartAfterDelay(0));
        }
    }
Ejemplo n.º 3
0
        public void PlayAndPauseAndPlay()
        {
            var songPlayer = new SongPlayer(MP3MattRedman, GtTimeSignature.Time4x4);

            try
            {
                songPlayer.Play();
                Thread.Sleep(100);

                songPlayer.Pause();
                var currentPosition = songPlayer.CurrentPosition;

                Thread.Sleep(100);

                Assert.AreEqual(SongPlayerStatus.Paused, songPlayer.Status);

                //Is really paused
                Assert.AreEqual(currentPosition, songPlayer.CurrentPosition);

                //start again from the paused point
                songPlayer.Play();
                Thread.Sleep(100);

                Assert.AreEqual(SongPlayerStatus.Playing, songPlayer.Status);
                Assert.Greater(songPlayer.CurrentPosition, currentPosition);
            }
            finally
            {
                songPlayer.Dispose();
            }
        }
Ejemplo n.º 4
0
        public void StatusIsStopoedWhenFinished()
        {
            var songPlayer = new SongPlayer(SmallSample, GtTimeSignature.Time4x4);

            try
            {
                songPlayer.Play();

                Assert.AreEqual(SongPlayerStatus.Playing, songPlayer.Status);

                //wait until the status change to Stopped
                int i = 0;
                while (songPlayer.Status != SongPlayerStatus.Stopped)
                {
                    Thread.Sleep(200);

                    i++;
                    if (i > 50) //after 10seg the test fail
                    {
                        Assert.Fail("The song didn't stoped at the end.");
                    }
                }

                Assert.AreEqual(SongPlayerStatus.Stopped, songPlayer.Status);
            }
            finally
            {
                songPlayer.Dispose();
            }
        }
Ejemplo n.º 5
0
    private void Start()
    {
        var player = new SongPlayer(this.song);

        this.GetComponent <MusicManager>().AssignPlayer(player);
        player.Play();
    }
Ejemplo n.º 6
0
        public void PlayReallyWorks()
        {
            var songPlayer = new SongPlayer(MP3MattRedman, GtTimeSignature.Time4x4);

            try
            {
                songPlayer.Play();
                Assert.AreEqual(SongPlayerStatus.Playing, songPlayer.Status);

                var position = songPlayer.CurrentPosition;

                int i = 0;
                while (i++ < 5)
                {
                    Thread.Sleep(100);

                    //Trace.TraceWarning(string.Format("PlayReallyWorks: CurrentPositionAsSeconds = {0}.", songPlayer.CurrentPositionAsSeconds));
                    Assert.Greater(songPlayer.CurrentPosition, position);

                    position = songPlayer.CurrentPosition;
                }
            }
            finally
            {
                songPlayer.Dispose();
            }
        }
Ejemplo n.º 7
0
        //[Test]
        //public void LogOfTicksAndBeats()
        //{
        //    var songPlayer = new SongPlayer(Matt_4Beats, GtTimeSignature.Time4x4);
        //    try
        //    {
        //        this.fTickNotificationList.Clear();

        //        //This event will populate this.fTickNotificationList with all tick notification.
        //        songPlayer.TickNotifyEvent += new TickNotifyEvent(HandleTickNotifyEventForTest);

        //        songPlayer.Play();

        //        //wait for the song's end
        //        while (songPlayer.Status != SongPlayerStatus.Stopped)
        //        {
        //            Thread.Sleep(1);
        //        }

        //        //Prepare the expected list of tick notifications
        //        var beatsTicksExpected = PrepareExpectedTicksList();

        //        //trace...
        //        //for (int i = 0; i < beatsTicksExpected.Count; i++)
        //        //{
        //        //    string description = string.Format("Excpected {0}:{1} and found {2}:{3}",
        //        //        beatsTicksExpected[i].Beat, beatsTicksExpected[i].Tick,
        //        //        fTickNotificationList[i].Beat, fTickNotificationList[i].Tick);

        //        //    Trace.TraceInformation(description);
        //        //}

        //        Assert.AreEqual(beatsTicksExpected.Count, fTickNotificationList.Count);

        //        for (int i = 0; i < beatsTicksExpected.Count; i++)
        //        {
        //            string description = string.Format("Excpected {0}:{1} but was found {2}:{3}",
        //                beatsTicksExpected[i].Beat, beatsTicksExpected[i].Tick,
        //                fTickNotificationList[i].Beat, fTickNotificationList[i].Tick);

        //            Assert.AreEqual(beatsTicksExpected[i].Beat, fTickNotificationList[i].Beat, description);
        //            Assert.AreEqual(beatsTicksExpected[i].Tick, fTickNotificationList[i].Tick, description);
        //        }
        //    }
        //    finally
        //    {
        //        songPlayer.Dispose();
        //    }
        //}

        //private List<BeatTick> PrepareExpectedTicksList()
        //{
        //    var beatsTicksExpected = new List<BeatTick>();

        //    for (int beat = 1; beat <= 4; beat++)
        //    {
        //        for (int tick = 0; tick <= 470; tick += 40)
        //        {
        //            beatsTicksExpected.Add(new BeatTick()
        //            {
        //                Beat = beat,
        //                Tick = tick
        //            });
        //        }
        //    }

        //    //Remove the 1:0 (the event isn't fired for the position 0. So the first one is the 1:10)
        //    //beatsTicksExpected.RemoveAt(0);

        //    //Add the 5:0 (the last tick notification)
        //    beatsTicksExpected.Add(new BeatTick()
        //    {
        //        Beat = 5,
        //        Tick = 0
        //    });

        //    return beatsTicksExpected;
        //}

        //This test is too slow (full music).
        //[Test]
        public void NumberOfBeatsPlayed_CompleteSong()
        {
            var songPlayer = new SongPlayer(MP3MattRedman, GtTimeSignature.Time4x4);

            try
            {
                this.fNumberOfBeats = 0;

                //This event will increase the numberOfBeats for each new beat, and play the click sample
                songPlayer.TickNotifyEvent += new TickNotifyEvent(HandleTickNotifyEventForTest);

                songPlayer.Play();

                //wait for the song's end
                while (songPlayer.Status != SongPlayerStatus.Stopped)
                {
                    Thread.Sleep(1);
                }

                Assert.AreEqual(721, this.fNumberOfBeats);
            }
            finally
            {
                songPlayer.Dispose();
            }
        }
Ejemplo n.º 8
0
    //按钮激活
    public void StartPlaying(int playlistIndex)
    {
        //属性初始化
        ResetGameStateValues();

        //游戏UI
        SetInGameUserInterfaceVisibility(true);

        //运行歌曲文件
        Player.SetSong(Playlist[playlistIndex]);

        CreateNoteObjects();
        //DragonHP();

        Player.Play();
        StartCoroutine("DisplayCountdown");
    }
Ejemplo n.º 9
0
 void Play(object sender, EventArgs e)
 {
     SongPlayer.Play();
     positionBar.Enabled = pauseButton.Enabled = stopButton.Enabled = true;
     pauseButton.Text    = "Pause";
     timer.Interval      = (int)(1000f / Config.RefreshRate);
     timer.Start();
     UpdateTaskbarState();
 }
Ejemplo n.º 10
0
        private static void PlayButton_Click(object sender, EventArgs e)
        {
            Form.SongLabel.Text = SongReader.Position.ToString("X4");
            Form.Timer.Start();

            SongPlayer.Play();
            Midi.MidiPlayer.Start();

            Timer.Change(0, 10);
        }
Ejemplo n.º 11
0
        public void PlayEmptyFileName()
        {
            using (ISongPlayer songPlayer = new SongPlayer(string.Empty, GtTimeSignature.Time4x4))
            {
                songPlayer.Play();
                Thread.Sleep(100);

                Assert.AreEqual(-1, songPlayer.CurrentPosition);

                songPlayer.Pause();
                Thread.Sleep(100);

                Assert.AreEqual(SongPlayerStatus.Paused, songPlayer.Status);

                //start again from the paused point
                songPlayer.Play();
                Thread.Sleep(100);

                Assert.AreEqual(SongPlayerStatus.Playing, songPlayer.Status);
                Assert.AreEqual(-1, songPlayer.CurrentPosition);
            }
        }
Ejemplo n.º 12
0
 public MainMenuState()
 {
     selected     = 0;
     textRenderer = new TextRenderer();
     textRenderer.RegisterGlyphShader("shaky", new Shaky());
     spriteFont = Resources.ContentManager.Load <SpriteFont>(GlobalFontID.TrebuchetMS32);
     selector   = Resources.ContentManager.Load <Sprite>(GlobalSpriteID.selectorplaceholder);
     position   = new Vector2f(50, 50);
     rainy      = Resources.ContentManager.Load <Song>(GlobalSongID.RainyNostalgia);
     songPlayer = SongPlayer.Create();
     songPlayer.Play(rainy);
     songPlayer.IsLooping = true;
 }
Ejemplo n.º 13
0
        public void PlayAndStopAndPlay()
        {
            var songPlayer = new SongPlayer(MP3MattRedman, GtTimeSignature.Time4x4);

            try
            {
                songPlayer.Play();

                Thread.Sleep(100);
                var currentPosition = songPlayer.CurrentPosition;

                songPlayer.Stop();

                //start again from the beggining
                songPlayer.Play();

                Assert.AreEqual(SongPlayerStatus.Playing, songPlayer.Status);
                Assert.Less(songPlayer.CurrentPosition, currentPosition);
            }
            finally
            {
                songPlayer.Dispose();
            }
        }
Ejemplo n.º 14
0
        public void Play()
        {
            var songPlayer = new SongPlayer(MP3MattRedman, GtTimeSignature.Time4x4);

            try
            {
                songPlayer.Play();
                Assert.AreEqual(SongPlayerStatus.Playing, songPlayer.Status);
            }
            finally
            {
                songPlayer.Stop();
                songPlayer.Dispose();
            }
        }
        public void PlayReallyWorks(int velocity)
        {
            using (var songPlayer = new SongPlayer(MP3MattRedman, GtTimeSignature.Time4x4))
            {
                songPlayer.Play(velocity);
                Assert.AreEqual(SongPlayerStatus.Playing, songPlayer.Status);


                var waitTimeInSeconds = 2; //wait 2 seconds

                Thread.Sleep(waitTimeInSeconds * 1000);
                var position = songPlayer.CurrentPositionAsSeconds;
                Console.WriteLine(position);


                //check if the elapsed time is proportional to the velocity.
                Assert.Less((float)waitTimeInSeconds / (100.0f / velocity) - position, 0.2f); //0.2 seconds of tolerance
            }
        }
Ejemplo n.º 16
0
        //Replace With correct Manager
        protected override void OnLoadingContent()
        {
            Console.WriteLine("Something");
            FileSystemManager fileSystemManager = new FileSystemManager("E:\rendu\\EIP\\MakersSquare\\AComponent");

            this.contentManager = ContentManager.Create("Content");
            LoadContentManifests(contentManager);
            AudioManager audioManager = new AudioManager();
            Song         song         = this.contentManager.Load <Song>(GlobalSongID.SabatonTheLastStand);

            audioManager.addSong(song);


            // this.song = TODO load song
            songPlayer = SongPlayer.Create();
            songPlayer.Play(song);

            base.OnLoadingContent();
        }
Ejemplo n.º 17
0
        public void PlayAndStop()
        {
            var songPlayer = new SongPlayer(MP3MattRedman, GtTimeSignature.Time4x4);

            try
            {
                songPlayer.Play();
                Assert.AreEqual(SongPlayerStatus.Playing, songPlayer.Status);

                Thread.Sleep(100);

                songPlayer.Stop();
                Assert.AreEqual(SongPlayerStatus.Stopped, songPlayer.Status);
                Assert.AreEqual(0, songPlayer.CurrentPosition);
            }
            finally
            {
                songPlayer.Dispose();
            }
        }
Ejemplo n.º 18
0
 public void Play()
 {
     Played = true;
     player = SongPlayer.Create();
     player.Play(Song, Loop);
 }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!\n");

            var beat = 250;
            var song = new Song
            {
                Name  = "Axel F",
                Tempo = new Dictionary <string, int>
                {
                    { Notes.FIZZ, 1 },
                    { Notes.BUZZ, 2 },
                    { Notes.FIZZ_BUZZ, 4 },
                    { Notes.REST, 1 }
                }
            };
            var inputs = new int[]
            {
                5, 3, 2, 3, 3, 3, 3, 3,
                5, 3, 2, 3, 3, 3, 3, 3,
                3, 3, 3, 3, 3, 15,
                2, 2, 2, 2, 2,
                5, 3, 2, 3, 3, 3, 3, 3,
                5, 3, 2, 3, 3, 3, 3, 3,
                3, 3, 3, 3, 3, 15,
                2, 2, 2, 2, 2, 2
            };
            var songPlayer = new SongPlayer(song);

            var output = songPlayer.Play(inputs);

            Console.WriteLine("Press any key to start:");
            Console.ReadLine();
            Thread.Sleep(100);

            var count = 0;

            foreach (var note in output)
            {
                if (note.GetType() != typeof(Rest))
                {
                    if (!note.Value.Equals(Notes.FIZZ))
                    {
                        if (count > 0)
                        {
                            Console.WriteLine();
                            count++;
                        }

                        Console.WriteLine(note.Value);
                    }
                    else
                    {
                        Console.Write(note.Value);
                    }
                }

                Thread.Sleep(note.Beats * beat);
            }

            Console.WriteLine();
            Console.WriteLine("Wah cha cha...");
            Console.ReadLine();
        }
Ejemplo n.º 20
0
 public void SetSongPlayer(SongData songData)
 {
     m_SongPlayer.SetSong(songData);
     m_SongPlayer.Play();
 }
Ejemplo n.º 21
0
 // (0.0.4)
 #region StartQuestion
 private void StartQuestion_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     SongPlayer.CurrentPosition = CurrentQuestion.PlayPos;
     SongPlayer.Play();
     CurrentGameMode = GameMode.Playing;
 }