176
Some
Programming
Techniques
3.
Duration
selects
how
long
the
note
is
played.
The
values
in
the
duration
position
can
be
from
1,
which
equals
1
/
60th
of
a
second,
to
65535,
which
is
more
than
18
minutes.
You
can
also
use
decimal
numbers,
variables,
or
calculations
as
duration
values
but
only
their
integer
part
will
be
used.
Use
this
formula
to
figure
duration
value:
Duration
value
=
time
in
seconds
x
60
When
you
are
programming
a
song,
the
durations
of
all
notes
are
relative
to
the
whole-note
duration
you
choose.
After
you
select
the
duration
value
for the
whole
note,
other
note
duration
values
are
determined
by
fractions
of
the
whole-
note
value.
In
this
program,
voices
1
and
2
are
used
simultaneously
to
play
two-voice
harmony.
Although
a
frequency
value
of
zero
does
generate
a
sound,
this
pro
gram
uses
a
value
of
zero
to
mean
a
rest
(no
sound).
Example:
10
VOL8
20
DIMN1%(66),N2%(66)rDl%(66),D2%(66)
30
1=0
40
REArai%(I)fDl%(I):IFNl%(I)<0TOEN60
50
1=1+1:GOTO40
60
T1=I:I=0
70
READN2%(I),D2%(I):IFN2%(I)<0THEN90
80
1=1+1:GOTO70
90
I1=-1:I2=-1
100
IFDl>0mENl30:ELSESOUNDl,Nl,0
110
11=11+1:IFIKT1THEND1=D1%
(II)
:Nl=Nl%(Il)
:ELSE180
120
IFNl>0THENSOUNDl,Nl,300
130
IFD2>0THEN160:ELSESOUND2,N2,0
140
I2=I2+1:D2=D2%(I2):N2=N2%(I2)
150
IFN2>0THENSOUND2,N2,300
160
D1=D1-1:D2=D2-1
170
FORI=0TO80:NEXT:GOTO100
180
VOL0
190
DATA0,1,685,1,770,1,810,1
200
DATA798,1,685,1,798,1,834,1
210
DATA810,2,854,2,755,2,854,2
220
DATA770,1,685,1,770,1,810,1
230
DATA798,1,685,1,798,1,834,1
240
DATA810,2,770,2,0,4
250
DATA0,1,854,1,810,1,854,1
260
DATA770,1,810,1,685,1,739,1
270
DATA704,2,770,2,834,2,864,2
280
DATA864,1,834,1,798,1,834,1
290
DATA739,1,798,1,643,1,704,1
300
DATA685,2,739,2,810,2,854,2
310
DATA854,1,810,1,770,1,810,1
320
DATA704,2,834,2,834,1,798,1
330
DATA739,1,798,1,685,2,810,2