# -*- coding: utf-8 -*- """Los_Angeles_MIDI_Dataset_CHORDS_DATA_Decoder.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1HKcxhtWFX4zGE8ZxG59pzaWHDxnaxctR # Los Angeles MIDI Dataset CHORDS DATA Decoder (ver. 1.0) *** Powered by tegridy-tools: https://github.com/asigalov61/tegridy-tools *** #### Project Los Angeles #### Tegridy Code 2024 *** # (SETUP ENVIRONMENT) """ #@title Install all dependencies (run only once per session) !git clone https://github.com/asigalov61/tegridy-tools !pip install tqdm #@title Import all needed modules print('Loading core modules... Please wait...') import os import math import statistics import random from collections import Counter import shutil import hashlib from tqdm import tqdm print('Creating IO dirs...') if not os.path.exists('/content/CHORDS_DATA'): os.makedirs('/content/CHORDS_DATA') print('Loading TMIDIX module...') os.chdir('/content/tegridy-tools/tegridy-tools') import TMIDIX print('Done!') os.chdir('/content/') print('Enjoy! :)') """# (Load sample LAMDa CHORDS DATA file)""" chords_data = TMIDIX.Tegridy_Any_Pickle_File_Reader('/content/CHORDS_DATA/LAMDa_CHORDS_DATA_2500') print('Done!') """# (Decode to MIDI)""" data = random.choice(chords_data) file_name = data[0] song = data[1] song_f = [] time = 0 dur = 0 vel = 90 pitch = 0 channel = 0 patches = [-1] * 16 channels = [0] * 16 channels[9] = 1 for ss in song: time += ss[0] * 16 for i in range(0, len(ss[1:]), 4): s = ss[1:][i:i+4] dur = s[0] * 16 patch = s[1] if patch < 128: if patch not in patches: if 0 in channels: cha = channels.index(0) channels[cha] = 1 else: cha = 15 patches[cha] = patch channel = patches.index(patch) else: channel = patches.index(patch) if patch == 128: channel = 9 pitch = s[2] vel = s[3] song_f.append(['note', time, dur, channel, pitch, vel, patch ]) patches = [0 if x==-1 else x for x in patches] detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f, output_signature = file_name+'.mid', output_file_name = '/content/Los-Angeles-MIDI-Dataset-Composition', track_name='Project Los Angeles', list_of_MIDI_patches=patches ) """# Congrats! You did it! :)"""