Ejemplo n.º 1
0
        public static Pitch CreatePitch(string pitch)
        {
            // Since '#' can't be used in enums; I used 's' instead.
            pitch = pitch.Replace('#', 's');

            char octave;
            // Default to octave 4 in case none was provided
            int octaveNumber = 4;

            if (Char.IsDigit(octave = pitch[pitch.Length - 1]))
            {
                // Subtract 48 because '0' == 48.
                octaveNumber = (int)octave - 48;
                pitch        = pitch.Substring(0, pitch.Length - 1);
            }

            PitchClass pitchClass = PitchClass.CreatePitchClass(pitch);

            return(new Pitch(pitchClass, octaveNumber));
        }
Ejemplo n.º 2
0
 private Pitch(PitchClass pitchClass, int octave)
 {
     _pitchClass = pitchClass;
     _octave     = octave;
     _frequency  = FrequencyHelper.GetFrequency(pitchClass, octave);
 }