# Implementation of Computer-Aided Piano Music Automatic Notation Algorithm in Psychological Detoxification

Authors: Xinmei Zhang
Journal: Occupational Therapy International
 (2022)

---

## Abstract

This paper analyzes the modeling of a computer-aided piano music automatic notation algorithm, combines the influence of music on psychological detachment, and designs the piano music automatic notation algorithm in psychological detachment model construction. This paper investigates the multiresolution time-frequency representation constant Q-transform (CQT), which is common in music signal analysis, and finds that although CQT has higher frequency resolution at low frequencies, it also leads to lower temporal resolution. The variable Q-transform is introduced as a tool for multibasic frequency estimation of the time-frequency representation of music signals, which has better temporal resolution than CQT at the exact frequency resolution and efficient coefficient calculation. The short-time Fourier transform and constant Q-transform time-frequency analysis methods are implemented, respectively, and note onset detection and multibasic tone detection are implemented based on CNN models. The network structure, training method, and postprocessing method of CNN are optimized. This paper proposes a temporal structure model for maintaining music coherence to avoid manual input and ensure interdependence between tracks in music generation. This paper also investigates and implements a method for generating discrete music events based on multiple channels, including a multitrack correlation model and a discretization process. In this paper, the automatic piano music notation algorithm can play an influential role in significantly enhancing the actual effect of psychological detoxification.


---

## Body

## 1. Introduction

Music is a natural expression of human thoughts and emotions and an indispensable part of our daily life. Since the 1990s, the rapid development of Internet technology has enabled music to be widely disseminated. The study of effective methods for extracting, retrieving, and organizing music information, i.e., music information retrieval, has received widespread attention from the academic and knowledge communities. Music information retrieval (MIR) is a new research direction involving many disciplines, including music theory, psychology, music signal processing, and information retrieval. Its research mainly includes four levels: signal layer, element layer, semantic layer, and user layer [1]. In the signal layer, the computer transforms and processes the audio signal; in the element layer, the computer analyzes the essential elements of music, such as pitch and rhythm; in the semantic layer, some semantic concepts are summarized by synthesizing the results obtained from the element layer; in the user layer, the user retrieves and reads music according to the semantic images obtained from the semantic layer. The signal layer to user layer in music information retrieval is arranged from low to high, and the research in the lower layer provides the basis for the research in the higher layer. Computer-assisted piano teaching is a process in which computer software simulates a piano teacher evaluating and correcting a student’s performance in a self-study situation, thus lowering the barrier to learning piano and making piano music accessible to the general public [2]. The most basic evaluation of a student’s performance is usually the evaluation of whether the notes are misplayed, which shows that estimating the fundamental frequency of the letters is the most central technique in assisted piano teaching.Automatic music notation converts the sound signal of music into a musical score. Notes are the basic units of music, and the main task of AMT is to extract information about individual notes in the musical sound signal. Most AMT studies limit their scope to focus only on the pitch and onset moment of the notes [3]. Piano music intuitive notation technology can detect what notes are played at what moment in the piano music sound signal, and by comparing it with the standard score, it can automatically and objectively evaluate the correctness of piano performance, help piano learners to discover their performance errors in time, avoid repeating wrong exercises, understand their mastery level in time, and improve learning efficiency. This technology can be applied to computer-aided piano teaching and piano grade exams [4]. The core problem of automatic piano music notation is pitch detection, also known as multibasic detection. While the issue of fundamental detection of monophonic (where at most one pitch exists now in time) signals can be considered solved, accurate detection of polyphony (where multiple angles live now in time) is still a challenging problem that “lags significantly behind that of skilled human musicians” in terms of accuracy and flexibility. Using the unique language and functions of music, the treatment seeker, with the joint participation of the music therapist, experiences a variety of specially designed musical acts to eliminate psychological barriers and restore and enhance psychological detachment.The computer-assisted piano-based automatic music notation algorithm studied in this paper combines techniques related to the field of computer-automated notation algorithms with psychological detoxification methods to achieve research on psychological detoxification in the direction of music. Computer-automated composition, also known as algorithmic composition, is the process of enabling a computer to assist a person in composing music through specific formalized processes [5]. With the development of machine learning technology and the in-depth research on music theory in recent years, automated computer notation technology has been developed rapidly. More and more automatic notation methods have been proposed because the abstractness and richness of music make the music generated by the notation method in the composition process have little causality with the input. On this basis, the research on hiding carrier-free information using this characteristic has essential [6]. The study of the use of this feature to hide carrier-free details is of great value. In addition, the combination of computerized notation technology and psychological detachment in this paper is also meaningful for the integrated research of automated notation technology, signal processing technology, and information security technology.


## 2. Related Works

Automatic composition refers to computers learning the rules, theories, and knowledge of human composition. Then, computers can compose automatically without any human intervention [7]. Unlike human composers who write directly through their professional knowledge of music theory and their strong musicianship, machines such as computers need to process musical rules and theoretical knowledge into patterns that they can understand and recognize and then conduct in-depth learning and research on compositional techniques and skills to generate new music eventually international research on automatic composition dates to the 1950s, with a relatively late start in the field. Lu and Chou published String Quartet; this suite became one of the first-ever entirely computer-generated musical works [8]. They first used Markov models to generate random notes with limited control, then tested the forged notes using specific rules of harmony and polyphony, finally selecting the notes that fit the rules, adjusting, and combining them to form a string quartet notated for traditional music, pioneering contemporary automatic composition. The first public performance by Gombert et al. was a computer-generated musical composition for piano [9]. At the same time, the computer was able to perform simple pattern recognition on various pieces. It could analyze and use these patterns to generate new melodies for public enjoyment. Composer Reis Experiments in Musical Intelligence (EMI) was first publicly presented at the International Computer Music Conference [10]. The bridge between computer music and traditional music has been gradually built.Genetic algorithms, artificial neural networks, and techniques with a significant impact, such as deep learning and reinforcement learning, are currently recognized in automatic composition. These techniques are being rapidly and widely used in intuitive pieces with the development of computer technology. However, mechanical design is still in its infancy, and automatic compositions do not fully reflect the complex relationship between the musical elements in the spatial and temporal dimensions of the actual musical works [11]. However, challenges and opportunities coexist. More researchers and technology innovation companies are needed to continue their research and exploration to bring more breakthroughs in this field and provide music lovers with better quality music works and a new mode of music creation. According to previous public information, most automatic composition research directly uses note features extracted from MIDI, such as pitch and pitch length, to train and generate music as training data [12]. In this case, the contextual semantic relationships between notes are not fully considered in the representation of musical features. In this paper, we first construct a note feature vector with contextual semantic information based on the word vector model and then select a Bidirectional Gated Recurrent Unit (Bi-GRU) network based on the note feature vector and introduce the self-attention mechanism to form a composition model for training and generate music to provide a new way of thinking for automatic composition.Researchers have introduced many new techniques to investigate multibasic frequency estimation in the twenty-first century and have obtained many practical algorithms. For example, Yun et al. used iterative spectral analysis of deletion to estimate the fundamental frequencies of simultaneous vocalizations [13]. Jumani et al. used a machine learning method of multilabel classification to decide whether a particular note is present or not. They used a factorized hidden Markov model (HMM) to generate the messages [14]. Tatarenko et al. obtained the estimation of multiple fundamental frequencies by modeling the time-domain signal [15]. Fries proposed to view the multibasic frequency estimation problem as a maximum likelihood estimation problem for fundamental frequencies in the frequency domain [16]. Tao et al. suggested using a probabilistic-based approach to estimate multiple fundamental frequencies [17]. Li et al. proposed the nonnegative matrix decomposition (NMF) algorithm and were the first to use NMF to estimate multiple fundamental frequencies of music signals [18]. In recent years, the research of multibasic frequency estimation based on nonnegative matrix decomposition has been receiving attention from a wide range of researchers, such as Yan et al. proposed the method of adding harmonic constraints to NMF [19]. Salim used NMF with cost function of scattering for real-time spectral decomposition of music signals; Bianchi proposed the unsupervised NMF algorithm; Hachem proposed the sparse and interframe continuity constrained NMF [20]. Arthur et al. proposed a sparse and partially smoothed constrained NMF algorithm [21]. Because the piano has a wide frequency range and is highly polyphonic (multiple notes are being played simultaneously), Hellaby has indicated in the literature that multibasic frequency estimation for piano music is more complicated than that for other polyphonic music [22]. There are few studies on polyphonic music multibasic frequency estimation mainly. Guo Yi uses a method based on music category and probability statistics for multibasic frequency estimation of synthesized electronic music. Wan Yulong proposes a multinote identification technique based on nonnegative matrix decomposition of energy spectral envelope.


## 3. Computer-Aided Piano Music Automatic Notation Algorithm Model Construction

With the continuous development of music notation and the advent of the computer age, the representation of scores in electronic format is gaining more and more attention. The electronic form of sheet music has dramatically improved in terms of editing and preservation compared to the original handwritten method but also has significantly changed in terms of new media applications such as communication, reuse, retrieval, data mining, and analysis of scores. Among the many forms of electronic expression, the three most widely used and popular electronic scores are MIDI format, music XML format, and ABC format. MIDI (short for Musical Instrument Digital Interface) is a common technical standard describing protocols, digital interfaces, and connectors that allow the interconnection and communication between various electronic instruments, computers, and other related devices. A single MIDI link can carry up to sixteen channels of information, each of which can be independently assigned to a separate device. A diagram of the relationship between piano keys, note names, MIDI values, and corresponding fundamental frequencies is shown in Figure1. MIDI files only need start and stop (onset and offset) and absolute pitch (MIDI pitch) to be played (timbres and such can be set to default like the piano), which is why the data is so cluttered. The music XML format is much better because it is a format oriented to the display or layout of the score and contains basic musicological information as to its basis. ABC music notation language creates music files that store scores in plain text ASCII format; they can be translated and laid out as actual scores or played using compatible applications.Figure 1
Relationship between piano keys, note names, MIDI values, and corresponding fundamental frequencies.Notes contain three main pieces of information: onset, offset, and pitch, the basics of piano pitch related to AMT. The piano is a stringed instrument, and the strings vibrate by striking the piano keys. The effect of the vibration varies from string to string: long and thick strings vibrate at a low frequency and produce a low pitch, while short and thin strings vibrate at a high frequency and produce a high rise. When only a single key is struck, that is, a single note is played, the musical signal is a harmonic structure, which can be expressed as a series of superimposed sine signals, where the lowest frequency sine component is vital and is the core part of the sound, called the fundamental, and the frequency corresponding to the whole is called the fundamental frequency. In contrast, the frequencies of the remaining higher frequency sine components are integer multiples of the fundamental frequency and are called overtones (partial). The whole is called the first harmonic, and the overtone with frequencyn is called the nth harmonic [23]. The fundamental tone varies from pitch to pitch, and identifying the type of the whole tone in a sound signal is equivalent to specifying the type of pitch. The interval refers to the distance in pitch between two styles. The octave (octave) in the gap represents the distance between two tones whose values are multiples of each other, and there are eight natural levels (e.g., 12345671), which are also used to measure the distance between tones. Nowadays, people generally use the twelfth mean law for musical notation, which means that a pure octave is divided into 12 equal parts; each part is called a semitone. The fundamental frequency ratio of two adjacent semitones is 2112. Nowadays, the rigid piano is tuned according to the twelfth mean law. There are different methods for pitch notation in other contexts. The twelve equal temperament means that the octave intervals are divided equally into twelve equal parts in proportion to their wavelength, each first part being called a semitone (minor second). A significant second is two equal parts and is called a whole tone. The division of an octave into twelve equal parts has some fantastic coincidences. In the practical memo, scientific pitch notation is used, using the letters (C, D, E, F, G, A, and B), a variant notation, and a number representing the pitch’s octave. In the digital domain, the MIDI (Musical Instrument Digital Interface) standard is used, which means that an actual number is used to represent pitch, where the relationship between the MIDI value p and the corresponding fundamental frequency f is
(1)P=12∗logf−14402+69.Music is a type of audio, and audio is a form of sound signal. Music data is a relatively complex class of time-dependent data. This paper investigates the structural format of such data as music and its representation in computers. The presentation of music data can be divided into the following three main categories.(1)
Structured Symbolic Representation. Structured symbolic representation uses digital control signals of notes to record music. The prominent representatives of this type of representation are MIDI (Musical Instrument Digital Interface). This type of music expression form contains rich music information. It can play a massive role in the creation, but because they transmit not sound signals but some parameter instructions, it cannot reproduce the authentic natural sound, so it cannot be used in need for speech occasions(2)
Audio Form. Audio form can describe all the sounds of music, voice, sound effects, etc.; it is the most widely used form of music representation, mainly divided into two kinds: compressed format, such as MP3, MPEG, and RM; and noncompressed format, such as PCM format of WAV(3)
Sheet Music Form. Sheet music form is the most traditional and oldest form of music representation, which is usually used in the paper version of books and magazines in the past, but nowadays, it is mainly stored on computers in the form of electronic files, and the sheet music mainly contains detailed music information such as notes and lyrics. Since this paper focuses on the generation of computerized multitrack music, it will involve two common forms of music representation: MIDI and piano roll formats. The picture of music data is shown in Figure 2Figure 2
Representation of music data.When sound is converted from an analog signal to a digital signal, it becomes a sound file that can be read, edited, and processed by computers. Because of the increasing computing power of computers, the ways and means of acquiring, editing, and processing sound have become more convenient, intuitive, and diverse. In addition, computer technology can process sound and interact with useful information in certain areas that were not possible in the analog era. Thus, the development of computer technology has had a significant impact on the diversification of electronic music [24]. Computer music is composed and vocalized by composers on computer hardware and software platforms and played back or by sound systems in real-time. As an essential disciplinary branch of contemporary electronic music, computer music usually uses programming as the core of its creation, using the computer language itself as the basic architecture of electronic music works, creating sounds, and synthesizing sounds with various computer codes and formulas. The programs used in computer music are usually characterized by open source, interactivity, and integration and have specific requirements for the user’s programming language skills and programming thinking. The programming platforms associated with computer music have evolved over approximately 30 years and now have relatively user-friendly interfaces and user-friendly operations. Standard computer music programming software includes CSound, Pure Data, and Max. In addition, computer technology has provided significant technical support for contemporary interactive electronic music, multimedia, and cross-artistic compositions.CSound is a computer music language based on C, one of the best known and most symbolic developed sound programming languages in sound programming. Csound is a direct offshoot of the Music-N language, which Max Mathews developed at Bell Labs. Pure Data (referred to as Pd) is a visual programming tool. Unlike CSound, a text-only programming language, Pd is a graphical visual programming language for music and multimedia, focusing more on real-time interaction and real-time processing of music and multimedia. Earlier, Pd worked only within the scope of mathematical formulas, MIDI sequencing, and digital audio. With the creation of the GEM graphical multimedia environment extension package, Pd became a cross-language, cross-platform programming interface that provides almost unlimited interaction possibilities for audio, video, external sensors, etc., in real-time. In terms of interface style and operation, Pd is very similar to Max, developed by Miller Puckette.Max is currently a relatively widely used computer interactive programming software in the field of contemporary interactive electronic music. Like Pd, it is a visual programming language for music and multimedia, and its high degree of modularity and API (application programming interface) interface, as well as its ability to allow third parties to develop new modules for use with Max, provide a more intuitive and user-friendly computer music language programming environment. The programs used in computer music are usually characterized by open source, interactivity, and integration and have specific requirements for the user’s programming language skills and programming thinking. Max was initially designed to provide a platform for creating interactive computer music. Thanks to its user-friendly human-machine interface and open-source nature, Max is now a programming environment that integrates digital signal processing, audio signal processing, and multimedia processing. Like most Music-N languages, two axes are established in the time domain: event scheduling and digital signal processing. Max is composed of several programs called “Object” squares and various data squares to define, modulate, etc., objects and connect them (patch).


## 4. Piano Music Automatic Notation Algorithm Model Design

Most of the best-performing AMT algorithms are based on spectral decomposition techniques or deep learning methods. Deep learning-based automatic piano notation algorithms require a large amount of labeled data for model training. The trained model can be generalized by using training data from various environments, such as audio recorded in multiple recording settings and played by various pianos. The trained model has e ability [25]. The spectral decomposition-based automatic piano can music notation algorithm only requires the audio of individual notes when they are played individually, from which the spectral templates of personal letters are extracted. Still, it is more suitable for specific pianos in specific recording environments. This paper uses the MIREX dataset for evaluation and only considers the correctness of the onset of the note, not the end of the note. Furthermore, the automatic notation task for piano sheet music in the MIREX competition implements several algorithms with the highest values based on probabilistic learning.For the input piano music sound signal, the first time-frequency analysis is performed to transform the original time-domain waveform of the piano music sound signal into a representation of the frequency distribution over time, and the time-frequency analysis method used can be STFT or CQT; then, the note onset detection is performed; finally, the multibase detection is committed to take a section of the time-frequency representation near each note onset point and detect the new notes at the note onset point. The flowchart of the piano music automatic notation algorithm is shown in Figure3.Figure 3
Flowchart of piano music automatic notation algorithm.Unlike traditional machine learning methods, the hierarchical structure of neural networks allows them to be applied directly to raw data or low-level representations to learn features and classifiers jointly. The model’s performance depends on manually extracted features. Traditional machine learning is a general term (and arguably discipline) for a class of methods to achieve artificial intelligence. A neural network is a model, and a model is only one of the elements that implement machine learning. Analysis methods commonly used in signal processing can be classified into time domain, frequency domain, and time-frequency analysis methods [26]. When the AMT algorithm is implemented based on deep learning, the input of the neural network model can be the original time-domain waveform or frequency domain representation of the piano music sound signal. The AMT algorithm usually performs time-frequency analysis first for the following reasons: (1) the music signal is a nonstationary signal, and the distribution of the signal changes over time. (2) The note onset characteristics are reflected in the change of signal energy in the time domain and the change of frequency distribution in the frequency domain. (3) The pitch of a sound signal is mainly determined by its frequency. (4) When implementing the AMT algorithm based on deep learning, end-to-end (end-to-end) learning, i.e., using the original time-domain waveform of the signal as the input to the neural network model, has significantly poorer performance than using the classical frequency filter bank transformations. It is noted that, on the one hand, overfitting occurs due to more parameters in the end-to-end structural model. On the other hand, since the filter bank representation is an ordered structure from low to high frequencies on the frequency axis, it is suitable for a CNN model to improve performance through parameter sharing. DNN is the simplest type of neural network. Each neuron belongs to a different layer. Each neuron is connected to all neurons in the previous layer. The signal propagates unidirectionally from the input layer to the output layer. CNN is a feedforward neural network computed by convolution, which is proposed by the biological perceptual field mechanism with translation invariance and uses convolutional kernels to maximize the application of local information and preserve the planar structural details. The intrinsic form of this feature representation is difficult to reproduce by end-to-end learning STFT and CQT are two widely used methods for time-frequency analysis in AMT. AMT implementations can be classified as frame-based or note-based. If the note-based implementation is used because note onset detection has a specific error rate, note onset detection errors will cause the AMT algorithm’s detection errors. If the frame-based implementation is used, it is difficult to accurately label the training data because the end moment of the note itself is not clearly defined. In this paper, we adopt a note-based implementation.The paper adopts a note-based approach to the automatic notation of piano music, taking a time-frequency representation of a segment near the start of each note and detecting the newly played note at the beginning of that note.


### 4.1. Input

The input settings are the same as those of the note onset detection module, except that only the continuous multiframe time-frequency representation with the note onset as the middle frame is used as input.


### 4.2. Selection of Neural Network Model

In this paper, we study and implement multibase head detection based on CNN kernel; type. Advantages of using CNN kernel; type for multibase head detection: (1) when a neural network model is used to complete a task if the task-related features of the input representation have translational isotropy, it is more suitable to use the CNN model, which can reduce the model parameters and avoid overfitting. If the frequency axis of the time-frequency representation is on a logarithmic scale, the first and second harmonics of all pitches will have the exact distance between them, and so on. The frequency spectrum of notes of different pitches is obtained as if they were translated from the same image, except that the amplitude of each harmonic is different. The frequency axis of the CQT time-frequency representation is on a logarithmic scale [27]. The CQT amplitude spectrum of 88 piano notes is shown in Figure 4, where the horizontal axis represents the MIDI value of 88 piano notes, a column of data represents the CQT amplitude spectrum of one note, the vertical axis represents the frequency, and the color shade indicates the magnitude of the amplitude value. On the other hand, a given interval, such as a pure octave, corresponds to a fixed distance on the frequency axis of the logarithmic scale. Some musical patterns, such as triads (chords formed by one tone and the upper third and fifth), are translation invariant on the frequency axis of the logarithmic scale. Weight sharing in CNN models is ideal for learning such features, e.g., a single convolution kernel can be sensitive to triads at arbitrary frequencies. (2) The pooling operation in the CNN model provides a small translation invariance that can make automatic piano music notation algorithms implemented based on CNN models insensitive to deviated tones and more minor tuning differences between pianos. (3) Compared with the DNN model, the CNN model has fewer parameters, and it is not easy to obtain a considerable amount of labeled data for the AMT task.Figure 4
CQT amplitude spectrum of 88 piano notes.


### 4.3. Output

The output of the multibasher detection module represents the newly played notes in the middle frame of the input. The output layer of the multibasher detection network has 88 output units corresponding to 88 piano keys. Multibasic tone detection is a multilabel classification task where there are multiple tone pains at one moment. The activation number is sigmoid instead of SoftMax. The expression for sigmoid isfx=1/1+e−x. The output value represents the independent probability of each note being newly played in the middle frame of the input temporal frequency representation.


## 4.1. Input

The input settings are the same as those of the note onset detection module, except that only the continuous multiframe time-frequency representation with the note onset as the middle frame is used as input.


## 4.2. Selection of Neural Network Model

In this paper, we study and implement multibase head detection based on CNN kernel; type. Advantages of using CNN kernel; type for multibase head detection: (1) when a neural network model is used to complete a task if the task-related features of the input representation have translational isotropy, it is more suitable to use the CNN model, which can reduce the model parameters and avoid overfitting. If the frequency axis of the time-frequency representation is on a logarithmic scale, the first and second harmonics of all pitches will have the exact distance between them, and so on. The frequency spectrum of notes of different pitches is obtained as if they were translated from the same image, except that the amplitude of each harmonic is different. The frequency axis of the CQT time-frequency representation is on a logarithmic scale [27]. The CQT amplitude spectrum of 88 piano notes is shown in Figure 4, where the horizontal axis represents the MIDI value of 88 piano notes, a column of data represents the CQT amplitude spectrum of one note, the vertical axis represents the frequency, and the color shade indicates the magnitude of the amplitude value. On the other hand, a given interval, such as a pure octave, corresponds to a fixed distance on the frequency axis of the logarithmic scale. Some musical patterns, such as triads (chords formed by one tone and the upper third and fifth), are translation invariant on the frequency axis of the logarithmic scale. Weight sharing in CNN models is ideal for learning such features, e.g., a single convolution kernel can be sensitive to triads at arbitrary frequencies. (2) The pooling operation in the CNN model provides a small translation invariance that can make automatic piano music notation algorithms implemented based on CNN models insensitive to deviated tones and more minor tuning differences between pianos. (3) Compared with the DNN model, the CNN model has fewer parameters, and it is not easy to obtain a considerable amount of labeled data for the AMT task.Figure 4
CQT amplitude spectrum of 88 piano notes.


## 4.3. Output

The output of the multibasher detection module represents the newly played notes in the middle frame of the input. The output layer of the multibasher detection network has 88 output units corresponding to 88 piano keys. Multibasic tone detection is a multilabel classification task where there are multiple tone pains at one moment. The activation number is sigmoid instead of SoftMax. The expression for sigmoid isfx=1/1+e−x. The output value represents the independent probability of each note being newly played in the middle frame of the input temporal frequency representation.


## 5. Analysis of Results

### 5.1. Analysis of Automatic Piano Music Notation Algorithms in Psychological Detachment

Music therapy has gradually become essential for psychological guidance, determined by its functions and characteristics. First, music therapy can effectively improve the psychological state, significantly relieving and eliminating their nervousness and anxiety to maintain a calm state of mind and cooperate with the counselors in their counseling work. Contemporary college students are very fond of music. When a neural network model is used to accomplish a specific task, if the input representation of task-related features has translational isotropy, it is more suitable to use a CNN model, reducing the model parameters and avoiding overfitting. They like to rely on music to regulate their mood after school, so music therapy can fully improve their state of mind and encourage them to release their stress. Second, music can promote emotional communication between counselors and students, thus optimizing the effect of psychological counseling. As an art that focuses on emotional expression, music can often give the listener solid emotional resonance and mobilize the listener’s emotions. Both counselors and college students are highly educated and have a certain degree of artistic cultivation, making it easier to resonate when enjoying music [28]. Therefore, with the help of music therapy, counselors and college students tend to form emotional and spiritual resonance through the medium of music, thus building a passionate and dynamic bridge. In this way, college students will be more inclined to open their hearts to the counselors, close the communication distance between each other, strengthen the emotional exchange, and promote the effective implementation of psychological guidance work. In addition, most college counselors are not psychology majors; their understanding and mastery of the more professional shock therapy, aversion therapy, etc., are not enough. Music therapy is practicable and straightforward, which is very suitable for college counselors to make reasonable use of it in the psychological counseling work of college students. Finally, the effective use of music therapy can inspire students and enlighten their minds with music art, which can help them gradually form innovative thinking patterns and have positive significance for their personal growth. The results of the automatic piano music notation are shown in Figure 5.Figure 5
Piano music automatic notation results.At present, theories, techniques, and methods related to music therapy are not perfect and are still in the stage of continuous development and maturity. Therefore, counselors should pay more attention to exploring music therapy theories and techniques when applying music therapy in college psychological guidance work to build a system that meets their own work needs and is sounder at a certain level. Since most college counselors are not psychology majors and have little mastery of related professional knowledge and skills, they should be fully aware of their nonprofessional nature when exploring music therapy theories and techniques and explore them in a nonprofessional form while simply learning the essential contents of related professions [29]. In this way, counselors can construct a music therapy system that suits their nonprofessional characteristics and use it effectively in psychological counseling.The most common method for note onset detection is based on spectral features, and this method achieves relatively good results in analyzing polyphonic music. First, a time-frequency representation of the music signalxn is performed to obtain its amplitude spectrum Xk,n. Next, in the signal subtraction stage, many scholars have proposed various detection functions to subtract the signal approximately to obtain the information of the note onset point. Two standard detection functions are analyzed below [30]. One is called the high-frequency content (HFC) detection function. The signal’s energy exists mainly at low frequencies, and the energy shift of the signal at high frequencies is more apparent when a new note is added. So, the basic idea of the detection function based on high-frequency content is to weight the spectral energy of the signal, giving a higher weight at high frequencies. The HFC equation is the weighted sum of the point of each frequency band; the formula is as follows.
(2)HFC=∑k=1Wk+1xk+n,Wk−1=∑k+1k.HFC makes the notes have a sharp peak in the transient phase, this method is more effective for percussion instruments, but according to its principle, it is difficult to detect the change in energy of low-frequency signals. Another more common detection function is obtained by calculating the “distance” of the music signal spectrum, the energy difference between the spectra. If this change is quantified as a distance, the greater the distance between adjacent frames, the more likely a note onset is. There are various ways to calculate distances, the most common being the Euclidean distance (Euclidean), the following equation.(3)D=∑k=1xk+n−1xk+n.Masri usesl1 parametric, and Duxbury uses l2 parametric to improve the distance formula by first checking if the difference is positive and taking the part of the difference that is greater than 0 to sum up, i.e.,
(4)Dn=∑k=1khx−k−nxk+n.Among them,H=x−1/2 is the half-wave rectification function. If x is positive, return the original value; otherwise, return 0. A more significant value of the detection function indicates a more pronounced energy rise, which may be the note onset point. Take a small piano music signal from piano.wav of the TRIOS database as an example; the waveform diagram is shown in Figure 6.Figure 6
Time-domain waveform of piano music signal.Since the spectral difference method can prevent the energy changes of harmonic components from being ignored, making the energy starting point of small amplitudes also detectable [31]. The peak of the detection function of this method is more noticeable and more suitable for percussion instruments such as pianos; the detection function of l1 parametric equation (4) is chosen in this paper. The following task is to optimize the detection function, extract the actual peak points in the graph, and remove the pseudopeak topics.


### 5.2. Piano Music Automatic Notation Algorithm Implemented in Psychological Detachment

MAPS is the most used dataset for the piano music automatic notation task. The division of the training and validation sets used in the multibasic tone detection module is the same as that of the note onset detection module, with all the synthesized audio in the MAPS dataset as the training set. The difference is that, to facilitate comparison with the automatic piano music notation algorithms in other papers, the first 30s of the piano pieces in ENSTDkCl are used as the test set in this paper [32]. In addition, when making the data set used for the multibasic note detection module, according to the annotation in MAPS, only the consecutive multiframe time-frequency representations with the note onset as the middle frame are taken as samples and labeled as 88-dimensional 0-1 binary vector indicating whether each note is newly played in the middle rack of the input time-frequency representation. The total number of samples in the training and test sets was 342791 and 2745, respectively. The psychological effects of the number of times 88 notes were played in the training and test sets are shown in Figure 7. The notes in the alto region were played more often in the piano piece, and the letters in the bass and treble parts were played less often.Figure 7
Comparison of the mental effects of playing each note in the training set and the test set.This paper uses a TensorFlow deep learning framework to implement a model for training a multitone onset time detection model. The L2 regular term is added to the loss function to avoid the overfitting problem, in which the L2 stable coefficient of the convolution parameter is 5e-5, and the L2 regular coefficient of the fully connected parameter is 4e-3; the Xavier method is used for the initialization of the model parameters; the Adam method is used for the optimization strategy to minimize the value of the loss function, with a total of 40 iterations (epochs), the base learning rate is set to 0.01, and the learning rate is decayed by dividing by 10 in 12, 18, 24, and 30 rounds; 1024 samples are used in the batch size of each iteration. The monitoring results, such as the loss values on the training and validation sets, are output every 500 iterations during the training process. The loss function curves of the multitone onset time detection model during the training process are shown in Figure8. The model network decreases smoothly on the training set validation set and converges without the overfitting phenomenon.Figure 8
Loss function change curve during the training of multi-tone onset time detection model.
(a)(b)The combination of piano music automatic notation algorithm and psychological detachment methods through the detection model training can often play a one plus one effect than two. When carrying out psychological detoxification work for college students, combining the piano music automatic notation algorithm with other psychological detoxification methods should be actively explored according to the actual situation to improve the natural detoxification effect significantly. The standard psychological detoxification methods include persuasion, good catharsis, and relaxation, which can be deeply compatible with music to better play the psychological detoxification effect. Through communication, it was found that those who received psychological detoxification were depressed and piled up many negative emotions, which needed to be cathartic as soon as possible. Then, when guiding the catharsis of emotions, you can play some more dynamic songs to strengthen the catharsis effect.


## 5.1. Analysis of Automatic Piano Music Notation Algorithms in Psychological Detachment

Music therapy has gradually become essential for psychological guidance, determined by its functions and characteristics. First, music therapy can effectively improve the psychological state, significantly relieving and eliminating their nervousness and anxiety to maintain a calm state of mind and cooperate with the counselors in their counseling work. Contemporary college students are very fond of music. When a neural network model is used to accomplish a specific task, if the input representation of task-related features has translational isotropy, it is more suitable to use a CNN model, reducing the model parameters and avoiding overfitting. They like to rely on music to regulate their mood after school, so music therapy can fully improve their state of mind and encourage them to release their stress. Second, music can promote emotional communication between counselors and students, thus optimizing the effect of psychological counseling. As an art that focuses on emotional expression, music can often give the listener solid emotional resonance and mobilize the listener’s emotions. Both counselors and college students are highly educated and have a certain degree of artistic cultivation, making it easier to resonate when enjoying music [28]. Therefore, with the help of music therapy, counselors and college students tend to form emotional and spiritual resonance through the medium of music, thus building a passionate and dynamic bridge. In this way, college students will be more inclined to open their hearts to the counselors, close the communication distance between each other, strengthen the emotional exchange, and promote the effective implementation of psychological guidance work. In addition, most college counselors are not psychology majors; their understanding and mastery of the more professional shock therapy, aversion therapy, etc., are not enough. Music therapy is practicable and straightforward, which is very suitable for college counselors to make reasonable use of it in the psychological counseling work of college students. Finally, the effective use of music therapy can inspire students and enlighten their minds with music art, which can help them gradually form innovative thinking patterns and have positive significance for their personal growth. The results of the automatic piano music notation are shown in Figure 5.Figure 5
Piano music automatic notation results.At present, theories, techniques, and methods related to music therapy are not perfect and are still in the stage of continuous development and maturity. Therefore, counselors should pay more attention to exploring music therapy theories and techniques when applying music therapy in college psychological guidance work to build a system that meets their own work needs and is sounder at a certain level. Since most college counselors are not psychology majors and have little mastery of related professional knowledge and skills, they should be fully aware of their nonprofessional nature when exploring music therapy theories and techniques and explore them in a nonprofessional form while simply learning the essential contents of related professions [29]. In this way, counselors can construct a music therapy system that suits their nonprofessional characteristics and use it effectively in psychological counseling.The most common method for note onset detection is based on spectral features, and this method achieves relatively good results in analyzing polyphonic music. First, a time-frequency representation of the music signalxn is performed to obtain its amplitude spectrum Xk,n. Next, in the signal subtraction stage, many scholars have proposed various detection functions to subtract the signal approximately to obtain the information of the note onset point. Two standard detection functions are analyzed below [30]. One is called the high-frequency content (HFC) detection function. The signal’s energy exists mainly at low frequencies, and the energy shift of the signal at high frequencies is more apparent when a new note is added. So, the basic idea of the detection function based on high-frequency content is to weight the spectral energy of the signal, giving a higher weight at high frequencies. The HFC equation is the weighted sum of the point of each frequency band; the formula is as follows.
(2)HFC=∑k=1Wk+1xk+n,Wk−1=∑k+1k.HFC makes the notes have a sharp peak in the transient phase, this method is more effective for percussion instruments, but according to its principle, it is difficult to detect the change in energy of low-frequency signals. Another more common detection function is obtained by calculating the “distance” of the music signal spectrum, the energy difference between the spectra. If this change is quantified as a distance, the greater the distance between adjacent frames, the more likely a note onset is. There are various ways to calculate distances, the most common being the Euclidean distance (Euclidean), the following equation.(3)D=∑k=1xk+n−1xk+n.Masri usesl1 parametric, and Duxbury uses l2 parametric to improve the distance formula by first checking if the difference is positive and taking the part of the difference that is greater than 0 to sum up, i.e.,
(4)Dn=∑k=1khx−k−nxk+n.Among them,H=x−1/2 is the half-wave rectification function. If x is positive, return the original value; otherwise, return 0. A more significant value of the detection function indicates a more pronounced energy rise, which may be the note onset point. Take a small piano music signal from piano.wav of the TRIOS database as an example; the waveform diagram is shown in Figure 6.Figure 6
Time-domain waveform of piano music signal.Since the spectral difference method can prevent the energy changes of harmonic components from being ignored, making the energy starting point of small amplitudes also detectable [31]. The peak of the detection function of this method is more noticeable and more suitable for percussion instruments such as pianos; the detection function of l1 parametric equation (4) is chosen in this paper. The following task is to optimize the detection function, extract the actual peak points in the graph, and remove the pseudopeak topics.


## 5.2. Piano Music Automatic Notation Algorithm Implemented in Psychological Detachment

MAPS is the most used dataset for the piano music automatic notation task. The division of the training and validation sets used in the multibasic tone detection module is the same as that of the note onset detection module, with all the synthesized audio in the MAPS dataset as the training set. The difference is that, to facilitate comparison with the automatic piano music notation algorithms in other papers, the first 30s of the piano pieces in ENSTDkCl are used as the test set in this paper [32]. In addition, when making the data set used for the multibasic note detection module, according to the annotation in MAPS, only the consecutive multiframe time-frequency representations with the note onset as the middle frame are taken as samples and labeled as 88-dimensional 0-1 binary vector indicating whether each note is newly played in the middle rack of the input time-frequency representation. The total number of samples in the training and test sets was 342791 and 2745, respectively. The psychological effects of the number of times 88 notes were played in the training and test sets are shown in Figure 7. The notes in the alto region were played more often in the piano piece, and the letters in the bass and treble parts were played less often.Figure 7
Comparison of the mental effects of playing each note in the training set and the test set.This paper uses a TensorFlow deep learning framework to implement a model for training a multitone onset time detection model. The L2 regular term is added to the loss function to avoid the overfitting problem, in which the L2 stable coefficient of the convolution parameter is 5e-5, and the L2 regular coefficient of the fully connected parameter is 4e-3; the Xavier method is used for the initialization of the model parameters; the Adam method is used for the optimization strategy to minimize the value of the loss function, with a total of 40 iterations (epochs), the base learning rate is set to 0.01, and the learning rate is decayed by dividing by 10 in 12, 18, 24, and 30 rounds; 1024 samples are used in the batch size of each iteration. The monitoring results, such as the loss values on the training and validation sets, are output every 500 iterations during the training process. The loss function curves of the multitone onset time detection model during the training process are shown in Figure8. The model network decreases smoothly on the training set validation set and converges without the overfitting phenomenon.Figure 8
Loss function change curve during the training of multi-tone onset time detection model.
(a)(b)The combination of piano music automatic notation algorithm and psychological detachment methods through the detection model training can often play a one plus one effect than two. When carrying out psychological detoxification work for college students, combining the piano music automatic notation algorithm with other psychological detoxification methods should be actively explored according to the actual situation to improve the natural detoxification effect significantly. The standard psychological detoxification methods include persuasion, good catharsis, and relaxation, which can be deeply compatible with music to better play the psychological detoxification effect. Through communication, it was found that those who received psychological detoxification were depressed and piled up many negative emotions, which needed to be cathartic as soon as possible. Then, when guiding the catharsis of emotions, you can play some more dynamic songs to strengthen the catharsis effect.


## 6. Conclusion

This paper develops an analytical model based on piano music automatic notation algorithm in psychological detachment. This paper uses an analytical method based on piano music analysis of automatic notation algorithm. This paper studies and implements a CNN-based automatic piano music notation algorithm that can detect the onset and pitch of each note contained in the piano music sound signal. For the input piano music sound signal, first, time-frequency analysis is performed to transform the original time-domain waveform of the piano music sound signal into a table of frequency distribution over time not; then, first note onset detection is performed; finally, multibasis onset detection is performed to detect the newly played notes at the onset of each first note by taking a segment of time-frequency representation near it, respectively. Both note onset detection and multibase note detection are implemented based on CNN models. The algorithm can realize a computer-aided piano music automatic notation algorithm in mental detachment. The STET and CQT time-frequency analysis methods are implemented, respectively, and note onset detection and multibasic tone detection are implemented based on the CNN model. The network structure, training method, and postprocessing method of the CNN are optimized. The accuracy of CNN networks with different input representations and training methods is compared experimentally.



---

*Source: 4457167-2022-06-30.xml*