Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import random
- # import pyperclip
- # 0 1 2 3 4 5 6 7 8 9 10 11
- notes = ["G", "A", "H", "C", "D", "e", "f", "g", "a", "h", "c", "d"]
- virtual_piano = ["5", "6", "7", "8", "9", "0", "q", "w", "e", "r", "t", "y"]
- chords = [[[1, 3, 5, 8, 10], [0, 0]],
- [[2, 4, 6, 9, 11], [4, 6]],
- [[0, 3, 5, 7, 10], [5, 5]],
- [[4, 1, 11, 6, 8], [4, 6]],
- [[0, 2, 5, 7, 9], [0, 0]],
- [[1, 3, 6, 8, 10], [1, 3]],
- [[0, 2, 4, 7, 9, 11], [0, 0]]]
- def generate_note(current_note_index):
- note_index_delta = 0
- halt_flag = random.randint(0, 1)
- while halt_flag != 1:
- note_index_delta += 1
- halt_flag = random.randint(0, 1)
- sign_number = random.randint(0, 1)
- if sign_number == 0:
- test_note_index = current_note_index + note_index_delta
- else:
- test_note_index = current_note_index - note_index_delta
- return(test_note_index)
- def pick_chord():
- global first_launch_flag
- global chord_index
- if first_launch_flag == 1:
- first_launch_flag = 0
- else:
- chord_index = random.choice(chords[chord_index][1])
- return(chords[chord_index][0])
- break_flag=""
- while break_flag != "q":
- first_launch_flag = 1
- chord_index = random.randint(0, 6)
- current_note_index = random.randint(0, 11)
- to_clipboard = ""
- phrase = input("Enter the structure: ")
- words = phrase.split(" ")
- for word in words:
- syllables = list(word)
- for syllable in syllables:
- if syllables == "+":
- chord_notes = pick_chord()
- test_note_index = generate_note(current_note_index)
- while test_note_index < 0 or test_note_index > 11 or test_note_index not in chord_notes:
- test_note_index = generate_note(current_note_index)
- print(notes[test_note_index], end = "\t")
- to_clipboard += notes[test_note_index] + "\t"
- else:
- test_note_index = generate_note(current_note_index)
- while test_note_index < 0 or test_note_index > 11:
- test_note_index = generate_note(current_note_index)
- print(notes[test_note_index], end = "\t")
- to_clipboard += notes[test_note_index] + "\t"
- # pyperclip.copy(to_clipboard)
- print("")
- break_flag = input("?:")
Add Comment
Please, Sign In to add comment