                                        




                              MUSIC COMPILER PROGRAM 
                                  (Version 3.3) 
                                  R. T. Russell 


   This  program  is  an amalgam of ideas from various sources but mainly from
   the 8080 program MUSIC on the CP/M users' group library disk 39.   The 8080
   program  allows  tunes  in  up  to  three  voices to be entered in a "human
   readable" form which are subsequently "scored" and then  played.   Its main
   limitation   is   that   whereas  the  entry  and  scoring  system  is very
   sophisticated the actual generation of the notes  is  primitive, consisting
   of  toggling  the INTE line of the 8080.  No control of volume or waveshape
   is possible.  Another  problem  is  that  it  uses  a  peculiar hexadecimal
   notation for the notes of the scale rather than the familiar A-G.  This Z80
   music  program  is an attempt to adopt the good ideas from the 8080 program
   and combine them with a playing routine capable of four simultaneous voices
   whose waveforms (and therefore, to some degree, volume) can be selected and
   changed  throughout  the  duration  of  a  tune.   At  the  same  time  the
   opportunity  has  been taken to improve the notation somewhat.  Despite its
   similarities to the 8080 program the  code  is  entirely  original  and was
   written  in  Z80 assembly language.  It will NOT run on an 8080 or 8085 and
   cannot be modified to do so!

   The music is entered  with  line  numbers  like  BASIC,  making  subsequent
   changes  and  additions  straightforward.  After the music has been entered
   the score is compiled (SCORE command) and then played (PLAY  command).  The
   SCORE  command  is  so  fast  that  it  is not really necessary to save the
   compiled data, therefore the SAVE and  LOAD  commands  work  only  with the
   'human' version of the music in ASCII.  Once the program is playing a piece
   of  music, it can be interrupted by pressing ESCape but it will only return
   to command level at the end of the next "part" of the  tune.   If necessary
   the  processor  may  be  reset and the program entered at 100H; the program
   will not re-initialise and the music will not be lost.

   Files created by this program are given the extension .MUS and are  in  SOL
   cassette format, as the main source of tunes was people with cassette-based
   systems!.  The .MUS files are therefore not true ASCII and cannot be edited
   or printed.  To print a tune simply use the CTRL/P function and LIST it.

   To run the program bring up CP/M and type:

                 MUSIC<carriage return>

   The system will respond:

                 Music Compiler Version 3.3
                 (C) Copyright R.T.Russell 1982
                 >

   Alternatively  a  list  of  tune names can be entered after MUSIC, in which
   case these tunes will be played immediately.





                                                                       Sheet 1




                                        




   The following commands are valid after the prompt (>):

   APPEND filename  Load the specified tune and append it to the  end  of  the
                    tune  in memory (if any).  The resulting composite tune is
                    renumbered before returning to command level.

   EDIT nnnn        The specified line is printed to the screen and edit  mode
                    is  entered.   In this mode CTRL/I is cursor right, CTRL/H
                    is cursor left, CTRL/A is insert character  and  CTRL/E is
                    delete   character.   Editing  is  terminated  by carriage
                    return. To abort edit mode without any changes to the line
                    type ESCape.

   FILES afn        Lists the disk directory.  If afn is omitted then all .MUS
                    files are listed.

   LIST             LIST the current tune.
   LIST nnnn        LIST line nnnn in the current tune.
   LIST ,nnnn       LIST the current tune up to and including line nnnn.
   LIST nnnn,       LIST the current tune from line nnnn to the end.
   LIST nnnn,mmmm   LIST the current tune from lines nnnn to  mmmm  inclusive.

   LOAD filename    Load the specified tune from disk.

   NEW              Clear the current tune from memory.

   PLAY             Score  (if  necessary)  and  play  the  tune  currently in
                    memory.
   PLAY filename    Load the specified tune, score it and play it.  If a  list
                    of tunes is entered, separated by spaces, then these tunes
                    are played in sequence.

   RENUMBER         Renumber  the  lines  of the tune starting at line 100 and
                    incrementing in tens.
   RENUMBER nnn     Renumber the tune, starting at line nnn  and  incrementing
                    in tens.
   RENUMBER nnn,mm  Renumber  the  tune, starting at line nnn and incrementing
                    by mm.

   SAVE filename    Save the current tune to disk.

   SCORE            SCORE (compile) the current tune in memory.  If  an  error
                    is  detected the offending line is displayed with a marker
                    to the point where the error was found.
   SCORE nnnn       Score the current tune  starting  from  line  nnnn.   This
                    command  is  useful during the writing of a tune when only
                    one section needs to be heard.

   SOUND data       Score and immediately play the given tune data.

   All commands can be abbreviated to one or two letters followed  by  a  full
   stop.  For  example, L.  is equivalent to LIST; LO.  is equivalent to LOAD.




                                                                       Sheet 2




                                        




   TUNE CONSTRUCTION

   Tunes consist of numbered lines, each of which normally  corresponds  to  a
   musical  bar.  Each line consists of a sequence of single character symbols
   plus numeric values and modifiers.  Note DURATION is signified by a decimal
   value (e.g.   12=quaver,  24=crotchet);  all  subsequent  notes  have  this
   duration  (unless  modified  to  a  dotted  note or triplet) until the next
   duration is given.  Notes themselves are signified by the  usual alphabetic
   notation  (ABCDEFG),  plus  the  following  modifiers which follow the note
   character. More than one modifier per note is permitted.

      Note
    Modifier      Meaning

       #      ACCIDENTAL SHARP
       b      ACCIDENTAL FLAT
       &      ACCIDENTAL FLAT (alternative)
       %      ACCIDENTAL NATURAL
       +      Up an octave
       -      Down an octave
       .      DOTTED NOTE (duration 1.5 times normal)
       :      TRIPLET (duration 2/3 normal)
       '      Short gap before next note
       "      Long gap before next note
       ,      Staccato

   Accidentals are effective until the end of the current line,  but  only  in
   the current voice.  An accidental in one voice has no effect on the others.


   SYMBOL MODIFIER

   ;      None         All  characters on the rest of the line are ignored.  A
                       REMARK line.

   P      Letter (A-Z) Define beginning of part identified  by  the  modifier.
                       Any previous part is ended.  If the part was previously
                       defined, the old definition is lost.

   R      Letter (A-Z) Repeat the part named by the modifier.

   V      Digit (1-4)  All of the notes following belong to the voice named by
                       the modifier.

   W      Digit (0-9)  Select  the  specified  waveform  to the current voice.
                       The change takes place at the start of the next part or
                       repeat.   Waveform  0  is  silence;   waveform   9   is
                       unallocated  and  may be user-defined, its table starts
                       at 1500H.

   <      Number       All the notes following are transposed down the  number
                       of semi-tones specified by the modifier (decimal).




                                                                       Sheet 3




                                        




   >      Number       All the notes following are transposed up the number of
                       semi-tones specified by the modifier.

   T      None         All  notes  following  are  assumed to be in the treble
                       clef.

   S      None         All notes following are assumed to be in the bass clef.

   K      Digit Char   Key signature is defined by the  number  of  sharps  or
                       flats  as  given  in  the modifier, e.g.  K2#.  If this
                       symbol is omitted the key defaults to C-MAJOR (K0).

   X      None         Terminate the tune.  All subsequent lines are  ignored.

   =      Number       Set tempo to the decimal value given.  The change takes
                       place  at  the  start of the next part or repeat.  Note
                       that the larger the number, the  slower  the  tempo (!)
                       and  that the maximum value allowed is dependent on the
                       processor clock frequency.

   \      None         Continuation character, if put at the  end  of  a  line
                       then   the   next   line  is  used  as  a continuation.
                       Otherwise each line is assumed to represent one bar.

   $                   Rest for duration previously defined.  A "dotted"  rest
                       is permitted.

   [      Text         The  characters following the square bracket, up to the
                       end of the line, are printed to the screen at the start
                       of the next part or repeat, when the  tune  is  played.
                       This  allows  you  to put words on the screen while the
                       tune is playing although a short pause in the  music is
                       inevitable  while this happens.  Control characters may
                       be incorporated in the text.

   !      Number       A machine-code  subroutine  at  the  specified  address
                       (decimal)  is  called.   This allows special effects to
                       accompany the music.  Use this  facility  with  care as
                       specifying the wrong address, or forgetting to load the
                       subroutine beforehand, will result in a crash!

   *      Command      Execute  the  specified command.  A tune can be made to
                       play continuously by making the last line *PLAY.  Also,
                       several tunes can be played in sequence if  their  last
                       lines  consist  of *PLAY filename where the filename is
                       that of the next tune in the sequence.










                                                                       Sheet 4




                                        




                               MUSICAL NOTE SYMBOLS 
                                       D++
                                   -- C++ --
                                     B+
                                 -- A+ --
                                   G+
                ----------------- F+ -
                                 E+
                --------------- D+ ---
                TREBLE         C+
                ------------- B ------
                 CLEF        A
                ----------- G --------
                           F                  F+
                --------- E ----------    -- E+ --
                         D                  D+
                     -- C --  MIDDLE C  -- C+ --
                       B-                 B
                   -- A- --  ----------- A ----
                     G-                 G
                             --------- F ------
                                      E    BASS
                             ------- D --------
                                    C      CLEF
                             ----- B- ---------
                                  A-
                             --- G- -----------
                                F-
                            -- E- --
                              D-
                          -- C- --
                                   EXAMPLE TUNE 

     100  ;CODED BY R.T.RUSSELL, 16-02-1981
     110  [  The Coventry Carol
     120  K2b =160
     130  PA
     140  T V1 24GGF#  V2 24DDD    S V3 24BBA      V4 24GB-D
     150  T V1 48G24B  V2 48D24D   S V3 48G24G     V4 48B24G
     160  T V1 24AAG   V2 24DDD    S V3 24AAB      V4 24F#F#G
     170  T V1 48F#.   V2 48D.     S V3 48A.       V4 48D.
     180  T V1 24GAB   V2 24B-FF   S V3 24GC+B     V4 24EED
     190  T V1 24C+48A V2 24E48D   S V3 48G24F#    V4 24C48D
     200  T V1 48G24D+ V2 48B-24D  S V3 48G24F     V4 48G24B-
     210  T V1 48C+24B V2 48E12ED  S V3 24E.12F24G V4 24C.12D24E
     220  T V1 48A24B  V2 48C24D   S V3 48A24F     V4 48F24B-
     230  T V1 48A24G  V2 48C12B-C S V3 24E.12F24G V4 24C.12D24E
     240  T V1 48F#.   V2 48D.     S V3 48A.       V4 48D.
     250  T V1 24GF#G  V2 24DDD    S V3 24D+C+B    V4 24BAG
     260  T V1 24C+48A V2 48C24D   S V3 48G24F#    V4 48E24D
     270  T V1 48B%.   V2 48D.     S V3 48G.       V4 48G-.
     280  PB  50$ RA




                                                                       Sheet 5




                                        




                                   MUSICAL KEYS 


   For the musically ignorant, and that includes me, here is  a  list  of  the
   different musical keys and their machine notation:


          MAJOR KEY       NOTATION        MINOR KEY

          Cb major          K7b           Ab minor
          Gb major          K6b           Eb minor
          Db major          K5b           Bb minor
          Ab major          K4b           F minor
          Eb major          K3b           C minor
          Bb major          K2b           G minor
          F major           K1b           D minor
          C major           K0            A minor
          G major           K1#           E minor
          D major           K2#           B minor
          A major           K3#           F# minor
          E major           K4#           C# minor
          B major           K5#           G# minor
          F# major          K6#           D# minor
          C# major          K7#           A# minor



                              HARDWARE CONFIGURATION 


   The  MUSIC  program  requires  an  8-bit  parallel  output  port to which a
   digital-to-analogue convertor is connected.  The output of this  DAC should
   be  connected  to  an amplifier and loudspeaker, preferably via a good low-
   pass filter with a cutoff frequency of about 4.5 kHz.  A certain  amount of
   audible quantisation noise is inevitable.

   To  configure  the  program  for the appropriate port address and processor
   clock frequency, a SETUP utility  is  provided.   When  run,  this requests
   certain information about the system and produces a HEX file containing the
   relevant  data.   This  HEX  file  must  be  incorporated into your copy of
   MUSIC.COM using DDT or ZSID, as follows:

              A>DDT MUSIC.COM<return>
              -ICONFIG.HEX<return>
              -R<return>
              -^C
              A>SAVE 23 MYMUSIC.COM<return>


                                                                           RTR






                                                                       Sheet 6




                                        




                                                                                                                                                                                                             