Example #1
0
        // Lee una fraccion de tiempo en beats y la transforma en subpasos
        // Ej: 1/2 -> 8
        int ReadTime(string line, ref int charNumber)
        {
            // 0 = leyendo el dividendo, 1 = buscando el carácter de fracción, 2 = leyendo el divisor, 3 = leido los dos
            int readingState = 0;
            // Declaramos el dividendo y divisor con sus valores por defecto
            int dividend = 0, divisor = 1;

            for (; charNumber <= line.Length; charNumber++)
            {
                switch (readingState)
                {
                case 0:
                    dividend     = ReadInt(line, ref charNumber);
                    readingState = 1;
                    break;

                case 2:
                    divisor      = ReadInt(line, ref charNumber);
                    readingState = 3;
                    break;

                default:
                    goto ReturnValue;
                }

                // Si no estamos buscando una fracción, devolvemos el valor actual
                if (charNumber >= line.Length || readingState != 1)
                {
                    goto ReturnValue;
                }

                switch (line[charNumber])
                {
                case charComment:
                default:
                    goto ReturnValue;

                case ' ':
                    continue;

                case charFraction:
                    readingState = 2;
                    break;
                }
            }

ReturnValue:
            return(Subdivision.GetSubsteps(dividend, divisor));
        }