Data processing apparatus for electronic musical instruments

Abstract: A data processing apparatus for an electronic musi­ cal instrument permits a microcomputer (31) to run a tone generating program for generating various types of musical tones. The microcomputer (31) calls the program by a timer interrupt signal and runs it for tone genera­ tion. The tone generation process is executed to gene­ rate a musical tone in synchronism with an envelope waveform process. Further, even if the time for sam­ pling digital musical tones to be sent to a D/A con­ verter is not constant, an analog signal free of distortion can be acquired.

Description: The present invention relates to a data processing apparatus for a sound signal generator, and, more particularly, to the architecture of a data processing apparatus for electronic musical instruments. The invention furthermore relates to an electronic musical instrument comprising such a data processing apparatus. Although recent electronic musical instruments are computerized, that portion associated with tone generation which requires a high-speed computation of a vast amount of data, is still executed by exclusive or special-purpose hardware called a sound source circuit. A microcomputer merely processes control inputs to a musical instrument, such as an input from a keyboard or console panel, an input from a MIDI or other external units and an input from an internal or external unit, and sends proper commands to the sound source circuit. Sound source circuits, which have different structures depending on the system for generating musical tones, normally have a large circuit scale irrespective of the structure of the sound source systems. The circuit scale of typical sound source circuits is about two times that of a microcomputer (central processing unit). Fig. 1 exemplifies in a block diagram of a sound source circuit involving a PCM sound source. A microcomputer 2, which controls a PCM sound source 1, sends data (command) necessary for tone generation to the PCM sound source 1. Such a command is set in individual sections in the sound source through a sound source command analyzer 3. For instance, data is set through the following procedures at the beginning of tone generation. (a) Addresses (normally consisting of a start address, end address and loop address) for a waveform memory 8, in which waveforms to be generated are stored, are sent and set in an address controller 5. (b) Pitch data of a musical tone to be generated is sent and set in a pitch controller 6. (c) Envelope data is sent and set in an envelope controller 7. (d) Channel control is set ON (data is set in a channel ON/OFF controller 4). With the use of a polyphonic sound source, these data should have a matched channel number and the individual sections of the sound source 1 should be operated in time-sharing manner. When the above data is set, the PCM sound source 1 produces a musical tone in the following manner. The address controller 5 reads out from the waveform memory 8 waveform data located at two adjacent addresses closest to an accumulated result of the pitch data from the pitch controller 6, the waveform data representing an immediately preceding waveform value and an immediately following waveform value. The waveform data is sent to a waveform processor 9 which in turn computes the difference between these two waveform values. The difference and the immediately preceding waveform value are sent to a multiplier 10, which multiplies the computed difference by a decimal point portion PD of the address of the waveform memory (given from the pitch controller 6 in the diagram) and adds the immediately preceding waveform value to the resultant value to thereby provide an interpolation value. The multiplier 10 then multiplies this interpolation value by an envelope value ED produced in the envelope controller 7, thus providing an instantaneous value of a tone waveform of the channel. This instantaneous value is accumulated by an adder 11 for all the channels, and the resultant data is sent to a D/A converter 12 to be an analog tone signal. As is obvious from this example, it is necessary to provide an arithmetic operation unit and a memory for temporary storage of data, here and there at the data processing stages, thus requiring a large-scale circuit. A specific sound source circuit has a structure to simply realize a specific sound source system and one or combination of a specific number of polyphonic sounds, so that changing the polyphonic number necessitates great alteration of the circuit and/or addition of a circuit. It is also necessary to design a set of commands to be sent to the sound source circuit from the microcomputer in accordance with the sound source, thus requiring a significant time for developing a sound source control program. There may be a controller for an electronic musical instrument whose architecture permits a microcomputer alone to simultaneously execute processing of control inputs to a musical instrument and tone generation. To realize such a controller, there is a demand for a microcomputer having an architecture to ensure tone generation that requires a high-speed data processing of a vast amount of data. For instance, typical microcomputers use an internal register or a general-purpose internal register, called an accumulator, as memory means for temporary storage of computing data. The accumulator may hold data from a data memory on one occasion, and holds the result of computation (e.g., addition) of two pieces of data from the data memory performed by a computing circuit on another occasion. Data temporarily held in the accumulator is set back to the memory location specified on the data memory. Using a microcomputer with such a structure for tone generation requires a considerable time for frequent data transfer between the data memory and the accumulator (or general-purpose register) and thus becomes a hindrance to achieving tone generation processing that should deal with a vast amount of data. A description will now be given of the envelope controller 7 (envelope generator) which is incorporated in the hardware of a sound source circuit. Fig. 2 illustrates a typical envelope controller. Various values from a microcomputer are set in an envelope Δx register 24, an envelope Δy register 25 and a target envelope register 26 via the sound source analyzer 3 which serves as an interface. In operation, the content of an envelope Δx timer 21 is counted up by an INC counter 22. When the count value of this timer 21 coincides with the content of the envelope Δy register 24, a comparator 23 outputs a coincidence signal to clear the INC counter 22. The coincidence signal further opens an AND gate G1, and data Δy from the envelope Δy register 25 is input to an adder-subtracter 27. This data Δy is added to or subtracted from a present envelope value from a present envelope register 29 in accordance with an adding/subtracting flag (a specific bit of the envelope Δy register 25). The result of the computation is compared with a target envelope level from a target envelope register 29 by a second comparator 28. The comparison result is used to determine a new present envelope value. In other words, if the computed result has not reached the target envelope, it is output as a new present envelope value via a gate G2 and set back to the register 29. If the computed result reaches the target envelope, however, the coincidence signal from the comparator 28 opens a gate G3 through an inverter INV to output the target envelope as a new present envelope value, which is then set back to the register 29. The coincidence signal from the comparator 28 is held in a coincidence signal holding circuit 30 to request setting of data of the next envelope step (Δx, Δy, a target envelope). The envelope generator as shown in Fig. 2 has a shortcoming that it is part of the hardware of the sound source circuit. Once the microcomputer sets data of Δx, Δy and the target value, therefore, it cannot grasp a present envelope value thereafter. (Permitting the microcomputer to read out the present envelope value, though possible, requires a significantly complex circuit.) When it is necessary to jump the envelope step, therefore, it is difficult to set data (Δx, Δy, the target value) suitable for the present envelope value. Assuming that data for a release envelope which consists of three segments is on the microcomputer side as shown in Fig. 3, due to the present envelope value unclear, the microcomputer cannot determine data (Δx, Δy, the target value) to which segment should be sent to the sound source. A conventional solution to this problem is to send an envelope step update signal (the output of the coincidence signal holding circuit 30 in Fig. 2) to the microcomputer to request updating of the step and to transfer data for the next step to the sound source from the microcomputer. With this arrangement, although the microcomputer cannot grasp the present envelope value being produced by the sound source, it can grasp the envelope step being executed by the sound source. This permits the microcomputer to select a release envelope segment corresponding to a value which this envelope step can take at a tone release time, i.e., a release envelope segment having a target value lower than but closest to the target value of the present envelope, then transfer data for the selected release envelope segment to the sound source. This particular design, however, has a problem that a zigzag line characteristic of a release envelope is restricted by another envelope portion. This is because that release envelope data should be prepared in advance to match with the range of the envelope value of another step, thus limiting the characteristic that the envelope can have. With a design to allow a microcomputer itself to generate musical-tones, it is very difficult, if not impossible, to completely keep at constant the period of the sample sequence of digital musical tones to be sent to a digital-to-analog (D/A) converter from the microcomputer due to the nature of a program-controlled operation. In other words, since the amount of works (amount of processing) that should be done by the microcomputer varies with time by inputs to the microcomputer, the amount of processing required for tone generation included in intended data processing also varies. This means a variation in period for generating a digital musical tone. When a digital musical tone varying in an unstable period is converted into an analog signal, the resultant musical tone would be distorted, which is very crucial to electronic musical instruments. US-A 4,184,400 discloses a data processing apparatus according to the preamble of claim 1 as well as an electronic musical system which is provided with additional computer-external tone generator units generating the actual musical sound signals. The CPU determines control signals for the tone generator units. Similarly, GB-A-2 013 386 discloses an electronic sound processing device in which the output signals of the control processor are fed to an output control system. The output control system generates the musical sound signals. It is the primary object of this invention to provide a data processing apparatus for a sound signal generator which has a new and improved structure to ensure tone generation under the program control of a computer, e.g., a microcomputer, without requiring special-purpose hardware of a sound source circuit. To achieve this object there is provided a data processing apparatus comprising the features mentioned in claim 1. The present invention provides a data processing apparatus which can extract a digital musical tone generated by a microcomputer itself at an accurate sampling period and output it as an analog signal with less distortion. Herefor, the microcomputer comprises first latch means for latching a digital tone signal generated by the microcomputer at a timing of a program control signal from the microcomputer, and second latch means, provided between an output of the first latch means and D/A converting means, for latching an output signal of the first latch means at a timing of an accurate sampling time signal. With the above arrangement, a digital musical tone signal supplied to the input of the D/A converting means can be switched at a timing of an accurate sampling time signal by the function of the second latch means. This means that the conversion period for converting a digital signal into an analog signal in the D/A converting means is accurately maintained. Therefore, distortion on an analog musical tone signal which may occur during D/A conversion can be reduced as much as possible, so that an acoustic signal with a good quality can be output. The above apparatus requires no hardware of a sound source circuit for generating musical tones. The data processing apparatus for an electronic musical instrument having this novel architecture has significant advantages. The first advantage is freedom of design. More specifically, alteration of the number of polyphonic sounds and alteration of a tone combining system can be coped with design alteration of a program. The second advantage is its capability to significantly reduce the overall circuit scale because no sound source circuit hardware is needed. Conventionally, since a source circuit LSI chip has a large circuit scale, there is a limit to improving the yield in production of chips (the yield being substantially inversely proportional to the chip area). Those advantages can therefore considerably reduce the cost for manufacturing electronic musical instruments. In one structural example, the program storage means comprises a read only memory (ROM). The microcomputer is realized by an integrated circuit chip on which a D/A converter for converting a digital musical tone into an analog signal and a port for receiving an input to control the electronic musical instrument are mounted in addition to the aforementioned components of the microcomputer. The arithmetic operation means may include a multiplier for computing waveform data. Further improvements of the invention are stated in the subclaims. The program for generating musical tones can be executed by interrupt program processing (interrupt processing) invoked by an interrupt signal which is generated in a tone sampling period. The use of such a timer interrupt technique can ensure accurate tone generation. Further, programs to be stored in the program storage means can be efficiently prepared and the total number of steps of each program can be reduced, thus requiring less memory capacity for the program storage means. Furthermore, generation of an interrupt signal at every given time can be utilized so that if a routine for measuring the elapse of time is incorporated in the interrupt program, it is possible to acquire time data necessary in a main program (main flow), such as a period with respect to the resolution of a tempo for an automatic musical performance or accompaniment. Of parameters of a musical tone to be generated, an envelope gently changes with time, so that its generation may not be executed in the interrupt process. In that case, the timing at which the envelope is updated (at which a new envelope value is computed) can be known from the result of the time measuring process executed in the interrupt process while running the envelope producing process (if the envelope needs to be updated at a constant period). In another structural example, the microcomputer is realized by an integrated circuit chip on which a D/A converter for converting a digital musical tone data into an analog signal and a port for receiving an input to control the electronic musical instrument are mounted in addition to the aforementioned components of the microcomputer. In a specific arrangement, the registers in the arithmetic operation storage means can serve as means to store data as well as a so-called accumulator. This can eliminate the need for an ordinary accumulator. Further, the individual registers in the arithmetic operation storage means can be directly addressed by a program stored in the program storage means (which does not mean that it is not possible to execute indirect addressing such as the one done by an index). Accordingly, an arithmetic operation between the registers can be directly executed (without going through the accumulator) using the arithmetic operation means. Furthermore, the individual registers in the arithmetic operation storage means can be used exclusively; general use of the registers is also possible so that the "exclusive use" does not mean to deny the general use of part of the registers. Particularly, the arithmetic operation storage means includes a group of registers which are used for arithmetic operation and for exclusively storing various musical tone parameters (such as an envelope rate, a phase value parameter and a phase change degree parameter). Running the tone generating program can ensure efficient execution of arithmetic operations (with the highest efficiency) between those registers exclusive for the various musical tone parameters in an operational sequence until digital data sample of a musical tone is obtained, thus reducing the number of times data in the tone data storage means is referred to. This ensures quicker processing of a vast amount of data (musical tone parameters) and facilitates tone generation in real time. For instance, one register is exclusively used to hold the value of the present phase (phase of a waveform), while another register is exclusively used to hold data of the degree of a change in phase value. When conditions for updating the present phase value are met, the tone generating program issues a command to add the degree of change to the present phase value. At that time, it is not particularly necessary to read out data of the present phase value and the degree of change from the tone data storage means or to store the envelope value resulting from the required arithmetic operation. If the register (first register) for storing the present phase value is directly assigned as the first operand (item to be operated) and the register (second register) for storing the degree of change as the second operand (item to operate) and addition of these two values is specified by an operation code, then the data of the first register and the data of the second register are output and input to the arithmetic operation means where an adder performs the addition, and the output of this means (new phase value) is returned to the first register, all automatically, i.e., under the control of the operation control means. In case of a more complicated system where the degree of change in phase value varies depending on the phase ranges, a group of registers (referred to as group A) for exclusive storage of data about the degree of change within the respective ranges and another group of registers (referred to as group B) for exclusive storage of the phases at the boundaries of the phase ranges (boundary value data) should be prepared and the boundary values in the register group B need to be compared with the present phase value prior to executing the phase addition. Based on the comparison result, the register storing the selected or desired degree of change is determined among the register group A. During the process carried out in the above two examples, it is totally unnecessary to access to the tone data storage means to acquire data (musical tone parameters). In other words, unlike a typical microcomputer, it is possible to eliminate a process for reading data from the tone data storage means and holding it in an accumulator (or a general-purpose register). As one effective means for maintaining the sampling period for tone generation, there may be a structure which utilizes the control mechanism of a timer interrupt and executes a tone generating program upon each occurrence of an interrupt. (A musical tone is generated by a timer interrupt program in a second embodiment to be described later.) Upon reception of an interrupt, ordinary microcomputers need to save the status of a process at that point of time in order to continue the process after the interrupt processing is completed. In this case, in running the tone generating program (the program which has made the interrupt), only an exclusive register is used to store musical tone parameters. This means that no data rewriting or updating is performed for those registers which are used by a program that has been interrupted, while the tone generating program is running. If the content of that register involved in a process is not updated, the status of that process need not be saved. This can eliminate the need to save and recover the status of a process (status of a general-purpose register), thus resulting in reduction in the processing time. (The status of a program counter or an equivalent element has only to be saved at the beginning of an interrupt.) In preferred embodiments which will be described later, an input/output port for receiving control inputs to a musical instrument, a timer interrupt controller for causing an interrupt and a D/A converter for converting a digital data sample of a generated musical tone into an analog signal are also mounted on the IC chip containing the microcomputer. In addition, the arithmetic operation means includes a multiplier used for computing waveform data. The invention also provides a data processing apparatus for an electronic musical instrument which can generate a musical tone without using exclusive sound source circuit hardware and can produce an envelope whose characteristic is free of any restriction at an accurate timing. The elimination of the need for sound source circuit hardware results in reduction in circuit scale, improvement of the yield in production and design freedom. In addition, the generation of an envelope at an accurate timing can provide a better envelope. Furthermore, since the functions of an electronic musical instrument are realized entirely under a program control according to the present invention, the microcomputer can always grasp the present envelope value which is originated from execution of a routine to compute the envelope of a musical tone. Accordingly, it is free to jump the steps of an envelope, thus totally eliminating any restriction to the characteristic of an envelope that can be generated. The present invention also provides an electronic musical instrument having a microcomputer without the need for exclusive sound source circuit hardware, as stated in claim 11. This electronic musical instrument can generate an envelope free of restriction on its characteristic at an accurate timing. The electronic musical instrument can have microcomputer that controls a tone generating program to generate a musical tone and can extract a digital musical tone at an accurate sampling period to thereby acquire an analog signal with less distortion. This invention can be more fully understood from the following detailed description when taken in conjunction with the accompanying drawings, in which: Fig. 1 is a general diagram of a conventional electronic musical instrument of a PCM sound source system; Fig. 2 is a diagram illustrating a conventional envelope generator for providing an envelope; Fig. 3 is a diagram illustrating the status of producing an envelope according to the prior art; Fig. 4 is a general block diagram of an electronic musical instrument according to the present invention; Fig. 5 is a block diagram of a microcomputer; Fig. 6 is a flowchart of a main program for a microcomputer; Fig. 7 is a flowchart of an interrupt program that generates a musical tone; Fig. 8 is a flowchart of a sound source process; Fig. 9 is a diagram illustrating the flow of the operation in the first embodiment; Fig. 10 is a time chart illustrating the operation in the first embodiment; Fig. 11 illustrates a table of a sound source processing RAM; Fig. 12 is a detailed flowchart illustrating one channel processing shown in Fig. 8; Fig. 13 is a diagram illustrating the status of an envelope to be generated; Fig. 14 is a diagram illustrating part of an envelope which is generated by a timer interrupt process; Fig. 15 is a diagram illustrating part of an envelope which is generated by an ordinary subroutine process; Fig. 16 is a diagram illustrating an original sound and waveform data read out with a doubled frequency; Fig. 17 is a diagram illustrating interpolation waveform data with respect to time; Fig. 18 is a flowchart illustrating the operational flow when a subroutine that is executed for a given period of time is used; Fig. 19 is a diagram illustrating part of a main flowchart in Fig. 18; Fig. 20 is a diagram illustrating part of a main flowchart involving a constant processing time; Fig. 21 is a flowchart illustrating a process for one channel in which all the processing times are constant; Fig. 22 is a time chart illustrating a waveform generating operation according to the third embodiment; Fig. 23 is a structural diagram in a case where the sampling period for tone generation is synchronized with the conversion period of a D/A converter; Fig. 24 is a structural diagram in a case where the timing for generating a waveform under a program control does not coincide with the conversion period of a D/A converter; Fig. 25(A) is a diagram illustrating an interrupt process and the status of a timing at which data is input to a D/A converter when the arrangement shown in Fig. 23 is used; and Fig. 25(B) is a diagram illustrating an interrupt process and the status of a timing at which data is input to a D/A converter when the arrangement shown in Fig. 24 is used. First Embodiment The first preferred embodiment of this invention will now be described referring to the accompanying drawings. Fig. 4 illustrates the general structure of an electronic musical instrument associated with the first embodiment. The general control of the apparatus is executed by a microcomputer 31. In other words, the microcomputer 31 executes not only processing of control inputs to a musical instrument but also a tone generation process, so that no sound source circuit hardware is required for tone generation. A switch section 34 comprising a keyboard 32 and function keys 33 serves as a source to enter control inputs to a musical instrument, and data entered via this switch section 34 is processed by the microcomputer 31. A digital tone signal generated by the microcomputer 31 is converted into an analog signal by a D/A converter (included within the microcomputer 31), filtered by a low-pass filter 35 and amplified by an amplifier 36 so that a musical sound is produced through a loudspeaker 37. A power source 38 serves to supply the necessary power to the microcomputer 31, low-pass filter 35 and amplifier 36. Fig. 5 illustrates in a block diagram the internal structure of the microcomputer 31. The individual elements illustrated are mounted on one chip. The microcomputer 31 actually manufactured with a chip size of 5 mm × 5 mm is capable of generating eight polyphonic sounds simultaneously and is of a PCM (Pulse Code Modulation) type tone forming system. It should however be noted that the present invention can well apply to other microcomputers capable of generating a different number of polyphonic sounds and having a different tone forming system. A program for processing various control inputs to a musical instrument and a program for generating musical tones are stored in a control ROM 41, and program words (commands) located at addresses specified via a ROM address decoder 42 by a ROM address controller 49 are sequentially output. In the specific embodiment, a program word has a length of 28 bits and part of the program word is input as a lower portion of the next address to be read out (address within a page) to the ROM address controller 49; this is a so-called next address system. Alternately, a program counter system may also be employed. When an operand of a command from the control ROM 41 specifies a register, a RAM address controller 43 specifies the address of an associated register in a RAM 44. The operand may also serve to set a numerical value in the register. The RAM 44 comprises registers which are used for general arithmetic operations, flag operations, arithmetic operations for musical tones, and so forth. As exemplified in Fig. 11, many registers are used exclusively for arithmetic operations for musical tones. A unit 45 serving as an adder-subtracter and logical operation section and a multiplier 46 constitute an arithmetic unit (AU), which is used when a command from the control ROM 42 is an arithmetic instruction. Particularly, the multiplier 46 is used for an arithmetic operation of a musical tone waveform, and first and second data inputs (e.g., 16-bit data) are multiplied and data having the same length as the inputs (i.e., 16 bits) is output in order to optimize the operation. A ROM 47 for control data and waveform stores various musical tone control parameters such as pitch data, envelope data (rate, level), and musical tone waveform data of a PCM type. The envelope data and tone waveform data are prepared for each timbre of a musical tone. As illustrated, the ROM 47 is accessed indirectly by referring to the contents of the register on the RAM 44 specified by the operand in a program stored in the control RAM 41. In the present embodiment, the ROM 47 is an internal memory and its operation is directly controlled by an operation controller 48 which controls the operation of the RAM 44, so that the time of accessing to the ROM 47 is the same as the time of accessing to the RAM 44. An operation analyzer (operation controller) 48 decodes an operation (OP) code of a command from the control ROM 41 and sends control signals to its individual units in order to execute the specified operation. In order to run a tone generating program stored in the control ROM 41 every given time, a timer interrupt is employed in this embodiment. That is, an interrupt controller 50 having a timer (hardware counter) sends a control signal (interrupt request signal) to the ROM address controller 49. In response to this signal, the ROM address controller 49 saves (holds) the address of the next command of the main program and sets the head address of an interrupt program (subroutine) that generates a musical tone in place of the former address. Then, the interrupt program starts running. Since a return command is placed at the end of the interrupt program, the ROM address controller 49 sets the saved address again and the flow returns to the main program when this return command is decoded by the operation analyzer 48. Although the interrupt controller 50, which causes the microcomputer 31 to stop a presently-executing task and requests a special process, is illustrated as an internal element of the microcomputer 31 (CPU) in the diagram, it is logically an external element (peripheral unit) of the microcomputer 31. The interrupt program includes a routine for computing the waveform of a musical tone on each channel as will be described later, the waveform and envelope can be generated in the interrupt period. An input port 51 and an output port 52 are used for scanning the keys of the keyboard 32 and the function keys 33. A digital musical tone generated in the interrupt program is converted by a D/A converter 53 into an analog signal which is then output. Fig. 6 illustrates the flow of the main program of the microcomputer 31 of this embodiment. Step A1 is an initializing process which clears the RAM (registers) 44 of the microcomputer 31 and sets the initial values of a rhythm tempo, etc. when power is turned on. In step A2, the microcomputer 31 outputs a key scan signal from the output port 52, and fetches the status of the switch section 34 from the input port 51 to thereby set the statuses of the function keys 33 and keys on the keyboard in the key buffer area of the RAM 44. In step A3 that function key whose status has changed is discriminated from the statuses of the function keys 33 acquired in step A2 and the previous statuses thereof, and the specified function is executed (e.g., setting of a tone number, an envelope number, a rhythm number, etc.). In step A4, that key whose status has changed (being pressed or released) is discriminated from the newest statuses of the keys on the keyboard 32 acquired in step A2 and the previous key statuses. In the subsequent step A5, key assigning for the tone generation process A9 is executed in accordance with the processing result attained in step A4. In step A6, when a "demo" play key included in the function keys 33 is pressed, "demo" play data (sequencer data) is sequentially read out from the ROM 47 and is processed to thereby execute a key assign process for the tone generation process A9. In A7, when a rhythm start key is pressed, rhythm data is sequentially read out from the ROM 47 to perform key assigning for the tone generation process A9. In a one flow cycle timer process A8, in order to know the timing of the necessary event in the main flow, an arithmetic operation is performed on the basis of the one flow cycle time to acquire the reference value for the envelope timer (arithmetic operation cycle of the envelope) and the reference value of a rhythm. (The one flow cycle time is obtained by measuring the number of timer interrupts executed during one flow cycle; this measuring is performed in an interrupt timer process B3 to be described later.) In the tone generation process A9, various arithmetic operations for actually generating musical sounds are executed based on the data set in steps A5, A6 and A7. The results of the operations are set in a sound source processing register (Fig. 11) in the RAM 44. For instance, when a key is de-pressed, the envelope Δx of the attack portion and the envelope Δy for the target envelope increment/decrement flag as parameters for envelope generation are computed or read out and set in the associated registers in Fig. 11, and the start address, end address, loop address and the value of added addresses as parameters for waveform generation are computed or fetched and set in the associated registers. With regard to updating of an envelope, the content of the present envelope register is checked and if it is at the target level, envelope data for the next step (Δx, Δy, the target envelope) are set back in the associated registers. The content of the present envelope register is also checked upon key depression. A release envelope is selected from the checked value and its data is set. Step A10 is a preparation process for a pass to the next main flow. In this processing, for example, the "NEW ON" status indicating a change to the key-de-pressed state obtained by the present pass is set during "ON Continuing" status, the "NEW OFF" status indicating a change to a key-released state is changed during "OFF Continuing" status. Fig. 7 illustrates the flow of the interrupt program which executes tone generation. In step B1, tone waveform data (accumulated waveform values for eight sounds) which has been produced in a sound source process B2 in the previous interrupting process is sent to the D/A converter 53. In this manner, samples of a musical tone are given to the D/A converter 53 in a constant interval. The subsequent sound source process B2 is a key point in this embodiment; this processing is conventionally executed by sound source circuit hardware. (Its detailed description will be given later.) In the next interrupt timer process B3, the content of a timer register (located in the RAM 44) for measuring one flow cycle is incremented by "1" every time an interrupt, which occurs for every given time, passes this timer register. According to this embodiment, since the contents of those registers in which data is written in the main program are not rewritten in the interrupt program, it is unnecessary to execute saving and recovering of the contents of the registers which are carried out at the beginning and the end of an ordinary interrupting process. That is, since those registers on the RAM 44 which are associated with tone processing are independent of those associated with the other processing, it is possible to leave the main program and go to the interrupting process quickly without delay. Fig. 8 gives a detailed illustration of the sound source process B2. After the RAM area (see Fig. 11) for addition of waveforms is cleared in step C1, steps C2 to C9 for eight channels are sequentially executed. At the end of each channel process, the waveform value of a musical tone on the channel is added to the data stored in this RAM area. Fig. 9 illustrates the flow of the operation of the first embodiment along the time. "A" through "F" are parts of the main program (Fig. 6), and an interruption (Fig. 7) is executed for each given time. The time chart of the operation is shown in Fig. 10. As illustrated, every time an interrupt occurs, a tone waveform signal is input to the D/A converter 53 and the corresponding analog signal is output therefrom. Fig. 12 presents a detailed illustration of one of the steps C2-C9 in Fig. 8 with respect to one of eight channels. The channel process mainly consists of an envelope process (D1 to D7) and a waveform process (D8 to D21). Fig. 13 illustrates an envelope produced by the envelope process. The envelope of one musical tone consists of several steps (segments). In the diagram, Δx represents an updating period of the envelope, and Δy the degree of change in the envelope value. The envelope process (D1-D7) for each channel performs computation of updating the envelope for each updating time and checks if the step target level is reached. When the target level is reached, the target value is set in the present envelope register (see Fig. 11) and this event is detected in the tone generation process A9 of the main program. Then, envelope data for the next step (Δx, Δy, the target envelope value) is set in the respective registers. The above process will be described below more specifically. The content of the timer register used for comparison with the computed period Δx of the envelope is incremented for each occurrence of an interruption in step D1. When the content of the timer register coincides with Δx in the step D2, the adding/subtracting flag (code bit) of the data Δy, a change in the envelope, is checked to see if the envelope is rising or falling in step D3. In the subsequent steps D4 and D5, the present envelope is subjected to subtraction and addition, respectively. In step D6, it is determined whether or not the present envelope has reached the target value. If the decision is affirmative, the target level is set to the present envelope. As a result, data of the next envelope step is set in the tone generation process A9 of the main program. If the read present envelope is zero in the process A9, it is treated as the end of tone generation. As should be obvious from the foregoing description, according to the present electronic musical instrument, the microcomputer 31 can always grasp the status of the present envelope. In other words, in the embodiment, an envelope is generated in the program-controlled envelope processes (D1-D7), the value of the present envelope is checked in the tone generation process A9 also controlled by the program, and a process according to the checking result is executed. This can eliminate the need for an envelope generator which is conventionally hardware, and can thus overcome the otherwise accompanying conventional problems. The reason why the program-controlled envelope process is executed particularly in the timer interrupt program will be discussed below referring to Figs. 14 and 15. Fig. 14 illustrates part of an envelope generated by a timer interrupt. Assuming that an envelope process is carried out in an ordinary subroutine, the result would be as shown in Fig. 15. If the subroutine for computing an envelope is placed in the main flow, the amount of work to be done varies and the time between subroutines for envelope computation also varies. This results in a change in time for measuring Δx; the updating of time may come earlier on one occasion or may come late on another, so that the slope of the expected envelope cannot be accurately realized. If the envelope process is done in the timer interrupt process, the updating period Δx can be kept constant due to the periodic occurrence of an interrupt, and the expected envelope can be obtained as shown in Fig. 14. Further, since the generated envelope is used in the waveform process within the same interrupting process, waveform generation can be effected in synchronism with changing the envelope. The waveform processes D8-D21 will now be described. In this processing, waveform data at two adjacent addresses are read out from the waveform ROM 47 using the integer portion of the present address, and the waveform value expected with respect to the present address indicated by (integer portion + decimal point portion) is attained through interpolation. The reason for requiring the interpolation is that the interrupt-initiated waveform sampling period is constant and the value of added addresses (pitch data) lies in a certain tone range in view of application to a musical instrument (with a musical instrument which produces only notes, if waveform data is prepared for each note, no interpolation is necessary with an unallowable increase in memory capacity, though). Since interpolation-originated deterioration and distortion of a timbre is prominent in a high pitch region, the original sound is normally reproduced in a frequency higher than the record sampling frequency of the original sound. In this embodiment, the reproducing frequency of an original sound (A4) is doubled (see Fig. 16). With the value of the added addresses being 0.5, therefore, the sound of A4 can be obtained. In this case, for note A4, the added address value becomes 0.529 and for note A3 it is 1. These added address values are stored as pitch data in the ROM 47. Upon depression of a key in the keyboard 32, pitch data associated with this key, and the waveform start address, waveform end address and waveform loop address of the selected timbre are set in the respective registers of the RAM 44, namely, added address register, start address/present address register, end address register and loop address register. Fig. 17 illustrates one example of interpolation waveform data with respect to time. In the diagram, white marks indicate waveform data values located at addresses of the waveform ROM, and black marks interpolation values. Although there are various interpolating systems, linear interpolation is employed in this embodiment. A detailed description of the waveform generation processes D8-D21 in Fig. 12 will be given below. First, in step D8, the present address is added with the added address value to provide a new present address. The present address is compared with the end address in step D9. If the present address > the end address, the physical (address) or logical (operational) next address is computed through steps D10 and D11. If the present address < the end address, the next address is computed through a step D12. In step D14, the waveform ROM is accessed using the integer portion of the address to acquire the next waveform data. The loop address is the address next to the end address from an operational point of view. In the case of Fig. 16, the illustrated waveform data is read out repeatedly. When the present address=end address, therefore, the waveform data at the loop address as the next address is read out (D13). In steps D15 and D16, the waveform ROM is accessed using the integer portion of the present address to read out the present waveform data. In step D17, the present waveform value is subtracted from the next waveform value, and the difference is multiplied by the decimal point portion of the present address in step D18. The result is added to the present waveform value in step D19 to thereby obtain linear interpolation value of the waveform. The linearly-interpolated data is multiplied by the present envelope value to obtain a tone data value of the channel (D20), and the obtained value is added to the content of the waveform adding register to accumulate tone data (D21). In the case involving the channel processing program as shown in Fig. 12, data in the ROM 47 that is indirectly accessed is referred to only in steps D14 (or D13) and D16 of the entire steps. All the remaining steps are for performing arithmetic operations on the exclusive registers on the RAM 44 which can be directly addressed. The channel process (tone generation process) can therefore be executed at a high speed. The high-speed processing comes from the structure of the microcomputer. The structural features include the design to permit direct addressing to the RAM 44, many registers constituting the RAM 44, and employment of exclusive register structure in the RAM 44 for exclusively storing various tone parameters in the tone generation process. With regard to the circuit scale and the operation time of the specific embodiment (PCM sound source system capable of producing eight polyphonic sounds), the control ROM has a size of 112 K bits, RAM 44 5.4 K bits and the control data/waveform ROM 47 (for 100 timbres) 508 K bits; one machine cycle is about 276 nanoseconds with a maximum number of cycles of the interrupt program when invoked being about 150; and the executing period of the interrupting process (tone output sampling period) is about 47 microseconds. As described above, according to the first embodiment, since the microcomputer 31 performs tone generation under the control of the timer interrupt program, sound source circuit hardware which is essential in the prior art is not necessary, thus resulting in reduction in circuit scale, improvement of the yield, reduction in manufacturing cost and high design freedom. Further, since a process for computing the waveform of a musical tone and a process for computing the envelope of the musical tone are executed by the timer interrupt program which is invoked by an interrupt signal that is accurately issued from the interrupt controller 50 at every tone sampling time, an envelope with the desired characteristic can accurately be generated. The microcomputer may be simply replaced with computer means or processing means for the mentioned operations. Second Embodiment In the first embodiment described above, a timer interrupt is issued to output a tone waveform sample for each given time and a musical tone is generated by running an interrupt program. In the second embodiment, however, a dummy command (NOP command) is set in a program to execute the process in place of the interrupting process at each constant interval of time; this processing will be hereinafter called constant time process. (See Figs. 18 to 21.) Since the time for executing each command of a program is determined by a master clock, a constant time processing program for generating a musical tone during that part of the main program which corresponds to the constant time (see Fig. 18) is inserted as a subroutine. To secure a constant time, all the branches in the main program and the constant time processing program in the subroutine should be processed by the same time. Assume that the main program has the flow as shown in Fig. 19 and constant time process is executed at the beginning and end of the flow. For the sake of simplicity and easy understanding, it is assumed that branch commands need two units of time while an ordinary command one unit of time. In the flow shown in Fig. 19, the time from the first branching to the constant time process requires two units of time when the route a is taken, five units of time for the route b, six units of time for the route c and five units of time for the route d; that is, the time varies depending on which route to take. If four dummy commands are put in the route a and one dummy command is put in the routes b and d, then, the units of time required for taking each route becomes six as shown in Fig. 20. If processing time differs depending on branches even in a constant time process, the time required to jump to the next constant time process changes. It is therefore necessary to insert a dummy command in the constant time process in order to make the processing time required for all the branching routes constant. Fig. 21 illustrates an example of the above case where a dummy command is put in tone generation process in constant time process. Third Embodiment Referring to Fig. 10, the interval T in which an interrupt signal is generated is very stable. This is because that the interrupt signal is produced by a hardware counter in an interrupt controller 50. The stability of the signal generation is determined by the stability of a clock generator (typically, a crystal oscillator) though not illustrated. According to the first and second embodiments, the main process is interrupted by this interrupt signal and tone generation process (interrupting process) is executed during the interruption so as to keep the tone generation sampling period constant. Of course, this technical approach can set the averaged, tone generation sampling period equal to the interrupt signal generation interval T. Nevertheless, the timing at which the interrupting process actually starts may vary as emphasized in Fig. 22. This variation is originated in the program-controlled operation. More specifically, even an external interrupt is made to the microcomputer 31, the microcomputer 31 cannot immediately stop the presently-executing operation, so that the interrupting process starts upon termination of that operation. If the microcomputer 31 is in a process whose interruption is not desirable, the interruption is held until a sequence of operations for this process is completed. Transition to an interrupting process depends on the process which is being performed upon occurrence of an interrupt, so that the tone generation period inevitably becomes unstable. Specifically, the timing of the process executed in step B1 in Fig. 7, i.e., fetching digital tone data from the waveform adding register in the RAM 44 and setting it at the input port of the D/A converter 53, is shifted forward or backward. If the sampling period of the D/A converter 53 is the same as the executing interval of the step B1, a significant distortion would be caused on the signal during D/A conversion. This shortcoming is solved by the third embodiment. The sampling period of tone generation by the microcomputer 31 is not strictly constant. Fig. 23 illustrates the structure which sets the sampling period of tone generation equal to the conversion period of the D/A converter 53. More specifically, a software-controlled latch 55 is provided as a port of the D/A converter 53, and this latch 55 is controlled by a program control signal from the operation analyzer 48 to supply the output of the latch 55 to a control gate of an associated bit switch in a block 53A (not illustrated; typically, a current-controlled type electronic switch). As the block 53A actually converts a digital signal into an analog signal, it will be called D/A converter hereinafter. In the case of Fig. 23, the waveform adding register in the RAM 44 is specified under the control of the operation analyzer 48 while the step B1 in the interrupt program, and newest digital tone data to be stored in the register is fetched on a data bus. A program control signal for strobe is supplied to a clock input of the latch 55 from the operation analyzer 48 at a timing where the digital tone data is on the data bus. Then, the data on the data bus is set, and new digital tone data is input to the D/A converter 53A from the latch 55. As shown in Fig. 25A, therefore, digital tone data to be input to the D/A converter 53A is switched at an unstable period due to the program control involved. If the conversion period (sampling period) of the D/A converter 53A is not significantly stable, large distortion occurs in the converted signal during the conversion. For instance, with the machine cycle of the microcomputer 31 being several tens of nanoseconds or several hundreds of nanoseconds, even a delay of one machine cycle significantly hinders the necessary accuracy of the conversion period for converting a digital signal of an audio-frequency into an analog signal with high fidelity. In other words, even deviation of the order of nanoseconds causes such distortion that can be audibly sensed by a person. This problem may be overcome by utilizing the structure as shown in Fig. 24. An interrupt-controlled latch 56, which is controlled by an interrupt signal or accurate timing signal from the interrupt controller 50, is provided between the software-controlled latch 55 controllable by a program control signal from the operation analyzer 48 and the D/A converter 53A. As the period for generating an interrupt signal depends on the stability of the clock generator, it is significantly stable. The output of the latch 56 is switched in synchronism with the timing of the interrupt signal. That is, the interrupt signal generating period is the conversion (sampling) period of the D/A converter 53A. Fig. 25B illustrates a time chart for the structure shown in Fig. 24. As illustrated, although the timing at which the output of the latch 55 is switched varies according to a shift of the timing of the interrupt process, the latch 56 which functions by the interrupt signal permits the timing for switching the input data of the D/A converter 53A to be synchronized with the interrupt signal. Because of the presence of the latch 56, the digital tone signal input to the D/A converter 53A is delayed by one period of the interrupt signal on the average. This delay, however, is quite insignificant. For instance, the period of the interrupt signal is 47 microseconds, and such a short period of time cannot be audibly sensed by people. In general, the order of several milliseconds is the audible limit for human beings. Although the present invention has been explained in the foregoing description with reference to some particular embodiments, this invention is not restricted to those described but may be modified in various manners within the scope of the claims. For instance, although a waveform generating process is executed by a microcomputer in the above-described embodiments, it may be carried out by a minicomputer. The present invention can be worked out irrespective of the size of a computer or a processing system involved, as long as the computer or processor functions under software control.

Claims: A data processing apparatus for a sound signal generator, comprising computer or processor means (31), said computer or processor means comprising: program storage means (41) for storing a program for generating one or more sound signals; address control means (42, 49) for controlling an address of said program storage means; tone data storage means (47) for storing tone data necessary for the generation of said sound signals; arithmetic operation means (45, 46) for computing one or more sound signals according to the tone data stored in said tone data storage means; and operation control means (48) for decoding each command of said program stored in said program storage means and controlling operation of said address control means, said tone data storage means and said arithmetic operation means, whereby one or more sound signals can be generated by executing said program in said program storage means; characterized by a first latch means (55) for latching said one or more sound signals generated by said computer or processor means (31) in response to a program control signal from said computer or processor means (31); a second latch means (56) for latching an output signal of said first latch means at a timing of an accurate sampling time signal. A data processing apparatus according to claim 1, wherein said tone data storage means (47) stores pitch data, envelope data, and sound waveform data of a PCM type as said tone data. A data processing apparatus according to claim 1 or 2, wherein said computer or processor means (31) comprises an integrated circuit chip provided with a digital-to-analog converter for converting a digital sound signal into an analog signal and a port for receiving an input of said sound signal generator. A data processing apparatus according to claim 1, 2 or 3, wherein said arithmetic operation means (45, 46) includes a multiplier (46) for computing said sound signals. A data processing apparatus according to any of the preceding claims, wherein said arithmetic operation means (45, 46) includes an interpolation means for interpolating a waveform value expected with respect to an address between two adjacent addresses of said tone data storage means (47). A data processing apparatus according to claim 5, wherein arithmetic operation means (45, 46) reads the sound waveform data in a frequency higher than the record sampling frequency of the original sound from the tone data storage means. A data processing apparatus according to any of the preceding claims, wherein said input of said sound signal generator includes a key input designating a pitch of said sound signals to be generated, an input from a console panel of said sound signal generator, an input of automatic musical performance data and an input for operating an external unit. A data processing apparatus according to any of the preceding claims further comprising timer interrupt control means (50) for generating an interrupt signal in a musical tone sampling period, whereby said program for generating one or more sound signals is fetched from said program storage means by said address control means which receives said interrupt signal from said timer interrupt control means and generation of said sound signals is effected by executing said fetched program. A data processing apparatus according to any of the preceding claims, further comprising arithmetic operation storage means (44) comprising a number of registers directly addressable by said program in said program storage means, said registers including those which are used for an arithmetic operation in executing said program for generating one or more sound signals and exclusively holding said tone data; wherein said arithmetic operation means (45, 46) executes arithmetic operations between said registers of said arithmetic operation storage means; said tone data storage means is addressable indirectly through said registers of said arithmetic operation storage means by said program in said program storage means; and said operation control means (48) further controls operation of said arithmetic operation storage means, said registers of said arithmetic operation storage means (44) being used for arithmetic operation and store exclusively said tone data by executing said programs for generating a musical tone. A data processing apparatus according to claim 8, wherein said program to be fetched and executed in response to said interrupt signal includes a routine for computing a plurality of tone signals and a routine for computing a plurality of envelopes of said musical tone signals, and generation of said musical tone signals is executed substantially in synchronism with generation of said envelopes of said musical tone signals, whereby said plurality of sound signals are generated by respectively multiplying said plurality of musical tone signals with said plurality of envelopes. An electronic musical instrument comprising: a data processing apparatus according to any of the preceding claims and an acoustical tone generating means (35 to 38) for generating musical tones based on the sound signals generated by said computer or processor means.

Inventors: DAIGO KOICHIRO PATENT DPT DEV, OGURA KAZUO PATENT DPT DEV DIV, SHIBA KOSUKE PATENT DPT DEV DI, USAMI RYUJI PATENT DPT DEV DIV, DAIGO, KOICHIRO PATENT DPT.DEV. DIV. HAMURA R&D CE, OGURA, KAZUO PATENT DPT.DEV. DIV. HAMURA R&D CENT., SHIBA, KOSUKE PATENT DPT.DEV. DIV. HAMURA R&D CENT, USAMI,RYUJI PATENT DPT.DEV. DIV. HAMURA R&D CENT., Daigo, Koichiro Patent Dpt.Dev. Div. Hamura R&amp;D Ce, Ogura, Kazuo Patent Dpt.Dev. Div. Hamura R&amp;D Cent., Shiba, Kosuke Patent Dpt.Dev. Div. Hamura R&amp;D Cent, Usami,Ryuji Patent Dpt.Dev. Div. Hamura R&amp;D Cent.
Applicants: CASIO COMPUTER CO LTD, CASIO COMPUTER COMPANY LIMITED
Application year: 1989
Main classification: G10H7
IPC codes: G10H1, G10H7