# Recognition and Error Correction Techniques for Piano Playing Music Based on Convolutional Cyclic Hashing Method

Authors: Dan Wang
Journal: Wireless Communications and Mobile Computing
 (2022)

---

## Abstract

Music as a sound symbol can express what people think; music is both a form of social behavior and can promote people’s emotional communication; music is also a form of entertainment and can enrich people’s spiritual life. In this paper, we propose a new convolutional recurrent hashing method CRNNH, which uses multilayer RNN to learn to discriminate piano playing music using convolutional feature map sequences. Firstly, a convolutional feature map sequence learning preserving similarity hash function is designed consisting of multilayer convolutional feature maps extracted from multiple convolutional layers of a pretrained CNN; secondly, a new deep learning framework is proposed to generate hash codes using a multilayer RNN, which directly uses the convolutional feature maps as input to preserve the spatial structure of the feature maps; finally, a new loss function is proposed to preserve the semantic similarity and balance of the hash codes, while considering the quantization error generated when the hash layer outputs binary hash codes. The experimental results illustrate that the proposed CRNNH can obtain better performance compared to other hashing methods.


---

## Body

## 1. Introduction

With the continuous improvement of human social development, music has become an essential part of people’s daily life. People have been exploring and researching music for a long time, and the earliest record of music theory in China can be traced back to the pre-Qin period [1]; after which Zhu Zaiyu, a famous musicologist in the Ming Dynasty, proposed twelve average laws, which divided octaves into twelve equal parts and used them to improve musical instruments, greatly enhancing their expressive power [2]. After entering the 21st century, the rapid development of big data technology and computers has triggered a global wave of artificial intelligence learning. Artificial intelligence technology quickly penetrated into various research directions and really came out of the laboratory and into people’s daily life [3], for example, face recognition technology which is widely used in ticket checking system of major transportation hubs and many companies and universities to punch cards; fingerprint recognition technology on smartphones which can be seen everywhere; and license plate detection technology in urban traffic [4, 5].In the United States and various music apps with song recognition functions, all of which bring convenience to people’s daily life. The application of piano playing music recognition also reflects the strong market demand. Looking at the booming music education in China, many families will let their children learn a musical instrument at an early age [6–8]. As the king of musical instruments, the piano is the most common choice for people to enter music learning, but piano learning requires professional guidance and a lot of practice. The fast pace of life in today’s society makes it impossible to squeeze in sufficient time for systematic training, and the lack of professional piano teachers makes the task of a single teacher more demanding, often unable to take care of all the students [9]. As a result, the cost for parents is too high for the escort apps, such as Vip Escort, Yuzi Escort, and Panda Escort [10].In order to solve the above problems, more and more scholars have devoted themselves to research in the field of music, and music recognition and simulation have become a popular research of artificial intelligence, and automatic music notation and melody recognition have been developed and broken through. However, even if the notes played can be accurately identified through technology, most piano beginners cannot know where they are playing mistakes without the guidance of professional teachers [11]. At this time, if the automatic error correction function can be added on the basis of accurate identification of piano recordings, it can not only meet the needs of self-taught pianists but also reduce the work intensity of instructors and greatly improve their work efficiency and also promote the development of music, the intelligent development of music recognition and creation [12–15].The traditional time domain analysis method is easily affected by noise and often has half-frequency/octave errors, while the traditional frequency domain analysis method has the disadvantages of high algorithm complexity and large computation [16]. In recent years, deep learning techniques, such as convolutional neural networks, have been widely used in various fields of research because of their ability to fit arbitrarily complex functions and to learn and adapt. Therefore, in this paper, we combine traditional time-frequency domain audio analysis techniques with advanced convolutional neural network recognition techniques to identify the pitch and temporal value of each note in piano playing music and compare them with MIDI music files recording standard scores to point out the errors in playing.


## 2. Related Work

Speech recognition and piano playing music recognition have many similarities in terms of technical aspects. In terms of concrete implementation, speech recognition is aimed at converting audio signals into corresponding linguistic textual content, while piano playing music recognition converts them into corresponding notes and melodies. For speech recognition, the first step is to recognize individual words from continuous speech and then combine them into a complete sentence through contextual information; for piano playing music recognition, the first step is also to recognize individual notes from continuous audio and then extract more advanced information such as melody and rhythm to combine all the notes into a complete piece of music. For more complex cases, information such as chords and instruments need to be recognized [17, 18]. Overall, endpoint detection techniques and fundamental frequency extraction techniques are the basic requirements for both speech recognition and piano playing music recognition [19].Reference [20] proposed an endpoint detection algorithm based on the average amplitude difference, which starts from the periodicity of the speech turbid tone signal and has the advantages of low algorithm complexity and easy implementation, but the false detection rate is high when the amplitude of the sound signal changes frequently. In [21], an endpoint detection algorithm based on a short-time autocorrelation function with the same period as the signal was proposed in 1977, and it will have a great value at an integer multiple of the period. In [22], for the shortcomings of the original algorithm in detecting poorly at low signal-to-noise ratios, an endpoint detection algorithm based on short-time autocorrelation and overzero rate was proposed, which also achieved high accuracy in low signal-to-noise environments. Endpoint detection algorithms based on hidden Markov (HMM) models are commonly used in the field of pattern recognition. Although this class of algorithms has better results, the algorithm complexity is high and the computational effort is large, which makes it difficult to achieve the goal of real-time detectionThe fundamental frequency extraction can be divided into two aspects: single-tone fundamental frequency extraction and multitone fundamental frequency extraction. The most straightforward method in single-tone fundamental frequency extraction is to perform a short-time Fourier transform on the signal, followed by using wavelet decomposition to extract the low-pass filtered fundamental frequency part and then converting it through the short-time Fourier transform to obtain the frequency value [23]. Reference [5] proposed a fundamental detection algorithm based on orthogonal transform, which first uses the orthogonal transform to eliminate the noise part of the signal, and after that, the short-time autocorrelation function and the short-time amplitude difference function of the signal are differentiated and squared to better identify the fundamental period [17]. In addition to this, some scholars have proposed to extract the fundamental period by CEP and LPC spectra [8] and extract the fundamental based on the subharmonic and harmonic ratio (SHR) [9]. There are also inverse spectral algorithms [20] and simplified inverse filter techniques [21].In recent years, people have started to apply artificial intelligence to speech recognition and piano playing music recognition. Among them, the hidden Markov model (DNN-HMM) with state output based on deep neural networks achieves a performance improvement of nearly one-third reduction in error rate over the traditional Gaussian mixture model HMM in Switchboard task and Fisher task, demonstrating the excellent acoustic modeling ability of neural networks. Reference [14] added the competing information of training samples to the traditional TENDEM to improve the recognition performance of the whole system. Reference [2] proposed an end-to-end speech recognition model combining CTC and attention mechanism by adding attention mechanism on the basis of traditional CTC model and also proposed an adaptive mapping model (RAM) based on recurrent neural network (RNN). Reference [3] proposed a speech recognition method based on dual microarray and convolutional neural network, which improves the noise immunity of the algorithm and solves the problem of low speech recognition rate at low signal-to-noise ratio. Reference [4] proposed a language recognition method using deep neural networks to extract factor-related bottleneck features, which improved the recognition performance of confusable languages and dialects.


## 3. Time-Frequency Domain Analysis of Piano Playing Music Signals

Depending on the parameters analyzed, piano playing music signal analysis can be divided into several methods such as time domain analysis, frequency domain analysis, and inverse spectral domain analysis. Since the piano playing music signal itself is a time domain signal, the time domain waveform is the first feature to be observed when performing piano playing music signal analysis. Time domain analysis is one of the earliest and most widely used methods among all signal analysis methods due to its simplicity and intuitiveness, small amount of operations, and clear physical meaning.Although time domain analysis is simple and intuitive, the waveform is easily affected by the external environment. In contrast, the frequency spectrum of a signal is more robust to external environmental changes and can provide very obvious acoustic features, so the features obtained from this analysis have actual physical meaning, such as the fundamental period, which is most commonly used in piano playing music signals. Therefore, the actual analysis is more around the frequency domain; commonly used frequency domain analysis methods are Fourier transform method, band-pass filter group method, linear prediction analysis method, and inverse spectrum method.


### 3.1. Time Domain Analysis of Piano Playing Music Signal

The analysis of the signal with time as the independent variable is the most direct and natural analysis method. The typical time-domain characteristics of piano playing music signal include short-time energy, short-time trans-zero rate, short-time autocorrelation function, and short-time average amplitude difference.


#### 3.1.1. Short-Time Energy

The energy of piano playing music signal changes with time, and the short-time energy can accurately describe this change process, which is an important feature in the signal time domain analysis. For the signalxn, its short-time energy is defined as follows:
(1)En=∑m=−∞∞xmwn−m2=∑m=−∞∞x2mhn−m=x2n∗hn.The above equation represents the short-time energy of thenth frame of the signal after framing and windowing, where hn=wn and wn is the window function.Using the short-time energy, we can determine the voiced and unvoiced segments, as shown in Figure1, and the short-time energy can clearly distinguish the noise segment, the ambient background sound segment, and the piano playing music segment. The decomposition of vowel and rhyme and hyphenation can also be used in speech signal analysis. It can also be used to distinguish between clear and turbid tones, since the energy of turbid tones is much higher than that of clear tones. In the field of piano playing music recognition, short-time energy as a one-dimensional feature is also often used to represent the energy level of the signal and noise segment information.Figure 1
Short-time energy diagram.


#### 3.1.2. Short-Time Zero Rate

As one of the simplest features of piano playing music signals in time domain analysis, the short-time overzero rate reflects the number of times the signal crosses zero in each frame. For a continuous signal, the overzero rate counts the number of times the signal crosses the coordinate axis, while for a discrete signalxm, it counts the number of times the sign of the sample point changes, with the following formula, where N is the length of the window function:
(2)Zn=12∑m=−∞∞∣sgnxm−sgnxm−1∣wn−m=12∑m=nm+N−1sgnxwm−sgnxwm−1,wheresgn denotes the symbolic function, which is defined as
(3)sgnxm=1,xm≥0,−1,xm<0.For example, the average overzero rate of a sine signal is its own frequency divided by twice the sampling frequency, and the sampling frequency is fixed, so the frequency information can be obtained from it.The overzero rate can also be used to distinguish the noise segment from the piano playing music segment. Piano playing music has a fixed fundamental frequency and its frequency distribution is regular, and the overzero rate is usually distributed in a fixed range, while the noise frequency distribution is irregular and the overzero rate changes very messily, as shown in Figure2.Figure 2
Comparison of the overzero rate of the noise section and the piano playing music section.In time-domain analysis, short-time energy and short-time excess zero rate are usually combined to identify the start and end points of piano playing music signals. In the case of low ambient noise, the use of short-time energy can have a good recognition effect. However, if the environmental noise is large, it is necessary to cooperate with the short-time overzero rate to filter out the influence of some noise.


#### 3.1.3. Short-Time Autocorrelation Function

Correlation function describes the degree of similarity between the two signals; there are two forms of correlation function and autocorrelation function. The correlation function describes the correlation between the two signals, while the autocorrelation function describes the synchronization and periodicity of the signal itself. This paper only discusses the autocorrelation function; for the discrete signalxn, its autocorrelation function is defined as follows:
(4)Rk=limN⟶∞12N+1∑n=−NNxnxn+k,whereN denotes the frame length and k denotes the number of delayed samples.From the above properties, it can be concluded that for a periodic signal, its short-time autocorrelation function must have a maximum at an integer multiple of the period, which provides an important basis for using it to extract the fundamental frequency of the signal, as shown in Figures3 and 4, for the noise segment, its short-time autocorrelation function curve is messy and nonperiodic; while for the piano playing music segment, its short-time autocorrelation function curve is a period oscillation decay curve.Figure 3
Short-time autocorrelation function curve of the noise segment.Figure 4
Short-time autocorrelation function curve of piano playing music section.


#### 3.1.4. Short-Time Amplitude Difference Function

Although the short-time autocorrelation function provides an important parameter for the time-domain analysis of the signal, it uses multiplication operations that can greatly increase the computational effort. So the proposed short-time amplitude difference function, in providing a similar role with the short-time autocorrelation function of the parameters, greatly reduces the amount of computation. For the signalxn, the short-time average amplitude difference function of the signal xin at the i-th frame after the framing and windowing process is defined as follows:
(5)γik=∑m=0N−k−1xim+k−xim,whereN denotes the frame length and k denotes the number of delayed sample points.Like the short-time autocorrelation function, the short-time amplitude difference function is also periodic, but the difference is that the short-time amplitude difference function appears as a valley at an integer multiple of the signal period, while the short-time autocorrelation function appears as a peak at an integer multiple of the signal period. Figures5 and 6 show the short-time amplitude difference functions of the noise section and the piano playing music section, respectively. The short-time amplitude difference function is faster than the short-time autocorrelation function to find the fundamental frequency of the piano playing music signal.Figure 5
Short-time amplitude difference function curve of the noise section.Figure 6
Short-time amplitude difference function curve of piano playing music section.


### 3.2. Frequency Domain Analysis of Piano Playing Music Signals

Humans are able to perceive external sounds because our auditory system has the function of spectral analysis; therefore, spectral analysis of signals is an important part of signal processing for piano playing music.Wavelet transform mainly uses the idea of multiresolution analysis, by dividing the time-frequency space nonuniformly so that the signal can be decomposed on a set of orthogonal bases, which provides a new way for the analysis of nonstationary signals. The so-called wavelet is a function or signalψt in the function space that satisfies the following conditions:
(6)Cψ=∫R∗∞ψw2∣w∣dw<∞,whereR∗ denotes all nonzero real numbers, ψw is the frequency domain representation of ψt, and ψt is the wavelet mother function. For any pair of real numbers a,b, a function of the following form is said to be a continuous wavelet function generated by the wavelet mother function ψt depending on the parameters a,b, where a is the scale of the wavelet transform, which is used to control the scaling of the wavelet function; b is the translation of the wavelet transform, which is used to control the translation of the wavelet transform:
(7)ψa,bt=1aψt−ba.For a square productable signalxt, its wavelet transform is defined as
(8)Wxa,b=∫R∞xtψa,b∗tdt=1a∫R∞xtψ∗t−badt.For the above equation, whena increases, the frequency domain observation range of the signal xt becomes narrower, the time domain observation range becomes wider, and the center frequency of the analysis moves toward the lower frequencies; when a decreases, the frequency domain observation range becomes wider, the time domain observation range becomes narrower, and the center frequency of the observation moves toward the higher frequencies. That is, using smaller a is equivalent to making a detailed observation of the signal with a high-frequency wavelet, while using larger a is a generalized observation of the signal with a low-frequency wavelet [4].


### 3.3. Inverse Spectrum Analysis

Cepstrum analysis is a well-known method for homomorphic signal analysis, and its calculation process can be roughly divided into three steps: (1) finding the Fourier transform of the signal, (2) finding the logarithm of the result of the previous step and taking the absolute value, and (3) finding the inverse Fourier transform. The mathematical definition is as follows.For the signalxn, its complex inverse spectrum is
(9)x^n=12π∫−ππX^ejwejwndw.x^ejw is generally complex; if its real part is inverted, then the real inverse spectrum cn, referred to as the inverse spectrum, can be obtained, which is defined as follows:
(10)cn=12π∫−ππlnXejwejwndw.There are many important properties of the inverse spectrum; only some of which are applied to this paper are listed below.(1)
The inverse spectrum is a bounded decay sequence(2)
For a string of uniformly spaced impulses, its inverse spectrum is also a string of uniformly spaced shocks, and both are equally spacedAs shown in Figures7 and 8, for the noise segment, its inverse spectrum curve decays gradually without a regular interval of shocks, while for the piano playing music segment, its inverse spectrum curve can be seen from its uniformly spaced impulses.Figure 7
Cepstrum curve of noise section.Figure 8
Inversion curve of piano playing music section.


## 3.1. Time Domain Analysis of Piano Playing Music Signal

The analysis of the signal with time as the independent variable is the most direct and natural analysis method. The typical time-domain characteristics of piano playing music signal include short-time energy, short-time trans-zero rate, short-time autocorrelation function, and short-time average amplitude difference.


### 3.1.1. Short-Time Energy

The energy of piano playing music signal changes with time, and the short-time energy can accurately describe this change process, which is an important feature in the signal time domain analysis. For the signalxn, its short-time energy is defined as follows:
(1)En=∑m=−∞∞xmwn−m2=∑m=−∞∞x2mhn−m=x2n∗hn.The above equation represents the short-time energy of thenth frame of the signal after framing and windowing, where hn=wn and wn is the window function.Using the short-time energy, we can determine the voiced and unvoiced segments, as shown in Figure1, and the short-time energy can clearly distinguish the noise segment, the ambient background sound segment, and the piano playing music segment. The decomposition of vowel and rhyme and hyphenation can also be used in speech signal analysis. It can also be used to distinguish between clear and turbid tones, since the energy of turbid tones is much higher than that of clear tones. In the field of piano playing music recognition, short-time energy as a one-dimensional feature is also often used to represent the energy level of the signal and noise segment information.Figure 1
Short-time energy diagram.


### 3.1.2. Short-Time Zero Rate

As one of the simplest features of piano playing music signals in time domain analysis, the short-time overzero rate reflects the number of times the signal crosses zero in each frame. For a continuous signal, the overzero rate counts the number of times the signal crosses the coordinate axis, while for a discrete signalxm, it counts the number of times the sign of the sample point changes, with the following formula, where N is the length of the window function:
(2)Zn=12∑m=−∞∞∣sgnxm−sgnxm−1∣wn−m=12∑m=nm+N−1sgnxwm−sgnxwm−1,wheresgn denotes the symbolic function, which is defined as
(3)sgnxm=1,xm≥0,−1,xm<0.For example, the average overzero rate of a sine signal is its own frequency divided by twice the sampling frequency, and the sampling frequency is fixed, so the frequency information can be obtained from it.The overzero rate can also be used to distinguish the noise segment from the piano playing music segment. Piano playing music has a fixed fundamental frequency and its frequency distribution is regular, and the overzero rate is usually distributed in a fixed range, while the noise frequency distribution is irregular and the overzero rate changes very messily, as shown in Figure2.Figure 2
Comparison of the overzero rate of the noise section and the piano playing music section.In time-domain analysis, short-time energy and short-time excess zero rate are usually combined to identify the start and end points of piano playing music signals. In the case of low ambient noise, the use of short-time energy can have a good recognition effect. However, if the environmental noise is large, it is necessary to cooperate with the short-time overzero rate to filter out the influence of some noise.


### 3.1.3. Short-Time Autocorrelation Function

Correlation function describes the degree of similarity between the two signals; there are two forms of correlation function and autocorrelation function. The correlation function describes the correlation between the two signals, while the autocorrelation function describes the synchronization and periodicity of the signal itself. This paper only discusses the autocorrelation function; for the discrete signalxn, its autocorrelation function is defined as follows:
(4)Rk=limN⟶∞12N+1∑n=−NNxnxn+k,whereN denotes the frame length and k denotes the number of delayed samples.From the above properties, it can be concluded that for a periodic signal, its short-time autocorrelation function must have a maximum at an integer multiple of the period, which provides an important basis for using it to extract the fundamental frequency of the signal, as shown in Figures3 and 4, for the noise segment, its short-time autocorrelation function curve is messy and nonperiodic; while for the piano playing music segment, its short-time autocorrelation function curve is a period oscillation decay curve.Figure 3
Short-time autocorrelation function curve of the noise segment.Figure 4
Short-time autocorrelation function curve of piano playing music section.


### 3.1.4. Short-Time Amplitude Difference Function

Although the short-time autocorrelation function provides an important parameter for the time-domain analysis of the signal, it uses multiplication operations that can greatly increase the computational effort. So the proposed short-time amplitude difference function, in providing a similar role with the short-time autocorrelation function of the parameters, greatly reduces the amount of computation. For the signalxn, the short-time average amplitude difference function of the signal xin at the i-th frame after the framing and windowing process is defined as follows:
(5)γik=∑m=0N−k−1xim+k−xim,whereN denotes the frame length and k denotes the number of delayed sample points.Like the short-time autocorrelation function, the short-time amplitude difference function is also periodic, but the difference is that the short-time amplitude difference function appears as a valley at an integer multiple of the signal period, while the short-time autocorrelation function appears as a peak at an integer multiple of the signal period. Figures5 and 6 show the short-time amplitude difference functions of the noise section and the piano playing music section, respectively. The short-time amplitude difference function is faster than the short-time autocorrelation function to find the fundamental frequency of the piano playing music signal.Figure 5
Short-time amplitude difference function curve of the noise section.Figure 6
Short-time amplitude difference function curve of piano playing music section.


## 3.1.1. Short-Time Energy

The energy of piano playing music signal changes with time, and the short-time energy can accurately describe this change process, which is an important feature in the signal time domain analysis. For the signalxn, its short-time energy is defined as follows:
(1)En=∑m=−∞∞xmwn−m2=∑m=−∞∞x2mhn−m=x2n∗hn.The above equation represents the short-time energy of thenth frame of the signal after framing and windowing, where hn=wn and wn is the window function.Using the short-time energy, we can determine the voiced and unvoiced segments, as shown in Figure1, and the short-time energy can clearly distinguish the noise segment, the ambient background sound segment, and the piano playing music segment. The decomposition of vowel and rhyme and hyphenation can also be used in speech signal analysis. It can also be used to distinguish between clear and turbid tones, since the energy of turbid tones is much higher than that of clear tones. In the field of piano playing music recognition, short-time energy as a one-dimensional feature is also often used to represent the energy level of the signal and noise segment information.Figure 1
Short-time energy diagram.


## 3.1.2. Short-Time Zero Rate

As one of the simplest features of piano playing music signals in time domain analysis, the short-time overzero rate reflects the number of times the signal crosses zero in each frame. For a continuous signal, the overzero rate counts the number of times the signal crosses the coordinate axis, while for a discrete signalxm, it counts the number of times the sign of the sample point changes, with the following formula, where N is the length of the window function:
(2)Zn=12∑m=−∞∞∣sgnxm−sgnxm−1∣wn−m=12∑m=nm+N−1sgnxwm−sgnxwm−1,wheresgn denotes the symbolic function, which is defined as
(3)sgnxm=1,xm≥0,−1,xm<0.For example, the average overzero rate of a sine signal is its own frequency divided by twice the sampling frequency, and the sampling frequency is fixed, so the frequency information can be obtained from it.The overzero rate can also be used to distinguish the noise segment from the piano playing music segment. Piano playing music has a fixed fundamental frequency and its frequency distribution is regular, and the overzero rate is usually distributed in a fixed range, while the noise frequency distribution is irregular and the overzero rate changes very messily, as shown in Figure2.Figure 2
Comparison of the overzero rate of the noise section and the piano playing music section.In time-domain analysis, short-time energy and short-time excess zero rate are usually combined to identify the start and end points of piano playing music signals. In the case of low ambient noise, the use of short-time energy can have a good recognition effect. However, if the environmental noise is large, it is necessary to cooperate with the short-time overzero rate to filter out the influence of some noise.


## 3.1.3. Short-Time Autocorrelation Function

Correlation function describes the degree of similarity between the two signals; there are two forms of correlation function and autocorrelation function. The correlation function describes the correlation between the two signals, while the autocorrelation function describes the synchronization and periodicity of the signal itself. This paper only discusses the autocorrelation function; for the discrete signalxn, its autocorrelation function is defined as follows:
(4)Rk=limN⟶∞12N+1∑n=−NNxnxn+k,whereN denotes the frame length and k denotes the number of delayed samples.From the above properties, it can be concluded that for a periodic signal, its short-time autocorrelation function must have a maximum at an integer multiple of the period, which provides an important basis for using it to extract the fundamental frequency of the signal, as shown in Figures3 and 4, for the noise segment, its short-time autocorrelation function curve is messy and nonperiodic; while for the piano playing music segment, its short-time autocorrelation function curve is a period oscillation decay curve.Figure 3
Short-time autocorrelation function curve of the noise segment.Figure 4
Short-time autocorrelation function curve of piano playing music section.


## 3.1.4. Short-Time Amplitude Difference Function

Although the short-time autocorrelation function provides an important parameter for the time-domain analysis of the signal, it uses multiplication operations that can greatly increase the computational effort. So the proposed short-time amplitude difference function, in providing a similar role with the short-time autocorrelation function of the parameters, greatly reduces the amount of computation. For the signalxn, the short-time average amplitude difference function of the signal xin at the i-th frame after the framing and windowing process is defined as follows:
(5)γik=∑m=0N−k−1xim+k−xim,whereN denotes the frame length and k denotes the number of delayed sample points.Like the short-time autocorrelation function, the short-time amplitude difference function is also periodic, but the difference is that the short-time amplitude difference function appears as a valley at an integer multiple of the signal period, while the short-time autocorrelation function appears as a peak at an integer multiple of the signal period. Figures5 and 6 show the short-time amplitude difference functions of the noise section and the piano playing music section, respectively. The short-time amplitude difference function is faster than the short-time autocorrelation function to find the fundamental frequency of the piano playing music signal.Figure 5
Short-time amplitude difference function curve of the noise section.Figure 6
Short-time amplitude difference function curve of piano playing music section.


## 3.2. Frequency Domain Analysis of Piano Playing Music Signals

Humans are able to perceive external sounds because our auditory system has the function of spectral analysis; therefore, spectral analysis of signals is an important part of signal processing for piano playing music.Wavelet transform mainly uses the idea of multiresolution analysis, by dividing the time-frequency space nonuniformly so that the signal can be decomposed on a set of orthogonal bases, which provides a new way for the analysis of nonstationary signals. The so-called wavelet is a function or signalψt in the function space that satisfies the following conditions:
(6)Cψ=∫R∗∞ψw2∣w∣dw<∞,whereR∗ denotes all nonzero real numbers, ψw is the frequency domain representation of ψt, and ψt is the wavelet mother function. For any pair of real numbers a,b, a function of the following form is said to be a continuous wavelet function generated by the wavelet mother function ψt depending on the parameters a,b, where a is the scale of the wavelet transform, which is used to control the scaling of the wavelet function; b is the translation of the wavelet transform, which is used to control the translation of the wavelet transform:
(7)ψa,bt=1aψt−ba.For a square productable signalxt, its wavelet transform is defined as
(8)Wxa,b=∫R∞xtψa,b∗tdt=1a∫R∞xtψ∗t−badt.For the above equation, whena increases, the frequency domain observation range of the signal xt becomes narrower, the time domain observation range becomes wider, and the center frequency of the analysis moves toward the lower frequencies; when a decreases, the frequency domain observation range becomes wider, the time domain observation range becomes narrower, and the center frequency of the observation moves toward the higher frequencies. That is, using smaller a is equivalent to making a detailed observation of the signal with a high-frequency wavelet, while using larger a is a generalized observation of the signal with a low-frequency wavelet [4].


## 3.3. Inverse Spectrum Analysis

Cepstrum analysis is a well-known method for homomorphic signal analysis, and its calculation process can be roughly divided into three steps: (1) finding the Fourier transform of the signal, (2) finding the logarithm of the result of the previous step and taking the absolute value, and (3) finding the inverse Fourier transform. The mathematical definition is as follows.For the signalxn, its complex inverse spectrum is
(9)x^n=12π∫−ππX^ejwejwndw.x^ejw is generally complex; if its real part is inverted, then the real inverse spectrum cn, referred to as the inverse spectrum, can be obtained, which is defined as follows:
(10)cn=12π∫−ππlnXejwejwndw.There are many important properties of the inverse spectrum; only some of which are applied to this paper are listed below.(1)
The inverse spectrum is a bounded decay sequence(2)
For a string of uniformly spaced impulses, its inverse spectrum is also a string of uniformly spaced shocks, and both are equally spacedAs shown in Figures7 and 8, for the noise segment, its inverse spectrum curve decays gradually without a regular interval of shocks, while for the piano playing music segment, its inverse spectrum curve can be seen from its uniformly spaced impulses.Figure 7
Cepstrum curve of noise section.Figure 8
Inversion curve of piano playing music section.


## 4. CRNNH-Based Music Recognition Framework

We propose a new convolutional recurrent hashing method, CRNNH, to learn to discriminate piano playing music using multilayer RNNs, as shown in Figure9. The spatial structure of the convolutional feature map is used as input, and each column is input to the LSTM in a fixed order to learn the feature vector. To process the convolutional feature map sequence, the feature maps are directly input into the LSTM learning hash codes. The detailed process is as follows: each feature cabinet is input into the first LSTM to obtain the abstract features of each feature map, i.e., the state of the last hidden layer of the first LSTM. Many feature maps of a picture are input into the first LSTM to obtain many feature vectors, and then, these feature vectors are input into the second LSTM. Both LSTM structures are trained in an end-to-end manner, so this method can take advantage of the spatial structure of the convolutional feature map compared to the sum-pooling or max-pooling operation of the convolutional feature map. In addition, considering both spatial details and semantic features, a feature map sequence is constructed from convolutional feature maps extracted from multiple convolutional layers of a pretrained CNN. The first few convolutional layers tend to retain spatial details, while the last convolutional layer can capture more semantic information as well as less spatial details, so the feature map sequence contains both spatial details and semantic information, but the size and number of feature maps from different convolutional layers are not the same. The construction of the same size and number of feature maps from different convolutional layers can help RNNs generate effective hash codes, so the method proposed in this section generates hash codes by using multilayer RNNs using spatial information and semantic features. Finally, a new loss function is designed to control the quantization error when the hash layer outputs binary hash codes and to maintain the semantic similarity and the balance of hash codes at the same time. The experimental results show that the proposed CRNNH can achieve excellent performance compared with other advanced hashing methods.Figure 9
Flowchart of the music recognition method based on deep hashing.The CRNNH proposed in this paper is shown in Figure9, which uses a pretrained CNN to form a sequence of feature maps by extracting a multilayer convolutional feature map, and then, a multilayer RNN uses the multilayer convolutional feature map to generate hash codes, and the multilayer RNN consists of two LSTMs, and next describes how to generate hash codes using the multilayer convolutional feature map.When the convolutional feature map sequence is fed into the first LSTM, a feature vector sequence can be obtained(11)Hahssrect=h11,h21,⋯,hṗ1,h12,h22,⋯,hp2,⋯,h1S,h2S,⋯,hp′S.The second LSTM is used to summarize the sequence of feature vectors together in the following steps:(12)hend=LSTMencrudeubstrectHabsificuc,W2,v2,wherehend denotes the state of the last hidden layer of the second LSTM and W2 and v2 denote the weights and biases of the second LSTM, respectively.The hidden and hash layers of the second LSTM are fully connected, followed by the tanh function, so the hash code can be defined as(13)q=ϕWHThcnd+vH,wherez is a real value, CRNNH represents the sequence of feature maps as −1.1K and hash code q∈−1.1K as a continuous value; in order to obtain the binary code, the threshold function is defined as
(14)b=signq=signqk,k=1,2,⋯,K,wheresgm. denotes the sign function of the element, i.e., if x>0, then sgmx=1; otherwise, sgnx=−1. The goal of the hashing method is to obtain a binary code, so the optimization process often encounters the constraint of discrete values, so it is usually impossible to use the gradient-based method to optimize the objective function. To simplify the problem, it is common practice to use a more relaxed constraint, such as no longer requiring the “binary code” to be binary, but just within a specified range. After optimization, the relaxed “binary code” is then quantized to obtain the final true binary code, which is often used in deep hashing algorithms.Assuming that the binary codebn of image in is used as input to the softmax layer, the probability of predicting the label can be defined as follows:
(15)pyn=m,bn=expzm∑i=1Mexpz1,m=1,2,⋯,M,wherezm=wmγbn+vm and bn∈−1,1K,wm∈RK′×1 denote the vmth weight of the softmax layer, denote the Wth bias of the softmax layer, and M denotes the number of categories of the training images.However, continuous relaxation can lead to uncontrollable quantization errors; in [7], the regularization matrix L is used to control the quantization errors, the regularization term L is a reasonable criterion for hash code learning and can be easily optimized by backpropagation algorithm, unlike ITQ which requires additional optimization operations; in this paper, L regularization is used between continuous hash codes and discrete piano playing music, another advantage of L1 regularization. Another advantage of L1 regularization is that it requires less computational cost and is sparse compared to L2 regularization, i.e., its training process can be smoothly accelerated and more hash bits are 1 or -1, which can generate more efficient hash codes. However, optimizing the L regularization term may result in piano playing music consisting of all 1s, which may affect the final performance. This is because the optimization of L regularization affects the balance of the hash code. (2) In order to maintain the balance of the hash code, the squared and balanced criterion of the hash code mean is used, and the balance criterion can make each bit of the hash code as consistent as possible to -1 or 1. In order to generate good piano playing music, the optimization problem can be defined by the following equation:
(16)minB,QJ3=J2+γL+λϑn=−∑n=1N∑m=1M1yn=mlogexpz^m∑l=1Mexpz^2+γ∑n=1Nqn,−bn1+λ∑n=1Nρqn2,whereγ denotes the weight, which is used to control the regularization term; λ denotes the parameter that controls the equilibrium criterion.Regularization termi: it is difficult to calculate the derivative, similar to [3], when a smooth proxy function logcoshΨ, Ψ is applied to denote the difference; the smaller the difference the smaller and positive the function value, and the regularization term can be defined as
(17)L=∑n=1N∑k=1Klogcoshqkn−bkn.Considering Equation (17) together, the overall loss function of CRNNH can be defined as follows:
(18)minB.Q·W,JI=−∑n=1N∑m=1M1yn=mlogexpz^m∑i=1Mexpz^,+γ∑n=1N∑k=1Klogcoshqkn−bkn+λ∑n=1N1K∑k=1Nqkn2,where W and V denote all weights and bias vectors of the CRNNH model, respectively. The loss function of Equation (18) can be optimized by RMSprop. In the optimization process, the loss function can maintain the semantic similarity and balance of the hash code and also control the quantization error of the continuous hash code encoded as discrete piano playing music at the same time.


## 5. Experimental Results and Analysis

### 5.1. Experimental Parameter Settings and Evaluation Guidelines

The music recognition in this paper is a multilabel recognition task; a fragment will be given more than one label, so unlike the music style recognition task in Chapter 3, it is a single-label problem, and the output classification of the multilabel problem will have a geometric growth compared to the single-label one under the same label. At the same time, the multilabel training also requires more data, and the model needs more space and optimization strategies. If there areM different label dimensions, the single-label model only needs to identify one of them, while for the multilabel problem, the whole problem is able to reach 2M cases.In a general labeled dataset, many label dimensions may be zero, and it becomes less appropriate to use accuracy or mean square error as a measure. Therefore, this experiment uses three widely used metrics to evaluate the performance of hashing methods, which have two main advantages: firstly, good robustness for unbalanced datasets and, secondly, a simple number as a measure of the whole dataset description:(1)
Mean average precision (MAP): the test sample and the training sample are learned through the binary semantic features to find the Hamming distance, the similarity score of a pair of images can be obtained and then sorted, the recognition rate of each test sample is calculated according to the sorted list, and the mean value of the recognition rate is finally calculated(2)
Precision@k: the percentage of correct results in the firstk images with the smallest distance from the test image, when k is 500, Precision@500 means the percentage of correct results in the first 500 images with the smallest distance from the test image(3)
Hamming distance less than 2 (HAM2) accuracy: when the Hamming distance between the test sample and the training sample is less than 2, the percentage of correct results among these three indicators reflects the performance of the hash method in different aspects; the higher the value of these indicators, the better the performance of the hash method [24]


### 5.2. Comparative Experiments and Analysis

The depth structure containing multilayer RNN mainly contains several different RNN patterns, namely, SimpleRNN and GRULSTM, and this experiment compares three metrics of multilayer RNN structures containing different multilayer RNNs on the dataset. It is found that the multilayer RNN containing two LSTM layers has better performance compared to other multilayer RNN structures. Compared with SimpleRNN, LSTM and GRU have a significant contribution to image recognition, because both LSTM and GRU can preserve important features of the image through various gates to ensure that they are not lost during long-term propagation, and at the same time, when the errors are backpropagated from the output layer, the gates can be switched on and off to achieve temporal memory function and prevent gradient disappearance. As shown in Table1, the LSTM outperforms the GRU because the GRU does not control the number of activations when computing new memory content, while the LSTM unit can control the number of new memory content stored in the memory unit, so the LSTM can better utilize the convolutional feature map to generate hash codes.Table 1
Identification results of different RNN structures.
Multilayer RNN structureMAP%Precision@500%HAM2%SimpleRNN+SimpleRNN50.156.452.9SimpleRNN+GRU59.268.962.3SimpleRNN+LSTM62.370.564.8GRU+GRU72.174.773.5In this experiment, for the first layer, the convolutional feature map is processed using the filter sizes1∗1∗ and 1∗3∗3, Average Pooling (AP) and SimpleRNN. The different recognition results are listed in Table 2, from which it can be seen that the inclusion of 2 RNN layers gives better results on the 3 metrics, compared to those methods that use AP and convolution with different size filters for the convolutional feature maps because the feature maps contain more semantic and less spatial details as the feature maps increase. More importantly, LSTM is a neural network that can use its internal memory to process the sequence model, which is suitable for processing changing sequences, and as the LSTM sequence increases, the features in the hidden layer become more semantic.7S, so the multilayer RNN can generate better hash codes using the convolutional feature map, and this experiment also shows the importance of temporal dependence in the convolutional feature map.Table 2
Identification results of different structures of the first-layer RNN.
RNNMAP%Precision@500%HAM2%AP+SimpleRNN36.645.640.1Filter1∗1∗1+SimpleRNN38.946.645.2Filter1∗3∗3+SimpleRNN4346.243.7SimpleRNN+SimpleRNN50.155.451.9AP+GRU46.452.846.8Filter1∗1∗1+GRU48.545.349.8Filter1∗3∗3+GRU49.645.252.4AP+LSTM48.545.349.8Filter1∗1∗1+STM51.57.953.6Filter1∗3∗3+LSTM52.758.956.5SimpleRNN+LSTM62.370.165.2Using different combinations of feature maps that evaluates the three metrics of the CRNNH model using convolutional feature maps from different convolutional layers, all feature maps from five convolutional layers, and feature map sequences, and the recognition results using these feature maps can be seen in Table3, from which it can be seen that using feature map sequences can obtain better recognition accuracy than using feature maps from different convolutional layers, which is due to the fact multiple convolutional. The feature map sequences contain richer spatial details and semantic information than the feature maps from a single convolutional layer. In all evaluation metrics, the method using feature map sequences outperforms the method using all convolutional feature maps, which indicates that this method can obtain a more efficient feature representation and thus better recognition accuracy [25].Table 3
Recognition results of different convolutional feature maps.
Characteristic diagram of different combinationsMAP%Precision@500%HAM2%Of the first convolution55.458.356.9Of the first second accretion layer62.764.363.5Of the first third convolution62.370.564.8Of the first fourth convolution72.174.773.5Of the first fifth convolution67.469.969.2Of all convolutions73.475.774.9The firstp^ of the five convolutions77.678.978.1Figure10 illustrates the accuracy curves for Hamming distance less than 2 using different numbers of bits, from which it can be seen that CRNNH achieves the best recognition performance for all bits with Hamming distance less than 2. Figure 11 shows the correctness curves for the first 500 retrieved for various bit numbers, and CRNNH always has the best recognition accuracy. Figure 12 shows the correct rate of retrieval for different retrieval with 64-bit hash bits, and CRNNH still achieves the best recognition accuracy. It can be known that (1) comparing the traditional methods using hand-made features (KSH, ITQ) and the methods using CNN features, it can be found that the CNN features improve the image representation and greatly improve the recognition accuracy of the traditional methods. (2) Compared with other hashing methods, CRNNH improves the recognition mean MAP, which is due to the fact that CRNNH designs a new loss function to maintain the semantic similarity and balance of the hash code and also considers the quantization error generated when the hash layer outputs the binary hash code, and obtains a hash code with stronger representation capability.Figure 10
Accuracy curve of Hamming distance less than 2.Figure 11
Accuracy curve for returning 500 nearest neighbors.Figure 12
Accuracy curve of 64-bit hash bits.


## 5.1. Experimental Parameter Settings and Evaluation Guidelines

The music recognition in this paper is a multilabel recognition task; a fragment will be given more than one label, so unlike the music style recognition task in Chapter 3, it is a single-label problem, and the output classification of the multilabel problem will have a geometric growth compared to the single-label one under the same label. At the same time, the multilabel training also requires more data, and the model needs more space and optimization strategies. If there areM different label dimensions, the single-label model only needs to identify one of them, while for the multilabel problem, the whole problem is able to reach 2M cases.In a general labeled dataset, many label dimensions may be zero, and it becomes less appropriate to use accuracy or mean square error as a measure. Therefore, this experiment uses three widely used metrics to evaluate the performance of hashing methods, which have two main advantages: firstly, good robustness for unbalanced datasets and, secondly, a simple number as a measure of the whole dataset description:(1)
Mean average precision (MAP): the test sample and the training sample are learned through the binary semantic features to find the Hamming distance, the similarity score of a pair of images can be obtained and then sorted, the recognition rate of each test sample is calculated according to the sorted list, and the mean value of the recognition rate is finally calculated(2)
Precision@k: the percentage of correct results in the firstk images with the smallest distance from the test image, when k is 500, Precision@500 means the percentage of correct results in the first 500 images with the smallest distance from the test image(3)
Hamming distance less than 2 (HAM2) accuracy: when the Hamming distance between the test sample and the training sample is less than 2, the percentage of correct results among these three indicators reflects the performance of the hash method in different aspects; the higher the value of these indicators, the better the performance of the hash method [24]


## 5.2. Comparative Experiments and Analysis

The depth structure containing multilayer RNN mainly contains several different RNN patterns, namely, SimpleRNN and GRULSTM, and this experiment compares three metrics of multilayer RNN structures containing different multilayer RNNs on the dataset. It is found that the multilayer RNN containing two LSTM layers has better performance compared to other multilayer RNN structures. Compared with SimpleRNN, LSTM and GRU have a significant contribution to image recognition, because both LSTM and GRU can preserve important features of the image through various gates to ensure that they are not lost during long-term propagation, and at the same time, when the errors are backpropagated from the output layer, the gates can be switched on and off to achieve temporal memory function and prevent gradient disappearance. As shown in Table1, the LSTM outperforms the GRU because the GRU does not control the number of activations when computing new memory content, while the LSTM unit can control the number of new memory content stored in the memory unit, so the LSTM can better utilize the convolutional feature map to generate hash codes.Table 1
Identification results of different RNN structures.
Multilayer RNN structureMAP%Precision@500%HAM2%SimpleRNN+SimpleRNN50.156.452.9SimpleRNN+GRU59.268.962.3SimpleRNN+LSTM62.370.564.8GRU+GRU72.174.773.5In this experiment, for the first layer, the convolutional feature map is processed using the filter sizes1∗1∗ and 1∗3∗3, Average Pooling (AP) and SimpleRNN. The different recognition results are listed in Table 2, from which it can be seen that the inclusion of 2 RNN layers gives better results on the 3 metrics, compared to those methods that use AP and convolution with different size filters for the convolutional feature maps because the feature maps contain more semantic and less spatial details as the feature maps increase. More importantly, LSTM is a neural network that can use its internal memory to process the sequence model, which is suitable for processing changing sequences, and as the LSTM sequence increases, the features in the hidden layer become more semantic.7S, so the multilayer RNN can generate better hash codes using the convolutional feature map, and this experiment also shows the importance of temporal dependence in the convolutional feature map.Table 2
Identification results of different structures of the first-layer RNN.
RNNMAP%Precision@500%HAM2%AP+SimpleRNN36.645.640.1Filter1∗1∗1+SimpleRNN38.946.645.2Filter1∗3∗3+SimpleRNN4346.243.7SimpleRNN+SimpleRNN50.155.451.9AP+GRU46.452.846.8Filter1∗1∗1+GRU48.545.349.8Filter1∗3∗3+GRU49.645.252.4AP+LSTM48.545.349.8Filter1∗1∗1+STM51.57.953.6Filter1∗3∗3+LSTM52.758.956.5SimpleRNN+LSTM62.370.165.2Using different combinations of feature maps that evaluates the three metrics of the CRNNH model using convolutional feature maps from different convolutional layers, all feature maps from five convolutional layers, and feature map sequences, and the recognition results using these feature maps can be seen in Table3, from which it can be seen that using feature map sequences can obtain better recognition accuracy than using feature maps from different convolutional layers, which is due to the fact multiple convolutional. The feature map sequences contain richer spatial details and semantic information than the feature maps from a single convolutional layer. In all evaluation metrics, the method using feature map sequences outperforms the method using all convolutional feature maps, which indicates that this method can obtain a more efficient feature representation and thus better recognition accuracy [25].Table 3
Recognition results of different convolutional feature maps.
Characteristic diagram of different combinationsMAP%Precision@500%HAM2%Of the first convolution55.458.356.9Of the first second accretion layer62.764.363.5Of the first third convolution62.370.564.8Of the first fourth convolution72.174.773.5Of the first fifth convolution67.469.969.2Of all convolutions73.475.774.9The firstp^ of the five convolutions77.678.978.1Figure10 illustrates the accuracy curves for Hamming distance less than 2 using different numbers of bits, from which it can be seen that CRNNH achieves the best recognition performance for all bits with Hamming distance less than 2. Figure 11 shows the correctness curves for the first 500 retrieved for various bit numbers, and CRNNH always has the best recognition accuracy. Figure 12 shows the correct rate of retrieval for different retrieval with 64-bit hash bits, and CRNNH still achieves the best recognition accuracy. It can be known that (1) comparing the traditional methods using hand-made features (KSH, ITQ) and the methods using CNN features, it can be found that the CNN features improve the image representation and greatly improve the recognition accuracy of the traditional methods. (2) Compared with other hashing methods, CRNNH improves the recognition mean MAP, which is due to the fact that CRNNH designs a new loss function to maintain the semantic similarity and balance of the hash code and also considers the quantization error generated when the hash layer outputs the binary hash code, and obtains a hash code with stronger representation capability.Figure 10
Accuracy curve of Hamming distance less than 2.Figure 11
Accuracy curve for returning 500 nearest neighbors.Figure 12
Accuracy curve of 64-bit hash bits.


## 6. Conclusions

Music is a form of entertainment that can enrich people’s spiritual life. In this paper, we propose a new convolutional recurrent hashing method, CRNNH, which uses multilayer RNN to learn to discriminate piano playing music using a sequence of convolutional feature maps. CRNNH generates hash codes using semantic information through shallow mapping, which significantly outperforms several other supervised hashing methods due to the use of deep neural networks (multilayer RNNs) to generate hash codes through convolutional feature maps containing both spatial details and semantic information. The experimental results illustrate that the proposed CRNNH can obtain better performance compared to other hashing methods.



---

*Source: 5660961-2022-04-09.xml*