ZX Forum #04
19 ноября 1997 |
|
world of sound Spectrum - Chapter 5: The operator PLAY for music coprocessor AY- 3-8910 (AY-3-8912).
5. Operator PLAY With this chapter begins the book, dedicated music coprocessor AY3-8910 (or AY-3-8912), built-in ZXSpectrum 128, as well as in all its variations. When you turn on ZX-Spectrum 128 on-screen menu appears, offering a choice of a few points. They are all well described in [2], in our case, select 128 BASIC. In this mode, you become available operator PLAY, music service co-processor. In general, the format statement PLAY looks like this: PLAY A $ [, B $, C $, D $, E $, F $, G $, H $] where A $ ... H $ - character string specifying music program. Coprocessor itself uses to manage its three channels (A, B and C) only A $, B $ and C $. If you three channels a lot, you can only use two or even one, setting the appropriate number of strings (Empty string also indicates that channel is not used). The remaining lines (D $ ... H $) are designed to control musical instruments, which can be connected to the ZX-Spectrum 128 via MIDI-interface. All defined Thong performed simultaneously, which allows you to create complex and beautiful melodies. In Thong uses special commands. Dwell on them in detail. Notes do, re, MI, FA, SOL, LA, and SR denote the current octave lower case Latin letters, respectively, c, d, e, f, g, a and b (international standard). Notes of the next octave indicated by capital Latin letters C, D, E, F, G, A and B. For example, the operator PLAY "cdefgabC" lose range of C major. Halftones are given marks # (sharp) and $ (Flat) facing the note. For example, C sharp is written as # c, and B-flat - $ B. To play a scale in C minor, enter PLAY "cd $ efg $ a $ bC". Permissible to use a few sharps or flats in a row. For example, note d can be written as # # c. Length is determined by a number from 1 to 9, standing in front of the note (Table 3). Installed length applies to all subsequent notes and rests (see command &). By default duration is 5 (one quarter). In addition to traditional music, you may ask triplets. For this purpose, the number of 10 12. Notes triplets follow directly after the number. For example: PLAY "3fed & 11fed & fed" Triplets do not alter the established duration of notes. Besides the standard duration of notes you can use arbitrary. To do this in front of the note by the underscore character ("_") put several parameters defining the desired length. For example, a note to a duration of 3 / 8 (1 / 8 +1 / 4) can be written as follows: "3_5c". The duration of follow-up notes and rests specifies the last option in the bundle. Quite strange effects are obtained when connecting to the usual duration of notes and triplets (eg: "3_12cde"). Experiment with it. Pro recording music, like, everything. Now on commands: O - changed octave. Number of octaves must be a number from 0 to 8 following the team (default octave 5). Relevance command option O musical octave is given in Table. 4. Notice that the notes an octave below b 1 without a MIDI-interface will be played correctly. It is also important that although the maximum number is eight octaves, you are free to use the following - the ninth, denoting notes in capital letters. N - delimiter options. Used to separate the two numerical parameters from each other. For example, when you have to ask duration of the note immediately after the installation of an octave: "O4N5d". In essence, this team is overkill, because instead You can use the blank: "O4 5d". & - A pause. Pause time is set as well as the duration of notes (See above). For example: "6c & de3 & de". V - set the volume. Volume is given a number from 0 (minimum - off) to 15 (maximum). For example: "V10". The default volume is 15. W - programming effects. Sheet music can be played not only with a fixed volume, but also with all sorts of effects: decay, wavelets, etc. Nature of the effect given by the number from 0 to 7 in accordance with the Table. 5. Default set the effect of 0. X - time parameter is the sound effect. For the effects of 0 ... 3 parameter sets duration of action for 4 and 5 - a period 6 and 7 - halftime (see Table 5). Value parameter is chosen from a range of 0 ... 65535. The default setting is 65535. Effects are disabled at the end of thongs or when the volume (command V). The following program will demonstrate action of all the effects: 10 FOR A = 0 TO 7 20 PLAY "UX1000W" + STR $ A + "cdef &" 30 NEXT A Unfortunately, the music co-processor is only one envelope generator, so you will not be able to configure multiple channels for different effects simultaneously. Although the same effects you can use in multiple channels, with parameters of the envelope must be set only one of them, and the rest is enough to specify a command U (see above). T - the pace of execution. Given by the number of 60 to 240. By default pace, the team T120. You can only set the pace for the whole tune in Overall, therefore, it is defined only in string of channel A (in other channels of T team is ignored.) (.) - Repeat (reprise). Music phrase, bracketed, repeated twice. Permissible to use brackets in brackets (up to 4 attachments). Closing bracket without a corresponding opening will make a musical phrase repeated endlessly from the beginning of string. Use it For example, a bass and drum parts. H - Stop operator PLAY. Met this command in a string of any channel operator PLAY finished. Team used, for example, to exit the "looped" bass line, the end of the main melody. !. " - A comment. Used to insert explanatory. For example: PLAY "! SCALE:! CdefgabC". If after a string of comments in any commands not, then closing mark "!" set is optional. M - sets the mode channels. Each channel can play not only a pure tone, but also the so-called white noise. The distribution of modes is given a number from 1 to 63, determined by the sum of the codes appropriate mode for each channel (Table 6). As well as an envelope generator, noise generator in the music co-processor only one, so you will not be able to configure multiple channels simultaneously noise with different frequency. By default, all three channels are set to tone (command M7). In the following example, channel A is set to the tone, and the channel B - the noise: PLAY "M17cegbdfaCH", "O3cC)". If you tell M0, then all channels will be silent and you hear the crackling. Y - install channel MIDI-interface. A number from 1 to 16 following the team specifies the number of channel interface, which need to output music data. Z - transfer control codes MIDI-interface. Code MIDI (a number from 0 to 255) must be located directly behind the team. Permissible to pass just two bytes. In this case, their values must be separated from each other by a space or a team of N. Note that all commands of the operator PLAY should be typed in capital letters! Finally, we give a brief summary of the commands of the operator PLAY (Table 7) and messages errors that may occur during execution time (Table 8).
Other articles:
Similar articles:
В этот день... 21 November