Created
April 21, 2025 21:29
-
-
Save NAEL2XD/13fe5e3a334caeb9695de3660de7fba6 to your computer and use it in GitHub Desktop.
MIDI Creation: Generates a MIDI with sorts of settings you can choose.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Randomly Generates a MIDI for you and you can set it up! | |
| It's very simple and easy to do! | |
| REQUIRES TQDM AND PRETTY_MIDI: pip install tqdm, pretty_midi | |
| """ | |
| from pretty_midi import PrettyMIDI, Instrument, Note | |
| from random import randint | |
| from tqdm import tqdm | |
| bpm = input("What bpm do you wanna use: ") | |
| bpm = int(bpm) | |
| notes = input("How many Notes: ") | |
| notes = int(notes) | |
| speed = input("Speed of the Notes: ") | |
| speed = int(speed) | |
| bandlab = input("Support for Bandlab BYCMACS? [y/n]: ") == "y" | |
| midi = PrettyMIDI(resolution=32767, initial_tempo=bpm) | |
| instrument1 = Instrument(program=0) | |
| for i in tqdm(range(notes)): | |
| time = (i/speed)/(bpm/60) | |
| end = time+(60/(bpm*speed)) | |
| instrument1.notes.append(Note(127, randint(0, 127) if not bandlab else randint(36, 51), time, end)) | |
| # print(f"Time: {time} | End: {end}") | |
| midi.instruments.append(instrument1) | |
| midi.write("midi_gen.mid" if not bandlab else "bandlab_support.mid") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment