occurrence = [] // Current occurrence, containing (onset, midi)
for line in input_file.readlines():
if "pattern" in line:
append_if_necessary(pattern, occurrence)
append_if_necessary(P, pattern)
occurrence = []
pattern = []
continue
After Change
// Add last occurrence and pattern to pattern_list
if occurrence != []:
pattern.append(occurrence)
if pattern != []:
pattern_list.append(pattern)
return pattern_list