Skip to content

athy125/musicgen_proj

Repository files navigation

AI Music Generator

This is a Deep Learning & Natural Language Processing model which can generate Piano Music

TABLE OF CONTENTS

  1. Introduction
  2. Dataset
  3. Music Theory
  4. Model
  5. Frameworks, Libraries & Languages
  6. Usage
  7. Acknowledgement

Introduction

Over time, the use of neural networks has grown gradually. Deep Learning has found applications in many domains of our everyday life, ranging from recommendation systems and customization to medical diagnostics and healthcare, with a plethora of papers produced each year. The use of these strategies for content production has lately gained popularity.
A similar principle may be used to train a neural network to make music, which has been popular in recent years. To produce piano music, I built a Long-Short Term Memory (LSTM) neural network in Python using Keras and Tensorflow.

Music Theory

Music is defined as "the art of mixing vocal or instrumental sounds (or both) to achieve beauty of form, harmony, and expression of emotion" by the Concise Oxford Dictionary. To put it simply, music is made up of one basic ingredient - the note. A note is simply the pitch of the music at that moment in time. Notes are a discretization of musical occurrences and are sometimes considered as the foundation of music.
Although pitch may be broadly understood to be connected with sound frequency, it is really more of an abstract quality that depends on the listener's perspective. It is frequently represented by capital letters: A, B, C, D, E, F, G. These letter names can also be changed by employing two accidentals: # (the shap symbol, which increases a note by one half-step) and (the flat sign, which lowers it by half-step).Each Note also has certain other characteristics namely - Offset (the length of time from the start of a piece when the note is played) and Duration (the time for which the note is held). If there are no periods of silence in the music and no occurrences of two notes being played together, then the offset of a note is effectively the sum of the previous durations.
In music, a chord is a group of numerous notes ("pitches") that sound at the same time. A piano often has multiple spans (or sets) of eight-white keys known as an Octave.

Model

Model Plot A plot of the model and its layers

Using the Keras Sequential API, we created an LSTM model that takes in fixed-length sequences of notes and learns to predict the next note in the series. Above is a visualisation of the model layers.

Frameworks, Libraries & Languages

  • Keras
  • Tensorflow
  • Numpy
  • Python3
  • timidity
  • pickle-mixin
  • glob
  • music21

Usage

  1. Install all dependencies
    pip install python3
    pip install numpy
    pip install tensorflow
    pip install keras
    pip install timidity
    pip install pickle-mixin
    pip install music21
  2. Clone the repository to your system and head over to it
    git clone https://github.com/athy125/musicgen_proj
    cd musicgen_proj
  3. To listen to a music file -
    cd songs
    timidity [filename]
    Replace [filename] with complete name of file you wish to listen
  4. To generate piano music from a random sequence from the songs/ directory
    python3 generate.py
    This will create a MIDI music file named "output.midi" in the same directory. To listen to this, type
    timidity output.midi

    This step can be repeated any number of times, and at each iteration a random music file will be generated

About

Music generation through LSTM

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published