Ejemplo n.º 1
0
    void Awake()
    {
        txt            = GameObject.Find("HRText").GetComponent <TMPro.TMP_Text>();
        heartText      = GameObject.Find("hrui").GetComponent <TMPro.TMP_Text>();
        beats          = new List <Beat>();
        onsetFeatures  = new List <Onset>();
        chromaFeatures = new List <Chroma>();
        musicPlayer    = GetComponent <MusicPlayer>();
        audioSource    = GetComponent <AudioSource>();
        rhythmPlayer   = GetComponent <RhythmPlayer>();

        rhythmData.GetIntersectingFeatures(onsetFeatures, 0, 200);
        rhythmData.GetIntersectingFeatures(beats, 0, 200);
        rhythmData.GetFeatures(chromaFeatures, 0, 200);

//        UnityEngine.Debug.Log(onsetFeatures);


        foreach (var onset in onsetFeatures) //여기서생성
        {
            SpawnRandomFootNote(onset.timestamp).importance = onset.strength;
            SpawnRandomNote(onset.timestamp).importance     = onset.strength;
        }
        //foreach(var chroma in chromaFeatures)
        {
            //    SpawnRandomNote(chroma.timestamp);
        }


        rhythmPlayer.Play();
    }
Ejemplo n.º 2
0
    public void process(RhythmData rData)//, float currentTimestamp = 0)
    {
        //TODO add more row types for secondary VFX features, like spectrum visualiser?
        //string patternFilePath = getPatternPath();
        //bool exists = File.Exists(patternFilePath);
        //float songDuration = audioSource.clip.length;
        //Debug.Log("************* SONGLOADER.PROCESS " + patternFilePath + " " + songDuration + " " + totalLanes);
        Debug.Log("************* SONGLOADER.COMPETED ANALYSIS " + songData);
        List <Beat> tmpBeats = new List <Beat>();

        rData.GetFeatures <Beat>(tmpBeats, 0, songData.getClipLength());
        //Debug.Log("beats detected " + tmpBeats.Count);
        rhythmData = rData;
        //getSegmentData(0, processedData);
        inited = true;
    }
Ejemplo n.º 3
0
    void getSongRows(float songEnd)
    {
        beats.Clear();
        onsets.Clear();

        //RhythmData rData = rhythmAnalyzer.rhythmData;
        rhythmData.GetFeatures <Beat>(beats, 0, songEnd);//songDuration);
        rhythmData.GetFeatures <Onset>(onsets, 0, songEnd);
        float bpm = -1;

        List <Beat> doubleBeats = new List <Beat>();

        for (int i = 0; i < beats.Count - 1; i++)
        {
            Beat b = new Beat();
            b.timestamp = beats[i].timestamp;
            doubleBeats.Add(b);

            Beat b2 = new Beat();
            b2.timestamp = b.timestamp + (beats[i + 1].timestamp - b.timestamp) / 2;
            doubleBeats.Add(b2);
        }
        //beats = doubleBeats;

        Debug.Log("Beats in this song " + beats.Count);


        //int[] prevActiveLanes = new int[AssetManager.MAX_LANES];
        int[] finalActiveLanes = new int[AssetManager.MAX_LANES];
        //Debug.Log("PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATTERN " + Settings.instance.patternUseHold);
        if (!Settings.instance.autoPatternUseBeats) //use onsets instead
        {                                           //use note starts as beat box spawn point (instead of beat time, shown at the else)
            rowsBpm.Add(new SongRow(0, 160));
            for (int i = 0; i < onsets.Count; i++)
            {
                Onset currentBeat = onsets[i];
                Onset nextBeat    = null;
                if (Settings.instance.patternUseHold && i < beats.Count - 1)
                {
                    nextBeat = onsets[i + 1];
                }


                rowsBeat.Add(new SongRow(currentBeat.timestamp));

                int[] currentActiveLanes = getActiveLanes(currentBeat, patternLanes);//get beats with chroma feature

                if (Settings.instance.patternUseHold && nextBeat != null && nextBeat.timestamp - currentBeat.timestamp < Settings.instance.patternHoldMinTimestamp)
                {
                    //Debug.Log("*************************************grehgerthgthtr " + Settings.instance.patternUseHold);
                    int[] nextActiveLanes = getActiveLanes(nextBeat, patternLanes);

                    for (int l = 0; l < AssetManager.MAX_LANES; l++)
                    {
                        //we don't do holds in onset mode
                        if (currentActiveLanes[l] == 0)
                        {
                            finalActiveLanes[l] = 0;
                        }
                        else
                        if (currentActiveLanes[l] == 1)
                        {
                            finalActiveLanes[l] = 1;
                        }
                    }
                    //Debug.Log("BeatCurr comparison " + showActiveLanes(currentActiveLanes));
                    //Debug.Log("BeatNext comparison " + showActiveLanes(nextActiveLanes));
                }
                else
                {
                    finalActiveLanes = currentActiveLanes;
                }

                //Debug.Log("****BeatFinl comparison " + showActiveLanes(finalActiveLanes));
                rowsBox.Add(new SongRow(currentBeat.timestamp, (int[])finalActiveLanes.Clone()));
            }
        }
        else
        {
            for (int i = 0; i < beats.Count; i++)
            {
                Beat currentBeat = beats[i];

                if (currentBeat.bpm != bpm)
                {
                    bpm = currentBeat.bpm;
                    rowsBpm.Add(new SongRow(currentBeat.timestamp, bpm));
                }

                //if (recordingMode)
                rowsBeat.Add(new SongRow(currentBeat.timestamp));
            }
            for (int i = 0; i < doubleBeats.Count; i++)
            {
                Beat currentBeat = doubleBeats[i];
                Beat nextBeat    = null;
                if (Settings.instance.patternUseHold && i < doubleBeats.Count - 1)
                {
                    nextBeat = doubleBeats[i + 1];
                }

                int[] currentActiveLanes = getActiveLanes(currentBeat, patternLanes);//get beats with chroma feature

                if (Settings.instance.patternUseHold && nextBeat != null && nextBeat.timestamp - currentBeat.timestamp < Settings.instance.patternHoldMinTimestamp)
                {
                    //Debug.Log("*************************************grehgerthgthtr " + Settings.instance.patternUseHold);
                    int[] nextActiveLanes = getActiveLanes(nextBeat, patternLanes);

                    for (int l = 0; l < AssetManager.MAX_LANES; l++)
                    {
                        if (currentActiveLanes[l] == 0)
                        {
                            finalActiveLanes[l] = 0;
                        }
                        else
                        if (finalActiveLanes[l] > 0 && currentActiveLanes[l] == 1)
                        {
                            finalActiveLanes[l] = 2;
                        }
                        else
                        if (currentActiveLanes[l] == 1 && nextActiveLanes[l] == 1)
                        {
                            finalActiveLanes[l] = 2;        //hold
                        }
                        else
                        if (currentActiveLanes[l] == 1)
                        {
                            finalActiveLanes[l] = 1;
                        }
                    }
                    //Debug.Log("BeatCurr comparison " + showActiveLanes(currentActiveLanes));
                    //Debug.Log("BeatNext comparison " + showActiveLanes(nextActiveLanes));
                }
                else
                {
                    finalActiveLanes = currentActiveLanes;
                }

                //Debug.Log("****BeatFinl comparison " + showActiveLanes(finalActiveLanes));
                rowsBox.Add(new SongRow(currentBeat.timestamp, (int[])finalActiveLanes.Clone()));
            }
        }
    }