comp.lang.ada
 help / color / mirror / Atom feed
* Simple Case Study in Types. Chords.
@ 1999-11-16  0:00 G
  1999-11-20  0:00 ` Simon Wright
  0 siblings, 1 reply; 7+ messages in thread
From: G @ 1999-11-16  0:00 UTC (permalink / raw)


  With the following code fragments, I am not
sure if I constructed the types in [Chord_Definition.ads]
such that they actually mean what I think they do.
(I have not worried about keys because that is unneccessary
and I am not planning on learning musical software design -
this is an exercise in type-casting and accessing records, for me).
  Please look through this brief code.  The [Chord_List]
contains thirteen elements to account for twelve semi-tones
and the octave (13th).  If I was to assign a [Major_Chord] variable
as an instance of  record [Chord_Fragment] I would need to define
the [Chord_List] array as containing the [one], [four] and [eight]
elements of type Twelve_Tone.
  Allowing that I have got my arrays and things in the right places
(even if they don't mean quite what I think they do), what small
ada code allows me to assign such a value to a variable
[Major_Chord] ?


--------------------------------
-- Chord_Definition.ads
-- a specification for a package
-- which defines chords
--------------

package Chord_Definition is

  type chord is abstract tagged null record;

  type Twelve_Tone is
  -- Thirteen because that allows the octave.
  (One, Two, Three, Four,
    Five, Six, Seven, Eight,
    Nine, Ten, Eleven, Twelve, Thirteen);

  type Chord_List is array (1..13) of Twelve_Tone;

  type Chord_Fragment is new Chord with
  record
    Current_Chord : Chord_List;
  end record;

  -- type Chord_Access is access Chord;
  -- (not sure about access types yet)

end Chord_Definition;
----------------------


------------------------------
-- Chord_Progression.adb
-- a simple procedure :
---------------------
with Chord_Definition;

procedure Chord_Progression is

   -- A sequence for compositional chord sequences.
  type Chord_Sequence is array
  (1..Chord_Definition.Chord_List'Last)
  of Chord_Definition.Chord_Fragment;

  -- I think I bodged that (?) with Chord_Sequence
  -- because I wanted to be able to define
  -- a sequence of variable chord_fragments.

  -- assign major_chord, minor_chord, etc. , but how ?
begin
  --- (...do stuff with chords...)
end Chord_Progression;

--------------------------------------------





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1999-12-11  0:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-16  0:00 Simple Case Study in Types. Chords G
1999-11-20  0:00 ` Simon Wright
1999-12-04  0:00   ` Richard D Riehle
1999-12-06  0:00     ` Robert Dewar
1999-12-06  0:00       ` David W. Glessner
1999-12-11  0:00         ` tmoran
1999-12-06  0:00       ` Richard D Riehle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox