コード例 #1
0
        /// <summary>
        /// Builds a scale.
        /// </summary>
        /// <param name="soundFiles">List of sounds to draw from.</param>
        /// <param name="scale">Scale type.</param>
        /// <param name="startIndex">Index of sound to start with.</param>
        public static Scale BuildScale(List <string> soundFiles, ScaleInfo scale, int startIndex)
        {
            Scale result = new Scale();
            int   i      = startIndex;

            try {
                while (i < soundFiles.Count)
                {
                    // Add root/octave
                    result.AddRoot(soundFiles[i]);

                    // Add second
                    i += scale.SecondInterval;
                    result.AddSecond(soundFiles[i]);

                    // Add third
                    i += scale.ThirdInterval;
                    result.AddThird(soundFiles[i]);

                    // Add fourth
                    i += scale.FourthInterval;
                    result.AddFourth(soundFiles[i]);

                    // Add fifth
                    i += scale.FifthInterval;
                    result.AddFifth(soundFiles[i]);

                    // Add sixth
                    i += scale.SixthInterval;
                    result.AddSixth(soundFiles[i]);

                    // Add seventh
                    i += scale.SeventhInterval;
                    result.AddSeventh(soundFiles[i]);

                    // Go to next octave
                    i += scale.RootInterval;
                }
                return(result);
            }
            catch (ArgumentOutOfRangeException) {
                return(result);
            }
            catch (NullReferenceException n) {
                Debug.LogError(n);
                return(result);
            }
        }
コード例 #2
0
 /// <summary>
 /// Returns the scale with the given criteria.
 /// </summary>
 /// <param name="key">Musical key.</param>
 /// <param name="scale">Musical scale.</param>
 /// <param name="inst">Melodic instrument.</param>
 public Scale GetScale(Key key, ScaleInfo scale,
                       MelodicInstrument inst)
 {
     return(_scales[key][scale][inst]);
 }