Esempio n. 1
0
    IEnumerator Noting()
    {
        var time_per_beat = 60.0f / bpm;
        var beatcount     = 0;

        while (true)
        {
            var t = audio.time;

            var next_beat = (beatcount + 1) * time_per_beat;
            var now_beat  = beatcount * time_per_beat;
            if (Math.Abs(next_beat - t) < Math.Abs(now_beat - t))
            {
                beatcount += 1;
            }


            if (Input.GetKeyDown(KeyCode.A))
            {
                note.Data note;
                note.timing = beatcount * time_per_beat;
                note.type   = 0;
                newdata.Add(note);
                Debug.Log("Note!");
            }
            else if (Input.GetKeyDown(KeyCode.Z))
            {
                note.Data note;
                note.timing = beatcount * time_per_beat;
                note.type   = 1;
                newdata.Add(note);
                Debug.Log("Note!");
            }

            if (longnote)
            {
                if (Input.GetKeyUp(KeyCode.A))
                {
                    note.Data note;
                    note.timing = beatcount * time_per_beat;
                    note.type   = 2;
                    newdata.Add(note);
                    Debug.Log("Note!");
                }
                else if (Input.GetKeyUp(KeyCode.Z))
                {
                    note.Data note;
                    note.timing = beatcount * time_per_beat;
                    note.type   = 3;
                    newdata.Add(note);
                    Debug.Log("Note!");
                }
            }

            yield return(null);
        }
    }
Esempio n. 2
0
 public void makeData()
 {
     data.Reset();
     for (int i = 0; i < newdata.notes.Count; ++i)
     {
         data.Add(newdata.notes[i]);
     }
     for (int i = 0; i < checkers.Length; ++i)
     {
         var checker = checkers[i];
         var len     = checker.GetNoteCount();
         Debug.Log("checker:" + len.ToString());
         for (int j = 0; j < len; ++j)
         {
             if (null != checker.GetNote(j))
             {
                 data.Add(checker.GetNote(j).GetNoteData());
             }
         }
     }
     data.ProcessStacked(interval_recog, creating_interval);
 }
Esempio n. 3
0
        public void KeyDown()
        {
            if (NoteTabSelected)
            {
                int noteCount = 0;
                foreach (var note in RGBData.Current.NoteList)
                {
                    if ((Keyboard.IsKeyDown(note.Value.Input1) && !note.Value.IsInput1Down) ||
                        (Keyboard.IsKeyDown(note.Value.Input2) && !note.Value.IsInput2Down))
                    {
                        if (Keyboard.IsKeyDown(note.Value.Input1))
                        {
                            note.Value.IsInput1Down = true;
                        }
                        if (Keyboard.IsKeyDown(note.Value.Input2))
                        {
                            note.Value.IsInput2Down = true;
                        }

                        PlayNote(note.Value);

                        double noteTime     = Music.CurrentTime;
                        double previousBeat = Music.PreviousBeat;
                        double nextBeat     = previousBeat + _BeatDelay;

                        noteTime =
                            noteTime - previousBeat < nextBeat - noteTime
                                                        ? previousBeat
                                                        : nextBeat;
                        //noteTime = Music.CurrentTime;

                        noteTime = (Convert.ToInt32(noteTime * 1000) + noteCount) / 1000.0;

                        //비교 연산을 위한 정수화
                        if (!NoteData.Any(x => Convert.ToInt32(x.NoteTime * 1000) == Convert.ToInt32(noteTime * 1000)))
                        {
                            NoteData.Add(
                                new NoteData
                            {
                                Note     = note.Value,
                                NoteTime = noteTime
                            }
                                );
                            Music.PreviousNote = noteTime;
                            RaisePropertyChanged(nameof(NoteData));
                        }

                        /*else if (noteTime == previousBeat)
                         * {
                         *      NoteData.Add(
                         *              new NoteData
                         *              {
                         *                      Note = note.Value,
                         *                      NoteTime = nextBeat
                         *              }
                         *      );
                         *      RaisePropertyChanged(nameof(NoteData));
                         * }*/
                    }
                    noteCount++;
                }
            }
        }