# Optimization of Intelligent Tuning System for Stringed Instruments Based on Wireless Sensor Network

Authors: Pin Zhuo
Journal: Journal of Sensors
 (2021)

---

## Abstract

With the increasing abundance of material civilization, people’s pursuit of spiritual civilization is also higher and higher. Although tuning is the analysis and processing of sound signal, the string signal is also a kind of sound signal, which follows the basic law of acoustics. In the field of wireless sensor network, this paper introduces the status quo of tuning tools for stringed instruments, analyses the existing problems of tuning tools for mainstream stringed instruments, and puts forward an automatic tuning system based on wireless sensor network. The hardware design of intelligent tuning system based on wireless sensor network includes audio acquisition module, tuning control module driver circuit design and voice broadcast module, and network communication module selection analysis. The software design of intelligent tuning system based on wireless sensor network includes embedded software design and mobile software design. Embedded software design mainly includes system flow design and automatic tuning function design. In this paper, an improved endpoint detection algorithm is used to separate the chord tone from the nonchord tone, and an improved pitch detection algorithm is used to get the accurate pitch frequency of the chord tone signal. The function and performance of the tuning system are tested to verify the reliability of the optimized intelligent tuning system.


---

## Body

## 1. Introduction

Wireless sensor network (WSN) is a wireless network composed of a large number of static or mobile sensors in a self-organizing and multihop way to cooperatively perceive, collect, process, and transmit the information of the perceived object in the geographical area covered by the network and finally send the information to the network owner. Sensor network realizes three functions of data acquisition, processing, and transmission. Together with communication technology and computer technology, it constitutes the three pillars of information technology [1]. In order to obtain accurate information, a large number of sensor nodes are often deployed in the monitoring area, which can reach tens of thousands or even more. The large scale of sensor network includes two aspects: on the one hand, sensor nodes are distributed in a large geographical area, such as forest fire prevention and environmental monitoring using sensor network in the original large forest; a large number of sensor nodes need to be deployed; on the other hand, sensor nodes are densely deployed. A large number of sensor nodes are densely deployed in a small space. Sensor nodes have the ability of self-organization, can be configured and managed automatically, and automatically form a multihop wireless network system that forwards monitoring data through topology control mechanism and network protocol [2]. In sensor networks in use process, part of the sensor node failure due to run out of energy or environmental factors, there are also some node in order to make up for failure, added to improve the accuracy and the monitoring network; the nodes in sensor networks dynamically increase or decrease, so that the topology of the network will dynamically change subsequently. The self-organization of sensor network should be able to adapt to the dynamic changes of network topology.The network reports information about a specified event to the user. This idea of using the data itself as a query or transmission cue is closer to the habit of natural language communication. Sensor network is a data-cantered network. A large number of sensor nodes are randomly deployed in or near the monitoring area and can form a network through self-organization. The data monitored by the sensor node is transmitted hop by hop along other sensor nodes. In the transmission process, the monitoring data may be processed by multiple nodes and then routed to the sink node through multiple hops and finally reached the management node through the Internet or satellite. The processing capacity, storage capacity, and communication capacity of sensor nodes are relatively weak, and they are powered by small-capacity batteries [3]. From the perspective of network function, in addition to local information collection and data processing, each sensor node also needs to store, manage, and fuse the data forwarded by other nodes and cooperate with other nodes to complete some specific tasks. The sink node has relatively strong processing capacity, storage capacity, and communication capacity. It is the gateway connecting sensor network and Internet external network. It realizes the conversion between the two protocols, simultaneously issues the monitoring tasks from the management nodes to the sensor nodes, and forwards the data collected by WSN to the external network. The management node is used to manage the whole wireless sensor network dynamically. The owner of the sensor network accesses the resources of the wireless sensor network through the management node. Sensor network is used to perceive the objective physical world and obtain the information of the physical world.Tuning is the basic pitch calibration before the performance of a string instrument. Due to the instrument composition characteristics of a string instrument, the string is fixed on the instrument by a rotating shaft, and tension is exerted on the string through the rotating shaft. The vibration frequency of the string changes with the amount of tension applied, thus changing the pitch of the sound [4]. At present, the technology commonly used in the orchestra provides the signal of pitch by using the tuner and then adjusts the pitch by the player turning the shaft of the string according to the signal instructions. If the stage is about to perform, the tuning signal is not used, but the pitch is adjusted by player’s own sense of pitch. However, the human body, after all, is not a precise machine; each player for pitch perception is also different; therefore, tend to be more of the same instruments in the orchestra will still exist errors made by pitch, because the audio is not exactly the same, physically unable to achieve constructive interference of the resonance effect, making the music of the orchestra of the division could resonate with [5]. How to calibrate string instruments in the whole group at the same pitch has always been an unsolved problem of existing technology. Existing technology is divided into passive and active tuning; passive tuning technology directly by the musicians with its own pitch to adjust elastic strings, or use a separate tuner with instrument itself, guided by means of led display musicians who manually adjust the strings to the appropriate firmness, actual applications to cooperate the artistic conception of music, and play effect. Many musicians will adjust the corresponding pitch; the existing active tuning tuner cannot do this; existing technology is an object with a single individual instrument to carry on the design; only in the case of the orchestra, music is responsible for rendering the music director of music only in advance before the performance will present the request message to the effect of musicians, not appropriate for fine-tuning in the process of performance.


## 2. Related Work

In recent years, with the continuous improvement of material living standards, people’s demand for spiritual and cultural entertainment is also growing. Musical instrument learning has become one of the prevailing spiritual and cultural entertainment activities. Among them, string instruments such as guitar and ukulele have gradually become popular instruments in China due to their advantages of being easy to use, convenient to carry, and affordable. When people use stringed instruments, tuning of stringed instruments will inevitably be involved [6]. Because only when the stringed instrument is in tune, it can make good music. Tuning is not an easy task for string instrument lovers without professional learning, especially beginners. Tuning of stringed instruments such as guitars and ukuleles refers to the process of constantly comparing the pitch of the strings with the target pitch and then adjusting the knob of the head to adjust the pitch to the target pitch. Initially, stringed instruments were tuned by ear, but this method was only suitable for professionals with long training and was difficult for instrument lovers and beginners. With the continuous development of science and technology and the popularity of stringed instruments, a variety of tuning tools appear on the market. At present, there are two main types of tuning tools for stringed instruments in the market, one is electronic tuner, and the other is tuning software. These tools detect the current pitch of a stringed instrument by sensing the sound it makes and then display the current pitch on the screen for user’s reference. This is equivalent to the instrument lovers having a pair of sensitive ears, but the following tuning work still needs to be manually completed by the user, which will inevitably lead to a long tuning time and unsatisfactory tuning results due to human error. Although these two kinds of tuning tools can solve the tuning problem of people to a certain extent, they have single function and are applicable to limited instruments, which cannot well meet people’s increasing demand for tuning devices.Although sound and voice are both sound signals, the basic principle of recognition also has something in common, that is, the analysis of sound signals, the application of noise processing, characteristic analysis, recognition, and other processing processes. However, after in-depth research on the sound characteristics of piano, it is found that there are obvious differences between piano sound and voice. The fundamental frequency range of speech is between to, while the fundamental frequency range of piano sound is much larger than that of speech, which increases the difficulty of applying speech recognition to piano sound recognition. However, harp recognition has stronger theoretical feasibility and practical operability than speech recognition. First of all, harp recognition is only for the whole range of notes to recognize, while speech recognition is completed by the establishment of a vocabulary database; the amount of data is relatively large. Secondly, there are great individual differences in pronunciation, and the sound is also very different, so it is impossible to be completely the same. Secondly, the individual difference of pronunciation is great, and the sound also exists great difference. But the sound produced by pressing the same key on the same instrument has a great deal of acoustic similarity and very little difference. Individual differences in speech determine that there is no completely accurate physical or mathematical quantitative description of speech. The acoustic characteristics of musical sound show that a strict mathematical model can be extracted, which provides a theoretical basis for the further research of musical sound recognition technology.Saeed et al. proposed an automatic tuner based on fuzzy control, which performs fast Fourier transform on the collected sound signal through computer to obtain the current pitch frequency of the string. Then, the frequency difference is obtained by comparing the standard frequency as the input to the fuzzy logic controller, which drives the motor to rotate and then achieves the purpose of automatic tuning [7]. Because of the abundant harmonic signals in the guitar string sound, Fourier transform can easily misjudge the frequency doubling as the fundamental frequency. To solve this problem, Wang et al. used cepstrum analysis to calculate the pitch frequency of the chord signal, avoiding frequency doubling errors to a certain extent and improving the accuracy of pitch detection [8]. Aiming at the problem that cepstrum analysis has a large amount of calculation and is not suitable for implementation in embedded system, Zhou et al. tried to detect pitch frequency by using autocorrelation algorithm and achieved good results in low frequency band [9]. In view of the computing capacity of the embedded system, Wang et al. optimized the autocorrelation algorithm by using the three-level clipping method, greatly reducing the calculation amount of the autocorrelation algorithm [10]. In order to solve the problem of inaccurate detection of autocorrelation algorithm in high frequency band, Li et al. used harmonic peak method to conduct short-time Fourier transform after terminal detection of chord signal, which improved pitch detection accuracy of chord signal in high-frequency band to a certain extent [11].


## 3. Design and Optimization of Intelligent Tuning System in Wireless Sensor Network

### 3.1. Layered Architecture of Wireless Sensor Networks

Wireless sensor network communication protocol generally can be divided into four layers: physical layer, data link layer, network layer, and application layer. They are mainly connected through an interlayer communication interface. The binding function is to provide data or services directly to adjacent layers. PD_SAP, MLDE_SAP, and NLDE_SAP indicate interfaces for data transmission. PLME_SAP, MLME_SAP, and NLME_SAP indicate interfaces for network management [12].Wireless sensor network systems are generally self-organizing, self-discovery, energy availability, data integration,W, and distributed computing capabilities. The physical layer provides the basic guarantee for wireless sensor network communication, including stable modulation, transmission, and receiving technology. The data link layer is mainly responsible for the multichannel technology of data flow and communication, data detection and shaking, media access and error control, and other functions, which provide the basic requirements for the network layer to realize path optimization, W, and multipoint communication. The network layer mainly focuses on the path optimization algorithm to ensure the delay of data communication and complete part of the data fusion processing [13]. The application layer mainly develops various sensor network application control software, user UI interaction design, W, and some debugging software tools for users.The main purpose of the physical layer of wireless sensor network system is to provide the powerful communication hardware interface and provide the function of the other layers of the wireless sensor network hardware foundation stable and effective communication; at the same time, in order to be able to achieve low-power wireless sensor network needs, need for the physical layer provides the function of the open/close communication services. The main function of data link layer is to control media access in wireless sensor network and error control in communication process. The purpose of media access protocol is to ensure the reliability of multipoint communication in network communication. Error control ensures the integrity and reliability of data information in the process of wireless communication and ensures that information can be transmitted to the terminal node (sink node) correctly. The main purpose of network layer protocol in wireless sensor network system is path design and maintenance. Network layer protocol is one of the important factors restricting the performance of wireless sensor network [14]. The performance of a wireless sensor network is closely related to the network layer protocol of the wireless sensor network, and the stability, robustness, redundancy, and power consumption of the whole system are closely related to the network layer protocol. The application layer is mainly for data storage and processing, among which the difficulty of research is data compression and fusion processing. When the data transmitted by the subordinate nodes meet certain conditions, the cluster-head node will discard certain data. Only when special circumstances occur, the actual situation data need to be sent. This can greatly reduce the amount of communication data, reduce the data redundancy of the system, and make the system more stable.


### 3.2. Hardware Design of Intelligent Tuning System in Wireless Sensor Network

The hardware design of the system is completed on the DE10-Nano-SoC development board. The ARM+FPG architecture and rich hardware resources can well meet the requirements of the system for the embedded platform master chip [15]. According to the resource distribution of the development board, IP design is carried out on the field programmable gate array (FPGA) end to realize the driver control of the main hardware modules, and voice data processing is carried out on the HPS end, and communication is carried out with the mobile phone end through wireless network. The system hardware design block diagram is shown in Figure 1.Figure 1
Hardware design frame diagram of intelligent tuning system in wireless sensor network.According to the function of the device in the system, the system hardware can be divided into the following four modules: audio acquisition module is composed of pickup and audio acquisition circuit board. The pickup picks up the sound in the surrounding environment and converts the sound signal into an analogy electrical signal input to the audio acquisition board. The audio acquisition circuit board converts the collected analogy signal into digital signal, which is convenient for the embedded end to further process the audio data. The tuning control module consists of stepper motor driving control board and stepper motor [16]. The tuning control module mainly realizes the conversion of pulse-width modulating (PWM) wave output by FPGA into the driving current that can drive the stepper motor to run smoothly, so as to drive the stepper motor to rotate according to the predetermined speed and direction, so as to drive the knob to rotate to achieve the purpose of automatic tuning. In order to better human-computer interaction experience, the voice broadcast module will issue the corresponding voice prompt at the appropriate time. In order to facilitate users to choose the functions of the tuning system and view the system status and other information, the network communication module uses Android smartphone as the remote control and display module and realizes the data interaction between the mobile terminal and the embedded terminal through network communication.


### 3.3. Software Design of Intelligent Tuning System for Line Sensor Network

The system software design consists of embedded software design and mobile software design. The system software design framework is shown in Figure2.Figure 2
Software design frame diagram of wireless sensor network intelligent tuning system.Embedded end software design is the key of system software design, mainly to complete the rapid and accurate automatic tuning of a variety of stringed instruments. In order to achieve this function, it is necessary to realize endpoint detection, pitch detection, motor control, and network communication functions in the embedded end. Endpoint detection: since the collected sound contains not only string sound but also speech and background noise and other sounds, and the system only needs to detect the pitch of string sound, it is necessary to conduct real-time endpoint detection on the original sound signal to eliminate the interference of speech and noise [17, 18]. Pitch detection: the system is tuned according to the continuous feedback of the difference between the pitch of the string and the target pitch, so the system needs to detect the pitch of the string signal to get the accurate pitch of the string. Motor control: according to the system mode, if the system is in automatic tuning mode, the motor speed, direction, and turn stop are continuously controlled by feedback based on the difference between the string pitch detected and the target pitch. If the system is in automatic winding mode, the motor speed, direction, and turn stop are controlled by winding parameters set by the user on the mobile end. Network communication: in order to realize stable data interaction between embedded terminal and mobile terminal, it is necessary to select communication protocol and design data segment format. In order to facilitate users to select functions of the tuning system, view frequency, system status, and other information and practice daily rhythm, the mobile software should have tuning parameter setting, winding control, wireless communication, frequency display, and metronome functions. Tuning parameters are set to meet users’ personalized tuning needs. Users can set the type of musical instrument, tuning mode, and string target pitch on the mobile terminal. The winding control is to improve the efficiency of the user changing strings. The user can remotely control the tuning module on the mobile phone to realize the automatic winding function. The above two functions are based on the data interaction between the mobile terminal and the embedded terminal, that is, the wireless communication function of the mobile terminal needs to be completed. Frequency display is to allow users to visually see the tuning frequency change and system status information. Metronome is a tool that can produce a steady beat at a variety of rates. It is mainly used to cultivate user’s sense of rhythm and rhythm. In music theory, beat refers to the relationship between the length and strength of the notes organized together. The beat sign is the mark of beat, expressed by fraction, where the denominator represents what note is a beat, and the numerator represents how many beats are in each bar.


### 3.4. Optimized Endpoint Detection

The purpose of endpoint detection is to distinguish chord sounds from nonchord sounds. The sound signal of the system to contain string sound, speech, and background noise such as a variety of voice signal, but the system only to pitch detection of string sound signal, so if the pitch detection on the original sound signals directly, it can detect many nonstring sound pitch leading to abnormal rotation of tuning module, thus affecting the normal operation of the system. Real-time endpoint detection of the original sound signal can eliminate the interference of voice segment, noise segment, and silent segment, which can not only ensure the normal operation of the system but also improve the performance of the system. The main purpose of preprocessing is to determine the frame length. Because the sound signal collected by the system is a kind of unsteady and time-varying signal, it cannot be analysed and processed directly by digital signal processing technology which deals with steady-state signal [19]. However, the chord sound is formed by the excitation pulse generated by the string passing through the sound box, and the motion of the sound box is slow. Therefore, in the range of “short time,” the chord sound signal can be considered to be steady and time-invariant. Therefore, before processing the collected sound signal, it is necessary to segment the signal into a stationary signal within a short time. The process of dividing a complete sound signal into many short-term stationary signals is called framing [20]. When the signal is divided into frames, there is usually a certain degree of overlap between two adjacent frames, which is called frame shift. This overlap is to ensure a smooth transition between frames.


### 3.5. Optimized Pitch Detection

Essentially is the pitch detection of music signals. Pitch, also known as pitch, is a measure by which the human ear differentiates the frequency of sound vibration. Pitch depends mainly on the frequency of the sound. Compared with speech signal, the periodicity of music signal is relatively stable. The pitch of each sound is approximately fixed, and its spectrum is approximately discrete spectrum, so it can detect the more accurate basic sound of music signal.Because of the correspondence between pitch and frequency, the recognition in frequency domain is more straightforward, so the harmonic peak method based on fast Fourier transform appears. The signal is transformed by fast Fourier transform (FFT) to obtain a discrete peak of the frequency spectrum corresponding to the fundamental frequency or the distance from the origin of the maximum peak. Frequency resolution is essentially the frequency resolution of detection accuracy determined by sampling frequency and number of points [6, 21]. Consider the twelve-tone relationship, that is, the relationship between adjacent semitones and multiples. In the lower part, such as ultralow tone and difference, the frequency resolution must be accurate enough to meet the standard of piano tuning. This means that if the peak harmonic method is to be used in low frequency band, the number of points of sampling frequency must reach 1, which is bound to greatly reduce the efficiency of the whole software. Therefore, different algorithms should be used to analyse high and low frequency bands.


## 3.1. Layered Architecture of Wireless Sensor Networks

Wireless sensor network communication protocol generally can be divided into four layers: physical layer, data link layer, network layer, and application layer. They are mainly connected through an interlayer communication interface. The binding function is to provide data or services directly to adjacent layers. PD_SAP, MLDE_SAP, and NLDE_SAP indicate interfaces for data transmission. PLME_SAP, MLME_SAP, and NLME_SAP indicate interfaces for network management [12].Wireless sensor network systems are generally self-organizing, self-discovery, energy availability, data integration,W, and distributed computing capabilities. The physical layer provides the basic guarantee for wireless sensor network communication, including stable modulation, transmission, and receiving technology. The data link layer is mainly responsible for the multichannel technology of data flow and communication, data detection and shaking, media access and error control, and other functions, which provide the basic requirements for the network layer to realize path optimization, W, and multipoint communication. The network layer mainly focuses on the path optimization algorithm to ensure the delay of data communication and complete part of the data fusion processing [13]. The application layer mainly develops various sensor network application control software, user UI interaction design, W, and some debugging software tools for users.The main purpose of the physical layer of wireless sensor network system is to provide the powerful communication hardware interface and provide the function of the other layers of the wireless sensor network hardware foundation stable and effective communication; at the same time, in order to be able to achieve low-power wireless sensor network needs, need for the physical layer provides the function of the open/close communication services. The main function of data link layer is to control media access in wireless sensor network and error control in communication process. The purpose of media access protocol is to ensure the reliability of multipoint communication in network communication. Error control ensures the integrity and reliability of data information in the process of wireless communication and ensures that information can be transmitted to the terminal node (sink node) correctly. The main purpose of network layer protocol in wireless sensor network system is path design and maintenance. Network layer protocol is one of the important factors restricting the performance of wireless sensor network [14]. The performance of a wireless sensor network is closely related to the network layer protocol of the wireless sensor network, and the stability, robustness, redundancy, and power consumption of the whole system are closely related to the network layer protocol. The application layer is mainly for data storage and processing, among which the difficulty of research is data compression and fusion processing. When the data transmitted by the subordinate nodes meet certain conditions, the cluster-head node will discard certain data. Only when special circumstances occur, the actual situation data need to be sent. This can greatly reduce the amount of communication data, reduce the data redundancy of the system, and make the system more stable.


## 3.2. Hardware Design of Intelligent Tuning System in Wireless Sensor Network

The hardware design of the system is completed on the DE10-Nano-SoC development board. The ARM+FPG architecture and rich hardware resources can well meet the requirements of the system for the embedded platform master chip [15]. According to the resource distribution of the development board, IP design is carried out on the field programmable gate array (FPGA) end to realize the driver control of the main hardware modules, and voice data processing is carried out on the HPS end, and communication is carried out with the mobile phone end through wireless network. The system hardware design block diagram is shown in Figure 1.Figure 1
Hardware design frame diagram of intelligent tuning system in wireless sensor network.According to the function of the device in the system, the system hardware can be divided into the following four modules: audio acquisition module is composed of pickup and audio acquisition circuit board. The pickup picks up the sound in the surrounding environment and converts the sound signal into an analogy electrical signal input to the audio acquisition board. The audio acquisition circuit board converts the collected analogy signal into digital signal, which is convenient for the embedded end to further process the audio data. The tuning control module consists of stepper motor driving control board and stepper motor [16]. The tuning control module mainly realizes the conversion of pulse-width modulating (PWM) wave output by FPGA into the driving current that can drive the stepper motor to run smoothly, so as to drive the stepper motor to rotate according to the predetermined speed and direction, so as to drive the knob to rotate to achieve the purpose of automatic tuning. In order to better human-computer interaction experience, the voice broadcast module will issue the corresponding voice prompt at the appropriate time. In order to facilitate users to choose the functions of the tuning system and view the system status and other information, the network communication module uses Android smartphone as the remote control and display module and realizes the data interaction between the mobile terminal and the embedded terminal through network communication.


## 3.3. Software Design of Intelligent Tuning System for Line Sensor Network

The system software design consists of embedded software design and mobile software design. The system software design framework is shown in Figure2.Figure 2
Software design frame diagram of wireless sensor network intelligent tuning system.Embedded end software design is the key of system software design, mainly to complete the rapid and accurate automatic tuning of a variety of stringed instruments. In order to achieve this function, it is necessary to realize endpoint detection, pitch detection, motor control, and network communication functions in the embedded end. Endpoint detection: since the collected sound contains not only string sound but also speech and background noise and other sounds, and the system only needs to detect the pitch of string sound, it is necessary to conduct real-time endpoint detection on the original sound signal to eliminate the interference of speech and noise [17, 18]. Pitch detection: the system is tuned according to the continuous feedback of the difference between the pitch of the string and the target pitch, so the system needs to detect the pitch of the string signal to get the accurate pitch of the string. Motor control: according to the system mode, if the system is in automatic tuning mode, the motor speed, direction, and turn stop are continuously controlled by feedback based on the difference between the string pitch detected and the target pitch. If the system is in automatic winding mode, the motor speed, direction, and turn stop are controlled by winding parameters set by the user on the mobile end. Network communication: in order to realize stable data interaction between embedded terminal and mobile terminal, it is necessary to select communication protocol and design data segment format. In order to facilitate users to select functions of the tuning system, view frequency, system status, and other information and practice daily rhythm, the mobile software should have tuning parameter setting, winding control, wireless communication, frequency display, and metronome functions. Tuning parameters are set to meet users’ personalized tuning needs. Users can set the type of musical instrument, tuning mode, and string target pitch on the mobile terminal. The winding control is to improve the efficiency of the user changing strings. The user can remotely control the tuning module on the mobile phone to realize the automatic winding function. The above two functions are based on the data interaction between the mobile terminal and the embedded terminal, that is, the wireless communication function of the mobile terminal needs to be completed. Frequency display is to allow users to visually see the tuning frequency change and system status information. Metronome is a tool that can produce a steady beat at a variety of rates. It is mainly used to cultivate user’s sense of rhythm and rhythm. In music theory, beat refers to the relationship between the length and strength of the notes organized together. The beat sign is the mark of beat, expressed by fraction, where the denominator represents what note is a beat, and the numerator represents how many beats are in each bar.


## 3.4. Optimized Endpoint Detection

The purpose of endpoint detection is to distinguish chord sounds from nonchord sounds. The sound signal of the system to contain string sound, speech, and background noise such as a variety of voice signal, but the system only to pitch detection of string sound signal, so if the pitch detection on the original sound signals directly, it can detect many nonstring sound pitch leading to abnormal rotation of tuning module, thus affecting the normal operation of the system. Real-time endpoint detection of the original sound signal can eliminate the interference of voice segment, noise segment, and silent segment, which can not only ensure the normal operation of the system but also improve the performance of the system. The main purpose of preprocessing is to determine the frame length. Because the sound signal collected by the system is a kind of unsteady and time-varying signal, it cannot be analysed and processed directly by digital signal processing technology which deals with steady-state signal [19]. However, the chord sound is formed by the excitation pulse generated by the string passing through the sound box, and the motion of the sound box is slow. Therefore, in the range of “short time,” the chord sound signal can be considered to be steady and time-invariant. Therefore, before processing the collected sound signal, it is necessary to segment the signal into a stationary signal within a short time. The process of dividing a complete sound signal into many short-term stationary signals is called framing [20]. When the signal is divided into frames, there is usually a certain degree of overlap between two adjacent frames, which is called frame shift. This overlap is to ensure a smooth transition between frames.


## 3.5. Optimized Pitch Detection

Essentially is the pitch detection of music signals. Pitch, also known as pitch, is a measure by which the human ear differentiates the frequency of sound vibration. Pitch depends mainly on the frequency of the sound. Compared with speech signal, the periodicity of music signal is relatively stable. The pitch of each sound is approximately fixed, and its spectrum is approximately discrete spectrum, so it can detect the more accurate basic sound of music signal.Because of the correspondence between pitch and frequency, the recognition in frequency domain is more straightforward, so the harmonic peak method based on fast Fourier transform appears. The signal is transformed by fast Fourier transform (FFT) to obtain a discrete peak of the frequency spectrum corresponding to the fundamental frequency or the distance from the origin of the maximum peak. Frequency resolution is essentially the frequency resolution of detection accuracy determined by sampling frequency and number of points [6, 21]. Consider the twelve-tone relationship, that is, the relationship between adjacent semitones and multiples. In the lower part, such as ultralow tone and difference, the frequency resolution must be accurate enough to meet the standard of piano tuning. This means that if the peak harmonic method is to be used in low frequency band, the number of points of sampling frequency must reach 1, which is bound to greatly reduce the efficiency of the whole software. Therefore, different algorithms should be used to analyse high and low frequency bands.


## 4. System Testing

### 4.1. System Overview

The embedded terminal and Android phone realize stable data interaction through network communication module. The user selects the embedded working mode through the mobile phone. The embedded end performs corresponding operations according to the parse instruction category. In the automatic tuning mode, the embedded end analyzes and processes the collected sound data in real time to get the string pitch and realizes the closed-loop adjustment of the string pitch by the tuning module according to the difference between the string pitch and the target pitch. In winding mode, the embedded end directly controls the tuning module movement according to the parameters set by the user to complete the operation of loosening or tightening the strings. In order to better human-computer interaction experience, voice broadcast module is added in the system to give users voice prompts when appropriate.


### 4.2. System Function Test

According to the analysis of design requirements, the system has automatic tuning function, automatic winding function, voice broadcasting function, wireless control function, and metronome function. In order to meet the diverse tuning requirements of users, the automatic tuning function of the system includes standard tuning and custom tuning. Standard tuning means that the system automatically adjusts the string pitch to standard pitch. The standard tuning function test will power on the development board, and after the system is started, use the mobile phone to establish a network connection with the embedded terminal. The tuning setting interface of the mobile terminal will select the instrument to be tuned and send the standard tuning mode to the embedded terminal. After the embedded terminal receives the data, the system status of the mobile terminal will be displayed as the standard tuning. Use the key on the embedded end to select the string number to be tuned and then connect the tuning module to the selected knob of the piano head to pluck the string. The following takes the standard tuning of guitar 2 strings as an example. When testing the standard tuning function, use the ROM electronic tuner as a reference. When the screen of the electronic tuner turns green, the tuning is complete. The test result statistics are shown in Figure3.Figure 3
Statistical chart of system function test results.


### 4.3. System Performance Test

According to the design requirements of the system, the factors affecting the performance of the system include four aspects: false detection rate and missed detection rate of endpoint detection, pitch detection accuracy, tuning accuracy, and tuning time.The system focuses on detecting the start and stop point of the chord signal as accurately as possible on the basis of not judging the nonchord sound as the chord sound. Use false detection rate and missed detection rate to measure the quality of endpoint detection method. Error detection rate represents the rate at which nonstring segments are judged as string segments by the endpoint detection algorithm, and is represented byPe. Miss rate represents the rate at which a string segment is judged to be a nonstring segment by the endpoint detection algorithm and is represented by Pm [22]. The calculation formula of error detection rate and missing detection rate is
(1)Pe=N2N1,(2)Pm=N3N1,where N1 represents the number of string segments detected by the algorithm, N2 represents the number of string segments incorrectly detected by the manually observed algorithm, and N3 represents the number of string segments missed by the manually observed algorithm.The system recorded a total of 50 sound signals with a duration of more than 2 minutes in the laboratory at different time periods in five days, and the strings were dialed irregularly during the recording process. Matlab was used for simulation experiments, and the experimental parameters were set the same as the system parameters. The test results of missed detection rate and false detection rate of endpoint detection are shown in Figure4.Figure 4
End point detection miss rate and error rate test results.The test results show that the endpoint detection method adopted by the system does not produce missed detection phenomenon, but it will produce false detection phenomenon. Analysis of the cause is that some sounds are recorded in noisy conditions, leading to the method to judge the voice or noise with high energy as string sound.The pitch frequency calculated by the system and the actual frequency, to test the pitch detection accuracy. The system selects the pitch frequency detected by the fundamental frequency analysis function provided by Praat speech analysis software as the actual frequency. The system uses Matlab to simulate the sound produced by the recorded guitar, ukulele, and bass, and its various parameters are consistent with the system parameters. Pitch detection uses harmonic peak tone method to detect pitch frequency, and the test results of treble detection accuracy are shown in Figure5.Figure 5
Treble detection accuracy test result diagram.As can be seen from the figure, doubling error may occur before the harmonic peak method is improved, but the improved method avoids the doubling error to a certain extent and improves its detection accuracy to a certain extent.Tuning precision refers to the proximity between the pitch frequency of the string and the target frequency after tuning. Therefore, it is necessary to use a third-party tool to detect the pitch of the instrument tuned by the system, and the difference between the current chord pitch frequency and the target frequency is the tuning precision. The system selects the pitch frequency detected by the fundamental frequency analysis function provided by Praat speech analysis software as the accurate frequency. The system adjusts the guitar and ukulele, records the sound of each string of the tuned guitar and ukulele, uses Praat voice analysis software to detect pitch and get pitch frequency, and then, calculates the tone difference between the detected pitch frequency and the target frequency, so as to test the tuning accuracy. The test data of ukulele tuning accuracy are shown in Figure6 and Table 1. According to ukulele tuning rules, the ukulele can have seven target frequencies. Therefore, each of the seven target frequencies of the ukulele was tested 60 times. The number of times that met the requirements represented the number of times that the pitch difference between the fundamental frequency and the target frequency was within 5cent as analyzed by the Praat speech analysis software. The mean error represented the mean of the 60 test results and the pitch difference between the target frequency.Figure 6
Ukulele tuning accuracy test data graph.Table 1
Statistical table of ukulele tuning accuracy test.
Frequency target, Hz392.00369.99329.63293.66261.63Compliance ratio, %96.0098.00100.0096.0098.00Average error3.153.032.682.532.89As with the ukulele tuning accuracy test. Guitars can have 21 target frequencies. Limited by the length of the paper, only 8 target frequencies are listed. Guitar tuning accuracy test is shown in Figure7 and Table 2.Figure 7
Guitar tuning accuracy test data graph.Table 2
Statistical table of guitar tuning accuracy test.
Frequency target, Hz329.63246.94196164.81146.8311082.4173.43Compliance ratio, %96981009698989898Average error2.672.982.542.682.682.782.852.75As can be seen from the figure, the average error of tuning precision of ukulele and guitar designed in this paper is within 5cent, which meets the requirements of tuning precision design index of the system.Tuning time is the time that a string takes from the beginning of tuning to the end of tuning. The difference between the frequencies before the string is adjusted, and the target frequency will affect the tuning time, so 6 frequency differences are selected to test the tuning time of guitar, ukulele, and other instruments. Tuning time test data is shown in Figure8.Figure 8
Tuning time test data graph.As can be seen from the figure, the tuning time for each string of guitar and ukulele is within 10 s, which meets the requirements of the system for tuning time design indicators.Through the function and performance test of the system, it can be seen that the human-machine interaction of the tuning system is good, and the functions of automatic tuning, winding, voice broadcasting, wireless control and display, and metronome are realized. Tuning systems currently support instruments such as guitars and ukulele. The tuning accuracy of the two instruments is within ±5 minutes, and the tuning time of each string is controlled within 10 s. In addition, the tuning system works stably and smoothly, and other functions also meet the design requirements.


## 4.1. System Overview

The embedded terminal and Android phone realize stable data interaction through network communication module. The user selects the embedded working mode through the mobile phone. The embedded end performs corresponding operations according to the parse instruction category. In the automatic tuning mode, the embedded end analyzes and processes the collected sound data in real time to get the string pitch and realizes the closed-loop adjustment of the string pitch by the tuning module according to the difference between the string pitch and the target pitch. In winding mode, the embedded end directly controls the tuning module movement according to the parameters set by the user to complete the operation of loosening or tightening the strings. In order to better human-computer interaction experience, voice broadcast module is added in the system to give users voice prompts when appropriate.


## 4.2. System Function Test

According to the analysis of design requirements, the system has automatic tuning function, automatic winding function, voice broadcasting function, wireless control function, and metronome function. In order to meet the diverse tuning requirements of users, the automatic tuning function of the system includes standard tuning and custom tuning. Standard tuning means that the system automatically adjusts the string pitch to standard pitch. The standard tuning function test will power on the development board, and after the system is started, use the mobile phone to establish a network connection with the embedded terminal. The tuning setting interface of the mobile terminal will select the instrument to be tuned and send the standard tuning mode to the embedded terminal. After the embedded terminal receives the data, the system status of the mobile terminal will be displayed as the standard tuning. Use the key on the embedded end to select the string number to be tuned and then connect the tuning module to the selected knob of the piano head to pluck the string. The following takes the standard tuning of guitar 2 strings as an example. When testing the standard tuning function, use the ROM electronic tuner as a reference. When the screen of the electronic tuner turns green, the tuning is complete. The test result statistics are shown in Figure3.Figure 3
Statistical chart of system function test results.


## 4.3. System Performance Test

According to the design requirements of the system, the factors affecting the performance of the system include four aspects: false detection rate and missed detection rate of endpoint detection, pitch detection accuracy, tuning accuracy, and tuning time.The system focuses on detecting the start and stop point of the chord signal as accurately as possible on the basis of not judging the nonchord sound as the chord sound. Use false detection rate and missed detection rate to measure the quality of endpoint detection method. Error detection rate represents the rate at which nonstring segments are judged as string segments by the endpoint detection algorithm, and is represented byPe. Miss rate represents the rate at which a string segment is judged to be a nonstring segment by the endpoint detection algorithm and is represented by Pm [22]. The calculation formula of error detection rate and missing detection rate is
(1)Pe=N2N1,(2)Pm=N3N1,where N1 represents the number of string segments detected by the algorithm, N2 represents the number of string segments incorrectly detected by the manually observed algorithm, and N3 represents the number of string segments missed by the manually observed algorithm.The system recorded a total of 50 sound signals with a duration of more than 2 minutes in the laboratory at different time periods in five days, and the strings were dialed irregularly during the recording process. Matlab was used for simulation experiments, and the experimental parameters were set the same as the system parameters. The test results of missed detection rate and false detection rate of endpoint detection are shown in Figure4.Figure 4
End point detection miss rate and error rate test results.The test results show that the endpoint detection method adopted by the system does not produce missed detection phenomenon, but it will produce false detection phenomenon. Analysis of the cause is that some sounds are recorded in noisy conditions, leading to the method to judge the voice or noise with high energy as string sound.The pitch frequency calculated by the system and the actual frequency, to test the pitch detection accuracy. The system selects the pitch frequency detected by the fundamental frequency analysis function provided by Praat speech analysis software as the actual frequency. The system uses Matlab to simulate the sound produced by the recorded guitar, ukulele, and bass, and its various parameters are consistent with the system parameters. Pitch detection uses harmonic peak tone method to detect pitch frequency, and the test results of treble detection accuracy are shown in Figure5.Figure 5
Treble detection accuracy test result diagram.As can be seen from the figure, doubling error may occur before the harmonic peak method is improved, but the improved method avoids the doubling error to a certain extent and improves its detection accuracy to a certain extent.Tuning precision refers to the proximity between the pitch frequency of the string and the target frequency after tuning. Therefore, it is necessary to use a third-party tool to detect the pitch of the instrument tuned by the system, and the difference between the current chord pitch frequency and the target frequency is the tuning precision. The system selects the pitch frequency detected by the fundamental frequency analysis function provided by Praat speech analysis software as the accurate frequency. The system adjusts the guitar and ukulele, records the sound of each string of the tuned guitar and ukulele, uses Praat voice analysis software to detect pitch and get pitch frequency, and then, calculates the tone difference between the detected pitch frequency and the target frequency, so as to test the tuning accuracy. The test data of ukulele tuning accuracy are shown in Figure6 and Table 1. According to ukulele tuning rules, the ukulele can have seven target frequencies. Therefore, each of the seven target frequencies of the ukulele was tested 60 times. The number of times that met the requirements represented the number of times that the pitch difference between the fundamental frequency and the target frequency was within 5cent as analyzed by the Praat speech analysis software. The mean error represented the mean of the 60 test results and the pitch difference between the target frequency.Figure 6
Ukulele tuning accuracy test data graph.Table 1
Statistical table of ukulele tuning accuracy test.
Frequency target, Hz392.00369.99329.63293.66261.63Compliance ratio, %96.0098.00100.0096.0098.00Average error3.153.032.682.532.89As with the ukulele tuning accuracy test. Guitars can have 21 target frequencies. Limited by the length of the paper, only 8 target frequencies are listed. Guitar tuning accuracy test is shown in Figure7 and Table 2.Figure 7
Guitar tuning accuracy test data graph.Table 2
Statistical table of guitar tuning accuracy test.
Frequency target, Hz329.63246.94196164.81146.8311082.4173.43Compliance ratio, %96981009698989898Average error2.672.982.542.682.682.782.852.75As can be seen from the figure, the average error of tuning precision of ukulele and guitar designed in this paper is within 5cent, which meets the requirements of tuning precision design index of the system.Tuning time is the time that a string takes from the beginning of tuning to the end of tuning. The difference between the frequencies before the string is adjusted, and the target frequency will affect the tuning time, so 6 frequency differences are selected to test the tuning time of guitar, ukulele, and other instruments. Tuning time test data is shown in Figure8.Figure 8
Tuning time test data graph.As can be seen from the figure, the tuning time for each string of guitar and ukulele is within 10 s, which meets the requirements of the system for tuning time design indicators.Through the function and performance test of the system, it can be seen that the human-machine interaction of the tuning system is good, and the functions of automatic tuning, winding, voice broadcasting, wireless control and display, and metronome are realized. Tuning systems currently support instruments such as guitars and ukulele. The tuning accuracy of the two instruments is within ±5 minutes, and the tuning time of each string is controlled within 10 s. In addition, the tuning system works stably and smoothly, and other functions also meet the design requirements.


## 5. Conclusion

In the field of wireless sensor network, this paper introduces the status quo of tuning tools for stringed instruments, analyzes the existing problems of tuning tools for mainstream stringed instruments, and puts forward an automatic tuning system based on wireless sensor network. The hardware design of intelligent tuning system based on wireless sensor network includes audio acquisition module, tuning control module driver circuit design and voice broadcast module, and network communication module selection analysis. The software design of intelligent tuning system based on wireless sensor network includes embedded software design and mobile software design. Embedded software design mainly includes system flow design and automatic tuning function design. Aiming at the problem that the traditional endpoint detection algorithm is susceptible to random noise and causes false detection, according to the characteristics of chord signal, the paper adopts the improved short-time average amplitude endpoint detection method, which improves the accuracy of chord signal endpoint detection to a certain extent. Aiming at the problem that single pitch detection method cannot meet the tuning accuracy requirement in the whole frequency band, the harmonic peak method is adopted. The function and performance of the tuning system are tested. The human-machine interaction of the tuning system is good, and the functions of automatic tuning, winding, voice broadcasting, wireless control and display, metronome are realized. Tuning systems currently support instruments such as guitars and ukulele. The tuning accuracy of the two instruments is within ±5 minutes, and the tuning time of each string is controlled within 10 s. In addition, the tuning system works stably and smoothly, and other functions also meet the design requirements. Although the system has reached the expected design requirements and performance indicators, there is still room for improving the tuning time. In the next step, more complex control algorithms can be studied to accelerate the tuning time.



---

*Source: 6538185-2021-11-09.xml*