home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol056 / prog3.doc < prev    next >
Text File  |  1984-04-29  |  19KB  |  608 lines

  1. {j:a
  2. {m:1=10,75
  3. {m:2=18,75
  4. {m:3=24,75
  5. {m:4=50,75
  6. {m:1
  7. IV.C. COMP
  8.  
  9.  
  10. IV.C.1. Command Sequence
  11.  
  12. A>^^COMP^songname^(press^return)
  13.  
  14.  
  15. IV.C.2. Discussion
  16.  
  17. COMP is a two pass compiler intended to permit the forward label
  18. reference facility required to support the chorus and repeat 
  19. functions. In the first pass,
  20. COMP loads the song into main memory while recording each label as
  21. it is encountered. On the second pass, COMP translates song lines into
  22. the numerical values required by PLAY. The translation process uses
  23. the information provided by SETUP to make allowances for CPU type
  24. and clock speed. Also, the information in the option lines is translated
  25. into numerical form to provide the controls needed during PLAY. The
  26. compiled information is written as it is generated to a new song
  27. file with the same name as the source song but with a type of .SCD.
  28.  
  29. As each line is compiled, COMP prints an indication on the CRT. Each
  30. option line is displayed along with the line number and each song
  31. line is represented with a period. When an error occurs, the bell is
  32. sounded (if your terminal has a bell), and an error message is
  33. displayed along with the line number of the line containing the error.
  34. A list of compiler errors is provided in Appendix B.
  35.  
  36.  
  37. IV.D. WAVE
  38.  
  39.  
  40. IV.D.1. Command Sequence
  41.  
  42. A>^^WAVE^(press^return)
  43.  
  44.  
  45. IV.D.2. Introduction
  46.  
  47. WAVE allows you to build a wide variety of waveforms.
  48. Sound is created by Musicraft by sending a sequence of numbers to
  49. a digital to analog convertor. The rate at which this is done is what
  50. determines the pitch of the resulting sound. The sequence of numbers
  51. chosen is called the waveform and determines the color or timbre of
  52. the sound. In Musicraft, a
  53. short sequence of numbers is stored on a floppy disk file and later
  54. retrieved by PLAY when you name that sequence as a waveform table.
  55. The sequence is used repeatedly to create the sound.
  56.  
  57. The primary method used by WAVE for building waveforms is the
  58. method called the Fourier synthesis technique. Fourier decided
  59. that periodic waveforms such as those encountered in sound could
  60. be constructed with combinations of sine waves. A sine wave is a very
  61. "pure" sound to our ear and soon becomes boring to listen to. But
  62. when several related sine waves are mixed, the resulting sounds
  63. become more interesting. There is extensive literature available
  64. on Fourier synthesis and you can certainly learn a great deal by
  65. studying the subject. But at least initially you can gain a good
  66. deal of intuitive knowledge just by playing with WAVE, creating
  67. many waveforms and playing songs with different waveforms to
  68. compare their sound colors.
  69.  
  70. Let's take a look at some common waveforms using WAVE to construct
  71. them. Under the several headings below are dialogs you can
  72. use to build waveforms.
  73.  
  74.  
  75. IV.D.3. The Fundamental
  76.  
  77. The Fourier method uses waveforms called the fundamental and its
  78. related harmonic waveforms. WAVE treats the fundamental (called the
  79. first harmonic in the dialog) as the root waveform. All the harmonics
  80. are sine waves but, as we will see, when they are combined, waveforms
  81. of very different shapes can be constructed. (Strictly speaking,
  82. waveforms are combined by adding corresponding instantaneous amplitudes
  83. of all the harmonics participating in the waveform.)
  84.  
  85. A>^^WAVE^(press^return)
  86.  
  87. (waveform table filename request)
  88.  
  89. {m:4
  90. {i:-40
  91. ^^^^SINE^(press^return)
  92. This becomes
  93. the name of a small file
  94. on diskette which will contain
  95. the numerical information
  96. describing the waveform.
  97.  
  98. {i:-40
  99. (Fourier^prompt)
  100.  
  101. {i:-40
  102. ^^^^1,0^(press^return)
  103. This entry
  104. describes the relative
  105. amplitude of the first
  106. harmonic to be present in
  107. the waveform.
  108.  
  109. {i:-40
  110. ^^^^(press^return)
  111. This terminates
  112. the specification  process
  113. to include on the first
  114. harmonic.
  115.  
  116. {m:1
  117. WAVE constructs the waveform...a sine wave...and draws
  118. it on the CRT for your observation. When the waveform is complete,
  119. WAVE writes the data to the waveform file you specified earlier...
  120. in this case SINE.WAV.
  121.  
  122. The waveform table contains one full wavelength of the first
  123. harmonic, or fundamental. Try playing one of the songs on the diskette
  124. using the SINE file when PLAY asks you to specify a waveform.
  125. After you have tried this, come back and we will find out about
  126. another harmonic.
  127.  
  128.  
  129. IV.D.4. The Second Harmonic
  130.  
  131. The second harmonic has a pitch which is one octave above that of
  132. the fundamental. This dialog constructs the second harmonic in
  133. isolation from the other harmonics (also the fundamental) so that
  134. you can hear the effect when you play a song using it.
  135.  
  136. A>^^WAVE^(press^return)
  137.  
  138. (waveform table filename request)
  139.  
  140. ^^^^HARM2^(press^return)
  141.  
  142. (Fourier prompt)
  143.  
  144. {m:4
  145. {i:-40
  146. ^^^^0,0^(press^return)
  147. This sets
  148. the amplitude of the first
  149. harmonic to zero so that it
  150. does not contribute to the
  151. final waveform.
  152.  
  153. {i:-40
  154. ^^^^1,0^(press^return)
  155. This sets the
  156. relative amplitude of the
  157. second harmonic.
  158.  
  159. {i:-40
  160. ^^^^(press^return)
  161. This terminates
  162. the specification of the
  163. waveform.
  164.  
  165. {m:1
  166. WAVE constructs the waveform. When the waveform is complete,
  167. WAVE writes the data to HARM2.WAV. Note that the waveform
  168. drawn on your CRT contained two complete wavelengths instead
  169. of one as in the case of SINE above. This is the graphic relation
  170. between a note and another note one octave above it. Play a
  171. song using HARM2 for your waveform table and observe the difference
  172. in the sound.
  173.  
  174. {a:p=1
  175. IV.D.5. The Square Wave
  176.  
  177. You can easily experiment with other harmonics, the third, the fourth
  178. and so on, isolating one at a time. But we now move to constructing a
  179. square wave. This will involve combining several harmonics with varying
  180. amplitudes as we will see.
  181.  
  182. A>^^WAVE^(press^return)
  183.  
  184. (waveform table filename request)
  185.  
  186. ^^^^SQUARE^(press^return)
  187.  
  188. (Fourier prompt)
  189.  
  190. {m:4
  191. {i:-40
  192. ^^^^100,0^(press^return)
  193. We are combining
  194. several harmonics, and the first
  195. harmonic will have the largest
  196. relative amplitude.
  197.  
  198. {i:-40
  199. ^^^^0,0^(press^return)
  200. Only the odd
  201. numbered harmonics are involved
  202. in the construction of a square
  203. wave.
  204.  
  205. {i:-40
  206. ^^^^33,0^(press^return)
  207. The relative
  208. amplitude of each harmonic is
  209. equal to 100 divided by the
  210. order of the harmonic. This
  211. is number three.
  212.  
  213. {i:-40
  214. ^^^^0,0^(press^return)
  215.  
  216. {i:-40
  217. ^^^^20,0^(press^return)
  218. 100 divided
  219. by 5.
  220.  
  221. {i:-40
  222. ^^^^0,0^(press^return)
  223.  
  224. {i:-40
  225. ^^^^14,0^(press^return)
  226. 100 divided
  227. by 7.
  228.  
  229. {i:-40
  230. ^^^^(press^return)
  231. This terminates
  232. the specification.
  233.  
  234. {m:1
  235. WAVE constructs the waveform. When the waveform is complete,
  236. WAVE writes the data to the file called SQUARE.
  237.  
  238. Note that the waveform drawn is not quite as square as you might have
  239. expected. If additional harmonics are included in the constructed 
  240. waveform
  241. (we only used the first seven harmonics), the shape would become more
  242. exact. But the sound quality of the waveform would deterioriate
  243. (in the higher pitches particularly) due to the limited speed of the
  244. CPU which would begin to cause extraneous non-harmonic artifacts due
  245. to its sampling rate.
  246.  
  247. Try building square wave tables using fewer or more harmonics. Observe
  248. the effect each additional harmonic has on the shape and the sound
  249. color of the waveform when used to play music.
  250.  
  251.  
  252. IV.D.6. Additional Waveforms
  253.  
  254. Two additional waveforms which are useful for music are the ramp
  255. (or sawtooth) and the triangle waveforms. These are somewhat more
  256. complex than the square wave and involve "phase shifting" some
  257. of the harmonics. Phase shifting refers to the point where, within
  258. the one wavelength of the fundamental, the harmonic waveform crosses
  259. zero (the vertical dividing line on the screen).
  260. If one full wavelength of the fundamental is counted as 360
  261. degrees from end to end, the phase shift of a harmonic may be 
  262. represented as any value from zero degrees to 359 degrees.
  263.  
  264. The first waveform described here is the sawtooth. It is comprised
  265. of all harmonics in increasingly smaller relative amplitudes.
  266. Additionally, all the even harmonics are shifted 180 degrees. To 
  267. construct a sowtooth waveform, the harmonic
  268. entries should be entered as in the table below:
  269.  
  270. {l:        harmonic        entry (followed by a return)
  271.  
  272. {l:           1            100,0
  273. {l:           2            50,180
  274. {l:           3            33,0
  275. {l:           4            25,180
  276. {l:           5            20,0
  277. {l:           6            16,180
  278. {l:           7            14,0
  279. {l:           etc...
  280.  
  281. The triangle waveform is somewhat more complicated; it seems to
  282. combine properties of both the square wave and the sawtooth. It
  283. is related to the square wave in that it contains only odd harmonics.
  284. But the triangle waveform also requires phase shifting of some
  285. harmonics as does the sawtooth. The triangle waveform entries should
  286. be entered as in the table below:
  287.  
  288. {l:        harmonic        entry (followed by a return)
  289.  
  290. {l:           1            100,0
  291. {l:           2            0,0
  292. {l:           3            11,180
  293. {l:           4            0,0
  294. {l:           5            4,0
  295. {l:           6            0,0
  296. {l:           7            2,180
  297. {l:           etc...
  298.  
  299. Experiment with the construction of these waveforms by first using
  300. only the first two harmonics, then adding an additional harmonic,
  301. then adding another and so on. You can watch the
  302. characteristic shapes take form and can hear this process as well.
  303.  
  304. With WAVE and PLAY, you have a complete laboratory to experiment with
  305. sound. Don't limit yourself to the waveforms discussed above. Experiment
  306. with the use of the relative amplitudes and phase shifting capabilities
  307. of WAVE and listen to the results with PLAY. You will soon build a 
  308. catalog of useful waveforms.
  309.  
  310.  
  311. IV.E. PLAY
  312.  
  313.  
  314. IV.E.1. Command Sequence
  315.  
  316. A>^^PLAY^songname^(press^return)
  317.  
  318. or
  319.  
  320. A>^^PLAY^(press^return)
  321.  
  322.  
  323. IV.E.2. Song Load
  324.  
  325. Using the first command sequence allows you to obtain one song and
  326. place it in the play area for performance. After loading the song, 
  327. PLAY proceeds to the waveform loading sequence.
  328.  
  329. Using the second sequence 
  330. allows you to obtain several songs and place them one after the other 
  331. in the play area. When you have obtained all the songs you wish to 
  332. load, press the carriage return key without a song name and PLAY will 
  333. terminate the song loading sequence.
  334.  
  335.  
  336. IV.E.3. Waveform Table Load
  337.  
  338. After the song (or songs) have been loaded, PLAY 
  339. requests the names of the waveform files you wish to use to fill the
  340. tables identified by the waveform 
  341. option lines found in the song(s). You enter each waveform file name 
  342. as it is requested and PLAY obtains it and places it in the waveform 
  343. table area in main memory. PLAY has room for 14 waveform tables.
  344. Notice that a distinction is being drawn here between a "waveform 
  345. file" and a "waveform table". Namely, a waveform file is a file on a 
  346. diskette containing a waveform which you built using WAVE. A waveform 
  347. table is an area in PLAY in which you can store the contents of a 
  348. waveform file for use in playing a song. You specify waveform tables 
  349. using the Waveform option line in EDIT. You specify which file fills 
  350. which table in PLAY.
  351.  
  352. There are three additional responses that you can make
  353. which are recognized 
  354. by PLAY when loading waveform tables:
  355.  
  356. {m:2
  357. {i:-8
  358. 1.
  359. "0" (a zero)
  360. {i:-8
  361. 2.
  362. an integer between 1 and 14
  363. {i:-8
  364. 3.
  365. an asterisk ("*")
  366.  
  367. {m:1
  368. A zero specifies that the table is to be set to zero and is to 
  369. contribute no sound to the playing of a song.
  370.  
  371. An integer (between 1 and 14) specifies that the table identified
  372. by the request is to be 
  373. copied from the table specified by your integer input. 
  374. Usually, the table you specify in this way has been previously filled 
  375. in some of the acceptable methods described here. If you specify a 
  376. table that has not been previously filled, the table will probably be 
  377. a sequence of random numbers (ie., noise)
  378.  
  379. An asterisk specifies that the table is to be left as it was 
  380. previously filled. Again, if you do not previously fill a waveform 
  381. table, this option will probably contribute a lot of noise to your 
  382. song and not much music.
  383.  
  384.  
  385. Example:
  386.  
  387. For this example, if you have not already compiled the two song files 
  388. provided on your system diskette under the names of INVENT4 and 
  389. INVENT8, use the following dialog to do so.
  390.  
  391. A>^^COMP^INVENT4^(press^return)
  392.  
  393. After INVENT4 has been compiled then...
  394.  
  395. A>^^COMP^INVENT8^(press^return)
  396.  
  397. Now continue with the following dialog:
  398.  
  399. {m:4
  400. {i:-40
  401. A>^^PLAY^(press^return)
  402. This requests
  403. the second song load option
  404. described above.
  405.  
  406. {m:1
  407. Please enter name of song 1  >
  408.  
  409. {m:4
  410. {i:-40
  411. ^^^^INVENT1^(press^return)
  412. This loads the
  413. first invention.
  414.  
  415. {m:1
  416. Please enter name of song 2  >
  417.  
  418. {m:4
  419. {i:-40
  420. ^^^^INVENT4^(press^return)
  421. This loads the
  422. fourth invention.
  423.  
  424. {m:1
  425. Please enter name of song 3  >
  426.  
  427. {m:4
  428. {i:-40
  429. ^^^^INVENT8^(press^return)
  430. This loads the
  431. eighth invention.
  432.  
  433. {m:1
  434. Please enter name of song 4  >
  435.  
  436. {m:4
  437. {i:-40
  438. ^^^^(press^return)
  439. This terminates
  440. the song loading sequence.
  441.  
  442. {m:1
  443. Please enter name of waveform table 1  >
  444.  
  445. {m:4
  446. {i:-40
  447. ^^^^WAVE^(press^return)
  448. This loads the
  449. waveform file provided on the 
  450. diskette.)
  451.  
  452. {m:1
  453. (Note: because none of the songs you loaded explicitly request a waveform 
  454. table, PLAY assigns waveform table 1 as a default.)
  455.  
  456. PLAY now performs all three of the inventions, one following the 
  457. other without further intervention on your part.
  458.  
  459. This form of the song load sequence has some restrictions which you
  460. should be careful to follow. Don't attempt to play songs of different
  461. numbers of
  462. voices within the same song load sequence. PLAY must scale the 
  463. waveform tables according to the number of voices in the song in 
  464. order not to overload the bit width of the DAC. Also, PLAY does not permit 
  465. voice change as the song in memory is performed since PLAY cannot 
  466. maintain control when various functions are used in the song.
  467.  
  468.  
  469. IV.E.4. Continuation
  470.  
  471. Upon completion of the performance, PLAY displays a menu to 
  472. allow several possible continuations.
  473.  
  474. {l:        Type a...
  475. {l:          1   to load a new song
  476. {l:          2   to repeat the current song
  477. {l:          3   to load new waveform tables
  478. {l:          4   to return to the system
  479. {l:          ...>
  480.  
  481. A single digit response will continue PLAY in the mode of your 
  482. choice. Any value not equal to 1, 2 or 3 is taken as 4 (1, 2, 3, 
  483. many).
  484.  
  485.  
  486. IV.E.5. Interaction
  487.  
  488. It is quite all right to sit back and listen to the products of your 
  489. labors when PLAY is in operation. But you can still exert control 
  490. over the performance of your music. PLAY permits two kinds of 
  491. interaction during actual performance of the music.
  492.  
  493. {m:2
  494. {i:-8
  495. 1.
  496. Rehearsal or practice mode
  497. {i:-8
  498. 2.
  499. Modified performance mode.
  500.  
  501.  
  502. {m:1
  503. IV.E.5.a. Rehearsal Mode
  504.  
  505. PLAY can be used to fill in the other voices when you want to 
  506. practice an instrument. To make this easier, PLAY will allow you to 
  507. request a new pickup point at any time while it is performing the 
  508. music if you include measure markers (M_option lines) when you enter 
  509. the song with EDIT. Whenever you need to stop the performance, press 
  510. the carriage return key. When PLAY reaches a M_option line in the 
  511. song, it will then request that you enter the measure number matching 
  512. the desired pickup point. Enter that number followed by a carriage 
  513. return. PLAY will find the new measure and then wait several seconds 
  514. and then begin performaing at the measure you requested.
  515.  
  516. In order to play a song with a single voice missing, make sure that 
  517. the voice you wish to practice is assigned a separate waveform using 
  518. the Waveform option function in EDIT. When you are requested to 
  519. identify
  520. the waveform file to load that waveform table, answer with "0" (a 
  521. zero). This will cause the table to be set to empty and no sound will 
  522. be generated for that voice.
  523.  
  524.  
  525. IV.E.5.b. Modified Performance Mode
  526.  
  527. While performing music, whenever PLAY encounters a Repeat option 
  528. line, PLAY checks to see if any key has been pressed on the keyboard. 
  529. If one has, PLAY examines a table of the Label option lines that it 
  530. found as it loaded the song. Each label has a character associated 
  531. with it called the Label Key. If you pressed a key matching a label 
  532. key, the song segment following the label will be performed. When the 
  533. next repeat option line is encountered, the above procedure is 
  534. repeated. This feature allows you to perform music with you in an 
  535. active capacity. To use this feature, you must assign unique 
  536. keys (on your CRT keyboard) to labels when you edit the song.
  537. Read the section describing 
  538. the Label option in both OPTION LINE DESCRIPTIONS and 
  539. the Options_mode description of EDIT above.
  540.  
  541.  
  542. Example:
  543.  
  544. Suppose you had entered a song having the following form:
  545.  
  546. {l:        *L REST     R
  547. {l:        (a rest in all voices)
  548. {l:        *R REST     255
  549.  
  550. {l:        *L PARTA    A
  551. {l:        (song segment A)
  552. {l:        *R PARTA    255
  553.  
  554. {l:        *L PARTB    B
  555. {l:        (song segment B)
  556. {l:        *R PARTB    255
  557.  
  558. {l:        *L PARTC    C
  559. {l:        (song segment C)
  560. {l:        *R PARTC    255
  561.  
  562. {l:        *L PARTD    D
  563. {l:        (song segment D)
  564. {l:        *R PARTD    255
  565.  
  566. {l:        *L PARTX    X
  567. {l:        *X
  568.  
  569. This piece has a rest part, four sound making parts, and an exit 
  570. part. Suppose the piece is called SONG.
  571.  
  572. A>^^PLAY^SONG^(press^return)
  573.  
  574. Please enter name of waveform table 1 >
  575.  
  576. {m:4
  577. {i:-40
  578. ^^^^WAVE^(press^return)
  579. Or whatever 
  580. waveform file(s) you want.
  581.  
  582. {m:1
  583. The piece begins to play. The first thing encountered is a repeated 
  584. rest. If you do not strike a key for a period of time, you will hear 
  585. nothing. If you wait too long, the Repeat will be played out and PLAY 
  586. will continue down to the next segment. Instead, press the letter C. PLAY
  587. will automatically begin performing 
  588. segment C. If, again, you do not press any key for awhile, PLAY will 
  589. repeat segment C for up to 255 times or until you finally do press a 
  590. key. If you press any key other than the defined ones, PLAY 
  591. automatically begins at the beginning of the piece which means, in 
  592. this example, you will hear nothing. Press the letter A. PLAY now 
  593. performs segment A. You get the idea?
  594.  
  595. Only the keys actually assigned 
  596. as Label Keys will operate to select song segments. Any other key 
  597. (except carriage return since that is used for the rehearsal mode) 
  598. will cause PLAY to begin playing the song from the top.
  599.  
  600. You can use this technique to implement a simple melody organ, a 
  601. chord organ; you can even use it as a programmable 
  602. instrument in a rock band. You can put any musical idea into a song 
  603. segment and perform it at any time you would like. There are a lot
  604. of possibilities.
  605. {a:p=1
  606.  
  607.  
  608.