MINSTREL
by J.W. Casson
from ZX Computing Oct/Nov.1984

Budding Beethovens begin here with Lancastrian
J W Casson's 16K computer composer program.


Although limited, this program will provide plenty of scope
for creative musicians to write and. play melodies of the
kind usually played on flute, tin whistle etc.

The two biggest limitations are:

1. You can only play one note at a time; and
2. You cannot play slurred notes (due to the first limitation).

Perhaps readers with sound boxes and 48K machines can adapt
the program to overcome these problems. However, the main
purpose of the program is to allow musical input into any
Spectrum using standard musical notation.


Operation

* KEY - To tell the computer which note to play - sharp or
flat. The computer will first ask "Sharps?" and expect to
enter, one by one, the letters of the notes to be played
sharp or, if none, just press ENTER.

Next the computer will ask "Flats?" and expect the letters
of the notes which it must play flat, again press ENTER if
there are none.

* TIME SIGNATURE - To tell the computer how many beats there
are in a bar.

When playing the tune the first note in each bar is played
slightly longer than it's written value to emphasise the
note. After the key inputs have been completed the computer
will prompt "Time as a fraction". Enter the required time,
3/4 for a waltz, 3/8 for a jig, 4/4 for com- mon time etc.
The screen should now look like fig. 1.

* CHARACTER SELECT - The musical characters of the tune can
now be entered, the options are:

REST        - a period of silence
FLAT NOTE   - a note 1 semitone below key note
NOTE        - a note played as written in the key
SHARP NOTE  - a note 1 semitone above key note

Normally the NOTE flag will flash.

All the options can only be selected from the NOTE mode, to
select REST hold R until the indicator flashes, to get back
to NOTE mode from REST hold key N.

To select SHARP or FLAT hold down S or F as required, to
cancel these hold down the opposite key to the option in
force; ie. if in Sharp mode hold key F to cancel.

* DURATION is selected by moving the duration cursor by
using the 6 and 7 keys to move it up and down the menu. When
the correct duration has been chosen press enter. If the
character is a REST then it will be drawn and the computer
returns to character select mode.

* PITCH selection - a cursor will now appear by the side of
the stave and this can be moved up and down again by using
the 6 and 7 keys until you reach the position you require.
When you press ENTER the correct note will be drawn in
position on the stave and the computer will return to
character select mode.

While in the character select mode you also have the
following options:

"P" Play tune from start to finish.

"K + number" List from note of the number given to finish

CAPS + "0" Delete the last note entered.

When in PITCH select you can press "D" to return to
character select mode.


Entering the program

The machine code to scroll the stave left must be entered
first, this is held in a line 1 REM and the REM must be
followed by 32 characters. [The printed listing expects only
31 bytes for the machine code (9900 FOR n=0 TO 30) - and
there are only 27 bytes in the DATA statement! JimG.] Enter
the short scroll left program and RUN it. To check that it
works type: PRINT AT 9,10;"ABC": FOR i=1 TO 9: RANDOMIZE USR
sc: NEXT I and press ENTER; the letters ABC should appear
and move to the left. If all is OK then delete one by one
lines 2, 9900, 9910, and 9920 - DO NOT REMOVE LINE 1! If it
doesn't work check the program - especially the DATA - and
re-run and check.

Now enter the main listing and let loose your musical
talent.


Program notes

1          USR machine code routine to scroll the centre
           of the screen (lines 8-15) left
2-160      Initialise variables, set Caps Lock on
300-370    Character input loop
400-490    Pitch select input loop
500-550    Draw note, scroll screen left
1000-1230  Input sharps, flat and time sig.
1500-1509  Draw start of stave & treble clef
1510-1541  Draw lines of stave
2010-2500  Compile tune into beeps and pauses
2500-2530  Play tune
3000-3099  Coordinates for drawing rests, notes, bar lines, etc.
4000-4060  Draw Rest, scroll left
8500-9000  Coordinates listing of tune
9000-9560  Draw note/rest subroutines


Variables

Tim      - No. of whole notes in a bar
BA       - No. of whole notes currently in the bar
T(4,100) - Contains tune data as follows:
T(1,100) - Note or rest type and
T(2,100) - Pitch of note - both as entered by the operator
T(3,100) - Actual note or rest length and
T(4,100) - Actual pitch of note - both as compiled
N(1,19)  - Data to convert number to beep statement
S$(100)  - Control characters - Sharps, flats and barlines
R        - Rest binary variable
S        - Sharp binary variable
F        - Flat binary' variable
L        - Points to current character
C        - Cursor variable
FN I     - Converts INKEY$ to var. C
FN B     - Converts note type to duration of beep
FN P     - Converts T(2,L) to screen coordinate


--
Another Fine Product transcribed by:
Jim Grimwood (jimg@globalnet.co.uk), Weardale, England
--
