Code Monkey home page Code Monkey logo

generating-music's Introduction

Artificial Composition of Multi-Instrumental Polyphonic Music

We have tried to create a generative model capable of composing polyphonic music. Contrary to other work in the same field, our goal was to generate music with multiple instruments playing simultaneously to cover a broader musical space.

We train three modules based on LSTM neural networks as the generative model; a lot of effort is put into reducing high complexity of multi-instrumental music representation by a thorough musical analysis.

YOUTUBE_SAMPLE

 

Musical Analysis

We need to reduce the complexity of input MIDI data without significant compromises on the possible musical expression. Training a neural network without this reduction would be impossible for current state-of-the-art neural architectures because the space of raw MIDI files is too large. The analysis consists of three main procesures:

Meter detection

Capturing the rhythmic structure correctly is difficult, as the rhythm is dependent on time which is inherently continuous. To discretize the time with as low loss of information as possible, we have to find the underlying metrical structure and normalize the tempo according to it.

Key detection

When considering the most usual major and minor modes, there are 24 different keys in total. A single pitch has a different role in each of these keys, which adds a lot of complexity that a prediction model should learn. Hence, we classify the keys (using a random forest model) and then transpose them to a unified key.

Chord sequences detection

We use the harmonic structure as a representation of music at a higher abstract level (than simple notes) to prolong the scope of the LSTM generative model. Therefore we try to estimate the chord progressions with a help of the detected meter and key.

 

Generative Model

The generative model consists of three modules: Chord Predictor, Note Predictor and Volume Predictor.

Illustration of the generative model

Chord Predictor is used to generate the underlying chords, one chord per beat. It is trained on data obtained from the chord detector. The most important module is Note Predictor, which generates events – either note-ons, note-offs or shifts in time. The Note Predictor accepts a chord obtained from the Chord Predictor and the last event to generate a new event. If the event constitutes a start of a new note, then the Volume Predictor is used to assign a volume to that note. Each module processes information in a sequential manner – it predicts a new state based on all of the previous states. Hence we use an LSTM network as the base of each module.

Illustration of Note Predictor architecture

 

Conclusion

In order to evaluate the performance of the proposed model, we have conducted an online survey. The results show that there is still space for enhancement, but overall the artificial music was rated almost as good as the real music and was rather hard to distinguish (with 62.6% accuracy).

We hope the thesis shows that it is indeed possible to let computers compose music. Although the output is not perfect and is limited to a symbolic representation, it can create listenable compositions that are hard to distinguish from human-made music.

Surcey ratings

 

Overview of the Repository

The repository is divided into four different folders that are briefly described below. More details can be found in readme files contained in each of them.

GUI application used for analysis, conversion and visualization of .mid and internal .mus files. Please note that the GUI front-end is a side project, not an explicit part of the bachelor thesis, but it contains all algorithms described in Chapter 5 about music analysis. We use it for an easier and more intuitive evaluation of the algorithms.

Source files for the generative model implemented in PyTorch (deep learning library for python). It also contains already trained models that can be used to generate new music.

Sample files outputed from the models contained in the Generative Model folder. The folder contains both good and bad sounding examples that should illustrate the overall behaviour of the generative model.

Files related to the online questionaire. Contains the 104 audio files used in the questionaire and also a table with all answers from 293 users.

Single-page version of the bachelor thesis.

 

BibTeX Citation

@thesis{SAMUEL18,
  author    = {David Samuel},
  title     = {Artificial Composition of Multi-Instrumental Polyphonic Music},
  year      = {2018},
  type      = {Bachelor's Thesis},
  publisher = {Univerzita Karlova, Matematicko-fyzik{\'a}ln{\'\i} fakulta},
  url       = {https://is.cuni.cz/webapps/zzp/detail/194043/},
}

generating-music's People

Contributors

davda54 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

generating-music's Issues

FileExistsError: ../Primers/ does not exist or is not

E:\Users\Raytine\Anaconda3\python.exe "F:/music/generating-music-master/Generative Model/Chord_Predictor/chord_generate.py"
WARNING: You have a CUDA device, so you should probably run with --cuda True
E:\Users\Raytine\Anaconda3\lib\site-packages\torch\serialization.py:367: SourceChangeWarning: source code of class 'torch.nn.modules.dropout.Dropout' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
E:\Users\Raytine\Anaconda3\lib\site-packages\torch\serialization.py:367: SourceChangeWarning: source code of class 'torch.nn.modules.sparse.Embedding' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
E:\Users\Raytine\Anaconda3\lib\site-packages\torch\serialization.py:367: SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File "F:/music/generating-music-master/Generative Model/Chord_Predictor/chord_generate.py", line 84, in
output = generate_chords(args.model, args.primer, args.cuda, args.priming_length, args.length, args.temperature, args.n_primes)
File "F:/music/generating-music-master/Generative Model/Chord_Predictor/chord_generate.py", line 10, in generate_chords
loader = Loader("../Primers/" + primer)
File "..\utils.py", line 69, in init
if not file.is_file(): raise FileExistsError(self.filename + " does not exist or is not a file, please add a valid training and validation file, or priming song to the parameters")
FileExistsError: ../Primers/ does not exist or is not a file, please add a valid training and validation file, or priming song to the parameters

Process finished with exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.