The design of a digital signal generator and a simple digital piano based on the maTLAB
Abstract
Digital signal generator is a kind of waveform generator based on software and hardware , can generate a variety of basic waveform .A variety of complexeng ineering signal is generated by the superposition of these basic signal, so it's widely used in engineering analysis and experiment teaching . MATLAB is a very practical engineering software for data analysis and processing,its data acquisition toolbox provides a very convenient functions and commands for data input and output, and it is convenient and practical in the digital signal processing. This paper first introduced the design process of digital signal generator based on MATLAB, realized the specific methods to achieve the simple waveform (sine square, triangle ,slope) , and then achieved a simple digital piano by the sinne.
1 .Introduction
With the development of computer software and hardware technology, more and more real goods functions can be realized by a computer.,that is what we often say. That the hardware becomes software can reduce the cost and make the implement modify and simulation easier . Now there is a lot of relatively mature software such as MATLAB. Based on this consideration, I made a simple digital generator with MATLAB, and in order to make it linked to the practical application, I make a simple digital piano. I think it can make a certain foundation for future learning and work.
1.1 the introduction of digital signal generator
Digital signal generator can produce sine ,square, triangle , saw , white noise , pulse and step etc.. Digital signals can also be called as discrete signal, it only give values for a function in discrete time ,and it is a sequence of discontinuous temporally.The interval of discrete time is uniform, and use
to express it .The value of
determined by the sampling frequency--Fs. In order to ensure the sampled signal can stay true to the original analog signal information, sampling frequency must be at least 2 times as high as the highest frequency component of the original signal. This is the basic rule of sampling, called the sampling theorem. In this paper, in order to make digital signal more close to the original analog signal, the sampling frequency is about 20 times higher than the original signal frequency . The MATLAB program provides a variety of common basic signal generating function . This design simulated four kinds of signals, three are directly using the function provided by MATLAB, only one signal is not a called function , directly written.
1.2 the introduction of digital piano
The promotion of digital piano in China began in eighty years twentieth Century , so far , the tone ,the quality,and the convenience of performance have reached a very mature stage, with the development of integrated circuit technology, the upgrading can keep the original structure remain unchanged by the replacement of a simple chip. However, the digital piano have obvious shortcomings:the concerto problems betwwen it and piano, orchestra restrict the use of digital piano in important place in music, which greatly affect the application and popularization of digital piano. The coordination of the digital piano and non electronic musical instrument is a pressing matter to the current music professionals and developers of digital piano. In this paper,I design a simple digital piano by MATLAB , to deepen the understanding of the digital piano.
2. Method
2.1 the realization of the digital signal generator
I first analy the GUI interface of digital signal generator according to the requirements of the design, and then enter the guide in the MATLAB workplace interface to open the GUI interface. And then build a good specific interface of digital signal generator in the GUI interface, and write the callback function of each waveform control,save the M file . Try to operate, if the result is correct, observe the simulation results. If the simulation of digital signal generator is in correct results, check the callback function of the control key, modify and save the M file, run again, and observe the simulation results .
2.1.1 build the GUI of the digital signal generator
GUI under the environment of MaTLAB is a user interface composed of window, cursor, buttons, menus, text and other objects. The user through certain methods (such as a mouse or keyboard) select, activate these graphical objects, to make the computer produce some action or change such as the realization of calculation, drawing etc.. The operation of a graphical user interface generally have two parts, first of all, choose the appropriate graphical objects to establish the reasonable GUI interface in accordance with the requirements of design, principle, and the need ; then write the callback function of the controls in the M file to make the constructed GUI interface run.
The GUI interface of the design of digital signal generator use graphics objects such as panel, Axes, pushbutton, Static Text, and simulate four kinds of signal: sine ,square , triangle , slope. GUI interface of digital signal generator are as follows:
2.1.2 the basic principle of the waveform
2.1.2.1 the realization of the sine wave
the mathematical expression of sin signals are as follows:
among them: A for the amplitude,
for the frequency ,
for phase . In MATLAB,because the processing objects are discrete digital signal, discretizate the time variable and construct a one dimension group:
; with them:
for the sampling frequency. But the value can not be too large, otherwise the waveform display will be very slow. the corresponding digital signal expression of sine :
After getting the discrete values of t and y , use plot mapping function to obtain the corresponding waveform display.
2.1.2.2 the realizationof square wave
The mathematical expression for the square signal:
y=A 0