Musical key determining device
BACKGROUND OF THE INVENTION 
     This invention relates to a musical key determining device which determines a musical key of a music piece on the basis of chord and melody data of the piece. 
     For application in automatic accompaniment and arrangement of a music piece, various devices are proposed which serve to determine a key of the music piece on the basis of actually performed contents (automatic performance data). For example, U.S. Pat. No. 5,056,401 discloses such a device that determines a key of a music piece on the basis of detection of a specific chord progression. But, the disclosed musical key determining device requires a very complex structure, since it determines a key by covering or tracing a very complicated progression of chords. In addition, because the same kind of chord progression is used for various different keys, it is not always possible to determine a specific key only by tracing a chord progression. In such a case, a specific key determined from among various different keys, very often, tends to be incorrect, and therefore the determined key can not be used for automatic accompaniment and/or automatic arrangement. Besides, in some cases, such a key is determined which corresponds to the chord progression but not to the melody. 
     SUMMARY OF THE INVENTION 
     It is therefore an object of the present invention to provide a musical key determining device which is capable of making an accurate key determination with a relatively simple construction. 
     In order to achieve the above-mentioned object, a musical key determining device in accordance with the present invention comprises a performance information supplying section for supplying melody information and chord information of a music piece, a possible musical key nomination section for nominating one or more possible musical keys on the basis of the chord information supplied by the performance information supplying section, and a judging section for judging, on the basis of the melody information supplied by the performance information supplying section, whether or not it is proper to determine any of the possible musical keys as a musical key of the music piece. 
     First, on the basis of the chord information, one or more possible musical keys are nominated. Then, on the basis of the melody information, it is judged whether it is proper to determine any of the possible musical keys as a musical key of the music piece. For example, since melody notes are generally composed of scale notes, those possible musical keys which do not contain all of the melody notes as their scale notes are excluded, and a single musical key which contains all of the melody notes as its scale notes is determined as the musical key of the music piece. This allows a musical key determination which is very reasonable from a musical point of view. Therefore, because a key is determined on the basis of both chord and melody, it is possible to greatly improve the accuracy of key determination. Besides, even if the possible key nomination on the basis of the chord is made relatively simple, the subsequent additional determination based on the melody can secure a desired accuracy, and thus it may not be necessary to perform a particular analysis of a complicated chord progression. Therefore, as a whole, it is possible to realize a much simpler structure. For example, because the &#34;dominant motion&#34; in the chord progression strongly suggests specific keys, it is allowed to make a proper musical key determination with a simplified construction, by nominating the possible keys on the basis of detection of such a dominant motion and by verifying whether or not the nominated possible keys are proper on the basis of the melody notes. 
     Now, the preferred embodiment of the present invention will be described in greater detail with reference to the accompanying drawings. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     In the drawings: 
     FIG. 1 is a block diagram illustrating an embodiment of a musical key determining device in accordance with the present invention; 
     FIG. 2A is a diagram illustrating a memory format in a melody memory shown in FIG. 1; 
     FIG. 2B is a diagram illustrating a memory format in a chord memory shown in FIG. 1; 
     FIG. 2C is a diagram illustrating a memory format in a musical key memory shown in FIG. 1; 
     FIG. 3 is a flowchart illustrating an example of a key determining process performed in the embodiment of FIG. 1; and 
     FIG. 4 is a flowchart illustrating another example of the key determining process. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT 
     FIG. 1 is a block diagram illustrating an embodiment of a musical key determining device in accordance with the present invention. This musical key determining device, which is adapted for being incorporated into an automatic performance device or an automatic arrangement device, has a function of determining a key of a music piece on the basis of automatic performance data of the music piece. Although not described here in detail, once a musical key has been determined, control is made of automatic accompaniment, automatic arrangement etc. 
     To a central processing unit (CPU) 10 are connected, via a bus 11, a program memory 12, a melody memory 13, a chord memory 14, a key memory 15 and a working memory 16. The program memory 12 has a program stored therein which will be described later using flowcharts. In the melody memory 13 and chord memory 14, there are stored automatic performance data which comprise melody data and chord data. The musical key memory 15 stores data indicative of a key determined on the basis of the automatic performance data. 
     FIGS. 2A through 2C illustrate memory formats in the memory 13, chord memory 14 and musical key memory 15, respectively. FIG. 2A illustrates the memory format in the melody memory 13. Each tone data of a melody (melody tone data) is composed of pitch data MDi and duration data DLi, and these melody tone data are sequentially stored in the melody memory 13 in the performance order of the melody. &#34;i&#34; is a suffix that represents the order in which the melody tone changes (melody tone change order). FIG. 2B illustrates the memory format in the chord memory 14. Each chord data is composed of root data Tn, chord type data TYPEn and chord duration data CDLn. &#34;n&#34; is a suffix that represents the order in which the chord changes (chord change order). Further, FIG. 2C illustrates the memory format in the musical key memory 15. This memory 15 stores key data indicative of keys having been determined on the basis of the automatic performance data, in the order in which the key changes. Each key data is composed of tonic data TNLYm, major/minor key data MODEm and key change timing data TMm. &#34;m&#34; is a suffix that represents the order in which the key changes (key change order). 
     FIG. 3 is a flowchart illustrating the operation of the musical key determining device. In the illustrated example, a single possible key is nominated on the basis of whether or not a dominant motion is present in a chord progression. When it has been confirmed that the nominated possible key is also not inconsistent with the melody, the possible key is made confirmed key. First, in step S1, every register is initialized. More specifically, the following procedures are taken for the initialization purposes. 
     ROOT0 which is the first chord data in the chord memory is set into a root register RT provided for a chord in the current section (current chord). TYPE0 is set into a type register TP provided for the current chord, and &#34;1&#34; is set into a section number register n. Further, &#34;FFH&#34; (which is the maximum value of the hexadecimal number system and represents &#34;undetermined&#34;) is set into a tonic register OTN provided for the key of a chord in the last section (last key) and into a mode (major/minor) register OMD provided for the last key. The section number n, which corresponds to the chord change order, is &#34;1&#34; at first and then increments its value one by one (&#34;2&#34;, &#34;3&#34;, . . . ) whenever a chord change occurs. 
     In subsequent steps S2 to S9, the following procedures are taken to determine a key in section n. First, the contents in the root register RT and type register RT (ROOT0, TYPE0) are copied into the root register ORT and type register OTP provided for the chord in the last section (last chord) (step S2). Next, the root ROOTn and type TYPEn of the chord in the current section are set into the registers Rt and TP for the current chord (step S3). Then, in view of the last chord, it is examined whether or not the progression or change to the current chord is a dominant motion (step S4). The dominant motion means a chord progression from the dominant seventh chord to the tonic chord. Namely, if the relation between the last and current chords corresponds to that between the dominant seventh and tonic chords, the chord progression is determined as being a dominant motion. 
     For this purpose, the following conditions are confirmed in step S4: 
     TP=Morm (the current chord is a triad of major or minor key), 
     OPT=7th (the last chord is a seventh chord), and 
     (ORT+12-RT)=7 (the interval between the last and current chords is perfect five degrees (seven semitones). 
     If the above conditions are all satisfied, the transfer from the last chord to the current chord can be said to be a dominant motion. 
     When such a dominant motion is detected, the current chord is judged as a tonic chord, and therefore data indicative of this key is set into a provisional new key tonic register TN and a provisional key mode register MD, as a provisional new key (i.e., possible new key commencing in this section). In other words, root data of the current chord is set into the register TN as tonic data, and data indicative of the type (major/minor) of the current chord is set into the register MD as mode data. Further, on the basis of the melody in the section, it is confirmed whether the provisional new key is correct or not (step S6). Namely, the provisional new key is confirmed as being correct, if note which is among the scale notes of the last key identified by the data stored in a last key tonic register OTN and a last key mode register OMD but is among the scale notes of the provisional new key identified by the data stored in the provisional key registers TN and MD is contained among the melody notes in the current section. Once the provisional new key has been confirmed as being correct, various data TNLTY, MODE, TM are stored into the musical key memory 15 at such addresses designated by order data m (step S7); that is, the chord section number n is set as key change timing data TMm, the data in the register TN is set as tonic data TNLTYm, and the data in the register MD is set as major/minor data MODEm. In addition, the data in the provisional new key registers TN and MD are transferred to the last key registers OTN and OMD. 
     On the other hand, if the provisional new key has not been confirmed as being correct, it is considered that no key determination has been made this time, and so the last key (OTN and OMD) is set into the provisional registers TN and MD (step S8). In step S9, it is determined whether or not the section number n is now indicative of the last section (i.e., the end of automatic performance). If the determination result is &#34;NO&#34;, the program goes to step S10. In step 10, the section number n is incremented, and the program goes back to step S2 to repeat the above-mentioned procedures. 
     The order data m for designating storage addresses in the musical key memory 15 is &#34;1&#34; (m=1) at first. Further, the last key registers OTN and OMD are initially set at an undetermined value FFH, and thus, when a first dominant motion is detected, the determination result in step S6 always becomes &#34;YES&#34; so that the program goes to step S7. Accordingly, when the first dominant motion is detected, the data TMm, TNLTYm and MODEm corresponding to m=1, i.e., TM, TNLTY and MODE are stored in step S7 into respective predetermined addresses (see FIG. 2C). In the case where the above-mentioned procedure has been done with respect to m=1, condition of m=0 is resumed, and the same data as TNLTY1 and MODE1 are stored into the memory as the first tonic data TNLTY0 and major/minor data MODE0 (FIG. 2C). This means that a key determined when the first dominant motion has been detected represents an original key of the music piece. Namely, TNLTY0=TNLTY1 and MODE0=MODE1. After that, the order data m is incremented to m=2, so that when the procedure of step S7 is done next time, data TM2, TNLTY2 and MODE2 will be stored into respective predetermined addresses. Subsequently, the order number m increases one by one each time the program takes step S7. However, in many cases, the value of m remains very small since modulation, i.e., key transfer generally does not occur so often in one music piece. 
     In the embodiment described above, key determination is carried out by detecting a dominant section in connection with the chord progression and by examining the scale notes of provisional new key and last key in connection with the melody. Alternatively, the key determination may be performed taking other factors into consideration. 
     FIG. 4 illustrates another embodiment of the key determining process. This process determines a key only on the basis of chord and melody of a section in question, without taking a chord progression into consideration. First, &#34;1&#34; is set as the section number n (step S21), and FFH (value indicating &#34;undetermined&#34;) is set into tonic register TN and mode register MD for a key to be determined (step S22). 
     In subsequent steps S23 to S29, the following procedures are taken to determine a key in section n. First, the contents in the tonic register TN and mode register MD are set into tonic register ORN and mode register OMD for the key in the last section (last key) (step S23). Next, root data ROOTn and type TYPEn of the chord in the current section are set into the root register RT and type register TP (step S24). Then, a key having this chord as diatonic chords is nominated as a possible key (step S25). At the greatest, six keys will be nominated as this possible key. For example, C major chord cab be diatonic chords of C major key, F major key, G major key, A minor key, D minor key and E minor key, and thus these keys will be the possible keys. A final possible key is selected on the basis of those of the melody notes corresponding to the section n that are not among the scale notes of the last key but are among the scale notes of specific one of the nominated possible keys (step S26). If more than one possible keys are selected in step S26, then one specific key is determined as the final key on the basis of some priority order (for example, related keys) obtained from the last key, and its tonic and mode are written into the register TN and register MD, respectively (steps S27 and S28). The priority order may be stored in, for example, a table in advance. Subsequently, while incrementing the section number n, the above-mentioned steps S23 to S28 are repeated until the last section (steps S29 and S30). 
     The repetition of routine passing step S10 or step S30 may be effected at each of predetermined fixed clock timings or in synchronism with automatic performance timings. 
     Furthermore, although the foregoing embodiment has been described as determining keys by the use of memory-stored automatic performance data, the key determination may be made by inputting data which are obtained from real-time performance on a keyboard or other suitable input instruments.