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

Re: BASIC music




On 01 Mar 2003 16:16:39 GMT dddddd0814@aol.com (Dddddd0814) wrote:

> 
> does anyone out there know where i can find a summary of programming codes to
> make music in BASIC on an apple iie? i remember once having a basic manual that
> gave appropriate commands and numerical values for each note, length of notes
> (whole notes, half notes,...), etc.
> it's for an art project i'm doing.... i would like to not have to go on ebay to
> buy an old apple manual, find out it's the wrong one, etc. plus my time is
> limited. let me know.
> 
> thanks!
> david
> 

Don't recall where I got this from, but it has all the info you'll need to make
some very rudimentary sounds:

<quote>

Ok here it is - the Applesoft BASIC routine for that CALL 770 tone
routine:

5 RESTORE
10 FOR L = 770 TO 790: READ V: POKE L,V: NEXT L
20 DATA 173,48,192,136,208,5,206,1,3,240,9
30 DATA 202,208,245,174,0,3,76,2,3,96
40 END

That's it - short & sweet. Just POKE 768,F where F is the frequency from 0
to 255, POKE 769,D where D is the duration from 0 to 255, and then CALL
770 to play the tone. Oh, heck with it - here's a frequency chart and a
duration chart for notes and piano music:

Octave 1

C - 255
C# or Db - 241
D - 227
D# or Eb - 214
E - 202
F - 191
F# or Gb - 180
G - 170
G# or Ab - 161
A - 152
A# or Bb - 143
B - 135

Octave 2 (middle)

middle C - 128
C# or Db - 121
D - 114
D# or Eb - 108
E - 102
F - 96
F# or Gb - 91
G - 85
G# or Ab - 81
A - 76
A# or Bb - 72
B - 68

Octave 3

C - 64
C# or Bb - 60
D - 57
D# or Eb - 54
E - 51
F - 48
F# or Gb - 45
G - 43
G# or Ab - 40
A - 38
A# or Bb - 36
B - 34

Duration Chart

Whole Note - 255
Dotted half note - 192
Half note - 127
Dotted quarter note - 96
Quarter note - 64
Dotted eighth note - 48
Eighth note - 32
Dotted sixteenth note - 24
Triplet - 21
Sixteenth note - 16

Note that you can't use rests with these codes - if you want a rest in the
music, in your music DATA statements, add a variable (such as -1) and have
the program check for these variables BEFORE playing a tone - if it is one
of these variables, have it run a rest routine, which may be just a simple
FOR ... NEXT loop such as:

REM *** T is the number of notes in the song contained in the DATA
statement(s). In this example, T = 7.

5 RESTORE
10 FOR L = 770 TO 790: READ V: POKE L,V: NEXT L
20 DATA 173,48,192,136,208,5,206,1,3,240,9
30 DATA 202,208,245,174,0,3,76,2,3,96
.
.
.
90 READ T
100 FOR X = 1 TO T
110 READ F,D
120 IF F < 0 THEN FOR Z = 1 TO 2 * D: NEXT Z: GOTO 190
130 D = D * 1
140 IF D > 255 THEN DU = D: FL = 1: D = 255
150 POKE 768,F
160 POKE 769,D
170 CALL 770
180 IF FL = 1 THEN FOR Z = 1 TO DU - 255: NEXT Z: FL = 0
190 NEXT X
199 END
1000 DATA 7: REM NUMBER OF NOTES
1010 DATA 128,64,96,64,76,64,64,64,-1,96,76,64,64,255

For this program, use the following values for rests:

Whole - 255
Half - 127
Quarter - 64
Eighth - 32
Sixteenth - 16

** The above programs were paraphrased from the excellent book "Applesoft
BASIC Subroutines & Secrets" by Jeanette and Dave Sullivan - you can find
these routines on pages 278-287. **

I hope this helps all of those who have been looking for this routine! -
Tony    :-)
JoeProES


-- 
Simon Williams
Luddite Technologies
http://www.luddite.ca