package sound;

/*
 * Open Source Software by http://www.Docjava.com
 * programmer: D. Lyon
 * e-mail: lyon@docjava.com
 * Date: Apr 29, 2002
 * Time: 12:39:06 PM
 */

public class Scales {
  private static int CHROMATIC[] = {
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  };
  private static int IONIAN[] = {
    2, 2, 1, 2, 2, 2, 1
  };
  protected static int HARMONIC_MINOR[] = {
    2, 1, 2, 2, 1, 3, 1
  };
  private static int GYPSY[] = {
    1, 3, 1, 1, 2, 1, 3, 1
  };

  public static void testPlayScale() {
    Utils.play(getScale(GYPSY, 64), 500);
    Utils.play(getScale(HARMONIC_MINOR, 32), 500);
  }

  /**

   * get a scale starting at any note,

   * in a given progression

   */
  public static int[] getScale(
      int progression[], int startNote) {
    int scale[] = new int[progression.length];
    for (int i = 0; i < progression.length; i++) {
      scale[i] = startNote + progression[i];
      startNote = scale[i];
    }
    return scale;
  }

  /**
   * start a prgression at any note and end and any note
   */
  public static int[] getScale(
      int progression[], int startNote, int endNote) {
    int scale[] = new int[endNote - startNote];
    for (int i = 0; i < scale.length; i++) {
      scale[i] = startNote + progression[i % progression.length];
      startNote = scale[i % scale.length];
    }
    return scale;
  }
}