An audio synthesis method and device for a simulated musical instrument
By generating analog instrument tone in the MCU, a built-in modulator, a note frequency generator and a carrier generator, the problems of circuit complexity and cost in the prior art are solved, and simple and efficient audio synthesis is achieved.
Patent Information
- Application Number
- CN202211731778.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2042-12-30
AI Technical Summary
In the prior art, analog musical instrument timbre needs to be processed through external circuits, resulting in increased circuit complexity and increased cost.
Through the MCU built-in modulator, note frequency generator, carrier generator and envelope signal generator, the amplitude modulation and pulse width modulation technology are used to generate analog instrument tones in the buzzer, simplifying the circuit structure.
It realizes the generation of analog instrument tones within the MCU, simplifies circuit design, reduces costs and improves reliability.
Smart Images

Figure CN116030775B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of smart home appliances, and particularly to an audio synthesis method and device for simulating musical instruments. Background Art
[0002] With the improvement of people's living standards, home appliances usually add the function of key prompt sounds in the process of human-computer interaction. In early home appliances, the key prompt sound was often a single-frequency "beep" sound emitted by a buzzer, which was rather dull and monotonous. In the past decade or so, there have been many key prompt sounds in the home appliance field that imitate the clear and pleasant sounds of musical instruments to improve the user experience.
[0003] However, in the prior art, appropriate processing through an external circuit is required to simulate the timbre of musical instruments, which increases the complexity of the circuit and the production cost of the appliance. Summary of the Invention
[0004] Based on this, it is necessary to provide an audio synthesis method and device for simulating musical instruments to address the above technical problems.
[0005] In a first aspect, an audio synthesis method for simulating musical instruments is provided. The audio synthesis method is applied to an audio synthesis device, which includes an MCU (Micro Control Unit) and a buzzer. The MCU includes a modulator, a note frequency generator, a carrier generator, and an envelope signal generator. The method includes:
[0006] In response to an audio synthesis trigger instruction, the note frequency generator outputs a note frequency signal corresponding to a preset tune, the envelope signal generator outputs an envelope signal corresponding to a preset timbre, and the carrier generator outputs a carrier signal;
[0007] The modulator performs amplitude modulation on the carrier signal according to the note frequency signal to obtain a first modulation signal, and performs pulse width modulation on the first modulation signal according to the envelope signal and the note frequency signal to obtain a second modulation signal, and outputs the second modulation signal to the buzzer;
[0008] The buzzer outputs the synthesized music corresponding to the preset tune and the preset timbre according to the drive of the second modulation signal.
[0009] As an optional implementation, the note frequency signal is a binary signal that periodically flips at a first preset frequency, the carrier signal is a binary signal that periodically flips at a second preset frequency, and the formula for performing amplitude modulation on the carrier signal according to the note frequency signal to obtain a first modulation signal is:
[0010]
[0011] Among them, f1 represents the primary modulation signal, Vcarry represents the carrier signal, and Vnote represents the note frequency signal.
[0012] As an alternative implementation manner, the envelope signal is a signal output according to the array elements of the envelope array corresponding to the sound amplitude envelope curve of the preset timbre. The pulse width modulation of the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal includes:
[0013] Modulating the duty cycle of the primary modulation signal to the product of the envelope signal and the note frequency signal.
[0014] As an alternative implementation manner, the outputting of the secondary modulation signal to the buzzer includes:
[0015] Outputting the secondary modulation signal to the buzzer in a complementary push-pull manner.
[0016] As an alternative implementation manner, the duty cycle of the note frequency signal is 50%.
[0017] As an alternative implementation manner, the value range of the second preset frequency is 22.05KHz to 44.1KHz.
[0018] As an alternative implementation manner, the capacity of the envelope array is 256 and the resolution is 256.
[0019] In a second aspect, an audio synthesis device for an analog musical instrument is provided, characterized in that the audio synthesis device includes an MCU and a buzzer, and the MCU includes a modulator, a note frequency generator, a carrier generator, and an envelope signal generator;
[0020] The note frequency generator is configured to output a note frequency signal corresponding to a preset tune in response to an audio synthesis trigger instruction;
[0021] The envelope signal generator is configured to output an envelope signal corresponding to a preset timbre in response to the audio synthesis trigger instruction;
[0022] The carrier generator is configured to output a carrier signal in response to the audio synthesis trigger instruction;
[0023] The modulator is configured to perform amplitude modulation on the carrier signal according to the note frequency signal to obtain a primary modulation signal, perform pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and output the secondary modulation signal to the buzzer;
[0024] The buzzer is configured to output synthesized music corresponding to the preset tune and the preset timbre according to the drive of the secondary modulation signal.
[0025] As an alternative embodiment, the note frequency signal is a binary signal that periodically flips at a first preset frequency, and the carrier signal is a binary signal that periodically flips at a second preset frequency.
[0026] As an alternative embodiment, the audio synthesis device further includes a protection resistor, one end of the protection resistor is connected to the MCU, and the other end is connected to the buzzer.
[0027] As an alternative embodiment, the envelope signal is a signal output according to the array elements of an envelope array corresponding to the sound amplitude envelope curve of the preset timbre, and the modulator is specifically configured to:
[0028] Modulate the duty cycle of the primary modulation signal to the product of the envelope signal and the note frequency signal.
[0029] As an alternative embodiment, the modulator is specifically configured to:
[0030] Output the secondary modulation signal to the buzzer in a complementary push-pull manner.
[0031] As an alternative embodiment, the duty cycle of the note frequency signal is 50%.
[0032] As an alternative embodiment, the value range of the second preset frequency is 22.05KHz to 44.1KHz.
[0033] As an alternative embodiment, the capacity of the envelope array is 256 and the resolution is 256.
[0034] In a third aspect, a computer device is provided, including a memory and a processor, where a computer program is stored on the memory and can run on the processor, and when the processor executes the computer program, the method steps described in the first aspect are implemented.
[0035] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the method steps described in the first aspect are implemented.
[0036] The present application provides an audio synthesis method and apparatus for a simulated musical instrument. The technical solutions provided by the embodiments of the present application at least bring the following beneficial effects: First, in response to an audio synthesis trigger instruction, a note frequency generator outputs a note frequency signal corresponding to a preset tune, an envelope signal generator outputs an envelope signal corresponding to a preset timbre, and a carrier generator outputs a carrier signal. Among them, the preset tune and the preset timbre can be set by engineers according to actual needs. Then, a modulator performs amplitude modulation on the carrier signal according to the note frequency signal to obtain a primary modulation signal, and performs pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and outputs the secondary modulation signal to a buzzer. Finally, the buzzer outputs synthesized music corresponding to the preset tune and the preset timbre according to the drive of the secondary modulation signal. Through the above method, an envelope signal can be generated inside the MCU and a modulation signal simulating the timbre of a musical instrument can be obtained, and synthesized music simulating the timbre of a musical instrument can be output without the need for processing by a specific external circuit, which has the advantages of a simple circuit, low cost, and high reliability.
[0037] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other drawings based on these drawings without creative efforts.
[0039] Figure 1 A schematic structural diagram of an audio synthesis apparatus for a simulated musical instrument in the prior art provided by an embodiment of the present application;
[0040] Figure 2 A schematic structural diagram of an audio synthesis apparatus for a simulated musical instrument provided by an embodiment of the present application;
[0041] Figure 3 A schematic structural diagram of another audio synthesis apparatus for a simulated musical instrument provided by an embodiment of the present application;
[0042] Figure 4 A flowchart of an audio synthesis method for a simulated musical instrument provided by an embodiment of the present application;
[0043] Figure 5 A schematic diagram of the sound amplitude envelope curve of a typical percussion instrument provided by an embodiment of the present application;
[0044] Figure 6Schematic diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0045] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0046] For ease of understanding, the audio synthesis device of household appliances in the prior art will be first introduced in the embodiments of the present application. Figure 1 Schematic diagram of an audio synthesis device of a simulated musical instrument in the prior art provided by an embodiment of the present application. As Figure 1 shown, in order to output the synthesized music of a simulated percussion instrument, the audio synthesis device includes an MCU1, an envelope signal generator unit 110, an amplification unit 120, and a buzzer BUZ1. Among them, the envelope signal generator unit 110 includes a resistor R1, a resistor R2, a triode Q1, a resistor R4, a resistor R5, a triode Q2, a resistor R6, and an electrolytic capacitor C1, which is also called an energy storage capacitor charging circuit and a buzzer charge discharge circuit; the amplification unit 120 includes a resistor R3, a resistor R7, a triode Q3, and a resistor R8, which is also called a square wave signal amplifier. After receiving the trigger signal for audio synthesis, the MCU1 can output a driving pulse at the output port. The electrolytic capacitor C1 is quickly charged under the drive of the driving pulse, thereby simulating the percussion process of the percussion instrument. Then, the MCU1 outputs a note frequency signal at the output port. After being amplified by the amplification unit 120, the note frequency signal drives the buzzer BUZ1 to emit sound. At this time, the electrolytic capacitor C1 discharges slowly, thereby simulating the aftersound of the percussion instrument after percussion.
[0047] However, in the prior art as Figure 1 shown, the external circuit (i.e., the amplification unit 120 and the envelope signal generator unit 110) involves many components, and an additional 12V voltage needs to be provided to drive the buzzer BUZ1 to emit a sufficiently loud sound, resulting in an increase in circuit complexity, a decrease in reliability, and an increase in occupied space. In some low-cost small appliances, it will also increase the considerable material cost.
[0048] The audio synthesis method of the simulated musical instrument provided by the embodiment of the present application can be applied to the audio synthesis device of the simulated musical instrument in household appliances. As Figure 2 shown, the audio synthesis device of the simulated musical instrument includes an MCU2 and a buzzer BUZ2. The output ports PA0.02 and PB0.01 of the MCU2 are respectively connected to the two input ports of the buzzer BUZ2. Among them, as Figure 3As shown in the figure, a modulator 310, a note frequency generator 320, a carrier generator 330, an envelope signal generator 340, and a complementary output port 350 are established inside the MCU2. When a household appliance detects a user's key press action or a specific program trigger, it is necessary to output synthesized music through the audio synthesis device as a key press prompt tone or an operation prompt tone. At this time, in response to the audio synthesis trigger instruction, the note frequency generator 320 outputs a note frequency signal corresponding to a preset tune, the envelope signal generator 340 outputs an envelope signal corresponding to a preset timbre, and the carrier generator 330 outputs a carrier signal. Then, the modulator 310 performs amplitude modulation (AM) on the carrier signal according to the note frequency signal to obtain a primary modulation signal, and performs pulse width modulation (PWM) on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and outputs the secondary modulation signal to the buzzer BUZ2 through the complementary output port 350 for complementary drive. Finally, the buzzer BUZ2 outputs the synthesized music corresponding to the preset tune and the preset timbre according to the drive of the secondary modulation signal as the key press prompt tone or the operation prompt tone. Preferably, the model of the MCU2 is MC96F8316.
[0049] Next, a method for audio synthesis of an analog musical instrument provided by an embodiment of the present application will be described in detail in conjunction with specific embodiments. Figure 4 It is a flowchart of a method for audio synthesis of an analog musical instrument provided by an embodiment of the present application. As Figure 4 shown, the specific steps are as follows:
[0050] Step 401, in response to the audio synthesis trigger instruction, the note frequency generator outputs a note frequency signal corresponding to a preset tune, the envelope signal generator outputs an envelope signal corresponding to a preset timbre, and the carrier generator outputs a carrier signal.
[0051] In implementation, when a household appliance detects a user's key press action or a specific program trigger, the MCU of the audio synthesis device in the household appliance can receive the audio synthesis trigger instruction. In response to the audio synthesis trigger instruction, the note frequency generator outputs a note frequency signal corresponding to a preset tune, the envelope signal generator outputs an envelope signal corresponding to a preset timbre, and the carrier generator outputs a carrier signal. Among them, engineers can set the frequency of the output note frequency signal according to the note frequency corresponding to the preset tune, and set the amplitude of the output envelope signal according to the sound amplitude envelope curve corresponding to the preset timbre. The modulation signal obtained by modulating the carrier signal by the note frequency signal and the envelope signal can drive the buzzer to output the synthesized music corresponding to the preset tune and the preset timbre.
[0052] Furthermore, the note frequency generator can be implemented by a timer PWM unit inside the MCU, and the output note frequency signal is a binary signal (i.e., 0 and 1) that periodically flips according to the first preset frequency. Preferably, the duty cycle of the note frequency signal is 50%. Among them, the first preset frequency is the note frequency corresponding to the notes of the preset tune. In the embodiments of the present application, the preset tune can be composed of a single note or multiple different notes. Table 1 shows the corresponding relationship between the notes and frequencies of the low, middle, and high notes of C major provided by the embodiments of the present application. Engineers can set the first preset frequency with reference to Table 1 according to the designed preset tune.
[0053] Table 1
[0054] Pitch name A B C D E F G Lower register 440 Hz 494 Hz 523 Hz 587 Hz 659 Hz 698 Hz 784 Hz Middle register 880 Hz 988 Hz 1047 Hz 1175 Hz 1319 Hz 1397 Hz 1568 Hz Upper register 1760 Hz 1976 Hz 2093 Hz 2349 Hz 2637 Hz 2794 Hz 3136 Hz
[0055] Furthermore, the carrier generator can be implemented by another timer PWM unit inside the MCU, and the output carrier signal is a binary signal that periodically flips according to the second preset frequency. Preferably, the value range of the second preset frequency is 22.05KHz to 44.1KHz, mainly considering the following two factors: First, in order to make the carrier component in the finally output synthesized music not be perceived by humans, the frequency of the carrier signal (i.e., the second preset frequency) should avoid the upper limit of the human auditory frequency, which is 20KHz; Second, in order to improve the operating speed of the MCU, the periodic flip frequency of the timer PWM unit (i.e., the second preset frequency) should be reduced as much as possible.
[0056] Step 402, the modulator performs amplitude modulation on the carrier signal according to the note frequency signal to obtain a primary modulation signal, and performs pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and outputs the secondary modulation signal to the buzzer.
[0057] In implementation, since the tune of the music corresponds to the high and low of the sound frequency, the primary modulation signal obtained by the modulator performing amplitude modulation on the carrier signal according to the note frequency signal can drive the buzzer to output the synthesized music of the preset tune. And the timbre of the music can be expressed as the waveform of the volume (also called loudness, sound amplitude) changing with time. For example Figure 5 is a schematic diagram of the sound amplitude envelope curve of a typical percussion instrument provided by the embodiments of the present application. As Figure 5As shown, the process of the amplitude of the sound emitted by the percussion instrument changing with time can be divided into three intervals. First, the sound amplitude increases sharply in interval A and then drops slightly, then remains for a period of time in interval B, and finally decays to near 0 in interval C according to the exponential curve rule. Therefore, the modulator modulates the duty cycle corresponding to each note in the primary modulation signal to a value proportional to the amplitude of the envelope signal (i.e., performs pulse width modulation on the primary modulation signal) according to the envelope signal and the note frequency signal, obtains the secondary modulation signal, and outputs the secondary modulation signal to the buzzer, so that the volume change process of each note in the synthesized music output by the buzzer conforms to the sound amplitude envelope curve of the preset timbre, thereby realizing the timbre of the simulated musical instrument. It should be noted that although there is a sequence in the execution order of amplitude modulation and pulse width modulation in the above description, in practical applications, from a macroscopic perspective, amplitude modulation and pulse width modulation are almost carried out simultaneously, and the time difference in the execution of amplitude modulation and pulse width modulation can be ignored by the human ear.
[0058] As an alternative embodiment, the note frequency signal is a binary signal that periodically flips at the first preset frequency, and the carrier signal is a binary signal that periodically flips at the second preset frequency. Therefore, the modulation depth of the amplitude modulation of the carrier signal by the modulator according to the note frequency signal is preferably 100%, and the formula for obtaining the primary modulation signal is:
[0059]
[0060] where f1 represents the primary modulation signal, Vcarry represents the carrier signal, and Vnote represents the note frequency signal.
[0061] As an alternative embodiment, in order to facilitate pulse width modulation, the sound amplitude envelope curve of the preset timbre can be quantized into an envelope array with an appropriate capacity and resolution. Among them, the capacity represents the number of equal parts into which the sound amplitude envelope curve is divided in the time dimension (i.e., the horizontal axis direction of Figure 5 ), and the resolution represents the number of equal parts into which the sound amplitude envelope curve is divided in the sound amplitude dimension (i.e., the vertical axis direction of Figure 5 ). The capacity and resolution can be set by engineers according to experience. In this way, the envelope signal can be a signal output according to the array elements of the envelope array corresponding to the sound amplitude envelope curve of the preset timbre. The process of the modulator performing pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain the secondary modulation signal is as follows: Modulate the duty cycle of the primary modulation signal to the product of the envelope signal and the note frequency signal.
[0062] In implementations, the modulator modulates the duty cycle of the primary modulation signal to the product of the envelope signal and the note frequency signal. When the note frequency signal = 1, the duty cycle of the modulated secondary modulation signal = note frequency signal * envelope signal = envelope signal; when the note frequency signal = 0, the duty cycle of the modulated secondary modulation signal = note frequency signal * envelope signal = 0. Thus, when the preset melody consists of a single note, the envelope signal output over time can modulate the duty cycle of the primary modulation signal to a value proportional to the sound amplitude in the sound amplitude envelope curve. When the preset melody consists of multiple different notes, the envelope signal can be a signal cyclically outputted from an envelope array corresponding to the sound amplitude envelope curve of the preset timbre. The envelope signal output over time can modulate the duty cycle of each note in the primary modulation signal to a value proportional to the sound amplitude in the sound amplitude envelope curve, thereby ensuring that the volume variation of each note in the output synthesized music matches the sound amplitude envelope curve of the preset timbre, ultimately achieving the timbre of the synthesized music simulating an instrument. It should be noted that a larger capacity and a deeper resolution in the envelope array can improve the sound quality of the output synthesized music, but will significantly increase the computing overhead of the MCU. Therefore, preferably, the capacity of the envelope array is 256 and the resolution is 256.
[0063] In step 403, the buzzer is driven by the secondary modulation signal to output synthesized music corresponding to the preset tune and preset timbre.
[0064] In practice, the buzzer can output the synthesized music corresponding to the preset tune and preset timbre according to the driving of the secondary modulation signal. Figure 1 In the prior art shown, external circuit processing can only make the timbre of the output synthesized music approximately simulate the envelope waveform (i.e., timbre) of a single instrument. The simulated timbre is limited in its variety. In the embodiments of the present application, however, engineers can set envelope signals corresponding to multiple preset timbres according to design requirements, thereby achieving software simulation of synthesized music with multiple instrument timbres based on a single set of audio synthesis devices. This allows for a wider range of variations and a more realistic simulation effect.
[0065] As an optional implementation manner, the process of the modulator outputting the secondary modulated signal to the buzzer is as follows: the secondary modulated signal is output to the buzzer in a complementary push-pull manner.
[0066] In practice, the MCU port's built-in driving function can be used to output the secondary modulation signal to the buzzer in a complementary push-pull manner, thereby amplifying the output secondary modulation signal and increasing the volume of the synthesized music. Figure 1 The prior art shown simplifies the circuit of the amplifying unit and further reduces the cost of the circuit.
[0067] An embodiment of the present application provides an audio synthesis method for a simulated musical instrument. First, in response to an audio synthesis trigger instruction, a note frequency generator outputs a note frequency signal corresponding to a preset tune, an envelope signal generator outputs an envelope signal corresponding to a preset timbre, and a carrier generator outputs a carrier signal. Wherein, the preset tune and the preset timbre can be set by engineers according to actual needs. Then, a modulator performs amplitude modulation on the carrier signal according to the note frequency signal to obtain a primary modulation signal, and performs pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and outputs the secondary modulation signal to a buzzer. Finally, the buzzer outputs synthesized music corresponding to the preset tune and the preset timbre according to the drive of the secondary modulation signal. Through the above method, an envelope signal can be generated inside the MCU and a modulation signal simulating the timbre of a musical instrument can be obtained, and synthesized music with the timbre of a musical instrument can be output without being processed by a specific external circuit, which has the advantages of simple circuit, low cost and high reliability.
[0068] It should be understood that although Figure 4 the steps in the flowchart of Figure 4 are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover,
[0069] at least a part of the steps in
[0070] An embodiment of the present application also provides an audio synthesis device for a simulated musical instrument. As Figure 2 and Figure 3 shown, the device includes an MCU2 and a buzzer BUZ2. The MCU2 includes a modulator 310, a note frequency generator 320, a carrier generator 330, and an envelope signal generator 340;
[0071] The note frequency generator 320 is configured to output a note frequency signal corresponding to a preset tune in response to an audio synthesis trigger instruction;
[0072] An envelope signal generator 340 for outputting an envelope signal corresponding to a preset timbre in response to an audio synthesis trigger instruction;
[0073] A carrier generator 330 for outputting a carrier signal in response to an audio synthesis trigger instruction;
[0074] A modulator 310 for amplitude - modulating the carrier signal according to the note frequency signal to obtain a primary modulation signal, pulse - width - modulating the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and outputting the secondary modulation signal to the buzzer BUZ2;
[0075] A buzzer BUZ2 for outputting synthesized music corresponding to a preset tune and a preset timbre under the drive of the secondary modulation signal.
[0076] As an alternative implementation, the note frequency signal is a binary signal that periodically flips at a first preset frequency, and the carrier signal is a binary signal that periodically flips at a second preset frequency.
[0077] As an alternative implementation, the audio synthesis device further includes a protection resistor. One end of the protection resistor is connected to the MCU, and the other end is connected to the buzzer.
[0078] In implementation, since the buzzer is a capacitive device, a short - term impact current will be generated when the signal alternates. Therefore, as Figure 2 shown, in order to avoid damage to the MCU2 caused by the impact current, the audio synthesis device further includes a protection resistor R9. One end of the protection resistor R9 is connected to the output port PA0.02 of the MCU2, and the other end is connected to the input port of the buzzer BUZ2, which can provide a buffer for the output port of the MCU2 when the impact current is generated, playing a role in protecting the chip (i.e., MCU2).
[0079] As an alternative implementation, the envelope signal is a signal output according to the array elements of an envelope array corresponding to the sound amplitude envelope curve of the preset timbre. The modulator is specifically used for:
[0080] Modulating the duty cycle of the primary modulation signal to be the product of the envelope signal and the note frequency signal.
[0081] As an alternative implementation, the modulator is specifically used for:
[0082] Outputting the secondary modulation signal to the buzzer in a complementary push - pull manner.
[0083] As an alternative implementation, the duty cycle of the note frequency signal is 50%.
[0084] As an alternative implementation, the value range of the second preset frequency is 22.05KHz to 44.1KHz.
[0085] As an alternative implementation, the capacity of the envelope array is 256 and the resolution is 256.
[0086] The embodiment of the present application provides an audio synthesis device for a simulated musical instrument. First, in response to an audio synthesis trigger instruction, a note frequency generator outputs a note frequency signal corresponding to a preset tune, an envelope signal generator outputs an envelope signal corresponding to a preset timbre, and a carrier generator outputs a carrier signal. Among them, the preset tune and the preset timbre can be set by engineers according to actual needs. Then, a modulator performs amplitude modulation on the carrier signal according to the note frequency signal to obtain a primary modulation signal, and performs pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and outputs the secondary modulation signal to a buzzer. Finally, the buzzer outputs synthesized music corresponding to the preset tune and the preset timbre according to the drive of the secondary modulation signal. Through the above method, an envelope signal can be generated inside the MCU and a modulation signal simulating the timbre of a musical instrument can be obtained, and the synthesized music simulating the timbre of a musical instrument can be output without being processed by a specific external circuit, which has the advantages of simple circuit, low cost and high reliability.
[0087] For the specific limitations of the audio synthesis device, reference can be made to the limitations on the audio synthesis method in the above text, which will not be elaborated here. Each module in the above audio synthesis device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above-mentioned modules.
[0088] In one embodiment, a computer device is provided, as Figure 6 shown, including a memory and a processor. A computer program that can run on the processor is stored on the memory. When the processor executes the computer program, the method steps of the above audio synthesis are implemented.
[0089] In one embodiment, a computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above audio synthesis method are implemented.
[0090] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in this application can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0091] It should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of another identical element in the process, method, article or device including the said element.
[0092] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0093] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and reference can be made to the corresponding parts of the method embodiments for the related content.
[0094] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered that they are within the scope described in this specification.
[0095] The above-described embodiments only represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. An audio synthesis method for a simulated musical instrument, characterized in that, The audio synthesis method is applied to an audio synthesis device, which includes a microcontroller MCU and a buzzer. The MCU includes a modulator, a note frequency generator, a carrier generator, and an envelope signal generator. The method includes: In response to an audio synthesis trigger instruction, the note frequency generator outputs a note frequency signal corresponding to a preset tune, the envelope signal generator outputs an envelope signal corresponding to a preset timbre, and the carrier generator outputs a carrier signal; The modulator performs amplitude modulation on the carrier signal according to the note frequency signal to obtain a primary modulation signal, and performs pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and outputs the secondary modulation signal to the buzzer; The buzzer outputs the synthesized music corresponding to the preset tune and the preset timbre according to the drive of the secondary modulation signal.
2. The method according to claim 1, characterized in that, The note frequency signal is a binary signal that periodically flips at a first preset frequency, and the carrier signal is a binary signal that periodically flips at a second preset frequency. The formula for performing amplitude modulation on the carrier signal according to the note frequency signal to obtain a primary modulation signal is: where f1 represents the primary modulation signal, Vcarry represents the carrier signal, and Vnote represents the note frequency signal.
3. The method according to claim 2, characterized in that The envelope signal is a signal output according to the array elements of an envelope array corresponding to the sound amplitude envelope curve of the preset timbre. Performing pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal includes: Modulating the duty cycle of the primary modulation signal to the product of the envelope signal and the note frequency signal.
4. The method according to claim 1, wherein The step of outputting the secondary modulation signal to the buzzer includes: Outputting the secondary modulation signal to the buzzer in a complementary push-pull manner.
5. The method according to claim 2, characterized in that, The duty cycle of the note frequency signal is 50%.
6. The method according to claim 2, characterized in that The value range of the second preset frequency is 22.05KHz to 44.1KHz.
7. The method according to claim 3, wherein The capacity of the envelope array is 256, and the resolution is 256.
8. An audio synthesis device for a simulated musical instrument, characterized in that, The audio synthesis device includes a microcontroller MCU and a buzzer. The MCU includes a modulator, a note frequency generator, a carrier generator, and an envelope signal generator; The note frequency generator is configured to output a note frequency signal corresponding to a preset tune in response to an audio synthesis trigger instruction; The envelope signal generator is configured to output an envelope signal corresponding to a preset timbre in response to the audio synthesis trigger instruction; The carrier generator is configured to output a carrier signal in response to the audio synthesis trigger instruction; The modulator is configured to perform amplitude modulation on the carrier signal according to the note frequency signal to obtain a primary modulation signal, and perform pulse width modulation on the primary modulation signal according to the envelope signal and the note frequency signal to obtain a secondary modulation signal, and output the secondary modulation signal to the buzzer; The buzzer is configured to output the synthesized music corresponding to the preset tune and the preset timbre according to the drive of the secondary modulation signal.
9. The device according to claim 8, characterized in that, The note frequency signal is a binary signal that periodically flips at a first preset frequency, and the carrier signal is a binary signal that periodically flips at a second preset frequency.
10. The device according to claim 8, characterized in that, The audio synthesis device further includes a protection resistor. One end of the protection resistor is connected to the MCU, and the other end is connected to the buzzer.
Citation Information
Patent Citations
Automatic duplicating method and device for single track polyphonic music signals
CN103854644A
Method and apparatus for simultaneously communicating voice and data in analog cordless telephone system
CN1539235A