[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sound-makes only one click?



In article <362f97f1.4898977@news.bright.net>,
Jm <j_2001_m@dejanews.com> wrote:
>Thanks everybody for the advice, I put in a delay and it makes sound
>now. I'm trying to write a SHORT program that will allow basic to make
>different tones (whatever frequency needed) by calling it. Does a
>freeware one already exist?

Unless you need something sophisticated, they're pretty simple to write.
Here's an example:

0300:A6 06    LDX 06
0302:A0 00    LDY #00
0304:CA       DEX
0305:D0 05    BNE 030C
0307:AD 30 C0 LDA C030
030A:A6 06    LDX 06
030C:88       DEY
030D:D0 F5    BNE 0304
030F:C6 07    DEC 07
0311:D0 F1    BNE 0304
0313:60       RTS

Call it like this:

     10  POKE 6,FR: REM Frequency
     20  POKE 7,DU: REM Duration
     30  CALL 768

The highest frequency is 1, the next-to-hightest is 2, and so on.  Frequency
0 is treated as if it were 256, so 0 is the lowest frequency.  Likewise 1
is the shortest duration, and 0 is the longest.  I tried to make the
duration more or less uniform for each frequency, but higher-frequency
tones may last longer than lower-frequency tones with the same duration
number.

This will probably be more useful for sound effects than for music, since
no attempt has been made to match frequency numbers to musical notes.

               - Neil Parker

P.S.  The above code was composed in my UNIX editor, without access to
a real Apple II to test it on (I'm in my office, and my Apple II is at
home).  Use with appropriate caution.
-- 
Neil Parker, nparker@ssil.uoregon.edu, nparker@axis.llx.com,
http://axis.llx.com/~nparker/     (Note new addresses and home page!)

Unsolicited commercial e-mail is not welcome, and will be discarded unread.