// Use this for initialization void Start() { InitializeLeadIn(); simpleMusicPlayer = simpleMusciPlayerTrans.GetComponent <SimpleMusicPlayer>(); simpleMusicPlayer.LoadSong(kgy, 0, false); // 初始化所有音轨. for (int i = 0; i < noteLanes.Count; ++i) { noteLanes[i].Initialize(this); } // 初始化事件。 playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); // 获取Koreography中的所有事件。 KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(eventID); //获取事件轨迹 List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); //获取所有事件 //KoreographyEvent rawEvent = rhythmTrack.GetEventAtStartSample(2419200); //rawEvent. for (int i = 0; i < rawEvents.Count; ++i) { //KoreographyEvent 基础Koreography事件定义。 每个事件实例都可以携带一个 //有效载荷 事件可以跨越一系列样本,也可以绑定到一个样本。 样品 //值(开始/结束)在“采样时间”范围内,* NOT *绝对采样位置。 //确保查询/比较在TIME而不是DATA空间中发生。 KoreographyEvent evt = rawEvents[i]; int noteID = evt.GetIntValue();//获取每个事件对应的字符串 // Find the right lane. 遍历所有音轨 for (int j = 0; j < noteLanes.Count; ++j) { LaneController lane = noteLanes[j]; if (noteID > 6) { noteID = noteID - 6; if (noteID > 6) { noteID = noteID - 6; } } if (lane.DoesMatch(noteID)) { //事件对应的字符串与某个音轨对应字符串匹配,则把该事件添加到该音轨 // Add the object for input tracking. lane.AddEventToLane(evt); // Break out of the lane searching loop. break; } } } //SampleRate采样率,在音频资源里有。 //命中窗口宽度,采样率*0.001*命中时长 hitWindowRangeInSamples = (int)(0.001f * hitWindowRangeInMS * SampleRate); }
private bool ProcessCommandLineArgs(SimpleMusicPlayer.Views.MainWindow window, IEnumerable<string> args) { if (window != null) { var vm = window.DataContext as SimpleMusicPlayer.ViewModels.MainWindowViewModel; if (vm != null) { vm.PlaylistsViewModel.HandleCommandLineArgsAsync(args.ToList()); } } return true; }
private bool ProcessCommandLineArgs(SimpleMusicPlayer.Views.MainWindow window, IEnumerable<string> args) { if (window != null) { var vm = window.DataContext as SimpleMusicPlayer.ViewModels.MainViewModel; if (vm != null) { vm.PlayListsViewModel.CommandLineArgs = new ReactiveList<string>(args); } } return true; }
void Start() { InitializeLeadIn(); //切歌选歌 simpleMusicPlayer = simpleMusciPlayerTrans.GetComponent <SimpleMusicPlayer>(); simpleMusicPlayer.LoadSong(kgy, 0, false); foreach (LaneController nl in noteLanes) { nl.Initialize(this); } //获取到Koreograhpy对象 playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); foreach (string _eventID in eventID) { //获取事件轨迹 KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(_eventID); //获取事件 List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); for (int i = 0; i < rawEvents.Count; i++) { KoreographyEvent evt = rawEvents[i]; int noteID = evt.GetIntValue(); //遍历所有音轨 for (int j = 0; j < noteLanes.Count; j++) { LaneController lane = noteLanes[j]; if (noteID > 4) { noteID = noteID - 4; if (noteID > 4) { noteID = noteID - 4; } } if (lane.DoesMatch(noteID)) { lane.AddEventToLane(evt); break; } } } } //SampleRate采样率,在音频资源里有。 //命中窗口宽度,采样率*0.001*命中时长 hitWindowRangeInSamples = (int)(SampleRate * hitWindowRangeInMS * 0.001f); }
void Awake() { Assert.IsNotNull(masterTrack); if (active == null) { active = this; } else { Destroy(this.gameObject); } simpleMusicPlayer = GetComponent <SimpleMusicPlayer>(); }
// Use this for initialization void Start() { //Peculiarity with unity scenes that will try and reload the object every time //everytime the scene is loaded, so destroy the imposters if(FindObjectsOfType<GameStateManager>().Length > 1) { Destroy(gameObject); return; } else { DontDestroyOnLoad(gameObject); _instance = this; } _musicPlayer = GetComponent<SimpleMusicPlayer>(); }
public void Init() { if (m_musicObj == null) { m_musicObj = new GameObject(); m_musicObj.name = "Music Player"; AudioSource source = m_musicObj.AddComponent <AudioSource>(); source.volume = 0; m_musicObj.AddComponent <Koreographer>(); m_simplePlayer = m_musicObj.AddComponent <SimpleMusicPlayer>(); GameObject.DontDestroyOnLoad(m_musicObj); } if (m_songObj == null) { m_songObj = new GameObject(); m_songObj.name = "Song Player"; m_SongAudioSource = m_songObj.AddComponent <AudioSource>(); m_SongAudioSource.playOnAwake = false; GameObject.DontDestroyOnLoad(m_songObj); } }
private void Start() { smp = GetComponent <SimpleMusicPlayer>(); }
// Use this for initialization void Start() { audioSource = GetComponent <AudioSource>(); smp = GetComponent <SimpleMusicPlayer>(); }
void Awake() { player = GetComponent <SimpleMusicPlayer>(); }
void Start() { gameManager = GameObject.Find("GameManager"); //PlayerPrefs.SetFloat("noteSpeed", noteSpeed); //PlayerPrefs.SetFloat("hitDelay", hitDelay); noteSpeed = PlayerPrefs.GetFloat("noteSpeed", 6f); hitDelay = PlayerPrefs.GetFloat("hitDelay", 0.08f); gameManager.transform.position = new Vector3(0, (float)(-noteSpeed * hitDelay - (2 + 0.5) * noteSpeed / 6), 0);//holy shit string songName; if (PlayerPrefs.GetString("PlayMode", "Play") == "Play") { songName = PlayerPrefs.GetString("SongName", GameStatics.songs[0].PlayBackName); eventID = PlayerPrefs.GetString("Difficulty", "Easy"); } else { songName = GameStatics.testSong.PlayBackName; eventID = "Easy"; } Debug.Log(songName); simpleMusicPlayer = GameObject.Find(songName).GetComponent <SimpleMusicPlayer>(); audioCom = GameObject.Find(songName).GetComponent <AudioSource>(); Koreographer.Instance.EventDelayInSeconds = 0f; InitializeLeadIn(); // Initialize all the Lanes. for (int i = 0; i < noteLanes.Count; ++i) { noteLanes[i].Initialize(this); } //Debug.Log(noteLanes.Count);//9 // Initialize events. if (songName == GameStatics.songs[0].PlayBackName) { playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); } else { playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(1); } //playingKoreo = Koreographer.Instance. // Grab all the events out of the Koreography. KoreographyTrack rhythmTrack = playingKoreo.GetTrackByID(eventID);//Easy or Hard List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); Debug.Log(rawEvents.Count); for (int i = 0; i < rawEvents.Count; ++i) { KoreographyEvent evt = rawEvents[i]; string payload = evt.GetTextValue(); // Find the right lane. for (int j = 0; j < noteLanes.Count; ++j) { Lane lane = noteLanes[j]; if (lane.DoesMatchPayload(payload)) { // Add the object for input tracking. lane.AddEventToLane(evt); // Break out of the lane searching loop. //break; } } } }