[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Basic Programming Question -- Music
- Subject: Re: Basic Programming Question -- Music
- From: dempson@actrix.gen.nz (David Empson)
- Date: 2000/02/19
- Newsgroups: comp.sys.apple2
- Organization: Empsoft
- References: <88l0tf$vq9$1@nnrp1.deja.com>
- User-agent: MacSOUP/2.4.2
[Posted and E-Mailed as requested]
<xanfan5378@hotmail.com> wrote:
> I'd like to incorporate simple music into the program, but I don't
> remember the BASIC programming commands to do such a thing. Does anyone
> know them?
Yes. There is only one command in Applesoft BASIC which generates a
sound:
P=PEEK(49200)
(Or any other expression which involes a PEEK to read this memory
location.)
This produces an audible click of the speaker every time it is accessed.
You can generate a variety of low frequency buzzing sounds by varing the
rate at which you access this location.
If you want to get any real sounds, you have to use a machine code
support routine. Since machine code runs a lot faster than Applesoft,
it can read the speaker at a higher rate and with more precise timing
control, allowing proper tones to be generated.
The speaker only produces square waves (unless you access it so fast
that it doesn't have time to travel the full distance), so you will
never get particuarly good sound out of it.
> Also, was the Apple II limited to playing one note at a time, or could
> chords be included? (I think it was one at a time, but I may be wrong).
With the right tone generation routine it would be possible to generate
chords (by generating a waveform which has all the desired single tones
superimposed).
> And how difficult would it be to program speech into the program?
It has been done by some games, but the end result was not particularly
good. A speech synthesiser card like SAM (Software Automatic Mouth) is
a better bet.
--
David Empson
dempson@actrix.gen.nz
Snail mail: P O Box 27-103, Wellington, New Zealand