MotifMax

Automated Music Composition using Motifs & Transformations

(A class project for CSCI575)

 

By - Anwar Hossain

Click here to go to my personal website

          anwar@bluehawk.biz

 

 

 

               

 

                    Introduction

                    Quick History

                    Components of MotifMax

                            Motif File Format

                                  Transformation Functions

                            Flexi-Rule Sets

                                  Evolution

                    Results

                    Limitations & Future Improvements

                    Conclusion

                    References

                    Tools Used

                    Source & Executables

 






Introduction:

There have been a lot of talks, dreams, and attempts to automate Music Composition process. Music composition is a creative process and thus we expect to see unexpected twist in it. Over history there have been different genres and sometimes few dominating ones. And those dominating ones controlled the shaping of what kind of composition will take place. In recent time, in the movies we see the ‘Motif-based’ or ‘Theme-based’ music have its own very powerful and interesting area. Composers working on this type of music starts with one or more than one motif (a small piece of music) and twists its different parameters to bring different moods in different parts of the movie. In my project, I basically attempted to automate this process in a simple, scalable framework. The system starts with some motifs and generates many more motifs based on different combination of transformations on the motifs. Then, a constrained selection process patches selected motifs together to make a bigger piece.

 

As another benefit, the system may also help us better understand the correlation between motifs and how some composers approaches to create different piece out of those.

 

 

A quick history of music:

 

Middle ages:

Around 500 A.D., western civilization began to emerge from the period known as "The Dark Ages" .For the next ten centuries, the newly emerging Christian Church would dominate Europe and among other things it would generally dicate the destiny of music. During this time, Pope Gregory I is generally believed to have collected and codified the music known as Gregorian Chant, which was the approved music of the Church. Much later, the University at Notre Dame in Paris saw the creation of a new kind of music called organum. Secular music was sung all over Europe by the troubadours and trouvčres of France.

.  While music composition is a creative process, it is not just random notes. There is this mysterious term ‘nice music’ which is difficult to formularize. But, again the history of music is very interesting and surely goes through lot of twists.

 

The Renaissance:

Generally considered to be from ca.1420 to 1600, the Renaissance  was a time of great cultural awakening  throughout Europe. With the rise of humanism, sacred music began for the first time to break free of the confines of the Church, and a school of composers trained in the Netherlands mastered the art of polyphony in their settings of sacred music.

 

The Baroque Age:

Named after the popular ornate architectural style of the time, the Baroque period (ca.1600 to 1750) saw composers beginning to rebel against the styles that were prevalent during the High Renaissance. Many monarchs employed composers at their courts, where they were little more than servants expected to churn out music for any desired occasions The greatest composer of the period, Johann Sebastian Bach, was such a servant. Yet the best composers of the time were able to break new musical ground, and in so doing succeeded in creating an entirely new style of music.

 

The Classical Period:

From roughly 1750 to 1820, musicians moved away from the heavily ornamented styles of the Baroque and the Rococo, and instead embraced a clean, uncluttered style they thought reminiscent of Classical Greece.

 

The Romantic Era:

As the many socio-political revolutions of the late eighteenth-century established new social orders and new ways of life and thought, so composers of the period broke new musical ground by adding a new emotional depth to the prevailing classical forms. Throughout the remainder of the nineteenth-century (from ca. 1820 to 1900), artists of all kinds became intent in expressing their subjective, personal emotions.

 

The Twentieth-Century:

By the turn of the century and for the next few decades, artists of all nationalities were searching for exciting and different modes of expression. Composers such as Arnold Schoenberg explored unusual and unorthodox harmonies and tonal schemes. In addition to new and eclectic styles of musical trends, the twentieth century boasts numerous composers whose harmonic and melodic styles an average listener can still easily appreciate and enjoy.

 

Components of the MotifMax System:

The system was developed in an object-oriented fashion. Each motif was designated as an object or class. Each motif class also had a number of transformation methods. The motifs are fed from an easily updateable text file containing motif information. For the experiment I used the following motif file “MotifB.txt” –

StartMotif------

480 E 3 100

480 C 4 110

200 B 3 120

100 A 3 127

EndMotif-------

 

StartMotif------

480 E 3 100

240 G 3 128

240 A 3 128

240 B 3 110

480 E 3 110

EndMotif-------

 

StartMotif------

480 F 3 100

480 A 3 128

480 D 4 128

480 F 3 110

EndMotif-------

 

StartMotif------

480 A 3 100

480 C 4 128

480 E 4 128

480 B 3 110

EndMotif-------

 

StartMotif------

550 G 4 100

550 E 4 128

550 D 4 128

550 C 4 128

550 B 3 110

550 C 4 128

550 D 4 128

550 E 4 128

550 F 4 128

EndMotif-------

 

END

 

 

Motif File Format:

The above example file has 5 motifs. Each motif data is surrounded by the 2 tags StartMotif------  and EndMotif------- . The file ends with the tag END. In each motif there are 4 columns and they are (from left to right)–

- Note Length (e.g.  480)

- Note Name (e.g. E)

- Note Octave (e.g. 3)

- Note Volume (e.g. 100)

 

 

Transformation Functions:

Transformation function is the main playground for changing a motif to a different variation of it which sometimes can be as simple as shifting pitch or changing scale or it could be as interesting as changing different note duration and inversion. In the current version of the system only a cut-down version of these functions have been implemented –

 

Shifting Pitch:

This is a very common practice in music. Now, in some literature and situations especially in vocal music, the pitch shifting is done by time stretching. But in the MotifMax system we do not deal with voice data rather we have known pitch class. So basically we shift pitch the way someone would do in piano. This transformation functions takes “Offset” as a parameter which can be either a positive or negative integer. All the notes in the motif are shifted by notes specified by Offset parameter. So, if a note in the motif were, C3, then the pitch will be E3 after shifting if the offset is +2, and it will be B2 if the offset is -1. By using the offset parameter 7, a whole scale shift can occur.

 

 

Scale Time:

This is another common technique in music. This function basically means changing the tempo of the music. The system allows limited range for this change to keep the generated motif not so unrealistically fast or slow. The function takes “Factor” as a parameter. If the factor is more than 1, then the time is scaled up and the tempo becomes slower. If the factor is less than 1, then the scale is timed down making the tempo faster. This could bring the excited, sad etc mood in a piece of motif.

 

Change Volume:

The transformation function is self explanatory from its name. The volume of all the notes in a motif is changed by some positive or negative offset. This could indicate highetended tension or mood if the volume is increased.

 

Inverse:

This transformation is the one which is not obvious to detect. The notes and related information are just reversed. So, the very first note in a motif becomes the very last note and versa. The very first motif in our experimental file is -

StartMotif------

480 E 3 100

480 C 4 110

200 B 3 120

100 A 3 127

EndMotif-------

 

After inverse, it becomes –

StartMotif------

100 A 3 127

200 B 3 120

480 C 4 110

480 E 3 100

EndMotif-------

 

Flexi-Rule set:

This phase of the system is more of a control block. This part decides whether a motif (including the newly generated ones by transformation) should be selected or not and if yes, in which location it should be selected. This phase also takes a parameter “IterationCount” as input. The music generation process stops when the number of motifs in the generated piece becomes same as “IterationCount”.

 

These rules or constrained determine whether a music piece is a rigid one or atonal. In this aspect, we can refer to the paper “Music Generation from Statistical Models” by Darrell Conklin. In that paper the author mentions several approaches for music generation by computer. One of them was Statistical Modeling technique. These models can classify whether a music is of certain genre or by certain composers. Then the author proposes – using random walk or stochastic sampling or some other sampling methods pieces (in our case motifs) can be chosen. Whether the motif will be retained or not can be decided by the model based on whether that generated piece is classify as right for intended music type.

 

In my implementation I wanted to take a little bit different approach. I wanted to use “Evolution”.

 

Evolution:

This feature is yet to implement in the project. But this is the part which is supposed to take care of the basic question we discussed in the introduction of so called “nice music”. To implement this, the first thing we need is “Fitness” function to quantify the how nice a piece of music is. The function will give a score for a piece of music based on its rhythm and melody structure.

We would use Genetic Algorithm for the evolution. So, in brief the steps for the music composition would be as follows –

 

1.    Create your kernel or seed motifs in the text file

2.    Apply different transformations in different combinations to create lot of other motifs from the kernels

3.    Select a motif based on the Flexi rule sets from the pool of motifs and add it to the already generated piece.

4.    Repeat steps 3 several times to get intended length for piece of music

5.    Repeat steps 3 & 4 to create multiple piece which will be used as the base population for the evolution process

6.    Define a fitness function to quantify how nice a piece is

7.    Select 2 pieces of music from the base population

8.    Do some random transformation on them, and possibly cross over and generate new pieces and add it to the base population

9.    Apply the fitness function and score all pieces in the population

10.           Remove the piece with the smallest score

11.           Repeat 7 to 10 until no pieces gets removed or certain iteration number is reached.

12.           These will end up in results having several pieces of nice music

 

Results:

Some sample output is added below. Click on the link to download the midi files and play it.

Sample Music 1

Sample Music 2

Sample Music 3

Sample Music 4

Sample Music 5

 

 

Limitation & Future Improvement:

The number of transformation functions implemented needs to be enhanced. Multi-track music is not track-synchronization at this point. Evolution method needs to be added.

 

Conclusion:

Since the evolution is yet to implement, at this point, we basically run the program, generate music, keep the one we like and discard the others. Even though this process may sound a bit manual, but we surely can think of application of it. When we are trying to compose music using some motifs, this program can play around those motifs in lot of different ways and might play something that we otherwise would not think about and may like it. Since the system automatically saves the music in Midi file and also gives text version of the midi, so it is also easy to go back and change some places if we need to tweak a little what the system gave us.

 

Reference:

  1. Darrel Conklin. "Music Generation from Statistical Models." AISB 2003 Symposium on AI and Creativity in the Arts and Sciences
  2. “CONTENTS of Music History 102”, http://www.ipl.org/div/mushist/

 

Tools used:

-         Visual Studio C++

-         Txt2Midi by Guenter Nagler

 

Source & Executables:

Download Source.

Download Executables.








 

The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees