示例#1
0
        public void Instantiation()
        {
            var songPlayer = new SongPlayer(MP3MattRedman, GtTimeSignature.Time4x4);

            Assert.AreEqual(SongPlayerStatus.Stopped, songPlayer.Status);
            Assert.AreEqual(0, songPlayer.CurrentPosition);
        }
示例#2
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();
            }
        }
示例#3
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();
            }
        }
示例#4
0
        public void SongProgress_Register()
        {
            // Arrange
            SongPlayer player = new SongPlayer(null, null);

            player.CurrentSong.AutoGenerate();
            player.ToggleSound();
            SongProgress prog = new SongProgress(player);

            // Start "playing" the song
            player.Start();
            Thread.Sleep(800);
            player.Tick();

            // Assert validity of unit test
            Assert.IsTrue(player.currentNotes.Count > 0);

            // Play one note correctly
            Note first = player.currentNotes.First();

            prog.Register(new PianoButton(
                              first.Octave,
                              first.Letter + (first.Black ? "#" : "")
                              ));

            // Assert
            Assert.AreEqual(1, prog.HitCount);
        }
        public void SongPlayer_SlidesVolumeCorrectly(AudioImplementation audioImplementation)
        {
            var songPlayer = default(SongPlayer);
            var song       = default(Song);

            GivenAnUltravioletApplicationWithNoWindow()
            .WithAudioImplementation(audioImplementation)
            .WithInitialization(uv => uv.GetAudio().AudioMuted = true)
            .WithContent(content =>
            {
                songPlayer = SongPlayer.Create();
                song       = content.Load <Song>("Songs/Deep Haze");

                songPlayer.Play(song, false);

                TheResultingValue(songPlayer.Volume).ShouldBe(1f);

                songPlayer.SlideVolume(0f, TimeSpan.FromSeconds(1));
            })
            .OnUpdate((app, time) =>
            {
                songPlayer.Update(time);
            })
            .RunFor(TimeSpan.FromSeconds(2));

            TheResultingValue(songPlayer.Volume).ShouldBe(0f);
        }
示例#6
0
    private void Start()
    {
        var player = new SongPlayer(this.song);

        this.GetComponent <MusicManager>().AssignPlayer(player);
        player.Play();
    }
示例#7
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();
            }
        }
        public void SongPlayer_PlayResetsVolumePitchAndPanWhenNotSpecified(AudioImplementation audioImplementation)
        {
            var songPlayer = default(SongPlayer);
            var song       = default(Song);

            GivenAnUltravioletApplicationWithNoWindow()
            .WithAudioImplementation(audioImplementation)
            .WithInitialization(uv => uv.GetAudio().AudioMuted = true)
            .WithContent(content =>
            {
                songPlayer = SongPlayer.Create();
                song       = content.Load <Song>("Songs/Deep Haze");

                songPlayer.Play(song, 0.25f, 0.50f, 0.75f, false);
                songPlayer.Stop();
                songPlayer.Play(song, false);

                TheResultingValue(songPlayer.Volume).ShouldBe(1f);
                TheResultingValue(songPlayer.Pitch).ShouldBe(0f);
                TheResultingValue(songPlayer.Pan).ShouldBe(0f);
            })
            .OnUpdate((app, time) =>
            {
                songPlayer.Update(time);
            })
            .RunForOneFrame();
        }
示例#9
0
    static public int GetMaxMark(SongTime[] sts)
    {
        int mark = 0;
        int c    = 0;

        for (int i = 0; i < sts.Length; i++)
        {
            if (sts[i] is LongSongTime)
            {
                if (c > 1)
                {
                    mark += SongPlayer.GetMark(c, Global.TIMING_JUAGE_TYPE.PREFECT);
                }
                c++;
            }

            if (c > 1)
            {
                mark += SongPlayer.GetMark(c, Global.TIMING_JUAGE_TYPE.PREFECT);
            }

            c++;
        }
        return(mark);
    }
示例#10
0
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     Stop(null, null);
     SongPlayer.ShutDown();
     MIDIKeyboard.Stop();
     base.OnFormClosing(e);
 }
示例#11
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();
            }
        }
示例#12
0
 public void SwapSegments(SongPlayer controller, AudioClip tempClip, float tempPitch, Material tempMaterial, Color tempColor, Vector3 tempScale, bool tempBool)
 {
     clip             = controller.clip;
     controller.clip  = tempClip;
     pitch            = controller.pitch;
     controller.pitch = tempPitch;
     Song.pitch       = pitch;
     Song.clip        = clip;
     Song.Play();
     indicator.GetComponentInChildren <SkinnedMeshRenderer>().material            = controller.indicator.GetComponentInChildren <SkinnedMeshRenderer>().material;
     pitchIndicator.GetComponent <MeshRenderer>().material                        = controller.indicator.GetComponentInChildren <SkinnedMeshRenderer>().material;
     controller.indicator.GetComponentInChildren <SkinnedMeshRenderer>().material = tempMaterial;
     controller.pitchIndicator.GetComponent <MeshRenderer>().material             = tempMaterial;
     indicator.GetComponentInChildren <Light>().color            = controller.indicator.GetComponentInChildren <Light>().color;
     pitchIndicator.GetComponent <Light>().color                 = controller.indicator.GetComponentInChildren <Light>().color;
     controller.indicator.GetComponentInChildren <Light>().color = tempColor;
     controller.pitchIndicator.GetComponent <Light>().color      = tempColor;
     pitchIndicator.transform.localScale            = controller.pitchIndicator.transform.localScale;
     controller.pitchIndicator.transform.localScale = tempScale;
     correctPitch            = controller.correctPitch;
     controller.correctPitch = tempBool;
     tempBool                     = correctReordering;
     correctReordering            = controller.correctReordering;
     controller.correctReordering = tempBool;
     controller.CheckReordering();
     controller.CheckPitch();
 }
示例#13
0
 public void Start(SongPlayer song)
 {
     foreach (var action in this.onStart)
     {
         action.Execute(song);
     }
 }
示例#14
0
    /// <summary>
    /// 玩家完了
    /// </summary>
    public void PlayerDead(SongPlayer p)
    {
        bool gameOver = true;

        for (int i = 0; i < players.Length; i++)
        {
            if (players[i].alive)
            {
                gameOver = false;
            }
        }

        if (gameOver)
        {
            for (int i = 0; i < players.Length; i++)
            {
                players[i].lose.gameObject.SetActive(false);
                players[i].timingJudge.gameObject.SetActive(false);
            }
            GameOver(true);
            audioSource.Stop();
            PlayLast5SMovie();
        }
        else
        {
            Sounder.instance.Play("一人失败音效");
            p.lose.SetActive(true);
            p.timingJudge.gameObject.SetActive(false);
        }
    }
示例#15
0
        private void CoverImageGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (SongPlayer.CurrentState != MediaElementState.Playing)
            {
                return;
            }
            if (((Song)e.ClickedItem).Thumbnail.UriSource.AbsolutePath.Contains("Assets"))
            {
                return;
            }

            //  Judge the user selection,
            //  Show UI effects about result of the user selection
            //  Change the user scores
            if (CurrentSong.Equals((Song)e.ClickedItem))
            {
                CurrentSong.GameMark = true;
                _correctSongs.Add(CurrentSong);
                ((Song)e.ClickedItem).Thumbnail = new BitmapImage(new Uri("ms-appx:///Assets/correct.png"));
                _ttlScore += (int)CountDownBar.Value * 2;
            }
            else
            {
                ((Song)e.ClickedItem).Thumbnail = new BitmapImage(new Uri("ms-appx:///Assets/incorrect.png"));
                _ttlScore += (int)CountDownBar.Value * -2;
            }
            SongPlayer.Stop();
        }
示例#16
0
        void ArgumentChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < 3; i++)
            {
                if (sender == argNumerics[i])
                {
                    var se = events[listView.SelectedIndices[0]];
                    object value = argNumerics[i].Value;
                    var m = se.Command.GetType().GetMember(argLabels[i].Text)[0];
                    if (m is FieldInfo f)
                        f.SetValue(se.Command, Convert.ChangeType(value, f.FieldType));
                    else if (m is PropertyInfo p)
                        p.SetValue(se.Command, Convert.ChangeType(value, p.PropertyType));
                    SongPlayer.RefreshSong();

                    var control = ActiveControl;
                    int index = listView.SelectedIndex;
                    LoadTrack(currentTrack);
                    SelectItem(index);
                    control.Select();

                    return;
                }
            }
        }
示例#17
0
 void RemoveEvent(object sender, EventArgs e)
 {
     if (listView.SelectedIndex == -1)
         return;
     SongPlayer.Song.RemoveEvent(currentTrack, listView.SelectedIndex);
     SongPlayer.RefreshSong();
     LoadTrack(currentTrack);
 }
 // (0.0.4)
 private void SwitchPlayPause_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (CurrentGameMode == GameMode.Thinking)
     {
         CurrentGameMode = GameMode.Talking;
     }
     SongPlayer.TogglePlayPause();
 }
示例#19
0
        private static void StopButton_Click(object sender, EventArgs e)
        {
            Form.Timer.Stop();
            Timer.Change(Timeout.Infinite, 10);

            SongPlayer.Stop();
            Midi.MidiPlayer.Stop();
        }
示例#20
0
        internal void PreviewASM(Assembler asm, string headerLabel, string caption)
        {
            Text = "GBA Music Studio - " + caption;
            bool playing = SongPlayer.State == PlayerState.Playing; // Play new song if one is already playing

            Stop(null, null);
            SongPlayer.SetSong(new M4AASMSong(asm, headerLabel));
            UpdateTrackInfo(playing);
        }
示例#21
0
    void Start()
    {
        GetComponent <AudioSource> ().clip = Resources.Load <AudioClip> ("Music/" + songName);
        song   = new Song(bpm, offset / 1000f, map, GetComponent <AudioSource>().clip);
        player = new SongPlayer(song, GetComponent <AudioSource>());

        engine = GameObject.FindWithTag("Engine").GetComponent <Engine> ();
        engine.setPlayer(player);
    }
示例#22
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();
 }
示例#23
0
        private static void Timer_Elapsed(object state)
        {
            //Timer.Change(Timeout.Infinite, 10);

            SongPlayer.Update();
            Midi.MidiPlayer.Update();

            //Timer.Change(10, 10);
        }
示例#24
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);
        }
        // (0.0.4)
        protected void StandbyQuestion(IntroQuestion question)
        {
            listBoxQuestions.SelectedItem = question;

            // 現在の曲を設定する。
            SongPlayer.Open(question.Song.FileName);
            // シークはStartQuestionコマンドで行う。
            CurrentQuestion = question;
            CurrentGameMode = GameMode.Standby;
        }
示例#26
0
 void AddEvent(object sender, EventArgs e)
 {
     var cmd = (ICommand)Activator.CreateInstance(Engine.GetCommands()[commandsBox.SelectedIndex].GetType());
     var ev = new SongEvent(0xFFFFFFFF, cmd);
     int index = listView.SelectedIndex + 1;
     SongPlayer.Song.InsertEvent(ev, currentTrack, index);
     SongPlayer.RefreshSong();
     LoadTrack(currentTrack);
     SelectItem(index);
 }
示例#27
0
        public void AlternativeInstantiation()
        {
            var songPlayer = new SongPlayer();

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

            songPlayer.SetupSong(MP3MattRedman, GtTimeSignature.Time4x4);

            Assert.AreEqual(SongPlayerStatus.Stopped, songPlayer.Status);
            Assert.AreEqual(0, songPlayer.CurrentPosition);
        }
示例#28
0
        private void GetYoutube_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            YoutubeMusic NextSong = new YoutubeMusic(YoutubeBox.Text); //create a new song to hold the data and allow us to play it

            if (CurrentSong != null)                                   //if there is a current song to stop
            {
                MusicPlayer.Stop();                                    //stop the currently playing song
            }
            CurrentSong = NextSong;
            SongPlayer.RunWorkerAsync(); //run the song playing worker
        }
示例#29
0
    public void UpdateTrackInfo()
    {
        SongPlayer player = SongPlayer.instance;
        var        bm     = player.loadedBeatmap;

        float diff = 0;

        for (int i = 0; i < bm.numTracks; i++)
        {
            if (!player.IsTrackEnabled(i))
            {
                continue;
            }

            float res = bm.GetTrack(i).Difficulty();

            if (res < 0)
            {
                diff = res;
                break;
            }
            else
            {
                diff += res;
            }
        }

        if (diff < 0)
        {
            diffText.text  = "impossible, need more keys";
            diffText.color = Color.red;
        }
        else
        {
            diffText.text  = diff.ToString("0.0") + " difficulty";
            diffText.color = Color.white;
        }

        float nps = 0;

        for (int i = 0; i < bm.numTracks; i++)
        {
            if (!player.IsTrackEnabled(i))
            {
                continue;
            }

            nps += (float)bm.GetTrack(i).Speed();
        }

        npmText.text = (nps * 60f).ToString("0.0") + "notes/mim";

        durText.text = Theory.DurationToString(player.selectedDuration);
    }
示例#30
0
    public void SetPlaying(int i, bool v)
    {
        SongPlayer player = SongPlayer.instance;

        player.SetPlaying(i, v);

        if (!_triggered)
        {
            StartCoroutine(InvokeEvent());
        }
    }
示例#31
0
	// Use this for initialization
	IEnumerator Start () {
	
		Player = GetComponent<SongPlayer>();
		NoteObjects = new List<GameObject>();
		
		
		plugin = FindObjectOfType(typeof(MicComponent)) as MicComponent;
		if (plugin == null) {
//			if (prePlugin != null) {
//				Transform obj = Instantiate(prePlugin) as Transform;
//				obj.name = "Plugin";
//				DontDestroyOnLoad(obj);
//				plugin = obj.GetComponent<Plugin>();
			//			} else {
#if EnglishVersion 
				Transform obj = (Transform)Instantiate(Resources.Load("Plugin_Quick_English", typeof(Transform))) ;
#elif TaiwanVersion
				Transform obj = (Transform)Instantiate(Resources.Load("Plugin_Quick_Taiwan", typeof(Transform))) ;
#else
				Transform obj = (Transform)Instantiate(Resources.Load("Plugin_Quick_Korea", typeof(Transform))) ;
#endif
				//Transform obj = (Transform)Instantiate(Resources.Load("Plugin_Quick_Korea", typeof(Transform))) ;
				obj.name = "Plugin";
				DontDestroyOnLoad(obj);
				plugin = obj.GetComponent<MicComponent>();
//				Transform obj = (Transform)Instantiate(Resources.Load("Plugin", typeof(Transform))) ;
//				obj.name = "Plugin";
//				DontDestroyOnLoad(obj);
//				plugin = obj.GetComponent<Plugin>();
//			}
		}
		
		gbl = plugin.GetComponent<Global>();
		
		dialogs = new CutsceneMgr.Dialog[2][];
		bgms = new CutsceneMgr.BGM[2][];
		
		yield return new WaitForSeconds(0.5f);
		StartPlaying(0);
	}
示例#32
0
	protected void OnEnable()
	{
		//Setup object references
		GuitarObject = GameObject.Find( "SongSystem" );

		if( GuitarObject == null )
		{
			return;
		}

		SongPlayer = GuitarObject.GetComponent<SongPlayer>();
		//MetronomeSource = GameObject.Find( "Metronome" ).audio;

		//Prepare playback
		SongPlayer.SetSong( (SongData)target );
//		LastMetronomeBeat = -Mathf.Ceil( SongPlayer.Song.AudioStartBeatOffset );
		
		if( actionReadDic != null )
			actionReadDic.Clear();
		if( loopActionReadDic != null )
			loopActionReadDic.Clear();
		actionReadDic = new Dictionary<ActorBase, ActorBase>();
		loopActionReadDic = new Dictionary<ActorBase, ActorBase>();
		

		RedrawProgressViewTexture();
	}