Auto-playing apparatus
.Iadd.This application is a continuation of application Ser. No. 07/275,439 filed Nov. 23, 1988 and now abandoned which is a reissue of application Ser. No. 06/821,521 filed Jan. 23, 1986 and now U.S. Pat. No. 4,624,171 which is a continuation of application Ser. No. 06/597,168 filed Apr. 5, 1984 and now abandoned..Iaddend. 
     .[.This application is a continuation, of application Ser. No. 597,168, filed Apr. 5, 1984..]. 
    
    
     BACKGROUND OF THE INVENTION 
     The present invention relates to an auto-playing apparatus for reading out and playing musical pieces preset in a memory device such as a ROM or a RAM. 
     Recently, there has been made available an auto-playing apparatus, which can read out and automatically play musical data preset in an internal memory and which can also read out and automatically play musical data preset in an external memory. These auto-playing apparatuses meet the demand for automatically playing music. Particularly, the auto-playing apparatus which uses an external memory permits a variety of musical pieces to be enjoyed by the user simply changing the external memory for another. External memories, such as the so-called ROM packs may be used. The ROM packs, however, usually contain data for only a single musical piece. Therefore, it has been impossible to enjoy continuous playing of a number of different musical pieces without frequently changing ROM packs. Additionally, since in order to enjoy the automatic playing of several different musical pieces, the corresponding number of ROM packs must be purchased, the cost to the user is very high. 
     SUMMARY OF THE INVENTION 
     An object of the invention is to provide an auto-playing apparatus, which can read out and automatically play musical data for one or more pieces from one external memory. 
     According to one aspect of the invention, there is provided an auto-playing apparatus in which it is possible to designate the sequence of music pieces to be played automatically, by using music data stored in an external music pack. 
     According to another aspect of the invention, there is provided an auto-playing apparatus in which a keyboard is provided for use both to enable a manual performance and for designating the music pieces contained in the memory pack. 
     According to still another aspect of the invention, there is provided an auto-playing apparatus in which it is possible to designate randomly the sequence of music pieces to be played automatically. 
     According to a further aspect of the invention, there is provided an auto-playing apparatus in which an automatic performance can be realized either by use of a memory pack or a magnetic tape. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIGS. 1A and 1B are a plan view showing an auto-playing apparatus incorporating an embodiment of the invention; 
     FIG. 2 is a bottom view of the same electronic musical instrument; 
     FIG. 3 is a perspective view showing a ROM pack; 
     FIG. 4 is a plan view showing a display section when power is off; 
     FIG. 5 is a view showing an electrode arrangement of a liquid crystal panel in the display section; 
     FIG. 6 is a block diagram showing a circuit of the electronic musical instrument; 
     FIG. 7 is a block diagram showing a control section 28 in the circuit shown in FIG. 6; 
     FIG. 8A is a view showing the format of the melody and the obligato line data; 
     FIG. 8B is a view showing the format of the chord line data; 
     FIG. 9A through 9G are views showing the formats of the ROM pack and magnetic tape data, and showing the ROM address, the main header, the musical data, the musical piece header, the melody line, the obligato line and the chord line, respectively; 
     FIGS. 10A through 10J are views showing various melody and obligato line data, with FIGS. 10A-1 and 10A-2 showing note data, FIG. 10B showing rest data, FIGS. 10C-1 and 10C-2 showing repeat data, FIGS. 10D-1 to 10D-3 showing timbre data, FIGS. 10E-1 to 10E-3 showing effect data, FIGS. 10F-1 to 10F-3 showing tie data, FIG. 10G showing time symbol data, FIG. 10H showing key symbol data, FIG. 10I showing bar data, and FIG. 10J showing end data; 
     FIGS. 11A to 11G show various chord line data, with FIG. 11A-1 to 11A-3 showing chord name data, FIGS. 11B-1 and 11B-2 showing rest data, FIGS. 11C-1 and 11C-2 showing repeat data, FIGS. 11D-1 to 11D-3 showing rhythm/fill-in/rhythm discrimination data, FIG. 11E showing tempo data, FIG. 11F showing counter reset data, and FIG. 11G showing end data; 
     FIG. 12 is a view showing note data; 
     FIG. 13 is a view showing tone duration data; 
     FIG. 14 is a view showing time symbol data; 
     FIG. 15 is a view showing key symbol data; 
     FIG. 16 is a view showing tempo data; 
     FIGS. 17 and 17B show an example of a music score; 
     FIGS. 18A to 18C are views showing the melody, obligato and chord line data for the same music score; 
     FIG. 19 is a view showing the order of operating the keys when selecting a ROM pack, or a magnetic tape containing several musical pieces; 
     FIG. 20 is a view showing the order of operating the keys to randomly designate a ROM pack or magnetic tape containing several musical pieces; 
     FIG. 21 is a general flow chart showing how musical pieces are automatically played according to the designated music sequence; 
     FIG. 22 is a flow chart illustrating how a musical piece is played; 
     FIG. 23 is a flow chart illustrating the tone data process step; 
     FIG. 24 is a flow chart illustrating the repeat process step; 
     FIGS. 25A to 25E are views showing examples of the repeat performance and the repeat flag change; 
     FIG. 26 is a view showing a display section when a ROM pack is selected; and 
     FIG. 27 is a view showing a display section when a magnetic tape is selected. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT 
     FIGS. 1A and 1B show a plan view of an electronic musical instrument. The top of the electronic musical instrument 1 has a keyboard 2, a switch section 3 having various switches, a sounding section 4, a display section 5 and a ROM (read only memory) pack setting section 6 for setting a ROM pack 25. The bottom of the instrument, as shown in FIG. 2, has an interface circuit setting section 7, to which data from a magnetic tape (not shown) is supplied. The body of the instrument accomodates various circuit components, a battery and a loudspeaker. 
     The keyboard 2 consists of 31 keys from F 2  to B 4 , for instance, for the usual manual operation. Of these keys, 16 white keys from G 2  to A 4  also serve as rhythm designation switches for designating rhythms from rock to swing (4-beat). Further, 10 white and black keys from C 4  to A 4  also serve as numeral keys for indicating the sequence of the pieces stored in the ROM pack 25 or in the magnetic tape. This sequence may be input as a program or by random selection. For example, when the sequence is being programmed, C 4  key is used as a designating key, and when the music sequence is randomly designated, B 3  key is used as a designation key. 
     Switch groups 8 and 9 are provided to write data for the musical pieces and for the chords in an internal RAM to be described later. The switch group 8 designates the root, and the switch group 9 designates the chord. The pitch and tone duration of the musical data are input by operating the keyboard 2. A one-key chord key 10 is provided for reading out the preset chord data and for sounding out the chords one by one. Volume switches 11, 12 and 13 are provided for controlling the main volume, the chord volume and the rhythm volume, respectively. Tempo switches 14A and 14B are provided to speed up and to slow down the tempo. A rhythm select switch 15 must be operated before designating a rhythm by the 16 white keys noted above. The start/fill-in switch 16 starts the automatic playing of the rhythm after the rhythm has been designated. 
     The demonstration switch 17 is used to repeatedly and sequentially play the music pieces in the ROM pack. A R/MT switch 18 is used to select either the ROM pack or the magnetic tape depending on if it has been operated for an odd or even number of times. 
     Switches 19 and 20 are utilized as save and load switches for writing and reading music data, chord data etc. between the internal RAM and magnetic tape. These switches are also used to transpose a played piece. Keys which are assembled in a predetermined sequence are changed every time the switch 19 or 20 is operated. The key change can be reversed by the switches 19 and 20. 
     Tone switches 21 are provided to designate 8 different timbres such as piano or violin. Memory switches 22A to 22H are control switches which are used when writing musical data, etc. in the internal RAM. The play switch 22A is used to play-back. The switch 22B serves to stop rhythm, and to reset and release the internal RAM. The switch 22C writes melody data (musical data). The chord switch 22D writes chord data. The record switch 22E writes musical data, etc. in the internal RAM. The switch 22F increments the addresses one by one. The delete switch 22G deletes data written in the internal RAM. The clear switch 22H clears the address counter, etc. One-key play switches 22I and 22J are provided to read out the melody data of the internal RAM tone by tone for playing, and a power switch 23 is also shown. A cord 24 can connect with an interface circuit (not shown) in the interface circuit setting section 7 so that data can be transferred between the electronic musical instrument 1 and a magnetic tape inside a tape recorder (not shown) that is separate from the instrument 1. 
     FIG. 3 is a perspective view of the ROM pack 25. It comprises a plastic case 25A which accommodates a printed circuit board having an LSI (large scale integrated circuit) containing written musical data for predetermined musical pieces, and a battery, etc. Terminals 25B and 25C are connected to a connector in the ROM pack setting section 6. The plastic case 25A of the ROM pack 25 is labeled with the names of musical pieces contained therein. 
     FIG. 4 is a plane view showing the display section 5 when the power is off. The display section 5 includes a liquid crystal display panel. FIG. 5 shows the electrode structure of the liquid crystal display panel. It consists of an upper keyboard display section 5A and a lower letter display section 5B. In the keyboard display section 5A, the white and black keys are displayed by liquid crystal having different colors. Shown as black dots on the individual keys are display points which are turned on when the corresponding keys are operated to indicate the pitch of the tone being used when the instrument is played manually or automatically. The letter display section 5B has a display symbol &#34;rhythm&#34; which is turned on when rhythm is played, a display symbol &#34;trans&#34; which is turned on during transposition, a display symbol &#34;R&#34; which is turned on when the ROM pack 25 is used for automatically playing, a display symbol &#34;MT&#34; which is turned on when the magnetic tape is used for automatically playing, display elements 5B1 for displaying numerals and chord, a display symbol &#34;melody&#34; which is turned on when writing melody data, a display symbol &#34;chord&#34; which is turned on when writing chord data, and bar display elements 5B2 which provide 8 different timbres and which are turned on when a corresponding timbre has been designated. 
     The circuitry of the electronic musical instrument will now be described with reference to FIGS. 6 and 7. Referring to FIG. 6. each key output on the keyboard 2 is coupled to a key detection section 27, which produces a key code when the key is operated. The key code is fed to a control section 28. Outputs from various switches on the switch section 3 are also fed to the control section 28. The control section 28 includes a microprocessor, etc. and controls the entire operation of the electronic musical instrument. More specifically, it provides a read/write control signal R/W to the internal RAM 29 to control its operation to write and to read data D such as musical data. At the same time, the control section 28 also provides address data Ad. For the ROM pack 25, the control section 28 first presets the first address of the musical piece data to be read out in an address counter 30, and then it reads the piece data while incrementing the address counter 30. If further reads out musical piece data from a magnetic tape 32 in a tape recorder 31 through an MT interface 33. For the manual operation of the keyboard or for the automatic operation with the ROM pack 25 and the tape recorder 31, the control section 28 feeds the necessary data for each function to a first melody generator 34, a second melody generator 35, a chord generator 36, a bass generator 37 and a rhythm generator 38. The first melody generator 34 generates melody data for a melody line to be described later. The second melody generator 35 generates melody data for an obligate line. The chord generator 36 generates chord data for a chord line. The base generator 37 generates base data, and the rhythm generator 38 generates rhythm data. These data are fed through an amplifier 39 and a loudspeaker 40 to the sounding section 4. 
     The control section 28 further controls the display operation of the display section 5. 
     FIG. 7 shows the construction of the circuit essential to the control section 28. When a program specifies a number of pieces that use the 12 keys from B 3  to B 4  on the keyboard 2. piece sequence data is directly and sequentially fed into the musical sequence memory 41 for storage. When a number of pieces are to be played randomly, data is preset in the counter 43 of the random number generator 42. Every time the random number generator 42 generates a random number data, the data is written as piece sequence data in the musical sequence memory 41. At the same time, the counter 43 correspondingly decreases. When the count becomes 0 the generation of random numbers is stopped. The musical sequence data in the musical sequence memory 41 is then fed either to the ROM pack 25 or to the tape recorder 31. After the play switch 22A is operated, musical data for one piece of music is sequentially read out and transferred through a data buffer 44 to the internal RAM 29. 
     A data register 45 is provided to store data for the melody line among the data read out from the ROM pack 25 or magnetic tape 32. Data input to the data register 45 is the transferred to a data identifying section 46. If the input data is tone duration data, the data identifying section 46 will set it in the tone duration register 47. If it is repeat flag data, the section 46 will feed it to a 2-bit repeat flag (RF) register 48, and thence to an address control section 49. If the data input to the data identifying section 46 is any other type of data, e.g., pinch, timbre, effect, etc., it is fed to the first melody generator 34. 
     A time measuring counter (timer) 50 feeds time count data to the tone duration register 47. The tone duration data in the tone duration register 47 is decreased by 1 every time the time count data is changed to correspond to a predetermined unit of time. When the tone duration data becomes 0, a one-shot signal is fed to the address control section 49. As will be described later, the tone duration data consists of ON-duration data (when the tone is audible) and OFF-duration data (when no tone is audible). 
     The address control section 49 includes an address counter (ADC) 51, a return address register (RAD) 52, and a jump address register (JAD) 53. When automatic playing begins, the first address of the piece is preset in the address counter 51 which is progressively incremented as the playing progresses. To change the address for the repeat function, data is transferred according to repeat flag data between the return address register 52 and the jump address register 53, and the address register 51. The address data provided from the address counter 51 is supplied to the internal RAM 29 for reading the next data. The data register 45, data identifying section 46, tone duration register 47, time measuring counter 50, repeat flag register 48 and address control section 49 are shown only for the data from the melody line. Although not shown, the same circuit can be provided for data from the obligato line, or that from the chord line. 
     An ON flag (F ON) register 54 is a one-bit register in which &#34;1&#34; is set while the tone is on and &#34;0&#34; is set while it is off. The same ON flag register is also provided for the obligato line and chord line data although they are not shown. 
     FIG. 8A shows the format of the melody and obligato line tone data for a tone stored in the ROM pack 25 or on the magnetic tape 32. The format consists of a total of 6 digits, including a 4-bit note code (SC), a 4-bit octave code (OC), an 8-bit ON-duration code and an 8-bit OFF-duration code. This format is also used for rest data. FIG. 8B shows the format for chord line tone data. It consists of a total of 4 digits, including a 4-bit note code (SC) indicative of the name of the root, a 4-bit octave code (OC) indicative of the kind of chord used, and an 8-bit ON-duration code. FIG. 12 shows specific examples of the note code (SC) and octave code (OC). Notes F 3  to B5 are used for the note code and octave code for the melody line, and notes F 3  to B 5  are used for those in the obligato line. FIG. 13 shows examples of data representing ON and OFF duration. The tone duration data is largely classified into normal tone duration data having small values or into double duration data having larger values. Normal tone duration is expressed as 8-bit data. Its upper 4 bits are designated at L 2 , and its lower 4 bits are designated at L 1 . The scope of tone duration covers 16 different tone durations from a triplet of sixty-fourth notes to a dotted whole note. The double duration data includes upper 8-bit data in addition to the 8-bit data L 2  and L 1  noted above. Of the additional 8-bit data, the upper 4 bits are designated at U 1 , and the lower 4 bits are designated at U 2 . The double tone duration covers 16 different durations from twice to 512 times the whole note. 
     Thus in this embodiment, a total of 32 different tone durations are used. 
     FIGS. 9A to 9G show data formats adopted for the ROM pack 25. More specifically, FIG. 9A shows the overall data format. It comprises a main header (having addresses 0 to α 1  -1), musical pieces data areas for n musical pieces (with addresses α 1  to γ 1  -1, the first addresses for the individual pieces being α 1 , α 2 , . . . , α n , n being an integral number), and vacant areas (with addresses γ to BFCF), unused areas (BFDO to BFFF). The total storage capacity is 4 bits by 49,152 digits. 
     FIG. 9B shows the data format of the main header. The head 11-digit area is for writing work data as shown. The next 4-digit area is for writing the number n of pieces. The next 6-digit area is for writing the head address of the vacant area. The next individual 6-digit areas are for writing the head addresses of the pieces from No. 1 to No. n. The next 6-digit area is for writing the head address of the vacant area. 
     FIG. 9C shows the data format of each musical piece data area. Here, the typical musical piece data of the first piece (No. 1) is shown. It comprises from the head thereof a piece header, melody data, obligato data and chord data. Symbols δ 1 , δ 2  and δ 3  represent the initial addresses of the melody data, obligato data and chord data, respectively. 
     FIG. 9D shows the data format of the piece header. The head 2-digit area is for writing all &#34;0&#34; data. The next 6-digit area is for writing the melody data head address δ 1 . The next 2-digit area is a 2-digit gap. The next 6-digit area is for writing the obligato data head address δ 2 . The next 2-digit area is a 2-digit gap. The next 6-digit area is for writing the chord data head address δ 3 . 
     FIG. 9E shows the data format of the melody line data. The head data area is for a rest (the duration being 0). Then, bar data, time data, key data and timbre ON data are written. After that, if there is an effect ON in the music score, its data is written. Then the note data of the music score is written. Then the timbre OFF data and effect OFF data, if any, are written along with the end data. 
     FIG. 9F shows the data format of the obligato line data. The head data area is for a rest (the duration being 0). Then timbre ON data and effect ON data, if any, are written. Then the note data on the music score, the timbre OFF data, effect OFF data and END data are written, respectively. 
     FIG. 9G shows the data format of chord line data. The head data area is for a rest (the duration being 0). Then, the counter reset data is written. The counter is provided in the rhythm generator 38 shown in FIG. 6 and counts the time of the rhythm being generated. Subsequent to the counter reset data, rhythm discrimination data, tempo ON data, rest data and rhythm ON data are written. Then the individual chord data depending on the music score, the rhythm OFF data, the tempo OFF data and the END data are written. 
     FIGS. 10A through 10J show examples of the various data described above used as the melody and obligato line data. More specifically, FIGS. 10A-1 and 10A-2 show note data. FIG. 10A-1 shows normal tone duration data in which the tone duration is shorter than triplet of thirty-second notes. It comprises 2-digit pitch data consisting of a note code (SC) and an octave code (OC), 2-digit tone duration data L 1 , L 2  representing the ON duration, and 2-digit rest duration data L 1 , L 2  representing the OFF duration. 
     FIG. 10A-2 shows double duration data, in which the tone duration is equal to or longer than a triplet of thirty-second notes. It comprises: the pitch data SC, OC; tone duration data L 1 , L 2  ; rest duration data L 1 , L 2  ; 2-digit double duration command data; upper bit tone duration data (2 digits) u 1 , u 2  ; and rest duration data (2 digits) u 1 , u 2 . 
     FIG. 10B shows the rest data. The rest is shorter than a triplet of thirty-second notes and is provided at the head of the melody and obligato line data (the rest duration being 0 in this case). It is also used when there is a rest immediately after the repeat data to be described layer. It comprises rest duration command (2 digits) and rest duration data (2 digits). 
     FIGS. 10C-1 and 10C-2 show a specific example of the repeat data. FIG. 10C-1 shows its configuration. It comprises repeat command data (2 digits, to be described later) and no chord data (4 digits). FIG. 10C-2 shows 10 different examples of the repeat command. 
     FIGS. 10D-1 to 10D-3 show examples of timbre data. FIG. 10D-1 shows timbre ON and OFF data which is less than a triplet of thirty-second notes. Each data consists of timbre command data (2 digits), timbre data (2 digits) to be described later, and rest duration data L 1  and L 2  (2 digits) representing a rest lasting for at least one time. Mark x indicates variable data. FIG. 10D-2 shows timbre ON and OFF data in which the time is 32/3 or greater. Each data consists of: timbre command data; timbre data; rest duration data (lower bit data) L 1 , L 2  ; double duration command data (2 digits); no chord data (2 digits); and 2-digit rest duration data u1, u2 (upper bit data). FIG. 10D-3 shows 8 different timbre data for piano, etc. 
     FIGS. 10E-1 to 10E-3 show examples of effect data. FIG. 10E-1 shows effect ON and OFF data which is less than a triplet of thirty-second notes. Each data consists of effect command data (2 digits), effect data (2 digits) to be described later and rest duration data (2 digits) L 1  and L 2 . FIG. 10E-2 shows data which is larger than a triplet of thirty-second notes. In this case, each data consists of: effect command data; effect data; rest duration data (lower bit data) L 1 , L 2  ; double duration command data (2 digits); no-chord data (2 digits); and rest duration data (uppper bit data) u 1 , u 2 . FIG. 10E-3 shows three different examples of effect data (short sustain, vibrato and delay vibrato). 
     FIGS. 10F-1 to 10F-3 show examples of tie data. FIG. 10F-1 shows tie ON and OFF data. Each data consists of tie command data (2 digits) and no-chord data (4 digits). FIG. 10F-2 shows an example of a tie data as it appears in a musical score. Note data is inserted after the ON and OFF commands of the tie data. FIG. 10F-3 shows data representing the contents of the score shown in FIG. 10F-2. 
     FIG. 10G shows an example of time symbol data. It consists of: a time symbol command (2 digits); time symbol data (2 digit data) L, u to be described later; and no-chord data (2 digits). FIG. 14 shows the specific data of the time symbols L, u. The symbols L and u represent the numerator and denominator of the time. 
     FIG. 10H shows an example of key symbol data. It consists of: key symbol command data (2 digits); key symbols (2 digits) L, u to be described later; and no-chord data (2 digits). FIG. 15 shows a specific example of the key symbol L, u. 
     FIG. 10I shows an example of bar data. It consists of bar command data (2 digits) and no-chord (4 digits) data. It is provided at the head of the melody line data. 
     FIG. 10J shows an example of end data. It consists of 6 digits and is provided at the end of the melody and obligato line data. 
     FIGS. 11A-1 through 11G show examples of the various data noted for the chord line. FIGS. 11A-1 to 11A-3 show chord name data. FIG. 11A-1 shows chord name data when the duration of a nomal chord is less than a triplet of thirty-second notes. It consists of root data SC (to be described later), the chords name OC (to be described later), and 2-digit chord duration data L 1 , L 2 . FIG. 11A-2 shows chord name data when the duration is equal to or longer than a triplet of thirty-second notes. It consists of: root data SC; chord name data OC; 2-digit chord duration data (lower bit data) L 1 , L 2  ; double duration command data (2 digits); and 2-digit chord duration data (upper bit data) u 1 , u 2 . FIG. 11A-3 shows examples of the chord name data. Sixteen different chord names are shown. In the figure, &#34;off chord&#34; means the sole bass sound, and &#34;no chord&#34; means the absence of any tone. 
     FIGS. 11B-1 and 11B-2 show examples of rest data. FIG. 11B-1 shows rest data when the normal duration is less than a triplet of thirty-second notes. It consists of rest command data (2 digits) and rest duration data (2 digits) L 1 , L 2 . FIG. 11B-2 shows rest data when the double duration is equal to or longer than a triplet of thirty-second notes. It consists of: rest command data; rest duration data (lower bit data) L 1 , L 2  ; double duration command data (2 digits); and rest duration (2 digits) u 1 , u 2 . It is provided at the head of chord line data when the chord duration is 0. Because of the chord rest data, the previous chord is held. The rest data is further used when such data as repeat, rhythm and fill-in data are inserted between chords. 
     FIGS. 11C-1 and 11C-2 show an example of repeat data. FIG. 11C-1 shows the data structure. It consists of repeat command data (2 digits) to be described later and no-chord data (2 digits). FIG. 11C-2 shows examples of the repeat command. Ten different repeat commands are prepared as shown. 
     FIGS. 11D-1 to 11D-3 show rhythm/fill-in/rhythm discrimination data. FIG. 11D-1 shows its ON and OFF data structures. Each data consists of rhythm/fill-in/thythm discrimination command data (2 digits) and rhythm data (2 digits) to be described later. FIG. 11D-2 shows rhythm/fill-in command data. It consists of rhythm command data, fill-in command data, and thythm discrimination command data, each having 2 digits. FIG. 11D-3 shows 17 different kinds of rhythm data for rock, etc., having 2-digits. 
     FIG. 11E shows the ON and OFF data of the tempo data. Each data consists of tempo command data (2 digits) and tempo data (2 digits) to be described later. FIG. 16 shows specific tempo data. The bit shown as symbol x represents ON tempo data as &#34;0&#34; and OFF tempo data as &#34;0&#34;. 
     FIG. 11F shows counter reset data. It consists of 4 digits. 
     FIG. 11G shows end data. It consists of 4 digits, and is provided at the end of the chord line data. 
     FIG. 17A and 17B show an example of musical piece stored in the ROM pack 25 or on the magnetic tape 32. The score shown is &#34;Air on G String&#34; by Bach. 
     Numbers shown between the melody and obligato lines represent the measure number. In the music score shown in FIG. 17, the melody, obligato and chord line data are shown in FIGS. 18A to 18C. Individual data is written in a variety of formats as described in connection with FIGS. 10A to 10J and 11A to 11G. In FIGS. 17A and 17B, and 18A and 18C, the circled letters indicate an off chord, and symbol NC indicates when no chord is present. 
     The operation of the above embodiment will now be described with reference to FIGS. 19 through 27. 
     First, a given ROM pack 25 is set in the ROM pack setting section 6. Th cord 24 leading from the tape recorder 31 is connected to the interface circuit provided in the interface circuit setting section 7. Then, the power switch 23 of the electronic musical instrument 1 is turned on, making it ready to automatically play using the ROM pack 25 or the magnetic tape 32. 
     To specify the pieces to be automatically played from the ROM pack 25, the number of the piece is entered into the music sequence memory 41 by operating the keys shown in FIG. 19. First, the R/MT switch 18 is operated for an odd number of times. The output of this key is fed to the control section 28. The control section 28 decides that the ROM pack 25 is selected (steps S 1  and S 2 ) in the flow chart of FIG. 21). If pieces having the numbers 5, 2, 14, 9, and 17, for instance, are designated, the data for these pieces is input one after another by operating the 12 keys from B 3  to B 4  as shown in FIG. 19. Since the program key for note B 4  is operated, the random number generator 42 is not rendered operative, and the designated musical sequence having 5 pieces is written as such in the musical sequence memory 41 (steps S 4  and S 8 ). When the play switch 22A is subsequently operated, the designated musical pieces are read out from the ROM pack 25 and are automatically played (steps S 9  and S 10 ). 
     When the R/MT switch 18 is also operated for an odd number of times to input random musical sequence data in the music sequence memory 41, steps S 1  and S 2  are executed. When 10 music pieces are to be selected, for instance, random designation data is input by operating the random key for not E B 3 . The designation is detected in step S 4 , and the number 10 is then set in the counter 43 in the random number generator 42. At the same time, the random number generator 42 is operated to generate random number data one by one to be written in the music sequence memory 41 (steps S 5  and S 6 ). At this time, the data 10 which has been set in the counter 43 is decreased by one every time one random number is generated. When 10 random numbers have been generated and written in the musical sequence memory 41, the counter 43 becomes 0. This is detected in step S 7 , which renders the random number generator 42 inoperative. When the play switch 22A is subsequently operated, a music piece is automatically played (steps S 9  and S 10 ). 
     When selecting musical pieces preset on the magnetic tape 32, the R/MT switch 18 is operated for an even numbers of times, whereby data representing the selection of the magnetic tape 32 is fed to the control section 28. As for the rest of the sequence, the key operation procedure is entirely the same as that shown in FIGS. 19 and 20. Subsequent to step S 1 , step S 3  is executed in which the magnetic tape designation data is stored in the control section 28. Step S 10  in FIG. 21 checks if any musical sequence data has been preset in the musical sequence memory 41, i.e., if all the preset data music pieces have been played. 
     When the ROM pack 25 is selected, the symbol &#34;R&#34; is displayed on the display section 5 as shown in FIG. 26. When the magnetic tape 32 is selected, the symbol &#34;MT&#34; is displayed as shown in FIG. 27. 
     The automatic playing step S 9  will now be described in detail with reference to the flow charts of FIGS. 22 through 24. When the routine is started, the number of the first piece is read out from the musical sequence memory 41. When the ROM pack 25 has been selected, the control section 28 sets the initial address of the read-out piece data in the address counter 30. Then it proceeds to read out the musical data for one piece of music from the ROM pack 25 while at the same time incrementing the address counter 30, the read-out data being written in the internal RAM 29 through the buffer 44. When the data of one piece is written in the internal RAM 29, the automatic play of the piece is started. 
     More specifically, the control section 28 sets the initial address of the internal RAM 29 in the address counter (ADC) 51 (step M 1  in FIG. 22). The data designated by the ADC is then read out and fed to the control section 28 (step M 2 ). The control section 28 then discriminates the data as being tone data, repeat data or end data (step M 3 ). If the data is determined to be tone data, step M 4  of the tone data process is executed. More particularly, the control section 28 feeds data based on the tone data to the first melody generator 34, the second melody generator 35, the chord generator 36, the bass generator 37 and to the rhythm generator 38 to generate the respective tone signals which are then coupled through the amplifier 39 and loudspeaker 40 to produce an audible sound from the sounding section 4. At this time, tone generation is effected simultaneously with the melody and obligato line data in the first and second melody generators 34 and 35. Further, chord, bass and rhythm are simultaneously generated according to chord line data in the chord generator 36, the bass generator 37 and the rhythm generator 38. Steps of tone data process will be described later in detail with reference to the flow chart of FIG. 23. 
     After the simultaneous tone data process for the melody, obligato and chord lines in step M 4  has been executed, step M 6  is executed, causing the control section 28 to increase the address counter 51 by 4 for the chord line while increasing both the melody and obligato lines by 6. The routine then returns to step M 2  to read out the next data. 
     If the discriminated data in the step M 3  is repeat data, step M 5  of the repeat process is executed, which will be described later in detail with reference to the flow chart of FIG. 24. When this process is completed, step M 6  is executed, and the routine is returned to step M 2 . If the discriminated data is end data, which means that the piece play has ended, a check is done to see if there is more music sequence data. Since only the first piece has ended, the instrument automatically begins to play the second piece. When all of the pieces within the preset sequence have been played, the automatic play function stops. 
     Step M 4  of tone data process will now be described with reference to the flow chart of FIG. 23. The tone data read out from the ROM pack 25 is set in the data register 45. When the process is started, the time measuring counter 50 is reset (step N 1 ). Then, the data-identifying section 46 identifies the tone data as being note data, timbre data, and so on for the melody and obligato lines, or as being chord data, rhythm data or tempo data, etc. for the chord line (step N 2 ). If the identified data is note or chord data, step S 3  is executed to check if the ON flag (F ON) 54 has the value of &#34;1&#34;. If the identified data is other than note or chord data, step N 17  is executed to set or reset the timbre, rhythm, or tempo, etc. When this has been completed, the process is shifted to judge the next tone data. 
     The ON flag 54 has the value &#34;1&#34; only when a tone is being sounded, otherwise it is &#34;0&#34;. If it is &#34;0&#34;, the tone or chord is made audible in the manner described in step N 4 , and the ON flag 54 is set to &#34;1&#34; (step N 5 ). After that, the ON-duration data is set in the tone duration register 47 (step N 6 ). The data-identifying section 46 then checks to see if the next data is double duration data. If it is not, step N 9  is executed. If it is, step N 8  is executed to add the double duration data (i.e., upper bit data u 1 , u 2  of the tone duration data) to the lower bit data L 1 , L 2  set in the tone duration register 47. Then, the data-identifying section 46 checks to see if the data in the tone duration register 47 is 0 (step N 9 ). If it is not &#34;0&#34;, step N 11  is executed to see if the time count data of the time measuring counter 50 has been read and if the unit time (Δt) has lapsed. If the prescribed unit time has not yet lapsed, steps N 11  and N 12  are repeatedly executed. When the unit time has lapsed, step N 13  is executed, and the tone duration register 47 is decreased by 1. Next, step N 9  is executed. The steps N 9 , N 11 , N 12  and N 13  are repeatedly executed until the ON time has lapsed. When the ON time has lapsed so that the contents of the tone duration register 47 are 0, step N 10  is executed to see if the ON flag 54 having the value of &#34;1&#34; has been checked. Since the ON flag 54 has the value &#34;1&#34; at this time, steps N 14  and N 15  are executed to set the OFF time in the tone duration register 47. Then the ON flag 54 changes its value to &#34;0&#34; (step N 16 ). Step N 9  is executed, and the steps N 9 , N 11 , N 12  and N 13  are executed until the OFF time has lapsed so that the contents of the tone duration register 47 are &#34;0&#34;. When the OFF time has lapsed, step N 10  is executed. Since the ON flag 54 has the value of &#34;0&#34;, the process is repeated for the next tone data. 
     Step M 5  of repeat process will now be described with reference to the flow chart of FIG. 24. A piece in which repeat play occurs is shown in FIG. 25A. In the figure, the process of the piece is indicated by the circled letters  ○a  to  ○1 . and by the numerals 0, 1, 2 and 3 which represent the respective contents of the repeat flag (RF) register 48. When the repeat command data as shown in FIG. 10C-2 is registered in the data register 45, the repeat process is started. The data identifying section 46 identifies if the repeat symbol is,   or  , when N has a value from 1 to 8 (step P 1 ). If it is identified as a symbol  , data 0 is set in the repeat flag register 48 (step P 6 ). Then the prevailing data (a) in the address counter (ADC) 51 is set in the return address register (RAD) (step P 7 ). Then step M 6  (FIG. 22), i.e., the switching ON and OFF of the quarter note and the eighth note, is executed. When repeat data   is read out at the step  ○d , the repeat process is started, and the symbol   is identified in step P 1 . Thus, step P 10  is executed to check if the contents of the repeat flag 48 are &#34;1&#34;, greater than &#34;1&#34;,  or less than &#34;1&#34;. Since the contents are &#34;0&#34;, i.e., less than &#34;1&#34;, at this moment, step P 22  is executed, and data &#34;1&#34; is set in the repeat flag register 48. Then step M 6 , i.e., the ON and OFF process for the next half-note at the step  ○e , is executed. When the repeat symbol   at  ○f  is fed to the data register 45, the repeat process is started once again, and the sequence continues from step P 1  to step P 2 . 
     In step P 2 , a check is done to see if the contents of the repeat flag 48 is &#34;2&#34;, greater than &#34;2&#34;, or less than &#34;2&#34;. Since it is less than &#34;2&#34; at this time, step P 3  is executed in which the prevailing value ○f  in the address register 51 is set in the jump address register (JAD) 53. Then, the value of data 2 is set in the repeat flag register 48 (step P 4 ). The address of the repeat data (symbol  ) stored in the return address register 52 is set in the address counter 51 (step P 5 ). Then the step M 6 , i.e., the process for the next tone data, i.e., the quarter note at  ○b , is started. 
     The repeat data at  ○d , i.e., symbol  , is set again in the data register 45 after the ON and OFF process of the quarter note and eighth note at  ○b  and  ○c , and after the repeat play has been executed. Following this, step P 1  and the step P 10  are executed. Since the repeat flag register contents have the value of &#34;2&#34;, i.e., greater than &#34;1&#34;, Step P 11  is executed to set the data  ○f  in the jump address register 53 in the address counter 51. The contents of the address counter 51 are incremented by 2, and the data   of the address  ○h  is read out and stored into the data register 45 (steps P 12  and P 13 ). Step P 14  is executed to check the data  . Then the contents of the address counter 51 is decreased by 1 to ○g  (step P 15 ) and are set in the jump address register 53 (step P 16 ). Then the address counter 51 is increased by 1 to ○h  (step P 17 ). The data having the value &#34;3&#34; is then set in the repeat flag register 48 (step P 18 ), and the contents of the address counter 51 are increased by 1 to  ○i  (step P 19 ). Then the dotted half note at  ○i  is read out (step P 20 ), and judged to see if it has the value   (step P 21 ). Since it is not  , step P 24  is executed, and the address counter 51 is decreased by 1 to  ○h . Then step M 6  of the tone ON and tone OFF process on the dotted half note in  ○i  is executed. 
     When it has been detected in the step P 1  that the repeat symbol   in the score at  ○j  has been read, step P 2  is executed. Since the repeat flag has a value of &#34;3&#34;, i.e., greater than &#34;2&#34;, step P 4  is executed, in which data having a value of 2 is set in the repeat flag register 48. Then step P 5  is executed, in which the address ○a  in the return address register 52 is set in the address counter 51. Next, step M 6  which produces the tones at  ○b  and ○c  is executed. When it has been detected in step P 1  that the symbol   at d has been read out, step P 10  is executed. Since the repeat flag data is &#34;2&#34;, i.e., greater than &#34;1&#34;, step P 11  is executed, and the address  ○g  in the jump address counter 53 is set in the address counter 51 which is increased by &#34;2&#34; to  ○i (step P 12 ). Then the data representing the dotted half note, is read out (step P 13 ), and step P 14  is executed. In step P 14 , the data is judged not to be the symbol  . Thus, data having the value of 1 is set in the repeat flag register 28 (step P 23 ), and the address counter 51 is decreased by 1 to  ○h . Then the routine is returned to the step M 6  to reproduce the dotted half note in  ○i . 
     When it has been detected in the step P 1  that the repeat symbol   at ○j  has been read out, step P 2  is executed. Since the repeat flag data is &#34;1&#34;, i.e., smaller than &#34;2&#34;, step P 3  is executed, and the prevailing value  ○j  in the address counter 5 is set in the jump address register 53. Then data having the value of 2 is set in the repeat flag register 48 (step P 4 ), and the address  ○a  in the return address register 52 is set in the address counter 51 (step P 5 ). Then the routine once again returns to step M 6  to reproduce the tones at  ○b  and  ○c . 
     When it has been detected in step P 1  that the symbol   at  ○d has been read out again, step P 10  is executed. Since the repeat flag data is &#34;2&#34;, i.e., greater than 1, step P 11  is executed, and the address  ○j  in the jump address counter 53 is set in the address counter 51. The address counter 51 is then increased by 2 to  ○l (step P 12 ). Then the data, i.e., the whole note, is read out (step P 13 ). In the next step P 14 , the data is judged not to be the symbol  . Thus, step P 23  is executed; the data &#34;1&#34; is set in the repeat flag register 48; and the address counter 51 is decreased by 1 to ═k  (step P 24 ). The routine is then returned to the step M 6  to reproduce the whole note. 
     While the repeat process which has been described above in connection with the musical score shown in FIG. 25A, FIGS. 25B to 25E show how the contents of the repeat flag register 48 vary in other music pieces having repetition. In all of these cases, the repeat play is executed in accordance with the flow chart of FIG. 24. The repeat flag data &#34;0&#34; indicates that a new musical phrase has been entered after the repeat symbol has been read out. The repeat flag data &#34;1&#34; indicates that another phrase is selected when the repeat flag data has the value of 2, or when the symbol   is read out when the repeat flag data is 2 or 3 and the data preceding by two pieces of data is not  . The repeat flag data &#34;2&#34; indicates that the repeat symbol   has been read out when the repeat flag data is other than 2. The repeat flag data having the value of &#34;3&#34; indicates that the symbol   read out when the repeat flag data is 1, and also that the data preceding by 2 is the symbol   when the repeat flag data is either 2 or 3. 
     While in the above embodiment a ROM pack has been used, a RAM pack may also be used. Also, any magnetic recording device other than the magnetic tape recorder may be utilized. 
     As has been described in the foregoing, the automatically playing instrument according to the invention has a memory pack containing data for a plurality of musical pieces which can be selected and automatically played. Thus, complex musical pieces can be automatically played more inexpensively than with the prior art apparatus of this kind. 
     Additionally, with the auto-playing apparatus according to the invention a memory pack and a magnetic recording apparatus such as a tape recorder with musical piece data preset therein may be used, either one of which may be selectively used for automatic playing. Thus, the automatic playing music may be readily enjoyed without requiring the connection of a recording medium when changing the recorded media. 
     Further, with the auto-playing apparatus according to the invention, a memory pack is used in which melody, obligato data, and chord data which are to be played simultaneously in one musical piece are sequentially stored as musical data so that a plurality of different melodies can be automatically and simultaneously played with chords. Thus, automatic playing having richer musical expression can be obtained. 
     Still further, with the auto-playing apparatus according to the invention, a memory pack is used in which musical piece data containing repeat data is stored and in which a musical phrase can be repeatedly and automatically played according to the previously read-out repeat data. Thus, musical pieces having a number of repeated phrases can be stored using less of the memory. 
     Moreover, with the auto-playing apparatus according to the invention automatic playing can be obtained with a memory pack which stores musical piece data including pitch and tone duration data, and which also includes command data indicating which tone duration data is longer than the predetermined reference duration. Thus, tone duration data having a large value can be obtained using only a minimum amount of the memory, and automatic playing having a richer sound can be obtained.