// Path: android/src/com/google/synthesizer/core/music/Note.java
// public class Note {
//   /**
//    * Determines the log frequency of a note in 12 tone equal temperament (12-TET).
//    * @param note - the note, a value from one of the constants in this class.
//    * @param octave - the octave of the note.
//    */
//   public static double computeLog12TET(int note, int octave) {
//     return FACTOR + ((((12 * octave) + (note - 9) + 1) - 49) / 12.0);
//   }
// 
//   /**
//    * Returns the note, or midi key, that corresponds to the given log frequency.
//    * @param logFrequency - the log frequency that corresponds to a note.
//    * @return - the nearest note to that frequency.
//    */
//   public static int getKeyforLog12TET(double logFrequency) {
//     return (int)(12.0 * (logFrequency - FACTOR) + 57.5);
//   }
// 
//   /**
//    * Returns true if the note is natural, i.e. not a sharp or flat.
//    * @param note - the note, a value from one of the constants in this class.
//    */
//   public static boolean isNatural(int note) {
//     return NATURAL[note % NATURAL.length];
//   }
// 
//   /**
//    * Returns a printable name for the given note.
//    * @param note - the note, a value from one of the constants in this class.
//    */
//   public static String getName(int note) {
//     return NAMES[note];
//   }
// 
//   // Note frequencies in 12-TET are defined relative to log2 of A4 (440Hz).
//   // There's no reason to redo the log conversion every time a frequency is computed.
//   private static final double FACTOR = Math.log(440.0) / Math.log(2.0);
// 
//   // Constants for each of the possible notes.
//   public static final int NONE = -1;
//   public static final int C = 0;
//   public static final int C_SHARP = 1;
//   public static final int D_FLAT = 1;
//   public static final int D = 2;
//   public static final int D_SHARP = 3;
//   public static final int E_FLAT = 3;
//   public static final int E = 4;
//   public static final int F = 5;
//   public static final int F_SHARP = 6;
//   public static final int G_FLAT = 6;
//   public static final int G = 7;
//   public static final int G_SHARP = 8;
//   public static final int A_FLAT = 8;
//   public static final int A = 9;
//   public static final int A_SHARP = 10;
//   public static final int B_FLAT = 10;
//   public static final int B = 11;
//   
//   // Constants for intervals between notes.
//   public static final double HALF_STEP = 1.0f / 12.0f;
//   public static final double WHOLE_STEP = 1.0f / 6.0f;
//   public static final double OCTAVE = 1.0f;
// 
//   // A simple map of which notes are natural.
//   private static final boolean[] NATURAL = {
//       true, false, true, false, true, true, false, true, false, true, false, true };
// 
//   // A displayable name for each note.
//   private static final String[] NAMES = {
//       "C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab", "A", "Bb", "B"
//   };
// }


import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.util.Log;
import com.google.synthesizer.core.music.Note;
  // Is each keys currently being pressed?
  protected boolean[] pressed_;

  // The area this key occupies.
  protected Rect rect_;

  // Objects for subclasses to use for painting, just so they don't have to reallocate every time.
  protected Paint fillPaint_;
  protected Paint strokePaint_;

  protected Rect sideStartRect_;
  protected Rect sideEndRect_;
  protected Rect topRect_;

  protected PointF gradientStartPoint_;
  protected PointF gradientEndPoint_;

  private Paint sideStartPaint_;
  private Paint sideEndPaint_;
  private Paint topPaint_;
  private Paint shaderPaint_;

  private Path sideStartPath_;
  private Path sideEndPath_;
  private Path topPath_;

  // Constants to map notes onto the keys.
  protected static final int WHITE_KEYS[] = {
      Note.C, Note.D, Note.E, Note.F, Note.G, Note.A, Note.B };
  protected static final int BLACK_KEYS[] = {
// Path: android/src/com/google/synthesizer/core/music/Note.java
// public class Note {
//   /**
//    * Determines the log frequency of a note in 12 tone equal temperament (12-TET).
//    * @param note - the note, a value from one of the constants in this class.
//    * @param octave - the octave of the note.
//    */
//   public static double computeLog12TET(int note, int octave) {
//     return FACTOR + ((((12 * octave) + (note - 9) + 1) - 49) / 12.0);
//   }
// 
//   /**
//    * Returns the note, or midi key, that corresponds to the given log frequency.
//    * @param logFrequency - the log frequency that corresponds to a note.
//    * @return - the nearest note to that frequency.
//    */
//   public static int getKeyforLog12TET(double logFrequency) {
//     return (int)(12.0 * (logFrequency - FACTOR) + 57.5);
//   }
// 
//   /**
//    * Returns true if the note is natural, i.e. not a sharp or flat.
//    * @param note - the note, a value from one of the constants in this class.
//    */
//   public static boolean isNatural(int note) {
//     return NATURAL[note % NATURAL.length];
//   }
// 
//   /**
//    * Returns a printable name for the given note.
//    * @param note - the note, a value from one of the constants in this class.
//    */
//   public static String getName(int note) {
//     return NAMES[note];
//   }
// 
//   // Note frequencies in 12-TET are defined relative to log2 of A4 (440Hz).
//   // There's no reason to redo the log conversion every time a frequency is computed.
//   private static final double FACTOR = Math.log(440.0) / Math.log(2.0);
// 
//   // Constants for each of the possible notes.
//   public static final int NONE = -1;
//   public static final int C = 0;
//   public static final int C_SHARP = 1;
//   public static final int D_FLAT = 1;
//   public static final int D = 2;
//   public static final int D_SHARP = 3;
//   public static final int E_FLAT = 3;
//   public static final int E = 4;
//   public static final int F = 5;
//   public static final int F_SHARP = 6;
//   public static final int G_FLAT = 6;
//   public static final int G = 7;
//   public static final int G_SHARP = 8;
//   public static final int A_FLAT = 8;
//   public static final int A = 9;
//   public static final int A_SHARP = 10;
//   public static final int B_FLAT = 10;
//   public static final int B = 11;
//   
//   // Constants for intervals between notes.
//   public static final double HALF_STEP = 1.0f / 12.0f;
//   public static final double WHOLE_STEP = 1.0f / 6.0f;
//   public static final double OCTAVE = 1.0f;
// 
//   // A simple map of which notes are natural.
//   private static final boolean[] NATURAL = {
//       true, false, true, false, true, true, false, true, false, true, false, true };
// 
//   // A displayable name for each note.
//   private static final String[] NAMES = {
//       "C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab", "A", "Bb", "B"
//   };
// }


// Path: android/src/com/google/synthesizer/android/widgets/piano/PianoKey.java
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.util.Log;
import com.google.synthesizer.core.music.Note;

  // Is each keys currently being pressed?
  protected boolean[] pressed_;

  // The area this key occupies.
  protected Rect rect_;

  // Objects for subclasses to use for painting, just so they don't have to reallocate every time.
  protected Paint fillPaint_;
  protected Paint strokePaint_;

  protected Rect sideStartRect_;
  protected Rect sideEndRect_;
  protected Rect topRect_;

  protected PointF gradientStartPoint_;
  protected PointF gradientEndPoint_;

  private Paint sideStartPaint_;
  private Paint sideEndPaint_;
  private Paint topPaint_;
  private Paint shaderPaint_;

  private Path sideStartPath_;
  private Path sideEndPath_;
  private Path topPath_;

  // Constants to map notes onto the keys.
  protected static final int WHITE_KEYS[] = {
      Note.C, Note.D, Note.E, Note.F, Note.G, Note.A, Note.B };
  protected static final int BLACK_KEYS[] = {
      Note.C_SHARP, Note.E_FLAT, Note.NONE, Note.F_SHARP, Note.A_FLAT, Note.B_FLAT, Note.NONE };