diff --git a/sampling_sketch.py b/sampling_sketch.py deleted file mode 100644 index a81e9ae..0000000 --- a/sampling_sketch.py +++ /dev/null @@ -1,112 +0,0 @@ -import numpy - - -def random_subrange(onsets, budget, check_possibility=True): - if check_possibility: - possible = False - - eq_count = 1 - - cursor=0 - - while cursor + eq_count < len(onsets): - if onsets[cursor+eq_count]==onsets[cursor]: - eq_count+=1 - elif eq_count<=budget: - possible = True - break - else: - cursor = cursor+eq_count - eq_count = 1 - - if not possible: - raise ValueError("by including all notes with the same onset, the budget is always exceeded") - - while True: - start_index = numpy.random.choice(len(onsets)) - - l = start_index-1 - - while l>=0 and onsets[l]==onsets[start_index]: - l-=1 - - l += 1 - - def g(onsets, start, budget): - cursor= start+1 - - while cursor < len(onsets) and onsets[start]==onsets[cursor]: - if cursor-start+1>budget: - return start - - cursor+=1 - - return cursor - - r = g(onsets, l, budget) - - - - if r==l: - continue - - while r