Music Composer Program
A series that focuses on using the popular microcomputers for making music.
The previous issues of Electronics and Music Maker have described how the Sharp MZ-80K microcomputer can be programmed to play music. Regular readers will recall that the MZ-80K can be programmed from BASIC over a three octave range with the user selecting the note pitch and length. Using this simple programming method almost any notes can be transposed to play BASIC e.g. MUSIC 'CDEFGAB¯C' will play the scale of C major. Examples have already been published in E&MM of complete tunes with multiple tempos and a wide variety of notes which can be programmed in just a few lines of BASIC.
The computer can also be programmed to generate its own music and the program published this month incorporates this interesting feature. The program is quite short, taking only 2503 bytes of memory and can therefore be run on any MZ-80K regardless of its memory size. This program is longer than those previously published, so care and time must be taken to ensure that it is entered correctly. Remember that it is possible to enter a part of the program and save that section on to a cassette if you run out of time to enter the whole program at once. It is then easy to load this first section at a later date and then enter the remaining lines to complete the program. It is in any case good practice to save sections of the program as you enter them — there is nothing more frustrating than entering a 300 line program and to see it disappear in front of you because another member of the family has accidentally unplugged the micro! In the writer's home area there tends to be a few dips in the mains supply every other day which does not normally bother the Sharp but if the break is more than just a flicker and lasts more than a second then all the entered lines will disappear. Saving sections as you enter them is an excellent insurance against losing entire programs due to momentary mains failures.
The Composer Program generates music, either spontaneously creating tunes with the tempo, timing and range entirely selected by the micro or creating music to parameters set by the user. The program plays the scales in line 4 the moment it is run and then requests the user to enter S for a spontaneous tune or R which allows the user to select the tempo etc. If the user enters S, the MZ-80K takes a few seconds to silently compose a tune from the data in lines 11 to 17, select an Opus number, and will then print this on the screen along with the note durations it has chosen. A graphic display then shows the range of notes which are played and at the end of the piece the user has the option of hearing it again or going on to another composition. The spontaneous tunes are produced by the lines of the program which ensures that the notes are melodic and harmonically related to a certain degree.
The user can also set the parameters for the tune by selecting R and entering his requests. The screen display will ask for a tempo between one and seven (the fastest), a rhythm between one and five and the number of repetitions of a phrase. One further parameter can be set by the user and this number controls the effect — entering between one and six will create musical tunes, 7 to 19 selects electronic sounding tunes and numbers above 20 produce what can only be described as very modern 'cosmic' effects. Once the above selections have been entered on the keyboard the MZ-80K composes the music in a few seconds keeping to the parameters chosen by the user. The musical composition is again drawn graphically on the screen and then played through the speaker. The tunes thus created can be repeated over and over again and if a slow tempo number is selected it is quite easy to follow the notes played on the display.
It is hoped that users get a great deal of fun from this month's program and some recorded examples are given on E&MM demo cassette No. 2. Correspondence suggests that many readers were amused by the range of sounds effects detailed in issue 1 and several letters have commented on the morse tutor described in issue 2. A forthcoming article will also describe a light pen which can be used to draw on the screen and to play notes from music shown on the MZ-80K screen.
Feature by Graham Knight
mu:zines is the result of thousands of hours of effort, and will require many thousands more going forward to reach our goals of getting all this content online.
If you value this resource, you can support this project - it really helps!