asigalov61 commited on
Commit
83d6d2f
·
verified ·
1 Parent(s): 2ca80a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -78
app.py CHANGED
@@ -47,84 +47,6 @@ SOUDFONT_PATH = 'SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2'
47
 
48
  #==================================================================================
49
 
50
- def split_by_sublist(main_list, sublist):
51
-
52
- n = len(sublist)
53
- indices = []
54
- result = []
55
-
56
- # Find all starting indices where sublist matches main_list
57
- for i in range(len(main_list) - n + 1):
58
- if main_list[i:i + n] == sublist:
59
- indices.append(i)
60
-
61
- if not indices:
62
- # If the sublist is not found, return the entire main_list as one segment
63
- return [main_list]
64
-
65
- # Use the indices to split the main_list
66
- for idx, start_index in enumerate(indices):
67
- if idx < len(indices) - 1:
68
- # Slice from current sublist start to the next sublist start
69
- end_index = indices[idx + 1]
70
- segment = main_list[start_index:end_index]
71
- else:
72
- # For the last sublist occurrence, include the rest of the list
73
- segment = main_list[start_index:]
74
- result.append(segment)
75
-
76
- return result
77
-
78
- #==================================================================================
79
-
80
- def fuzzy_find(values, threshold=256):
81
- result = set()
82
- for i in range(len(values)):
83
- for j in range(i+1, len(values)):
84
- if abs(values[i] - values[j]) <= threshold:
85
- result.add(values[j])
86
- result.add(values[i])
87
- return sorted(result)
88
-
89
- #==================================================================================
90
-
91
- def kmp_search(main_list, sublist):
92
- if not sublist:
93
- return -1, -1 # Sublist is empty
94
-
95
- # Preprocess the sublist to get the longest prefix-suffix array
96
- lps = [0] * len(sublist)
97
- length = 0 # Length of the previous longest prefix suffix
98
- i = 1
99
- while i < len(sublist):
100
- if sublist[i] == sublist[length]:
101
- length += 1
102
- lps[i] = length
103
- i += 1
104
- else:
105
- if length != 0:
106
- length = lps[length - 1]
107
- else:
108
- lps[i] = 0
109
- i += 1
110
-
111
- # Start the search
112
- i = j = 0 # Index for main_list and sublist
113
- while i < len(main_list):
114
- if main_list[i] == sublist[j]:
115
- i += 1
116
- j += 1
117
- if j == len(sublist):
118
- start_index = i - j
119
- end_index = i - 1
120
- return start_index, end_index
121
- elif i < len(main_list) and main_list[i] != sublist[j]:
122
- if j != 0:
123
- j = lps[j - 1]
124
- else:
125
- i += 1
126
- return -1, -1 # Sublist not found
127
-
128
  #==================================================================================
129
 
130
  def load_midi(midi_file):
 
47
 
48
  #==================================================================================
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  #==================================================================================
51
 
52
  def load_midi(midi_file):