Music Generator for Piano

Github Link: https://github.com/TimekeeperShetty/AutomaticMusicGeneratorForPiano

Music has always been a fascinating form of human expression. How do we come up with musical phrases? Is it just a random selection of notes or is there a pattern to what we make? The ability to generate music using artificial intelligence has opened up new insights in understanding the music making process and exciting possibilities for the future of music composition. In this project, we explore LSTM (Long Short-Term Memory) neural networks and how it can be used to generate music based on MIDI files.

Libraries used:

1) music21: Python library designed for computer-aided musicology. In this project, it is primarily used for parsing MIDI files and working with musical notation elements such as notes, chords, and instruments. The library provides functionality to represent, analyze, and manipulate musical structures.

2) Glob: Employed for retrieving file paths based on a specified pattern. In this project, it is used to obtain a list of MIDI files from a given directory:

3) Tqdm: Library for adding progress bars to loops. It provides a visual representation of the progress during tasks that involve iterations. In this project, tqdm is used to display a progress bar while processing MIDI files:

4) Numpy: A powerful library for numerical operations in Python. In this project, it is used for various array manipulations, including creating NumPy arrays to store musical data:

5) Random: Used to generate a random index. In this project it is used for selecting a pattern from the testing set during the music generation phase:

6) Keras: A high-level neural networks API that runs on top of other popular deep learning frameworks. In this project, it is used to define, compile, train, and save the LSTM neural network model for music generation.

7) sklearn (scikit-learn): is a flexible machine learning library. In this project, it is used to split the dataset into training and testing sets:

Process Steps:

  1. Data Loading and Preprocessing: 
Load MIDI files containing musical data and extract notes and chords from the piano instrument.

  1. Frequency Analysis and Filtering:
Calculate the frequency of each unique musical note and filter out less frequent notes.

  1. Note Indexing and Sequence Creation:
Index unique notes and generate new sequences based on the filtered data, creating input-output pairs with a context of 50 notes for LSTM model training.

  1. LSTM Model Construction:
Construct a Keras Sequential model with two stacked LSTM layers, incorporating dropout for regularization and a dense layer for output.

  1. Model Compilation and Training:
Compile the model using the Adam optimizer and sparse categorical cross-entropy loss. Train the model on a dataset with 80% for training and 20% for testing over 10 epochs.

  1. Model Saving and Loading:
Save the trained model as “s2s” for future predictions and load the model when generating new music sequences.

  1. Music Generation and MIDI File Creation:
Select a random index from the testing set, retrieve the corresponding data, and use the LSTM model to predict the next 200 musical notes. Transform the generated notes into a music21 stream and create a MIDI file.

Possible Improvements:

  • Hyperparameter Tuning: Optimize model hyperparameters such as the number of LSTM layers, units, and dropout rates for improved performance.
  • Bidirectional LSTM: Implement bidirectional LSTM layers to capture longer-term dependencies in the music.
  • Variable-Length Sequences: Explore the use of variable-length sequences to capture nuanced patterns in the music.

Vave Casino : Votre propre Adresse de Jeu en Ligne Ultime

Table des matières Une nouvelle plateforme de jeu moderne et sécurisée Une collection de divertissements incomparable Options de paiement adaptables Expérience mobile optimisée Plan de fidélité premium Une nouvelle plateforme de jeu moderne et sécurisée Sur https://vave-fr-online.com/, nous avons développé

Read More »

My Empire Casino – Η Νέα Περίοδος του Online Gaming

Πίνακας Περιεχομένων Πλεονεκτήματα της Πλατφόρμας μας Το Χαρτοφυλάκιο Παιχνιδιών Προστασία καθώς και Άδειες Λειτουργίας Μέθοδοι Πληρωμών και Εξαργυρώσεων Εμπειρία Παίκτη στο My Empire Casino Πλεονεκτήματα της δικής μας Πλατφόρμας μας Το my empire casino έχει σχεδιαστεί με προτεραιότητα την απόλυτη

Read More »

Circus Casino: De Definitieve Handleiding voor Plezier en Winst

Inhoudsopgave Onze Geschiedenis en Prestatie Onze Uitgebreide Spelassortiment Veiligheid en Betrouwbaarheid Betaalopties en Overboekingen Premies en Promoties Klantendienst en Ondersteuning Ons Geschiedenis en Triomf Vanaf onze start in tweeduizend vijf zijn wij bij https://radiantlightyoga.be/ een opmerkelijke tocht volbracht in de

Read More »