Distributed Representations of Melodic Phrases Based on Melody Segmentation
Total Page:16
File Type:pdf, Size:1020Kb
Journal of Information Processing Vol.27 278–286 (Mar. 2019) [DOI: 10.2197/ipsjjip.27.278] Regular Paper Melody2Vec: Distributed Representations of Melodic Phrases based on Melody Segmentation Tatsunori Hirai1,a) Shun Sawada2,b) Received: June 6, 2018, Accepted: December 4, 2018 Abstract: In this paper, we present melody2vec, an extension of the word2vec framework to melodies. To apply the word2vec framework to a melody, a definition of a word within a melody is required. We assume phrases within melodies to be words and acquire these words via melody segmentation applying rules for grouping musical notes called Grouping Preference Rules (GPR) in the Generative Theory of Tonal Music (GTTM). We employed a skip- gram representation to train our model using 10,853 melody tracks extracted from MIDI files primarily constructed from pop music. Experimental results show the effectiveness of our model in representing the semantic relatedness between melodic phrases. In addition, we propose a method to edit melodies by replacing melodic phrases within a musical piece based on the similarity of the phrase vectors. The naturalness of the resulting melody was evaluated via a user study and most participants who did not know the musical piece could not point out where the melody had been replaced. Keywords: melody processing, distributed representations, word2vec, melody retrieval might make it possible to quantitatively evaluate the quality of 1. Introduction melodies. Because melodies are essential elements of music, vec- Melody is one of the most significant elements in music. Sev- tor representations of melodies are worth pursuing for future de- eral methods for handling melodies using computers have been velopments in music information retrieval (MIR) research fields. proposed. These methods can be roughly divided into two cat- However, the extension of the word2vec framework to egories: symbolic processing approaches that directly handle melodies is not straightforward because the structures of a word melodies using notes and signal processing approaches that in- and a melody are not the same. To extend the approach, we must directly handle melodies using feature representations. While it first acquire a “word” within a melody. Because there is a cor- is difficult to directly handle melodies with signal processing, the respondence between GTTM and natural languages, we can use symbolic processing approach can focus on the melody itself. For it to acquire words in a melody. We assume melody phrases to example, the Generative Theory of Tonal Music (GTTM) [1] and be words and acquire them via melody segmentation using the the Implication-Realization Model (IRM) [2], [3] are well-studied Grouping Preference Rules (GPR) of GTTM. methods in this field. In particular, a melody tree structure can be In this paper, we propose a processing method to extend the obtained by applying GTTM to handle melodies in a form corre- word2vec framework to melodies including melody segmentation sponding to natural languages. using GPR. In addition, we evaluate our model melody2vec and Natural language processing (NLP) is one of the most success- discuss possible applications. ful fields in symbolic processing. Even though there are multiple studies that apply NLP approaches to music information process- 2. Related Work ing, the most successful method, called word2vec, cannot yet be Multiple approaches to handle music in the same framework as applied to handle melodies well. NLP have been proposed. GTTM is a fundamental theory for de- Word2vec is a model proposed by Mikolov et al. [4] that en- scribing the rules for melody generation, and many studies related ables words to be represented by a vector. It converts symbolic to GTTM have been proposed [6], [7]. GTTM enables melodies words into numerical vectors. A melody is a semantically com- to be symbolically analyzed by computer using a time-span tree. plex element; in fact, it used to be challenging to capture the intu- However, processing based on rules is not always successful be- itive and implicit similarity between melodies using conventional cause there are many exceptions in music. For example, conflicts similarity measures [5]. It might be possible to visualize the se- between rules occur with GTTM and the priority depends on the mantic relationship between melodies with a melody vector. This context. A method that enables more flexible processing accord- ing to the data is therefore required. 1 Faculty of Global Media Studies, Komazawa University, Setagaya, Word2vec is successful NLP framework that learns the rela- Tokyo 154–8525, Japan tionship between words and context from data [4]. Given large- 2 Future University Hakodate, Hakodate, Hokkaido 041–8655, Japan a) [email protected] scale data, the word2vec model learns word embedding for words b) [email protected] having a similar meaning or ways of being used via methods c 2019 Information Processing Society of Japan 278 Journal of Information Processing Vol.27 278–286 (Mar. 2019) called skip-gram and continuous bag-of-words (CBoW). These ciples. Of these methods, the effectiveness of GPR has been ver- methods are powerful for learning semantic relationships. If we ified via psychological experiments [18]. By employing GPR in can handle melodies using a similar framework, related NLP GTTM for melody segmentation, we can extend the word2vec methods developed by applying word2vec may be applicable to framework to a melody. music information processing. Several derived studies are applying the word2vec frame- 3. Dataset work or a similar idea to other domains [8], [9], [10]. Illustra- In a model using a neural network such as word2vec, the scale tion2vec [8] acquires vector representations of 2D illustrations of the training data greatly affects the model accuracy. The num- via CNN. It enables estimations of annotations to be predicted, ber of melodies is preferably as large as possible. In the original the retrieval of semantically similar illustrations, and a semantic word2vec paper by Mikolov et al. [4], the number of training data morphing algorithm for two given illustrations. The word2vec was 1.6 billion words. In this study, we use only music melodies framework has also been applied to the music domain. Mu- as training data. To prepare as much training data as possible, sic2vec [10] learns vectors of music by learning the context of lis- we used the 178,561 songs in the Lakh MIDI dataset [19]. As far tening to music pieces. The learned vector reflects a target user’s as the authors know, this dataset is the largest song dataset that preferences and is effective for music recommendation tasks. can be used to analyze melodies. The Lakh dataset is constructed Herremans et al. applied the word2vec framework to con- from MIDI files taken from the Internet. struct a semantic vector space model for capturing complex poly- If we can extract melodies from these MIDI data, we can eas- phonic musical contexts [11]. They extracted equal-length, non- ily prepare a large training data. Because the tracks are divided overlapping slices including onset information from a polyphonic into each part of the music, the MIDI file does not require prepro- musical piece and treated them as words. In this method, the cessing, such as music source separation which is necessary to length of a slice is fixed and is not long enough to capture the handle melodies within polyphonic audio data. However, accord- essence of a melody. Therefore, the model can only consider ing to Raffel et al. [20], there is no rule for specifying which of the the contextual information of short slices, which is not the direct tracks included in the MIDI file is the melody track. Therefore, modeling of a melody. A method to generate melodies using the we cannot explicitly extract the data of the melody tracks from LSTM model, which learns melodies assuming each note and its all the 178,561 MIDI files, especially in the case of MIDI files properties as a word has been proposed [12]. This method ex- “in the wild”. It might be possible to use a program number that presses the essence of a melody with a distributed representation. specifies the instrument for each track in a MIDI file to detect the However, it assumes that a musical note is a word, which is too melody track because many melody tracks are often played with limited in its variations compared to word vocabularies in natural certain instruments such as an acoustic piano or a synth voice. languages. Even though it may be possible to extract some melody tracks The biggest problem in applying the word2vec framework to using the program number, not all tracks played with those in- melodies is how to define a “word” within a melody. Musical struments are melody tracks. Therefore, using the program num- notes constituting a melody have elements such as a note name ber for melody track identification will result in adding noise to and a note value. It is possible to treat each of these elements as a the training data. Instead of using such an uncertain method, we letter in a word. In fact, there are description methods that express chose a method that can extract melody tracks with high probabil- a melody as a sentence by converting musical elements into let- ity. We chose two keywords (“melody” and “vocal”) and assumed ters (symbols), e.g., Music Macro Language (MML). Assuming that a track whose name included either of these two keywords that a note is a letter and a melody is a sentence, what kind of mu- as metadata was a melody track. As a result, we were able to ex- sical concept does a word correspond to? Bernstein insisted that tract melody tracks for 10,853 of the 178,561 songs in the dataset. a word in natural language corresponds to a phrase of music [13].