void LoadGraphy() { if (m_AudioClip && m_Track) { Koreographer.Instance.RegisterForEvents(m_Track.EventID, OnEventEasyChange); if (m_Koreography == null) { m_Koreography = Resources.Load <Koreography>("Music/StarlitKoreography"); } // 移除空的音轨 m_Koreography.CheckTrackListIntegrity(); m_Koreography.SourceClip = m_AudioClip; if (m_Koreography.CanAddTrack(m_Track)) { m_Koreography.AddTrack(m_Track); } m_simplePlayer.LoadSong(m_Koreography); m_SongAudioSource.clip = m_AudioClip; m_SongAudioSource.Play((ulong)(2.5 * 44100)); } }
// Use this for initialization void Start() { notes = new List <RhythmNote>(); koreo = Koreographer.Instance.GetKoreographyAtIndex(0); missPercentage = (RhythmGameManager.noteTravelSampleTime + RhythmGameManager.PERFECT_HIT_RANGE_IN_SAMPLES) / RhythmGameManager.noteTravelSampleTime; audioSource = GetComponent <AudioSource>(); }
public void Initialize() { mKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); mNoteToHitTravelTime = 2 * 1 * 44100; InitializeNotes(); }
// 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); }
void Start() { CheckDeviceType(); InitializeLeadIn(); playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); //获取Koreography对象 ReturnNoteToPool(sampleNote); InitClickNoteQueue(); ReturnFlipNoteToPool(sampleFlipNote); InitFlipNoteQueue(); ReturnHoldNoteToPool(sampleHoldNote); InitHoldNoteQueue(); }
public void SetKoreography(AudioClip clip, Koreography koreography, string songTitle) { numBeats = 0; numGoodHits = 0; numBadHits = 0; numMisses = 0; beatEventIndex = 0; multiplierCounter = 0; score = 0; multiplier = 1; Koreographer.Instance.ClearEventRegister(); //Koreographer.Instance.ClearEventRegister(); this.koreoGraphy = koreography; GetComponent <AudioSource>().clip = clip; smp.LoadSong(koreography, 0, false); Koreographer.Instance.LoadKoreography(koreography); for (int i = 0; i < indicatorManagers.Count; i++) { indicatorManagers[i].SetLaneEvents(koreography.GetTrackAtIndex(i)); numBeats += koreography.GetTrackAtIndex(i).GetAllEvents().Count; } for (int i = 0; i < koreography.GetNumTracks(); i++) { if (koreography.GetTrackAtIndex(i).EventID == "Beats") { beatEvents = koreography.GetTrackAtIndex(i).GetAllEvents(); } } //string[] eventIds = koreography.GetEventIDs(); /* foreach(string eventId in eventIds) * { * if(eventId != "Beats") * { * Koreographer.Instance.RegisterForEvents(eventId, OnMusicalHit); * } * }*/ Koreographer.Instance.RegisterForEvents("Beats", OnBeatHit); Koreographer.Instance.RegisterForEvents("EndOfSong", EndOfSong); Koreographer.Instance.RegisterForEvents("FreeHit", StartFreeHit); }
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); }
private void Awake() { positionEnum.Clear(); fishTypeQueue.Clear(); eventSampleTimeList.Clear(); InitPositionEnum(); InitTimeLeftToBegin(); InitFishEarlyTime(); fishDelayTime = timeLeftToBegin - fishEarlyTime; myAudioSource = gameObject.GetComponent <AudioSource>(); playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); sampleRate = playingKoreo.SampleRate; LoadEventSampleTime(); }
private void Start() { //Para regirstar respuestas a eventos del koreographer //Koreographer.Instance.RegisterForEvents(lightsEventID, ChangeLightColor); Koreographer.Instance.RegisterForEvents(keyEventID, GenerateKey); //get the current koreographer koreography = Koreographer.Instance.GetKoreographyAtIndex(0); //Get all events out of the track KoreographyTrackBase keyTrack = koreography.GetTrackByID(keyEventID); keyEvents = keyTrack.GetAllEvents(); keyEventsLength = keyEvents.Count; keyManager.SetAllSongKeys(keyEventsLength); }
// Use this for initialization void Start() { PERFECT_HIT_RANGE_IN_SAMPLES = perfectHitRangeInSamples; invertedNoteSpeed = 1 / noteSpeed; koreo = Koreographer.Instance.GetKoreographyAtIndex(0); KoreographyTrackBase rhythmTrack = koreo.GetTrackByID(TrackID); List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); noteTravelSampleTime = invertedNoteSpeed * SampleRate; nextEvent = new KoreographyEvent[6]; noteDirections = new Vector3[6]; lanes = new Queue <KoreographyEvent> [6]; for (int i = 0; i < 6; i++) { Vector2 dir; lanes[i] = new Queue <KoreographyEvent>(); Vector3[] corners = new Vector3[4]; buttonTransforms[i].GetWorldCorners(corners); Vector3 middlePoint = corners[0] + (corners[2] - corners[0]) / 2; dir = middlePoint - new Vector3(0, 0, 90); noteDirections[i] = new Vector3(dir.x, dir.y, 0); laneControllers[i].noteDirection = noteDirections[i]; } for (int i = 0; i < rawEvents.Count; ++i) { KoreographyEvent evt = rawEvents[i]; int payload = evt.GetIntValue(); lanes[payload].Enqueue(evt); } //prepare initial events for (int i = 0; i < 6; i++) { if (lanes[i].Count > 0) { nextEvent[i] = lanes[i].Dequeue(); } } Debug.Log("eventtest"); Debug.Log(nextEvent[0].StartSample); }
public void LoadSong(Koreography koreo, int startSampleTime = 0, bool autoPlay = true) { Koreographer.Instance.UnloadKoreography(koreography); koreography = koreo; if (koreography != null) { Koreographer.Instance.LoadKoreography(koreography); audioCom.clip = koreography.SourceClip; SeekToSample(startSampleTime); if (autoPlay) { audioCom.Play(); } } }
void Start() { //Find the animator for the dancing man. this.animationTarget = GameObject.FindObjectOfType <Animator>(); InitializeLeadIn(); // Initialize all the Lanes. for (int i = 0; i < noteLanes.Count; ++i) { noteLanes[i].Initialize(this); } // Initialize events. playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); // Grab all the events out of the Koreography. KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(eventID); List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); InitializeMetronomeIfPresent(rawEvents); 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) { LaneControllerBeatInfinity lane = noteLanes[j]; if (lane.DoesMatchPayload(payload)) { // Add the object for input tracking. lane.AddEventToLane(evt); // Break out of the lane searching loop. break; } } } }
void Start() { InitializeLeadIn(); // Initialize all the Lanes. for (int i = 0; i < noteLanes.Count; ++i) { noteLanes[i].Initialize(this); } Debug.Log(noteLanes.Count);//6 // Initialize events. playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); // Grab all the events out of the Koreography. KoreographyTrack rhythmTrack = playingKoreo.GetTrackByID(eventID); List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); 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) { LaneController lane = noteLanes[j]; if (lane.DoesMatchPayload(payload)) { // Add the object for input tracking. lane.AddEventToLane(evt); // Break out of the lane searching loop. break; } } } }
void Start() { InitializeLeadIn(); for (int i = 0; i < noteLines.Count; i++) { noteLines[i].Initialize(this);//音轨初始化 } //获取到koreography对象 playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); KoreographyTrack 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 < noteLines.Count; j++) { LaneController lane = noteLines[j]; if (noteID > 6) { noteID = noteID - 6; if (noteID > 6) { noteID = noteID - 6; } } if (lane.DoesMatch(noteID)) { lane.AddEventToLane(evt); break; } } } hitWindowRangeInSamples = (int)(SampleRate * hitWindowRangeInMS * 0.0001f); }
/// <summary> /// /// SET UP THE SELECTED SONG AND BEGIN PLAYING IT /// /// </summary> IEnumerator setUpKoreoStats() { int maxY = 0; int minY = 0; bool useFloat = false; int koreoTrackToUse = 0; Koreography myKoreo = currentSong.koreography; songCountdownTimer = currentSong.audioClip.length + universalOffset / 2; if (!myKoreo.Tracks[koreoTrackToUse].name.Contains("elody")) { koreoTrackToUse = 1; } int totalNotes = myKoreo.Tracks[koreoTrackToUse].GetAllEvents().Count; if (myKoreo.Tracks[koreoTrackToUse].GetAllEvents()[0].GetFloatValue() != 0) { useFloat = true; } // Debug.Log(useFloat); foreach (KoreographyEvent ke in myKoreo.Tracks[koreoTrackToUse].GetAllEvents()) { if (useFloat) { if (minY == 0) { maxY = Mathf.RoundToInt(ke.GetFloatValue()); minY = Mathf.RoundToInt(ke.GetFloatValue()); } if (ke.GetFloatValue() < minY) { minY = Mathf.RoundToInt(ke.GetFloatValue()); } if (ke.GetFloatValue() > maxY) { maxY = Mathf.RoundToInt(ke.GetFloatValue()); } } else { if (minY == 0) { maxY = ke.GetIntValue(); minY = ke.GetIntValue(); } if (ke.GetIntValue() < minY) { minY = ke.GetIntValue(); } if (ke.GetIntValue() > maxY) { maxY = ke.GetIntValue(); } } } // Debug.Log("HAYY"+minY + " "+maxY); om.maxNote = maxY; om.minNote = minY; // Debug.Log("OH "+minY + " "+maxY); sm.totalNotes = totalNotes; sm.notesHit = 0; om.setYRange(); //mainAudio.clip = Resources.Load("Audio/Music/Overcast") as AudioClip; yield return(new WaitForSeconds(universalOffset)); startMusic(); yield return(new WaitForSeconds(universalOffset)); EventManager.instance.Raise(new StartSongEvent()); yield return(null); }
void DrawBeatLines(Rect contentRect, WaveDisplayState displayState, Koreography koreo) { int startSample = displayState.firstSamplePackToDraw; int endSample = startSample + displayState.samplesPerPixel * (int)contentRect.width; int startSectionIdx = koreo.GetTempoSectionIndexForSample(startSample); int endSectionIdx = koreo.GetTempoSectionIndexForSample(endSample); TempoSectionDef drawSection = koreo.GetTempoSectionAtIndex(startSectionIdx); if (startSectionIdx < endSectionIdx) { // Multiple sections to draw! for (int i = startSectionIdx + 1; i <= endSectionIdx; ++i) { TempoSectionDef nextSection = koreo.GetTempoSectionAtIndex(i); DrawBeatLinesForSection(contentRect, displayState, drawSection, startSample, nextSection.StartSample, sectionBGColors[(i - 1) % sectionBGColors.Length]); // Set up for the next section! startSample = nextSection.StartSample; drawSection = nextSection; } } // Draw the lines for the final (or only) section. DrawBeatLinesForSection(contentRect, displayState, drawSection, startSample, endSample, sectionBGColors[endSectionIdx % sectionBGColors.Length]); }
public void Draw(Rect displayRect, WaveDisplayState displayState, Koreography koreo, bool bShowPlayhead, List<KoreographyEvent> selectedEvents) { // Draw background. Color originalBG = GUI.backgroundColor; GUI.backgroundColor = mainBGColor; GUI.Box(displayRect, ""); GUI.backgroundColor = originalBG; GUI.BeginGroup(displayRect); // Calculate drawing metrics for channels. float left = GUI.skin.box.padding.left + 1f; float top = GUI.skin.box.padding.top; float width = GetChannelPixelWidthForWindow((int)displayRect.width); float height = (displayRect.height - GUI.skin.box.padding.vertical) / MAX_CHANNELS_TO_DRAW; Rect contentRect = new Rect(left + displayState.drawStartOffsetInPixels, top, width - displayState.drawStartOffsetInPixels, displayRect.height - GUI.skin.box.padding.vertical); // Adjust for start offset! Rect channelRect = new Rect(left + displayState.drawStartOffsetInPixels, top, width - displayState.drawStartOffsetInPixels, height); // Draw the beat markers before the actual audio content. // NOTE: This contains GUI code. EveytType.Repaint optimizations handled internally. DrawBeatLines(contentRect, displayState, koreo); // Only process this drawing if we're repainting (DOES NOT USE GUI SYSTEM). if (Event.current.type.Equals(EventType.Repaint)) { // Draw Channels (waveforms) for (int i = 0; i < channelDisplays.Count; ++i) { channelRect.y += i * height; // Draw ZERO Line Handles.color = new Color(0f, 0f, 0f, KoreographerColors.HandleFullAlpha); Handles.DrawLine(new Vector2(channelRect.x, channelRect.center.y), new Vector2(channelRect.x + channelRect.width, channelRect.center.y)); // Draw Channel Content channelDisplays[i].Draw(channelRect, displayState); } } // Draw Tracks (events) if (trackDisplay.EventTrack != null) { Rect trackRect = new Rect(channelRect.x, contentRect.center.y - 12f, channelRect.width, 24f); trackDisplay.Draw(trackRect, displayState, selectedEvents); } // Only process this drawing if we're repainting (DOES NOT USE GUI SYSTEM). if (Event.current.type.Equals(EventType.Repaint) && bShowPlayhead) { // Draw overlays if (displayState.playheadSamplePosition >= displayState.firstSamplePackToDraw && displayState.playheadSamplePosition <= displayState.firstSamplePackToDraw + (width * displayState.samplesPerPixel)) { // Make the playhead position flexible to allow for scrolling (while maintaining playhead position). int position = displayState.drawStartOffsetInPixels + ((displayState.playheadSamplePosition - displayState.firstSamplePackToDraw) / displayState.samplesPerPixel); DrawPlayheadLine((int)left + position, (int)top, (int)(top + (2f * height))); } } if (Event.current.type == EventType.Repaint) { // Store rect. This must be done during Repaint as the values are not properly handled on Layout. waveContentRect = displayRect; } GUI.EndGroup(); }
public void UnloadKoreography(Koreography koreo) { if (koreo != null && loadedKoreography.Contains(koreo)) { foreach (KeyValuePair<string,EventObj> mapping in eventBoard) { if(koreo.DoesTrackWithEventIDExist(mapping.Key)) { // Untie the Koreography from existing event requests. koreo.UnregisterForEventsWithTime(mapping.Key, mapping.Value.Trigger); } } loadedKoreography.Remove(koreo); } }
public void LoadKoreography(Koreography koreo) { if (koreo != null && !loadedKoreography.Contains(koreo)) { foreach (KeyValuePair<string,EventObj> mapping in eventBoard) { // Tie the Koreography to pre-existing event requests. koreo.RegisterForEventsWithTime(mapping.Key, mapping.Value.Trigger); } loadedKoreography.Add(koreo); } }
public bool IsKoreographyLoaded(Koreography koreo) { return loadedKoreography.Contains(koreo); }
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; } } } }
public void PlaySynced(Koreography koreo) { player.LoadSong(koreo); isPlaying = true; }