Exemple #1
0
    static bool IgnoresSpecialMode2(string blockType)
    {
        print(blockType);
        RhythmType t = Resources.Load <GameObject>(blockType).GetComponent <RhythmObject>().Type;

        return(t == RhythmType.Misc);
    }
Exemple #2
0
 // Used to create rhythms using AI algorithms.
 public Rhythm(Dictionary <int, int> _rhythmStructure, List <bool> _ignoreClaps)
 {
     this._rhythmStructure = _rhythmStructure;
     this._ignoreClaps     = _ignoreClaps;
     _isComputerGenerated  = true;
     _rhythmClass          = RhythmClass.GENERAL_RHYTHM;
     _rhythmType           = RhythmType.GENERAL_CLAPS;
 }
Exemple #3
0
        // Combine two different rhythms.
        public void ConcatenateRhythm(Rhythm anotherRhythm, int timeInBetween)
        {
            Rhythm rhythm = ConcatenateRhythm(this, anotherRhythm, timeInBetween);

            _rhythmStructure     = rhythm._rhythmStructure;
            _ignoreClaps         = rhythm._ignoreClaps;
            _isComputerGenerated = rhythm._isComputerGenerated;
            _rhythmClass         = rhythm._rhythmClass;
            _rhythmType          = rhythm._rhythmType;
        }
Exemple #4
0
        public Rhythm()
        {
            _ignoreClaps         = new List <bool>();
            _rhythmStructure     = new Dictionary <int, int>();
            _isComputerGenerated = false;
            _rhythmType          = RhythmType.SIMILAR_CLAPS;
            _rhythmClass         = RhythmClass.RHYTHM_ONE;

            for (int index = 1; index <= 300; index++)
            {
                _ignoreClaps.Add(false);
                _rhythmStructure.Add(index * 1000, 1);
            }
        }
Exemple #5
0
    /// <summary>
    /// Checks how close the current frame is to the beat.
    /// </summary>
    /// <returns>A percentage of how close the current frame is to the beat.</returns>
    /// <param name="rhythmType">A type of rhythm to constrain the beat to.</param>
    public float PerfectTiming(RhythmType rhythmType = RhythmType.None)
    {
        float calcTempo = 60f / BPM;

        float val             = 2f;
        int   samplesInTempo  = (int)(music.clip.frequency * calcTempo);
        int   samplesPastBeat = music.timeSamples % (samplesInTempo);

        float t = ((float)samplesPastBeat / samplesInTempo);            // how far along we are in this beat (0..1)

        float quarterAccuracy = Mathf.Abs(2 * (t % 1) - 1);
        float eighthAccuracy  = Mathf.Abs(2 * ((t * 2) % 1) - 1);
        float tripletAccuracy = Mathf.Abs(2 * ((t * 3) % 1) - 1);

        float result = 0f;

        if (enableQuarter)
        {
            result = quarterAccuracy;
            if (rhythmType == RhythmType.Quarter)
            {
                return(result);
            }
        }
        if (enableEighth)
        {
            result = Mathf.Max(result, eighthAccuracy);
            if (rhythmType == RhythmType.Eighth)
            {
                return(result);
            }
        }
        if (enableTriplet)
        {
            result = Mathf.Max(result, tripletAccuracy);
        }

        return(result);
    }
Exemple #6
0
 // Categorize a rhythm class into different rhythm types.
 public RhythmType DetermineRhythmType()
 {
     if (_rhythmClass == RhythmClass.RHYTHM_ONE || _rhythmClass == RhythmClass.RHYTHM_TWO ||
         _rhythmClass == RhythmClass.RHYTHM_THREE)
     {
         _rhythmType = RhythmType.SIMILAR_CLAPS;
     }
     else if (_rhythmClass == RhythmClass.RHYTHM_FOUR || _rhythmClass == RhythmClass.RHYTHM_FIVE ||
              _rhythmClass == RhythmClass.RHYTHM_SIX)
     {
         _rhythmType = RhythmType.TWO_ALTERNATING_DISTINCT_CLAPS;
     }
     else if (_rhythmClass == RhythmClass.RHYTHM_SEVEN || _rhythmClass == RhythmClass.RHYTHM_EIGHT ||
              _rhythmClass == RhythmClass.RHYTHM_NINE || _rhythmClass == RhythmClass.RHYTHM_TEN ||
              _rhythmClass == RhythmClass.RHYTHM_ELEVEN || _rhythmClass == RhythmClass.RHYTHM_TWELVE)
     {
         _rhythmType = RhythmType.THREE_ALTERNATING_DISTINCT_CLAPS;
     }
     else
     {
         _rhythmType = RhythmType.GENERAL_CLAPS;
     }
     return(_rhythmType);
 }