-- $Date: 2004/03/08 11:05:10 $
-- $Revision: 1.7 $
-- $Author: jcrocholl $
-- $Hash: 5fa170167eea6e538032a3a32865b0a4 $

-- This file was automatically created with ado.php.
-- Manual changes will be lost when it is updated.

package body Pitches is

   -- Constructor for instances.
   function Create
     (Step   : in Step_Enum-- The initial step.
      Alter  : in Integer;   -- The initial alter.
      Octave : in Integer)   -- The initial octave.
     return Pitch_Access     -- The newly created pitch.
   is
      Result : Pitch_Access := new Pitch;
   begin
      Result.Step := Step;
      Result.Alter := Alter;
      Result.Octave := Octave;
      return Result;
   end Create;

   -- Accessor to read the step of a pitch.
   function Get_Step
     (This : access Pitch-- The pitch to read from.
     return Step_Enum is   -- The step of that pitch.
   begin
      return This.Step;
   end Get_Step;

   -- Accessor to read the alter of a pitch.
   function Get_Alter
     (This : access Pitch-- The pitch to read from.
     return Integer is     -- The alter of that pitch.
   begin
      return This.Alter;
   end Get_Alter;

   -- Accessor to read the octave of a pitch.
   function Get_Octave
     (This : access Pitch-- The pitch to read from.
     return Integer is     -- The octave of that pitch.
   begin
      return This.Octave;
   end Get_Octave;

   -- Return the pitch position relative to middle C.
   function Get_Position
     (This : access Pitch-- The pitch object instance.
     return Integer is     -- Up or down from middle C.
   begin
      case This.Step is
      when C => return (This.Octave - 4) * 7;
      when D => return (This.Octave - 4) * 7 + 1;
      when E => return (This.Octave - 4) * 7 + 2;
      when F => return (This.Octave - 4) * 7 + 3;
      when G => return (This.Octave - 4) * 7 + 4;
      when A => return (This.Octave - 4) * 7 + 5;
      when B => return (This.Octave - 4) * 7 + 6;
      end case;
   end Get_Position;

end Pitches;