Waveform adjusting system for music file

A waveform adjusting system for a music file suitable in hand held devices is described. A music file includes a plurality of tones, and the waveform adjusting system includes a maximum magnitude estimating module and an adjusting module. The waveform adjusting system is capable of analyzing the whole music file, superposing the magnitudes of all the tones, and calculating a scale factor according to the maximum superposed magnitude and a predetermined level. The adjusting module multiplies the magnitude of each tone by the scale factor K, thus the volume of the music is kept to a suitable level without suffering from too small volume problem or signal distortion due to too large volume.

BACKGROUND OF THE INVENTION

1. Field of the Invention

This present invention relates to a waveform adjusting system, particularly to a waveform adjusting system for adjusting the magnitude of an overall waveform corresponding to a music file.

2. Description of the Prior Art

With regard to hand-held devices (such as mobile phone, personal digital assistant, etc), the output volume range of the music or sound effect is usually limited and has its upper bound limitation. Referring toFIG. 1, a schematic diagram shows the functional blocks of a music synthesizer used in a hand-held device in the prior art. Conventionally, a music synthesizer10is a module having a music file database11, a music file decoder12, a tone generator14, a tone generator14, a D/A converter16and an amplifier18. The traditional method for processing the music file (such as a MIDI music file) in a hand-held device utilizes the music file decoder12to decode a music file13into a series of tones. Each tone is represented by a set of tone data121including, as an example, the pitch, the duration, the magnitude, and the type of the tone. Different types of tones correspond to different kinds of musical instruments, thus have different kinds of corresponding waveforms. The music file decoder12transmits these tone data to the tone generator14. The tone generator14generates a PCM signal15based on the received tone data as well as the waveform corresponding to the tone. The D/A converter16transfers the PCM signal15to an analog signal17which is further amplified by the amplifier18to drive the speaker19. The magnitude of each tone in the music file and the maximum number of overlapped tones (also known as “polyphony”) in the music will affect the output volume when the music file is executed and played. In other words, if the amplification ratio of the amplifier18in the output circuit is fixed, the magnitude of the overall waveform (the waveform generated by synthesizing all the tones in the music file13) output from the tone generator14will also affect the ultimate output volume. The output circuit here means the circuit set after the D/A converter16. As shown inFIG. 1; the output circuit includes the amplifier18and the speaker19.

Referring toFIG. 2, it shows an overall waveform22corresponding to a first music file and an overall waveform24corresponding to a second music file. In this example, the first music file comprises fewer polyphonies and/or the tones in the first music file have small magnitude. The magnitude of the overall waveform22outputted from the tone generator14might be too small to be suitable for alert ringing purpose, and the input dynamic range26of the D/A converter16is not fully utilized.

On the other hand, the second music file comprises more polyphonies and/or the tones in the second music file have higher magnitude, the magnitude of the overall waveform24outputted from the tone generator14might become too high to exceed the input dynamic range26of the D/A converter16, and thus leads to undesirable signal distortion.

SUMMARY OF THE INVENTION

An objective of the present invention is to provide a waveform adjusting system for adjusting the magnitude of an overall waveform of a music file. The present invention appropriately adjusts the magnitude of the overall waveform of the music file and keeps it within the input dynamic range of the output circuit to keep the volume of the music around a suitable level no matter what kind of music file to be played.

The waveform adjusting system, according to the present invention, comprises a magnitude estimating module and an adjusting module. The magnitude estimating module estimates the maximum magnitude of the overall waveform of the music file. The adjusting module is used to adjust the magnitude of each tone in the music file according to a scale factor which is calculated based on the maximum magnitude of the overall waveform and a default level. By this way, the waveform adjusting system according to the present invention keeps the magnitude of the overall waveform of the music file within the input dynamic range of the output circuit so as to keep the volume of the music around a suitable level no matter what kind of music file to be played.

After receiving and decoding a music file, the present invention estimates the maximum magnitude of the overall waveform of the music file. A scale factor is calculated based on the maximum magnitude and a predetermined default level. The magnitude of each tone in the music file is then multiplied by the scale factor. By this way, the method described above keeps the overall waveform such that the volume of the music around a suitable level no matter what kind of music file to be played

The advantage and spirit, according to the present invention, may be understood by the following recitations together with the appended drawings.

DETAILED DESCRIPTION OF THE INVENTION

The present invention is a kind of waveform adjusting system in the audio synthesizer. It is used to adjust the magnitude of the overall waveform corresponding to a music file. No matter what music file the hand-held device is playing, the waveform adjusting system can substantially keep the volume of the music around a suitable level without suffering from too small volume problem or signal distortion due to too large volume.

Referring toFIG. 3, it is a schematic diagram of the waveform adjusting system30according to the present invention. In the present invention, the waveform adjusting system30comprises a maximum magnitude estimating module32and an adjusting module34. The maximum magnitude estimating module32is used to estimate the maximum magnitude LMof the overall waveform corresponding to a music file to be played. Each music file comprises a series of tones, and each type of tone has an individual waveform associated with a magnitude curve. After the music file13is transmitted to the music file decoder12, the music file decoder12decodes the music file13and obtains a series of tone data wherein each tone data contains, as an example, the initial time, pitch, duration, magnitude, timbre, and type of the tone.

Referring toFIG. 4, it is a schematic diagram that shows a waveform40corresponding to a tone type wherein the dotted line represents the magnitude curve48of the waveform40. There are many ways to describe the magnitude curve of a waveform. Basically, as well know to those skilled in the art, the magnitude curve of a waveform can be described by a set of envelope characteristic parameters such as the well known ADSR parameters. Taking ADSR parameters as an example, the magnitude curve48of the waveform40is divided into four phases called Attack41, Delay42, Sustain43, and Release44as shown inFIG. 4. The magnitude curve during each phase is described by one or more characteristic values, e.g. the slop of the magnitude curve, the level of the magnitude curve, etc. And these characteristic values associated with these phases are together regarded as the ADSR parameters. Each type of tone has its own corresponding ADSR parameters, or in general, the envelope characteristic parameters. The envelope characteristic parameters of each tone type are usually stored in the system memory in advance.

Based on the tone data generated by the music file decoder12as well as the envelope characteristic parameters corresponding to the tone type, the maximum magnitude estimating module32is capable of estimating the magnitude of the waveform corresponding to the tone at any time point.

Please refer toFIG. 5which is a schematic diagram that shows the magnitude curve of the waveform corresponding to the superposed consecutive tones. The x-coordinate indicates the time line, and the y-coordinate indicates the magnitude. The overall waveform of a music file is obtained by superposing a series of waveforms of the tones. InFIG. 5, two magnitude curves52and54respectively corresponding to the waveforms of two tones were taken as an example for illustrating the present invention. InFIG. 5, the magnitude curve52corresponds to a first tone, while the magnitude curve54corresponds to a second tone. The magnitude curve of each tone is calculated based on the envelope characteristic parameters. InFIG. 5, when the waveform of the first tone superposes the waveform of the second tone, it is found that the magnitude curve56of the superposed waveform can be well approximated by superposing the magnitude curves52and54. As can be seen inFIG. 5, the maximum magnitude LMappears around the end of the Attack phase of the magnitude curve54. By this way, according to one embodiment of the present invention, after all the waveforms of tones are superposed, the maximum magnitude estimating module32analyzes the overall magnitude curve corresponding to the music file to obtain a maximum magnitude value LM.

In another preferred exemplary embodiment, the magnitude curve of each tone type is sampled and saved as a magnitude table in advance. The maximum magnitude estimating module32according to the present invention then obtains the magnitude of the waveform of each tone at each specified time point based on looking up the magnitude table, computes the magnitude of the superposed waveforms, and finally finds out the value of maximum magnitude LMof the overall waveform corresponding to the music file.

Referring toFIG. 3again, after the maximum magnitude estimating module32obtains the value of maximum magnitude LMof the overall waveform corresponding to the music file, the adjusting module34performs adjusting the magnitude of the overall waveform to a suitable level. The adjusting module34has a predetermined default level L0, and the default level L0is well chosen such that the input dynamic range26of the D/A converter16can be well utilized as well as can avoid the signal distortion due to too large magnitude. The adjusting module34is used to adjust the magnitude of each tone in the music file according to a scale factor K which is calculated based on the default level L0and the maximum magnitude LMof the overall waveform.

In a preferred exemplary embodiment of the present invention, the scale factor K is calculated by:
scale factorK−L0/LM(1)

Based on the scale factor K by Eq. (1), all the magnitudes of the waveforms of the tones in the music file are multiplied by the obtained scale factor K such that the maximum magnitude outputted from the tone generator14to the D/A converter16will be substantially the default level L0. Note that the adjusting module34multiplies the magnitude of each tone by the same scale factor K, thus achieves a uniformly scaling of the volume of the music to be played.

FIG. 6is a flow chart that shows the waveform adjusting method according to the present invention. The waveform adjusting method according to the present invention includes the following steps:

Step60: receiving a music file and decoding it to obtain a series of tone data.

Step62: acquiring the overall waveform corresponding to the music file.

Step64: estimating the maximum magnitude LMof the overall waveform corresponding to the music file.

Step66: generating a scale factor K based on the maximum magnitude LMand a predetermined default level L0.

Step68: adjusting the magnitude of each tone in the music file according to the scale factor K.

Therefore, the present invention analyzes the music file to be played, finds out the maximum magnitude LM, and calculates a scale factor K for scaling the volume of the music to a suitable level. By this way, the problem of too small volume or signal distortion due to too large volume is avoided.