Skip to content

Instantly share code, notes, and snippets.

@jedberg
Created June 13, 2020 22:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedberg/37e9680806bc517925daeaae4798eb9e to your computer and use it in GitHub Desktop.
Save jedberg/37e9680806bc517925daeaae4798eb9e to your computer and use it in GitHub Desktop.
Make a random music URL
#!/usr/bin/env python
import random
import sys
base_url="https://music-grid.surge.sh/#"
def make_notes(rows=10):
notes_string = ""
# for each row...
for i in range(rows):
# build a list of all possible values for a row
# seperated out so you can add bias if desired
note_choices = range(2049)
# make a series of random notes
notes_string = notes_string + str(random.choice(note_choices)) + "-"
return notes_string
def make_url(rows=10, beats="200"):
return base_url + make_notes(rows) + "&" + beats
if __name__ == "__main__":
rows=10
beats="200"
if len(sys.argv) > 1:
rows = int(sys.argv[1])
if len(sys.argv) > 2:
beats = str(sys.argv[2])
print(make_url(rows=rows, beats=beats))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment