From: G <Dizzy@interact.net.au>
Subject: Simple Case Study in Types. Chords.
Date: 1999/11/16
Date: 1999-11-16T00:00:00+00:00 [thread overview]
Message-ID: <3831283B.20807F08@interact.net.au> (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;
--------------------------------------------
next reply other threads:[~1999-11-16 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-16 0:00 G [this message]
1999-11-20 0:00 ` Simple Case Study in Types. Chords 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox