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

* Re: Simple Case Study in Types. Chords.
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Wright @ 1999-11-20  0:00 UTC (permalink / raw)


G <Dizzy@interact.net.au> writes:

>   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.

Since I don't know what you think they mean (!), may I just suggest

>   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;

  -- Assuming that no Chord ever spans more than an octave, we can
  -- represent a Chord by indicating the Notes present in it
  type Chord is array (Twelve_Tone) of Boolean;




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

* Re: Simple Case Study in Types. Chords.
  1999-11-20  0:00 ` Simon Wright
@ 1999-12-04  0:00   ` Richard D Riehle
  1999-12-06  0:00     ` Robert Dewar
  0 siblings, 1 reply; 7+ messages in thread
From: Richard D Riehle @ 1999-12-04  0:00 UTC (permalink / raw)


In article <x7vogcpowyx.fsf@pogner.demon.co.uk>,
	Simon Wright <simon@pogner.demon.co.uk> wrote:

>  -- Assuming that no Chord ever spans more than an octave, we can
>  -- represent a Chord by indicating the Notes present in it
>  type Chord is array (Twelve_Tone) of Boolean;

This works fine for an equal-tempered scale such as that on a
pianoforte or fretted string instrument.  One of the beauties of
the violin family is the ability to play the subtle difference
between, say, an  G Sharp and an A Flat.  Of course, most of us
are accustomed to thinking that the sharp form of one note exactly
corresponds to the flat form of the next ascending note, so the
distinction is often unimportant.  There is also the problem of
Asian tones, some of which are slightly off from the Pythagorean
model.  

Richard Riehle




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

* Re: Simple Case Study in Types. Chords.
  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
  1 sibling, 1 reply; 7+ messages in thread
From: David W. Glessner @ 1999-12-06  0:00 UTC (permalink / raw)
  To: Robert Dewar

Robert Dewar wrote:
> 
> In article <829qci$ctj$1@nntp8.atl.mindspring.net>,
>   Richard D Riehle <laoXhai@ix.netcom.com> wrote:
> > the violin family is the ability to play the subtle difference
> > between, say, an  G Sharp and an A Flat.
> 
> That's misleading, it implies that there are still absolute
> values for G sharp and A flat, but the whole point of course
> is that these values vary depending on what key you are playing
> in, so it is not nearly as simple as that!

I'm not sure what you're getting at here.

I think Richard's point was that, except for equal temperament,
there is a limitation in using only 12 tones in a scale;
namely, you can't differentiate between, say, a sharped fifth
and a flatted sixth.  We normally think that G-sharp and A-flat
are the same, but "it ain't necessarily so."

Check out pages like
http://www.globetrotter.net/gt/usagers/roule/accord.htm
and http://www.rev.net/people/aloe/music/temperament.html
for more information.


Is anyone aware of any freely available Ada packages that can be
used to mess around with a sound card on a Win98 or Linux/Intel PC?

--
David




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

* Re: Simple Case Study in Types. Chords.
  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-06  0:00       ` Richard D Riehle
  0 siblings, 2 replies; 7+ messages in thread
From: Robert Dewar @ 1999-12-06  0:00 UTC (permalink / raw)


In article <829qci$ctj$1@nntp8.atl.mindspring.net>,
  Richard D Riehle <laoXhai@ix.netcom.com> wrote:
> the violin family is the ability to play the subtle difference
> between, say, an  G Sharp and an A Flat.

That's misleading, it implies that there are still absolute
values for G sharp and A flat, but the whole point of course
is that these values vary depending on what key you are playing
in, so it is not nearly as simple as that!


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Simple Case Study in Types. Chords.
  1999-12-06  0:00     ` Robert Dewar
  1999-12-06  0:00       ` David W. Glessner
@ 1999-12-06  0:00       ` Richard D Riehle
  1 sibling, 0 replies; 7+ messages in thread
From: Richard D Riehle @ 1999-12-06  0:00 UTC (permalink / raw)


In article <82fdjq$l0e$1@nnrp1.deja.com>,
	Robert Dewar <robert_dewar@my-deja.com> wrote:

>In article <829qci$ctj$1@nntp8.atl.mindspring.net>,
>  Richard D Riehle <laoXhai@ix.netcom.com> wrote:
>> the violin family is the ability to play the subtle difference
>> between, say, an  G Sharp and an A Flat.
>
>That's misleading, it implies that there are still absolute
>values for G sharp and A flat, but the whole point of course
>is that these values vary depending on what key you are playing
>in, so it is not nearly as simple as that!

Exactly.  I knew when I posted the original response you would
highlight the subtleties of this issue.

Richard
 




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

* Re: Simple Case Study in Types. Chords.
  1999-12-06  0:00       ` David W. Glessner
@ 1999-12-11  0:00         ` tmoran
  0 siblings, 0 replies; 7+ messages in thread
From: tmoran @ 1999-12-11  0:00 UTC (permalink / raw)


>Is anyone aware of any freely available Ada packages that can be
>used to mess around with a sound card on a Win98 or Linux/Intel PC?
  CLAW includes a package to handle Windows sound, including
dynamically creating a waveform in memory (the demo program plays a
tune while you can vary attack and harmonic content with two slider
bars).  The package doesn't do the MultiMedia stuff, but you can do
a lot.  Claw is freely available to anyone who wants to write a
check to RR Software.  Claw.Sounds is not part of the $0
downloadable version of Claw, however.
  Someone posted a package to do some of the Windows sound stuff
about a year ago - check dejanews.
  I have routines to control a SoundBlaster type card, including
handling the interrupts and DMA, but I wrote it for a 16 bit DOS
environment and it likely won't even run under tyrannical OSes like
Windows.  Send mail if you want it anyway (but I'll be out of town
next week).




^ 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