# Research on Music Style Classification Based on Deep Learning

Authors: Wei Wang; Mishal Sohail
Journal: Computational and Mathematical Methods in Medicine
 (2022)

---

## Abstract

Music style is one of the important labels for music classification, and the current music style classification methods extract features such as rhythm and timbre of music and use classifiers to achieve classification. The classification accuracy is not only affected by the classifier but also limited by the effect of music feature extraction, which leads to poor classification accuracy and stability. In response to the abovementioned defects, a deep-learning-based music style classification method will be studied. The music signal is framed using filters and Hamming windows, and the MFCC coefficient features of music are extracted by discrete Fourier transform. A convolutional recurrent neural network structure combining CNN and RNN is designed and trained to determine the parameters to achieve music style classification. Analysis of the simulation experimental data shows that the classification accuracy of the studied classification method is at least 93.3%, and the classification time overhead is significantly reduced, the classification results are stable, and the results are reliable.


---

## Body

## 1. Introduction

Music categorization, on the other hand, is a crucial aspect of music retrieval, because classified music information may considerably reduce the scope of a search. Music categorization has a wide range of applications and plays a vital role in music retrieval. Music classification tags are one of the most common ways for users to filter out specific types of music, and music style is one of the most accurate classification tags [1, 2]. Many music platforms provide a search portal, and one of the main ways to filter out specific types of music is through music classification tags, and music style is one of the most accurate classification tags. Music genres may be classified to assist individuals easily identify their favorite music and to play various types of music at different times and for different purposes.The most critical step in the production of music style identification is still the extraction of relevant data and the selection of classifiers. Various classification effects are achieved when different music feature vectors are utilized for music style identification, and characteristics such as pitch, timbre, and loudness are still often used [3]. Numerous factors contribute to the difficulty of extracting musical elements, resulting in ineffective categorization and identification of musical genres. To enhance style recognition, researchers have taken a variety of approaches, including adding musical features, combining machine learning principles, support vector machine models, convolutional neural networks, and CRF models, or attempting to solve the problem using signal generation principles [4–9]. These approaches have improved the categorization of music to some degree, although feature extraction remains challenging in certain unique circumstances.People are gradually attempting to apply machine learning and deep learning to the field of music recognition, and because deep learning is more powerful than machine learning in storing and processing large amounts of data, more and more deep neural networks, particularly recurrent neural networks and long short-term memory networks, are being used in music analysis and processing [10–12]. Recurrent neural networks were first employed to classify music; however, the classification results are not particularly satisfying. Due to music’s high before-and-after correlation, when using conventional recurrent neural networks, data between the previous and previous moments cannot be obtained, and the extracted musical features such as pitch, timbre, loudness, and rhythm are skewed, resulting in inaccurate classification results. In the context of the above research analysis, this paper investigates deep-learning-based music style classification methods with the aim of improving the accuracy of music style classification.


## 2. Research on Music Style Classification Based on Deep Learning

### 2.1. Music Digital Signal Preprocessing

The music signal is initially preprocessed to a standard format using appropriate methods before the feature extraction activity begins. Preprocessing is a broad term that encompasses operations such as antialiasing filtering, preemphasis, digitisation, windowing, and frame. Because most music and songs saved on the internet are digital, they are merely treated by preemphasis, windowing, and framing.The concept of human vocalization indicates that the high-frequency component approximately above 800 Hz reduces by 6 dB/octave during sound emission through sound gate excitation and mouth and nose radiation. As a result, while solving the spectrum of a music signal, the high-frequency component is more challenging to locate than the low-frequency component. The purpose of preemphasis is to increase the signal’s high-frequency component [13].The music signal preemphasis is implemented using a first-order high-pass digital filter with the expression:(1)Hz=1−μz−1.In formula (1), μ is the preemphasis coefficient of music signal, and the value range is 0.9,1.0. In order to facilitate the subsequent processing of music signal, the preemphasis output signal is usually normalized. The waveform peak after preemphasis is more prominent for further processing.Because the music signal is time-varying and unstable, but the portion of the signal between 10 ms-30 ms is typically smooth, the spectrum waveform may be viewed as a short-time and smooth process. As a result, the musical features may be determined by removing this portion of the signal.This is often accomplished by segmenting the music signal into a number of frames that can then be conveniently evaluated using appropriate signal processing methods. The framing procedure is often accomplished by windowing a limited length of the signal window, which also eliminates significant frequency domain peaks and troughs.The mathematical expression for adding a window to each frame of the music signal is as follows [14]:
(2)Sn=∑m=−∞+∞Txmwn−m.In formula (2), xm is a music signal frame, T represents signal conversion operation, and wn−m is a window function applied to each frame on the music signal. The signal’s short-time analysis characteristics are heavily influenced by the window function used. Short-time parameters may better depict the changing features of the music signal if the window function is adequate. The advantages and disadvantages of regularly used window functions are examined in this work. Hamming windows are utilized to process music signals in this research. Three synthetic rectangular windows may be used to simulate the spectrum of Hamming windows, and the first side’s lobe attenuation rate can reach -42 dB. The Hamming window has the following expression [15]:
(3)wn=0.54−0.46cos2πnN−1,0≤n≤N−1,0,else.After preprocessing the music signal according to the above, the feature variables that can represent the music style are selected to extract the music style features, thus facilitating the classification of music based on the music style.


### 2.2. Selection of Musical Style Features

In the feature extraction of music signals especially in speech signals, most of the extracted features are short-time features. These short time feature parameters are able to capture the characteristic attributes of music signals such as loudness, pitch, and timbre. In this study, MFCC coefficient features are used instead of the traditionally extracted short-time music feature parameters to represent the music signal more accurately with the help of MFCC coefficients. The extraction process of MFCC is shown in Figure1 [16].Figure 1
MFCC feature extraction process.In this paper, the discrete Fourier transform of the music signal is performed with the following parameters: the sampling rate is 16 kHz, the window function is 32 ms, and the frame shift is 16 ms. The window length isN=512 samples, i.e., there are 512 samples in a frame. The discrete Fourier transform (DFT) of these N points gives the spectral expression of a frame of music signal as
(4)Xk=∑n=0N−1xne−j2πnk/N0≤n,k≤N−1.After the spectrum value of the signal is obtained, the energy spectrum is obtained by squaring it. In order to avoid zero, a fixed jitter constant is added to the energy spectrum. We convert the actual Hertz frequency of the musical signal to the Mel frequency scale according to the following formula. Mel filter banks are composed ofm triangular filter banks defined on the Mel frequency scale. In this paper, m=19 is selected. The intermediate frequency fm of each triangular filter is distributed at equal distances and intervals on the Mel frequency axis and widens with the increase of m on the frequency axis. The frequency response of triangular filter is defined as [17]
(5)Hmk=2k−fm−1fm+1−fm−1fm−fm−1,fm−1≤k≤fm,2fm+1−kfm+1−fm−1fm+1−fm,fm≤k≤fm+1,0,else.In formula (5), fm is the center frequency of the mth triangle filter, and the formula is as follows:
(6)fm=NFsB−1Bf1+mBfh−Bf1M+1.In formula (6), fl and fh are the lowest frequency and highest frequency of the triangle filter, respectively. N is FFT points, Fs is the sampling rate of music signal, and B−1 is the conversion formula of Mel frequency to time domain.
(7)B−1b=700⋅eb/2595−1.After the short-time energy spectrum passes through the Mel filter bank, in order to obtain the spectrum estimation error with good robustness, we take the logarithm of the output signal.(8)Sm=lg∑n=0N−1Xk2Hmk,0≤m≤M.The obtained logarithmic energy is transformed into spectrum by discrete cosine transform [18].
(9)ci=∑m=1M−1Smcosnπm+0.5M.The retrieved signal’s MFCC feature parameters are obtained from the first 20 coefficients of each frame. The act of combining all of a frame’s short-time feature vectors across a longer period of time into a new vector is known as temporal feature ensemble. Music characteristics like timbre and loudness can only be retrieved during a 10 to 40 ms time span, and their features only reflect the features of that time period, not the connection between its musical qualities in subsequent time periods. Other qualities like rhythm, melody, and melodic effects like vibrato, on the other hand, can only be detected on a larger time scale. Convolutional neural networks and recurrent neural networks in deep learning are utilized to accomplish the categorization process of musical styles after extracting the musical style attributes.


### 2.3. Deep Convolutional Recurrent Neural Network Design and Implementation

#### 2.3.1. Network Architecture Design

We provide a novel deep learning neural network model, the convolutional recurrent neural network, in this research by combining CNN and RNN. This network architecture can be used to process class sequence information such as music; it employs average processing for the output of each previously processed analysis window, and if the first few segments at this point are fed into the RNN as class sequence objects for analysis, the final output will be more stable. The structure of the CRNN enables learning without the need for comprehensive annotation of each segment, but rather on the basis of the music’s categorization as a whole. Additionally, there is no need to do feature extraction for each analysis window during the preprocessing step, since the CRNN’s head uses a CNN structure without linked completely connected layers, which enables feature extraction immediately from the spectrogram. The tail has the same qualities as RNN; it does not need a fixed audio length, has less parameters, and is capable of producing a category output for each analysis window processed. The CRNN network structure is shown in Table1.Table 1
CRNN network structure.
Network hierarchy numberNetwork layer nameInput sizeNetwork hierarchy numberNetwork layer nameInput size1Input layer1×43×128103×3 maximum pooling layer 3128×3×62Convolutional layer513×4×15110.25 descending layer128×3×63Residual unit1×4×10012Filters256×7×1043×3 maximum pooling layer 132×15×4413Global maximum pooling layer256×1×150.25 descending layer32×15×4414LSTM128×6×166Filters64×19×4815Fully connected layer 130073×3 maximum pooling layer 264×6×1616Fully connected layer 215080.25 descending layer64×6×1617Fully connected layer 310/69Filters128×10×2018Output layerThe network consists of multiple convolutional layers finally connecting three fully connected layers. By superimposing many convolutional layers, each layer increasingly integrates the output features from the preceding layer to produce more global characteristics, resulting in the formation of a high-level representation containing semantic features. Following each layer of convolution, this approach employs a one-dimensional maximum pooling layer to reduce the dimensionality of the parameters. The output of the final convolutional layer in the network is utilized as the features learnt by the convolutional network and is no longer pooled throughout the whole temporal domain, thereby maintaining the temporal dimension. The feature map may be thought of as the outcome of sewing together a series of features from several moments, and the dimensionality of these features is defined as the product of their dimensionality and the frequency of the feature map. Feature maps may therefore be utilized as feature sequences in recurrent neural networks, which are then merged to form convolutional recurrent neural networks.Two convolutional layers are utilized in the residual unit. The input data is first passed through the first convolutional layer, which is then activated by batch normalization and ReLU function in turn, and the output feature map is then activated by the second convolutional layer, batch normalization, and ReLU function in turn to complete the mapping, and the obtained feature map is superimposed correspondingly with the input data. Finally, the residual unit’s output is obtained by ReLU activation once more. The loss function was determined after building the convolutional recurrent network structure, and the network was trained using the music style training set to identify the network’s parameters. The music to be processed was classified using a CRNN network with predetermined parameters [19].


#### 2.3.2. Determining Network Parameters and Implementing Music Style Classification

Softmax, as an extension of Logistics, is often mostly used to solve multiclassification problems. However, it is clearly inappropriate to directly use the loss function of softmax for multilabel classification problems directly, because from each training of minibatch, it can only calculate the probability of one correct label. In contrast, the output of one of the convolutional recurrent neural networks designed in this paper for music style classification is multiple music style labels, i.e., corresponding to multiple categories. But, in practice, not all predictions are perfect, and it is possible that the wrong category predictions will be high. So, for such a situation, a dynamic Euclidean distance-based loss function is proposed in this paper, as shown in the following equation:(10)L=12N∑n=1N∑g∈Ynpng−p¯ng2+∑h∈ZhfRnhQhpnh−p¯nh2.In formula (10), N represents all samples in a minibatch, and Rnh represents the predicted value of the hth error label in the nth sample. Qh represents the cardinality of the error label set. Yn represents correctly classified sets, Zh represents the error set, png represents the predicted value of the actual correct tag in category g of the nth sample, pnh represents the predicted value of the actual error label for category h in the nth sample, and f is the reweighting function for learning sorting and is a harmonic series. We use p¯ng and p¯nh to represent the expected output of the n training batch. In this paper, the stochastic gradient descent method is used to train CRNN network parameters, and the specific training process is shown in Figure 2 [20].Figure 2
Convolutional recurrent neural network training flow chart.After training the CRNN network parameters using music with known music style as the training set, the music to be classified is processed using the network with known parameters [21]. The music to be classified is processed according to the above research, and the corresponding music style category labels are obtained from the output of the CRNN network to achieve music style classification and complete the research on deep-learning-based music style classification methods.


## 2.1. Music Digital Signal Preprocessing

The music signal is initially preprocessed to a standard format using appropriate methods before the feature extraction activity begins. Preprocessing is a broad term that encompasses operations such as antialiasing filtering, preemphasis, digitisation, windowing, and frame. Because most music and songs saved on the internet are digital, they are merely treated by preemphasis, windowing, and framing.The concept of human vocalization indicates that the high-frequency component approximately above 800 Hz reduces by 6 dB/octave during sound emission through sound gate excitation and mouth and nose radiation. As a result, while solving the spectrum of a music signal, the high-frequency component is more challenging to locate than the low-frequency component. The purpose of preemphasis is to increase the signal’s high-frequency component [13].The music signal preemphasis is implemented using a first-order high-pass digital filter with the expression:(1)Hz=1−μz−1.In formula (1), μ is the preemphasis coefficient of music signal, and the value range is 0.9,1.0. In order to facilitate the subsequent processing of music signal, the preemphasis output signal is usually normalized. The waveform peak after preemphasis is more prominent for further processing.Because the music signal is time-varying and unstable, but the portion of the signal between 10 ms-30 ms is typically smooth, the spectrum waveform may be viewed as a short-time and smooth process. As a result, the musical features may be determined by removing this portion of the signal.This is often accomplished by segmenting the music signal into a number of frames that can then be conveniently evaluated using appropriate signal processing methods. The framing procedure is often accomplished by windowing a limited length of the signal window, which also eliminates significant frequency domain peaks and troughs.The mathematical expression for adding a window to each frame of the music signal is as follows [14]:
(2)Sn=∑m=−∞+∞Txmwn−m.In formula (2), xm is a music signal frame, T represents signal conversion operation, and wn−m is a window function applied to each frame on the music signal. The signal’s short-time analysis characteristics are heavily influenced by the window function used. Short-time parameters may better depict the changing features of the music signal if the window function is adequate. The advantages and disadvantages of regularly used window functions are examined in this work. Hamming windows are utilized to process music signals in this research. Three synthetic rectangular windows may be used to simulate the spectrum of Hamming windows, and the first side’s lobe attenuation rate can reach -42 dB. The Hamming window has the following expression [15]:
(3)wn=0.54−0.46cos2πnN−1,0≤n≤N−1,0,else.After preprocessing the music signal according to the above, the feature variables that can represent the music style are selected to extract the music style features, thus facilitating the classification of music based on the music style.


## 2.2. Selection of Musical Style Features

In the feature extraction of music signals especially in speech signals, most of the extracted features are short-time features. These short time feature parameters are able to capture the characteristic attributes of music signals such as loudness, pitch, and timbre. In this study, MFCC coefficient features are used instead of the traditionally extracted short-time music feature parameters to represent the music signal more accurately with the help of MFCC coefficients. The extraction process of MFCC is shown in Figure1 [16].Figure 1
MFCC feature extraction process.In this paper, the discrete Fourier transform of the music signal is performed with the following parameters: the sampling rate is 16 kHz, the window function is 32 ms, and the frame shift is 16 ms. The window length isN=512 samples, i.e., there are 512 samples in a frame. The discrete Fourier transform (DFT) of these N points gives the spectral expression of a frame of music signal as
(4)Xk=∑n=0N−1xne−j2πnk/N0≤n,k≤N−1.After the spectrum value of the signal is obtained, the energy spectrum is obtained by squaring it. In order to avoid zero, a fixed jitter constant is added to the energy spectrum. We convert the actual Hertz frequency of the musical signal to the Mel frequency scale according to the following formula. Mel filter banks are composed ofm triangular filter banks defined on the Mel frequency scale. In this paper, m=19 is selected. The intermediate frequency fm of each triangular filter is distributed at equal distances and intervals on the Mel frequency axis and widens with the increase of m on the frequency axis. The frequency response of triangular filter is defined as [17]
(5)Hmk=2k−fm−1fm+1−fm−1fm−fm−1,fm−1≤k≤fm,2fm+1−kfm+1−fm−1fm+1−fm,fm≤k≤fm+1,0,else.In formula (5), fm is the center frequency of the mth triangle filter, and the formula is as follows:
(6)fm=NFsB−1Bf1+mBfh−Bf1M+1.In formula (6), fl and fh are the lowest frequency and highest frequency of the triangle filter, respectively. N is FFT points, Fs is the sampling rate of music signal, and B−1 is the conversion formula of Mel frequency to time domain.
(7)B−1b=700⋅eb/2595−1.After the short-time energy spectrum passes through the Mel filter bank, in order to obtain the spectrum estimation error with good robustness, we take the logarithm of the output signal.(8)Sm=lg∑n=0N−1Xk2Hmk,0≤m≤M.The obtained logarithmic energy is transformed into spectrum by discrete cosine transform [18].
(9)ci=∑m=1M−1Smcosnπm+0.5M.The retrieved signal’s MFCC feature parameters are obtained from the first 20 coefficients of each frame. The act of combining all of a frame’s short-time feature vectors across a longer period of time into a new vector is known as temporal feature ensemble. Music characteristics like timbre and loudness can only be retrieved during a 10 to 40 ms time span, and their features only reflect the features of that time period, not the connection between its musical qualities in subsequent time periods. Other qualities like rhythm, melody, and melodic effects like vibrato, on the other hand, can only be detected on a larger time scale. Convolutional neural networks and recurrent neural networks in deep learning are utilized to accomplish the categorization process of musical styles after extracting the musical style attributes.


## 2.3. Deep Convolutional Recurrent Neural Network Design and Implementation

### 2.3.1. Network Architecture Design

We provide a novel deep learning neural network model, the convolutional recurrent neural network, in this research by combining CNN and RNN. This network architecture can be used to process class sequence information such as music; it employs average processing for the output of each previously processed analysis window, and if the first few segments at this point are fed into the RNN as class sequence objects for analysis, the final output will be more stable. The structure of the CRNN enables learning without the need for comprehensive annotation of each segment, but rather on the basis of the music’s categorization as a whole. Additionally, there is no need to do feature extraction for each analysis window during the preprocessing step, since the CRNN’s head uses a CNN structure without linked completely connected layers, which enables feature extraction immediately from the spectrogram. The tail has the same qualities as RNN; it does not need a fixed audio length, has less parameters, and is capable of producing a category output for each analysis window processed. The CRNN network structure is shown in Table1.Table 1
CRNN network structure.
Network hierarchy numberNetwork layer nameInput sizeNetwork hierarchy numberNetwork layer nameInput size1Input layer1×43×128103×3 maximum pooling layer 3128×3×62Convolutional layer513×4×15110.25 descending layer128×3×63Residual unit1×4×10012Filters256×7×1043×3 maximum pooling layer 132×15×4413Global maximum pooling layer256×1×150.25 descending layer32×15×4414LSTM128×6×166Filters64×19×4815Fully connected layer 130073×3 maximum pooling layer 264×6×1616Fully connected layer 215080.25 descending layer64×6×1617Fully connected layer 310/69Filters128×10×2018Output layerThe network consists of multiple convolutional layers finally connecting three fully connected layers. By superimposing many convolutional layers, each layer increasingly integrates the output features from the preceding layer to produce more global characteristics, resulting in the formation of a high-level representation containing semantic features. Following each layer of convolution, this approach employs a one-dimensional maximum pooling layer to reduce the dimensionality of the parameters. The output of the final convolutional layer in the network is utilized as the features learnt by the convolutional network and is no longer pooled throughout the whole temporal domain, thereby maintaining the temporal dimension. The feature map may be thought of as the outcome of sewing together a series of features from several moments, and the dimensionality of these features is defined as the product of their dimensionality and the frequency of the feature map. Feature maps may therefore be utilized as feature sequences in recurrent neural networks, which are then merged to form convolutional recurrent neural networks.Two convolutional layers are utilized in the residual unit. The input data is first passed through the first convolutional layer, which is then activated by batch normalization and ReLU function in turn, and the output feature map is then activated by the second convolutional layer, batch normalization, and ReLU function in turn to complete the mapping, and the obtained feature map is superimposed correspondingly with the input data. Finally, the residual unit’s output is obtained by ReLU activation once more. The loss function was determined after building the convolutional recurrent network structure, and the network was trained using the music style training set to identify the network’s parameters. The music to be processed was classified using a CRNN network with predetermined parameters [19].


### 2.3.2. Determining Network Parameters and Implementing Music Style Classification

Softmax, as an extension of Logistics, is often mostly used to solve multiclassification problems. However, it is clearly inappropriate to directly use the loss function of softmax for multilabel classification problems directly, because from each training of minibatch, it can only calculate the probability of one correct label. In contrast, the output of one of the convolutional recurrent neural networks designed in this paper for music style classification is multiple music style labels, i.e., corresponding to multiple categories. But, in practice, not all predictions are perfect, and it is possible that the wrong category predictions will be high. So, for such a situation, a dynamic Euclidean distance-based loss function is proposed in this paper, as shown in the following equation:(10)L=12N∑n=1N∑g∈Ynpng−p¯ng2+∑h∈ZhfRnhQhpnh−p¯nh2.In formula (10), N represents all samples in a minibatch, and Rnh represents the predicted value of the hth error label in the nth sample. Qh represents the cardinality of the error label set. Yn represents correctly classified sets, Zh represents the error set, png represents the predicted value of the actual correct tag in category g of the nth sample, pnh represents the predicted value of the actual error label for category h in the nth sample, and f is the reweighting function for learning sorting and is a harmonic series. We use p¯ng and p¯nh to represent the expected output of the n training batch. In this paper, the stochastic gradient descent method is used to train CRNN network parameters, and the specific training process is shown in Figure 2 [20].Figure 2
Convolutional recurrent neural network training flow chart.After training the CRNN network parameters using music with known music style as the training set, the music to be classified is processed using the network with known parameters [21]. The music to be classified is processed according to the above research, and the corresponding music style category labels are obtained from the output of the CRNN network to achieve music style classification and complete the research on deep-learning-based music style classification methods.


## 2.3.1. Network Architecture Design

We provide a novel deep learning neural network model, the convolutional recurrent neural network, in this research by combining CNN and RNN. This network architecture can be used to process class sequence information such as music; it employs average processing for the output of each previously processed analysis window, and if the first few segments at this point are fed into the RNN as class sequence objects for analysis, the final output will be more stable. The structure of the CRNN enables learning without the need for comprehensive annotation of each segment, but rather on the basis of the music’s categorization as a whole. Additionally, there is no need to do feature extraction for each analysis window during the preprocessing step, since the CRNN’s head uses a CNN structure without linked completely connected layers, which enables feature extraction immediately from the spectrogram. The tail has the same qualities as RNN; it does not need a fixed audio length, has less parameters, and is capable of producing a category output for each analysis window processed. The CRNN network structure is shown in Table1.Table 1
CRNN network structure.
Network hierarchy numberNetwork layer nameInput sizeNetwork hierarchy numberNetwork layer nameInput size1Input layer1×43×128103×3 maximum pooling layer 3128×3×62Convolutional layer513×4×15110.25 descending layer128×3×63Residual unit1×4×10012Filters256×7×1043×3 maximum pooling layer 132×15×4413Global maximum pooling layer256×1×150.25 descending layer32×15×4414LSTM128×6×166Filters64×19×4815Fully connected layer 130073×3 maximum pooling layer 264×6×1616Fully connected layer 215080.25 descending layer64×6×1617Fully connected layer 310/69Filters128×10×2018Output layerThe network consists of multiple convolutional layers finally connecting three fully connected layers. By superimposing many convolutional layers, each layer increasingly integrates the output features from the preceding layer to produce more global characteristics, resulting in the formation of a high-level representation containing semantic features. Following each layer of convolution, this approach employs a one-dimensional maximum pooling layer to reduce the dimensionality of the parameters. The output of the final convolutional layer in the network is utilized as the features learnt by the convolutional network and is no longer pooled throughout the whole temporal domain, thereby maintaining the temporal dimension. The feature map may be thought of as the outcome of sewing together a series of features from several moments, and the dimensionality of these features is defined as the product of their dimensionality and the frequency of the feature map. Feature maps may therefore be utilized as feature sequences in recurrent neural networks, which are then merged to form convolutional recurrent neural networks.Two convolutional layers are utilized in the residual unit. The input data is first passed through the first convolutional layer, which is then activated by batch normalization and ReLU function in turn, and the output feature map is then activated by the second convolutional layer, batch normalization, and ReLU function in turn to complete the mapping, and the obtained feature map is superimposed correspondingly with the input data. Finally, the residual unit’s output is obtained by ReLU activation once more. The loss function was determined after building the convolutional recurrent network structure, and the network was trained using the music style training set to identify the network’s parameters. The music to be processed was classified using a CRNN network with predetermined parameters [19].


## 2.3.2. Determining Network Parameters and Implementing Music Style Classification

Softmax, as an extension of Logistics, is often mostly used to solve multiclassification problems. However, it is clearly inappropriate to directly use the loss function of softmax for multilabel classification problems directly, because from each training of minibatch, it can only calculate the probability of one correct label. In contrast, the output of one of the convolutional recurrent neural networks designed in this paper for music style classification is multiple music style labels, i.e., corresponding to multiple categories. But, in practice, not all predictions are perfect, and it is possible that the wrong category predictions will be high. So, for such a situation, a dynamic Euclidean distance-based loss function is proposed in this paper, as shown in the following equation:(10)L=12N∑n=1N∑g∈Ynpng−p¯ng2+∑h∈ZhfRnhQhpnh−p¯nh2.In formula (10), N represents all samples in a minibatch, and Rnh represents the predicted value of the hth error label in the nth sample. Qh represents the cardinality of the error label set. Yn represents correctly classified sets, Zh represents the error set, png represents the predicted value of the actual correct tag in category g of the nth sample, pnh represents the predicted value of the actual error label for category h in the nth sample, and f is the reweighting function for learning sorting and is a harmonic series. We use p¯ng and p¯nh to represent the expected output of the n training batch. In this paper, the stochastic gradient descent method is used to train CRNN network parameters, and the specific training process is shown in Figure 2 [20].Figure 2
Convolutional recurrent neural network training flow chart.After training the CRNN network parameters using music with known music style as the training set, the music to be classified is processed using the network with known parameters [21]. The music to be classified is processed according to the above research, and the corresponding music style category labels are obtained from the output of the CRNN network to achieve music style classification and complete the research on deep-learning-based music style classification methods.


## 3. Experimental Simulation and Analysis

The performance of the deep-learning-based music style categorization approach suggested before is evaluated and studied in this section using a two-part simulation study. The experiments consist of two sections. The first section is a simulation experiment examining the influence of the sound spectrum on the categorization of musical styles. As the sound spectrum is taken from the audio source and sent into the classification network. The short-time Fourier sound spectrum, the Meier sound spectrum, and the constant Q sound spectrum based on the CQT are the three primary sound spectra presently utilized for sound categorization. However, not all sound spectra are amenable to classification networks for the purpose of categorizing musical genres. As a result, the first section analyzes the influence of the three acoustic spectra on classification performance in order to choose the input acoustic spectrum for the future music style classification networks [22].The second portion of the simulation compares the deep-learning-based music style classification approach suggested in this study against the SVM classifier-based classification method and the network-based classification method. The classification accuracy as well as the time overhead of the classification techniques are compared to assess the performance of the music classification methods.


### 3.1. Comparative Simulation Data Preparation

MP3 tracks from various genre categories are collected online and added to the music database, and then, all tracks are recategorized by forming a “jury of experts”. The jury consisted of 100 music lovers, divided into 10 groups, to label the music. The collection included over 900 songs from each genre, totaling over 4,000 tracks over five genres, with each expert panel allocated an average of over 400 songs to categorize. If an unidentifiable category was present during the annotation, the experts were permitted to listen again until they arrived at the proper classification. Individual songs will be annotated ten times at the conclusion of the entire review annotation exercise, and only if a track is annotated as a category more than or equal to seven times will it be allocated to that category prior to being authorized to be included to the music database [23–25]. The final composition of the music training and test libraries obtained is shown in Table 2.Table 2
Music training and testing database.
Dance musicLyricismJazzChinese folk musicRock ‘n’ roll (music)Number of training library music500500500500500Number of test library music240360214351168Furthermore, since most individuals listen to music for a few minutes at a time, the data acquired would be enormous if the feature vector extraction were done directly. However, in most cases, a portion in the center of a piece of music may sufficiently convey its artistic characteristics. As a result, the experimental data sample may be cut from the middle 30 seconds of each song and set to mono, and the sampling rate is set to 16 KHz.


### 3.2. Analysis of the Effect of Acoustic Spectrogram on Classification Performance

Under varied frequency scale divisions and resolutions, all three sound spectrograms can depict the time-frequency variation of music signals. The same structured network is used in the experiments to train and extract features using convolutional neural networks using these three sound spectrograms as input to categorize them in two datasets and compare their classification impacts. Three convolutional layers and three fully linked layers were employed in the tests, with the particular values listed in Table3.Table 3
List of convolutional neural network parameters corresponding to different acoustic spectrograms.
Input typeSTFTMelCQTConvolutional layer 1513×4×128128×4×128128×4×128Maximum value pooling 11×21×21×2Convolutional layer 21×4×1281×4×1281×4×128Maximum value pooling 21×21×21×2Convolutional layer 31×4×1281×4×1281×4×128Maximum value pooling 31×261×261×26Fully connected layer 1300300300Fully connected layer 2150150150Fully connected layer 310/610/610/6For each convolutional layer, the parameters are expressed as the size and number of its convolutional kernels, arranged as frequency, time, and number of convolutional kernels. The parameters of the fully connected layer indicate the number of hidden units, and the output length of fully connected layer 3 varies depending on the number of categories contained in the dataset, from 10 dimensions when using GTZAN to 6 dimensions when using ISMIR2004. The activation function for fully connected layer 3 is a softmax function that maps the output to a probability vector, and the activation functions for the other layers use ReLU.After training the above networks with different input spectrograms, the classification results of the three spectrograms are finally obtained, as shown in Table4.Table 4
Comparison of classification performance of different spectrograms.
DatasetGTZANISMIR2004STFT85.46%86.41%Mel80.25%82.19%CQT85.35%86.57%It can be seen from Table4 that the classification accuracy of short-time Fourier spectrum is the highest on GTZAN dataset, which is 85.46%, and the classification accuracy of constant Q spectrum is the highest on ismir2004 dataset, which is 86.57%, and the accuracy of the two spectra is relatively close, while the frequency band division method of Mel spectrum is inconsistent with that of interval frequency in music, resulting in insufficient discrimination between scales. Classification performance decreased. Therefore, Mel spectrum is not selected as the input of the classification network when classifying music styles.


### 3.3. Comparison of Simulation Result Analysis

The performance and convergence speed of the algorithm are compared with traditional SVM-based classification method and convolutional neural network-based classification method to verify the performance and convergence speed of the algorithm in the case of unlabeled incremental data.In the database of labeled music samples, 300 songs are randomly selected in each category as the initial sample set, and the remaining labeled music samples are used as the test dataset. The remaining labeled music samples are used as the test dataset. An additional sample set including unlabeled samples of each category is collected, with about 3000 songs. The original training set is the same for all three methods, and the number of each incremental iteration and the accuracy statistics of the classifier are calculated by varying the size of the number of samples selected in each loop iteration of the network training process, and the experimental results are shown in Figures3 and 4 [26–28].Figure 3
Experimental results for a sample size of 100.Figure 4
Experimental results for sample size of 50.As can be seen in Figures3 and 4, both the SVM-based and the convolutional neural network-based classification methods are less accurate than the present method during the whole incremental training process. Moreover, this method converges to a smooth value very quickly, which is not bad compared with the other two methods. It can also be seen that the accuracy of the three methods is similar at the start of the iterative loop process, implying that this is due to the uneven distribution of samples and the small size of the initial training set, while samples that are extremely dissimilar are more likely to be randomized. The accuracy and convergence rate of the three classification algorithms varies depending on the size of the number of samples picked in each loop iteration, as shown in the figure. The more examples there are, the more likely the selection engine will choose more useful samples for expert labeling, contributing more to the correct classification model and increasing the classification model’s accuracy [29]. The comparison of classification accuracy and time cost of classification methods is shown in Table 5.Table 5
Comparison of classification accuracy and time overhead of classification methods.
Experiment numberMethod of this articleSVM classification methodCNN classification methodAccuracy rate (%)Standard deviation (%)Time overhead (s)Accuracy rate (%)Standard deviation (%)Time overhead (s)Accuracy rate (%)Standard deviation (%)Time overhead (s)195.54.88650.03186.28.06370.26890.36.38510.165296.74.54570.04284.38.51720.29589.96.75340.164393.34.63190.05685.18.69440.17991.26.68920.178494.86.74360.04986.48.37860.30690.86.84650.122596.14.80630.05083.68.90150.29391.76.76430.163When comparing the data in Table5 above, it can be observed that this approach’s overall classification accuracy is more than 93.3 percent, indicating that this method is more accurate in classifying music genres than the other two comparative classification methods. Each method’s standard deviation of classification accuracy is lower than the other two, and this method’s maximum fluctuation of the standard deviation of classification accuracy is roughly 0.34 percent, which is much lower than the other two techniques. It demonstrates that this technique has greater classification stability while categorizing items with varied compositions. This approach has a 0.0456 s average time overhead, which is less than the 0.1584 s average time overhead of SVM and convolutional neural network. This approach has a much greater classification effectiveness than the other two comparison methods [30].The above simulation analysis concludes that the classification accuracy of the deep-learning-based music style classification method proposed in this paper is higher than 93.3%, and the classification efficiency is higher, which has good classification performance.


## 3.1. Comparative Simulation Data Preparation

MP3 tracks from various genre categories are collected online and added to the music database, and then, all tracks are recategorized by forming a “jury of experts”. The jury consisted of 100 music lovers, divided into 10 groups, to label the music. The collection included over 900 songs from each genre, totaling over 4,000 tracks over five genres, with each expert panel allocated an average of over 400 songs to categorize. If an unidentifiable category was present during the annotation, the experts were permitted to listen again until they arrived at the proper classification. Individual songs will be annotated ten times at the conclusion of the entire review annotation exercise, and only if a track is annotated as a category more than or equal to seven times will it be allocated to that category prior to being authorized to be included to the music database [23–25]. The final composition of the music training and test libraries obtained is shown in Table 2.Table 2
Music training and testing database.
Dance musicLyricismJazzChinese folk musicRock ‘n’ roll (music)Number of training library music500500500500500Number of test library music240360214351168Furthermore, since most individuals listen to music for a few minutes at a time, the data acquired would be enormous if the feature vector extraction were done directly. However, in most cases, a portion in the center of a piece of music may sufficiently convey its artistic characteristics. As a result, the experimental data sample may be cut from the middle 30 seconds of each song and set to mono, and the sampling rate is set to 16 KHz.


## 3.2. Analysis of the Effect of Acoustic Spectrogram on Classification Performance

Under varied frequency scale divisions and resolutions, all three sound spectrograms can depict the time-frequency variation of music signals. The same structured network is used in the experiments to train and extract features using convolutional neural networks using these three sound spectrograms as input to categorize them in two datasets and compare their classification impacts. Three convolutional layers and three fully linked layers were employed in the tests, with the particular values listed in Table3.Table 3
List of convolutional neural network parameters corresponding to different acoustic spectrograms.
Input typeSTFTMelCQTConvolutional layer 1513×4×128128×4×128128×4×128Maximum value pooling 11×21×21×2Convolutional layer 21×4×1281×4×1281×4×128Maximum value pooling 21×21×21×2Convolutional layer 31×4×1281×4×1281×4×128Maximum value pooling 31×261×261×26Fully connected layer 1300300300Fully connected layer 2150150150Fully connected layer 310/610/610/6For each convolutional layer, the parameters are expressed as the size and number of its convolutional kernels, arranged as frequency, time, and number of convolutional kernels. The parameters of the fully connected layer indicate the number of hidden units, and the output length of fully connected layer 3 varies depending on the number of categories contained in the dataset, from 10 dimensions when using GTZAN to 6 dimensions when using ISMIR2004. The activation function for fully connected layer 3 is a softmax function that maps the output to a probability vector, and the activation functions for the other layers use ReLU.After training the above networks with different input spectrograms, the classification results of the three spectrograms are finally obtained, as shown in Table4.Table 4
Comparison of classification performance of different spectrograms.
DatasetGTZANISMIR2004STFT85.46%86.41%Mel80.25%82.19%CQT85.35%86.57%It can be seen from Table4 that the classification accuracy of short-time Fourier spectrum is the highest on GTZAN dataset, which is 85.46%, and the classification accuracy of constant Q spectrum is the highest on ismir2004 dataset, which is 86.57%, and the accuracy of the two spectra is relatively close, while the frequency band division method of Mel spectrum is inconsistent with that of interval frequency in music, resulting in insufficient discrimination between scales. Classification performance decreased. Therefore, Mel spectrum is not selected as the input of the classification network when classifying music styles.


## 3.3. Comparison of Simulation Result Analysis

The performance and convergence speed of the algorithm are compared with traditional SVM-based classification method and convolutional neural network-based classification method to verify the performance and convergence speed of the algorithm in the case of unlabeled incremental data.In the database of labeled music samples, 300 songs are randomly selected in each category as the initial sample set, and the remaining labeled music samples are used as the test dataset. The remaining labeled music samples are used as the test dataset. An additional sample set including unlabeled samples of each category is collected, with about 3000 songs. The original training set is the same for all three methods, and the number of each incremental iteration and the accuracy statistics of the classifier are calculated by varying the size of the number of samples selected in each loop iteration of the network training process, and the experimental results are shown in Figures3 and 4 [26–28].Figure 3
Experimental results for a sample size of 100.Figure 4
Experimental results for sample size of 50.As can be seen in Figures3 and 4, both the SVM-based and the convolutional neural network-based classification methods are less accurate than the present method during the whole incremental training process. Moreover, this method converges to a smooth value very quickly, which is not bad compared with the other two methods. It can also be seen that the accuracy of the three methods is similar at the start of the iterative loop process, implying that this is due to the uneven distribution of samples and the small size of the initial training set, while samples that are extremely dissimilar are more likely to be randomized. The accuracy and convergence rate of the three classification algorithms varies depending on the size of the number of samples picked in each loop iteration, as shown in the figure. The more examples there are, the more likely the selection engine will choose more useful samples for expert labeling, contributing more to the correct classification model and increasing the classification model’s accuracy [29]. The comparison of classification accuracy and time cost of classification methods is shown in Table 5.Table 5
Comparison of classification accuracy and time overhead of classification methods.
Experiment numberMethod of this articleSVM classification methodCNN classification methodAccuracy rate (%)Standard deviation (%)Time overhead (s)Accuracy rate (%)Standard deviation (%)Time overhead (s)Accuracy rate (%)Standard deviation (%)Time overhead (s)195.54.88650.03186.28.06370.26890.36.38510.165296.74.54570.04284.38.51720.29589.96.75340.164393.34.63190.05685.18.69440.17991.26.68920.178494.86.74360.04986.48.37860.30690.86.84650.122596.14.80630.05083.68.90150.29391.76.76430.163When comparing the data in Table5 above, it can be observed that this approach’s overall classification accuracy is more than 93.3 percent, indicating that this method is more accurate in classifying music genres than the other two comparative classification methods. Each method’s standard deviation of classification accuracy is lower than the other two, and this method’s maximum fluctuation of the standard deviation of classification accuracy is roughly 0.34 percent, which is much lower than the other two techniques. It demonstrates that this technique has greater classification stability while categorizing items with varied compositions. This approach has a 0.0456 s average time overhead, which is less than the 0.1584 s average time overhead of SVM and convolutional neural network. This approach has a much greater classification effectiveness than the other two comparison methods [30].The above simulation analysis concludes that the classification accuracy of the deep-learning-based music style classification method proposed in this paper is higher than 93.3%, and the classification efficiency is higher, which has good classification performance.


## 4. Conclusion

A huge number of various forms of music have emerged in tandem with the advancement of people’s aesthetic abilities and the development of diverse global civilizations. Consumers may access a huge variety of music services via music platforms, and categorizing music according to music types can help users find what they are looking for faster. We propose a deep-learning-based music style classification approach in this research, based on a study of existing common music classification methods and a comparison of several deep learning theories. The findings of the simulated experimental investigation reveal that additional characteristics, such as cochlear filter cepstral coefficients, may be retrieved in future research. The classification performance of the classification network may be enhanced by enriching the features, resulting in better classification results..



---

*Source: 3699885-2022-01-18.xml*