CN103902285A - Signal generator implementation method based on Android system - Google Patents
Signal generator implementation method based on Android system Download PDFInfo
- Publication number
- CN103902285A CN103902285A CN201410083204.6A CN201410083204A CN103902285A CN 103902285 A CN103902285 A CN 103902285A CN 201410083204 A CN201410083204 A CN 201410083204A CN 103902285 A CN103902285 A CN 103902285A
- Authority
- CN
- China
- Prior art keywords
- file
- wave
- peak
- button
- mediaplayer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 45
- 230000008859 change Effects 0.000 claims description 6
- 241001269238 Data Species 0.000 claims description 3
- 230000000694 effects Effects 0.000 claims description 3
- 230000008569 process Effects 0.000 claims description 3
- 238000013139 quantization Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 abstract description 15
- 230000008901 benefit Effects 0.000 abstract description 4
- 238000005070 sampling Methods 0.000 description 22
- 230000003068 static effect Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 2
- 238000009499 grossing Methods 0.000 description 2
- 230000005236 sound signal Effects 0.000 description 2
- 230000007704 transition Effects 0.000 description 2
- 238000004164 analytical calibration Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000007274 generation of a signal involved in cell-cell signaling Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 210000000352 storage cell Anatomy 0.000 description 1
Images
Landscapes
- Signal Processing For Digital Recording And Reproducing (AREA)
Abstract
The invention relates to the field of signal generators, in particular to a signal generator implementation method based on the Android system. The method includes the steps of establishing a layout file, creating a main thread, establishing an array variable, entering an output waveform setting state, establishing a File type variable, adding a MediaPlayer variable and the like. Compared with a traditional signal generator, according to the method, the functions of the signal generators are achieved on the basis of an Android platform, and corresponding equipment has the advantages of being small in size, low in weight, convenient to carry and the like.
Description
Technical field
The present invention relates to signal generator field, be specifically related to a kind of method that realizes signal generator based on Android system.
Background technology
Along with the development of mobile device, the function of various mobile devices is more and more complete, and its profile is also more and more convenient.Android platform is widely used in mobile device as on panel computer and mobile phone, and the mobile device based on Android platform has media play function, particularly has the function of output audio signal; The benefit that Android is increased income is to reduce the cost of design, also easily revises the variation of source code practical function; These advantages of Android platform are that other platforms are incomparable.
Special Signal-generator due to its fancy price and huge volume restrictions electronician's purchase and use, the inflexible interface of Special Signal-generator is also difficult to meet modern popular demand simultaneously, meets public demand so be badly in need of a kind of portable signal generator; The audio interface of utilizing equipment itself to have on Android platform, can realize the function of signal generator, make signal generator more portable, the simultaneously greatly cost of reduction equipment, relies on the man-machine interface that the powerful interface ability of Android platform can flexible design hommization.The volume of Special Signal-generator is greater than 3000cm conventionally
3, price is up to more than several thousand; Comparing and adopting the signal generator volume of Android system is only 100cm
3left and right, additional peripheral devices is lower than 1 yuan.
The audio interface of Android equipment has low pass smoothing filter and certain carrying load ability, can realize the output of low noise power signal, the signal generator based on Android platform can move on the different Android hardware platform of mobile phone, the panel computer etc. of Android platform; The method of utilizing Android platform audio interface to realize signal generator function is to realize the effective way of signal generator cheaply; The oscillograph of realizing based on Android platform is a kind of audio signal generator, can be used in low-frequency electronic electrician and robotization etc. for the less demanding field of signal bandwidth, as the supply of motor step inlet signal, pwm signal generation and the measurement of low-frequency power amplifier enlargement factor etc.
Summary of the invention
The object of the present invention is to provide a kind of realize the portable and utmost point at a low price realize the method for signal generator based on Android system.
The object of the present invention is achieved like this:
Step 1, set up topology file main.xml, be set to linear placement, add TextView object, then add two list layouts, first every row two is listed as; Add four EditText objects, be respectively used to input calibration value, peak-to-peak value, frequency and unit, unit is the unit of calibration value and peak-to-peak value here, and four EditText objects form the list layout arrangement that two row two are listed as.Second every row four of list layout is listed as, add eight Button objects, be respectively sine wave, rectangular wave, triangular wave, high bass wave, export, stop, exiting and help button, high bass wave represents Gaussian noise, and eight Button objects form the list layout that two row four are listed as;
Step 2, set up class Osc class and inherit activity class, create main thread, the topology file that main thread is set is main.xml; Variable is set and obtains EditText object and Button object; The output volume maximum of media is set;
Step 3, set up the array variable of 88244 elements of a large byte type, for stored waveform data, its quantization digit is 16BIT, and sample frequency is 44100Hz; In the time of main thread initializes, generate the sine wave of the peak-to-peak value maximum of 1kHz, and the file header that adds WAVE audio format file for this file is temporarily put in array, set up the variable of File type, mode with byte stream is kept at array data under the root directory of SD card, file is called wave1.wav, covers this file if file exists;
Step 4, for obtain Button button audiomonitor is set, while clicking sine wave, rectangular wave, triangular wave and Gaussian noise button, system enters the output waveform state that arranges, if system is at displaying audio file, system stops playing in output state, and allows system enter output waveform state is set, obtain calibration value, peak-to-peak value, frequency and unit in the EditText object of signal simultaneously, waveform parameter is set, generates respectively corresponding Wave data, acquiescence waveform side-play amount is zero; The Wave data that Gaussian noise generates if click is peak-to-peak value square divided by two gaussian distribution datas that are variance, if click square wave, to generate dutycycle be 50% square wave, generates isosceles triangle wave if click triangular wave;
After completing, step 5, Wave data setting add the file header of WAVE audio format file for this Wave data, temporarily be put in array, set up the variable of File type, mode with byte stream is kept at array data under the root directory of SD card, file is called wave.wav, covers this file if file exists;
When step 6, main thread initializes, add MediaPlayer variable by MediaPlayer () method, it is the file wave.wav preserving in SD card that played file source is set, and broadcast mode is loop play;
Step 7, while clicking calibration knob, MediaPlayer () method is added MediaPlayer variable, it is the file wave1.wav preserving in SD card that played file source is set, broadcast mode is loop play, use successively prepare () method and start () method to start played file, system enters output state; A.C. voltmeter is measured the peak-to-peak value of output signal, reads this peak-to-peak value and is input in the peak-to-peak value EditText object at interface, realizes calibration function;
Step 8, click button when output initialization MediaPlayer, use successively prepare () method and start () method to start played file, be that system enters output state, the information of display on TextView simultaneously, click when button stops and using stop () method to stop played file, system exits output state and enters halted state;
Step 9, while clicking exit button, first judge that whether MediaPlayer is playing, if playing, use stop () method to stop playing this file, uses release () method to discharge MediaPlayer, use finish to finish process, complete software and exit; While clicking help button, on TextView, show help information, click help button and only change system view, do not change system state.
Beneficial effect of the present invention is:
(1) compared with traditional signal generator, the present invention is based on Android platform and realize signal generator function, corresponding equipment has the advantages such as volume is little, lightweight, easy to carry;
(2) the present invention relies on the human-computer interaction interface of Android platform exploitation signal generator, can give full play to the feature of Android platform flexible interface and hommization.
(3) Android audio interface has low pass smoothing filter and certain carrying load ability, can realize the output of low noise power signal, thereby greatly reduce construction cycle and design cost without external related hardware equipment.
(4) Android platform equipment is many, and applied range takies software and hardware resources based on signal generator of the present invention few, is convenient to integrated or is embedded in relevant device, carries out functions of the equipments expansion.
Brief description of the drawings
Fig. 1 shows display interface figure.
Fig. 2 shows system state transition diagram.
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is described in greater detail.
The present invention is achieved in that
1, under Android platform, according to the data of user's input parameter structure signal waveform, leave in static overall array, realize waveform and generate;
2, the data of having constructed are added to the file header of WAVE file, generate audio file by the write method of FileOutputStream class, and deposit this file in SD card, realize waveform storage;
3, play this audio file by the MediaPlayer class of Android platform, signal waveform is outputed to audio interface, realize waveform output;
4, the sinusoidal signal of Android platform output maximum peak peak value, to audio interface, is pressed table calibration output voltage by external AC, realizes signal generator calibration
The present invention also comprises following technical characterstic:
1, under Android platform, the parameters such as the form of user input signal, amplitude, frequency, its sample frequency 44100Hz, according to parametric configuration signal output waveform, adds WAVE file header and leaves in internal memory in array mode, realizes waveform and generates;
2, the WAVE file data of having constructed is saved in SD card by the write method of FileOutputStream class, realizes waveform storage;
3, WAVE file is outputed to audio interface by MediaPlayer class, thereby output signal reaches the function that realizes signal generator based on Android platform audio interface, and realize menu function.
4, instrument calibration: the sinusoidal signal of system output maximum peak peak value, to audio interface, is pressed table calibration output voltage by external AC.
Step 1, establishment view: set up topology file main.xml, be set to linear placement, add TextView object, then add two list layouts, first every row two is listed as; Add four EditText objects, be respectively used to input calibration value, peak-to-peak value, frequency and unit, unit is the unit of calibration value and peak-to-peak value here, and four EditText objects form the list layout arrangement that two row two are listed as.Second every row four of list layout is listed as, add eight Button objects, be respectively sine wave, rectangular wave, triangular wave, high bass wave, export, stop, exiting and help button, high bass wave represents Gaussian noise, eight Button objects form the list layout that two row four are listed as, and the system interface that this layout generates as shown in Figure 1.
Step 2, establishment main thread: set up class Osc class and inherit activity class, create main thread; It is main.xml that topology file is set in main thread, create new variables and obtain EditText object and Button object, the output volume maximum of media is set, with MediaPlayer () method interpolation MediaPlayer variable, it is the file wave.wav preserving in SD card that played file source is set, and broadcast mode is loop play.。
Step 3, initialization system: set up the overall static array variable of 88244 elements of a large byte type, for stored waveform data, needing the waveform quantization figure place of preserving is 16BIT, and sample frequency is 44100Hz, signal length 1s; (Waveform generation method is shown in step 5) in the time of main thread initializes, to generate the sine wave of peak-to-peak value maximum of 1kHz, and the file header that adds WAVE audio format file for this file is temporarily put in front 44 bytes of this array, set up the variable of File type, mode with byte stream is kept at array data under the root directory of SD card, file is called wave1.wav, covers this file if file exists; Create overall static long variable for stored waveform mark, create overall static floating-point variable for storing calibration value, peak-to-peak value, frequency, create overall static strings for storage cell, respectively its value of initialization.
Step 4, audiomonitor is set: after system initialization, create Button and EditText variable, obtain Button and EditText object, for the Button button obtaining arranges audiomonitor; While clicking sine wave, rectangular wave, triangular wave and Gaussian noise button, system enters the output waveform state that arranges: if system is at displaying audio file, be that system stops playing in output state, and allow system enter output waveform state is set, obtain calibration value, peak-to-peak value, frequency and unit in the EditText object of signal simultaneously, waveform parameter is set, generates respectively corresponding Wave data, acquiescence waveform side-play amount is zero; The Wave data that Gaussian noise generates if click is peak-to-peak value square divided by two gaussian distribution datas that are variance, if click square wave, to generate dutycycle be 50% square wave, generates isosceles triangle wave if click triangular wave, and concrete sampling point data creation method is shown in step 5.
The method that step 5, waveform generate: use system function and realize waveform generation, the data of generation are left in static overall array successively, and concrete data method is: if sine wave: (sampling point sequence number) individual sampling point data value=peak-to-peak value/calibration value × 2^16 × Sin(sampling point sequence number × π × 2 × frequency/44100), if square wave: (sampling point sequence number/(44100/ frequency/2)) are removed to 2 delivery values, if after mould value rounds be 1: (sampling point sequence number) individual sampling point data value=peak-to-peak value/calibration value × 2^16 × 1, if it is 0 that mould value rounds: (sampling point sequence number) individual sampling point data value=peak-to-peak value/calibration value × 2^16 × (1), if triangular wave: (sampling point sequence number) individual sampling point data value=peak-to-peak value/calibration value × 2^16 × (sampling point sequence number-44100/ frequency × (rounding ((sampling point sequence number/(44100/ frequency))))/(sampling point sequence number/(44100/ frequency)), if Gaussian noise: (sampling point sequence number) individual sampling point data value=peak-to-peak value/calibration value × 2^16 × variance is that 1 average is gaussian random noise/2^0.5 of 0, because the static overall situation is byte type, so the individual sampling point data value of (2 × sampling point sequence number+43) individual byte data=the (sampling point sequence number) forces to convert to 16 high eight-bits after integer in overall array, in overall situation array, the individual sampling point data value of (2 × sampling point sequence number+42) individual byte data=the (sampling point sequence number) forces to convert to low eight after 16 integers.
Step 6, waveform storage: the file header that adds WAVE audio format file after Wave data setting completes for this Wave data, temporarily be put in static overall array, set up the variable of File type, mode with byte stream is kept at array data under the root directory of SD card, file is called wave.wav, covers this file if file exists.
Step 7, audiomonitor response: while clicking calibration knob, MediaPlayer () method is added MediaPlayer variable, it is the file wave1.wav preserving in SD card that played file source is set, broadcast mode is loop play, use successively prepare () method and start () method to start played file, system enters output state; A.C. voltmeter is measured the peak-to-peak value of output signal, reads this peak-to-peak value and is input in the peak-to-peak value EditText object at interface, realizes calibration function.
Step 8, push button function are realized: initialization MediaPlayer while clicking button output, use successively prepare () method and start () method to start played file, be that system enters output state, the information of display on TextView simultaneously, its information comprises current signal waveform, frequency, amplitude and calibration value.Click when button stops and using stop () method to stop played file, system exits output state and enters halted state.
Step 9, System menu button are realized: while clicking exit button, first judge whether MediaPlayer is playing, if playing, use stop () method to stop playing this file, use release () method to discharge MediaPlayer resource, use finish to finish process, complete software and exit; While clicking help button, on TextView, show help information (operation instructions), click help button and only change system view, do not change system state; System state transition diagram as shown in Figure 2.
Claims (1)
1. a method that realizes signal generator based on Android system, is characterized in that:
Step 1, set up topology file main.xml, be set to linear placement, add TextView object, then add two list layouts, first every row two is listed as; Add four EditText objects, be respectively used to input calibration value, peak-to-peak value, frequency and unit, unit is the unit of calibration value and peak-to-peak value here, and four EditText objects form the list layout arrangement that two row two are listed as.Second every row four of list layout is listed as, add eight Button objects, be respectively sine wave, rectangular wave, triangular wave, high bass wave, export, stop, exiting and help button, high bass wave represents Gaussian noise, and eight Button objects form the list layout that two row four are listed as;
Step 2, set up class Osc class and inherit activity class, create main thread, the topology file that main thread is set is main.xml; Variable is set and obtains EditText object and Button object; The output volume maximum of media is set;
Step 3, set up the array variable of 88244 elements of a large byte type, for stored waveform data, its quantization digit is 16BIT, and sample frequency is 44100Hz; In the time of main thread initializes, generate the sine wave of the peak-to-peak value maximum of 1kHz, and the file header that adds WAVE audio format file for this file is temporarily put in array, set up the variable of File type, mode with byte stream is kept at array data under the root directory of SD card, file is called wave1.wav, covers this file if file exists;
Step 4, for obtain Button button audiomonitor is set, while clicking sine wave, rectangular wave, triangular wave and Gaussian noise button, system enters the output waveform state that arranges, if system is at displaying audio file, system stops playing in output state, and allows system enter output waveform state is set, obtain calibration value, peak-to-peak value, frequency and unit in the EditText object of signal simultaneously, waveform parameter is set, generates respectively corresponding Wave data, acquiescence waveform side-play amount is zero; The Wave data that Gaussian noise generates if click is peak-to-peak value square divided by two gaussian distribution datas that are variance, if click square wave, to generate dutycycle be 50% square wave, generates isosceles triangle wave if click triangular wave;
After completing, step 5, Wave data setting add the file header of WAVE audio format file for this Wave data, temporarily be put in array, set up the variable of File type, mode with byte stream is kept at array data under the root directory of SD card, file is called wave.wav, covers this file if file exists;
When step 6, main thread initializes, add MediaPlayer variable by MediaPlayer () method, it is the file wave.wav preserving in SD card that played file source is set, and broadcast mode is loop play;
Step 7, while clicking calibration knob, MediaPlayer () method is added MediaPlayer variable, it is the file wave1.wav preserving in SD card that played file source is set, broadcast mode is loop play, use successively prepare () method and start () method to start played file, system enters output state; A.C. voltmeter is measured the peak-to-peak value of output signal, reads this peak-to-peak value and is input in the peak-to-peak value EditText object at interface, realizes calibration function;
Step 8, click button when output initialization MediaPlayer, use successively prepare () method and start () method to start played file, be that system enters output state, the information of display on TextView simultaneously, click when button stops and using stop () method to stop played file, system exits output state and enters halted state;
Step 9, while clicking exit button, first judge that whether MediaPlayer is playing, if playing, use stop () method to stop playing this file, uses release () method to discharge MediaPlayer, use finish to finish process, complete software and exit; While clicking help button, on TextView, show help information, click help button and only change system view, do not change system state.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410083204.6A CN103902285B (en) | 2014-03-08 | 2014-03-08 | Signal generator implementation method based on Android system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410083204.6A CN103902285B (en) | 2014-03-08 | 2014-03-08 | Signal generator implementation method based on Android system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103902285A true CN103902285A (en) | 2014-07-02 |
CN103902285B CN103902285B (en) | 2017-02-22 |
Family
ID=50993628
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410083204.6A Expired - Fee Related CN103902285B (en) | 2014-03-08 | 2014-03-08 | Signal generator implementation method based on Android system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103902285B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105515551A (en) * | 2014-10-14 | 2016-04-20 | 苏州普源精电科技有限公司 | Signal generator with arbitrary wave editing function |
CN112562746A (en) * | 2020-12-09 | 2021-03-26 | 四川长虹电器股份有限公司 | Dynamic control method for volume of player |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102306099A (en) * | 2011-08-23 | 2012-01-04 | 上海网达软件有限公司 | Cross-platform graphic display method and graphic display system on handheld terminal equipment |
US20120300588A1 (en) * | 2011-05-27 | 2012-11-29 | uBeam Inc. | Receiver communications for wireless power transfer |
CN202713532U (en) * | 2012-07-04 | 2013-01-30 | 四川长虹电器股份有限公司 | Flat television inspection debugging system based on intelligent operation system |
-
2014
- 2014-03-08 CN CN201410083204.6A patent/CN103902285B/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120300588A1 (en) * | 2011-05-27 | 2012-11-29 | uBeam Inc. | Receiver communications for wireless power transfer |
CN102306099A (en) * | 2011-08-23 | 2012-01-04 | 上海网达软件有限公司 | Cross-platform graphic display method and graphic display system on handheld terminal equipment |
CN202713532U (en) * | 2012-07-04 | 2013-01-30 | 四川长虹电器股份有限公司 | Flat television inspection debugging system based on intelligent operation system |
Non-Patent Citations (1)
Title |
---|
产品资讯与行业新闻: "泰克公司推出三个用于示波器的安卓应用程序", 《电子测试》 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105515551A (en) * | 2014-10-14 | 2016-04-20 | 苏州普源精电科技有限公司 | Signal generator with arbitrary wave editing function |
CN105515551B (en) * | 2014-10-14 | 2020-06-05 | 普源精电科技股份有限公司 | Signal generator with arbitrary wave editing function |
CN112562746A (en) * | 2020-12-09 | 2021-03-26 | 四川长虹电器股份有限公司 | Dynamic control method for volume of player |
CN112562746B (en) * | 2020-12-09 | 2022-05-17 | 四川长虹电器股份有限公司 | Dynamic control method for volume of player |
Also Published As
Publication number | Publication date |
---|---|
CN103902285B (en) | 2017-02-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112506341B (en) | Vibration effect generation method and device, terminal equipment and storage medium | |
CN103294447A (en) | Method and device for generating random numbers | |
US8624857B2 (en) | Haptics effect controller architecture and instruction set | |
CN110010151A (en) | A kind of acoustic signal processing method and equipment, storage medium | |
CN110070884B (en) | Audio starting point detection method and device | |
CN204594573U (en) | A kind of Audio Frequency Analyser | |
CN106651144B (en) | Tower and line relation modeling method with same-tower parallel line information | |
CN103902285A (en) | Signal generator implementation method based on Android system | |
CN104102659A (en) | Music searching method and terminal | |
CN110070885B (en) | Audio starting point detection method and device | |
CN103178783B (en) | Summation modulating signal generator | |
CN109697083A (en) | Fixed point accelerated method, device, electronic equipment and the storage medium of data | |
CN103944538B (en) | A kind of optional waveform generator | |
CN203014744U (en) | Arbitrary signal generator based on AD9951 chip and FPGA | |
CN104580732A (en) | Random waveform electric signal generator and generation method based on smart phone | |
CN203482173U (en) | Signal generator with multipath signal superposition function | |
CN106501613A (en) | The method of testing and test device of loudspeaker impedance | |
CN103873018A (en) | Method for generating harmonic signal and harmonic signal generator | |
CN110597084A (en) | Wind power plant simulation test method and device and wind power plant simulation model | |
Ivković et al. | The advantages of using Raspberry Pi 3 compared to Raspberry Pi 2 SoC computers for sensor system support | |
Liu | Design of typical waveform generator based on DDS/SOPC | |
CN105869614B (en) | Audio file deriving method and device | |
CN105515551A (en) | Signal generator with arbitrary wave editing function | |
CN105094802A (en) | Information processing method and electronic equipment | |
CN104104363A (en) | Function signal generator |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20170222 |