Random Melody Issues and too many declared variables

I decided to do a version of Giant Steps with a randomized solo, (thanks Marc E. for the random melody code)! I found that the melody works well, but at times, the pitch level of the solo drops to zero or near zero. Not sure why it is happening, curious if any of you see a solution. Also, I had to move the list of chords to another file, when I tried to run in the same file as the rest of the code, Thonny slowed down. Is this normal?

from scamp import *
from scamp_extensions.pitch import Scale
"""imports list of tuples which contain pitch values and durations"""
import Giantsteps_chord_duration_lst as gcd
import random


s = Session()

s.tempo = 240

saxophone = s.new_part("saxophone")
piano = s.new_part("piano")

scale = Scale.chromatic(60)

current_scale_degree = 5

MIN_DEGREE = 5
MAX_DEGREE = 12

"""sets rhythms possible based on max duration"""
lst_rhythms = [[.5, .5, .5, .5, 1, 1], [1, .5, 1, 1, 1, .5, 2, .5, .5], [.5, .5, .5, 2.5],[.5, .5, 1, 1, 1, 1, .25, .5, .25, 2], [.5, 7.5], [2, 2, 2, 1.5, 4.5], [1.5, 1.5, .5],[.25, .25, .25, .25, .25, .25, .25, .25, .25, .25, .25, .25]]
half_note_rhythms = [[.5, .5, .5, .5], [1, .5, .5, 1], [1.5, .5], [1, .5, .5] ]
dotted_quarter_rhythms = [[.5, .5, .5], [1, .5,], [.5, 1], [1, 1], [1.5]]
eighth_note_rhythms = [[.5]]         
whole_tied_eighth_rhythms = [[4.5], [1, 1, 1, .5, .5, .5,],[1, 2, 1.5],]
quarter_note_rhythms = [[.5, .5]]

"""used to generate list of tuples"""
# def lst_mkr_chord_duration(chords, durations):
#     chord_duration_lst = []
#     for i in range(len(chords)):
#         combined_tuple = (chords[i], durations[i])
#         chord_duration_lst.append(combined_tuple)
#         
#     return chord_duration_lst

                    

def get_scale_from_chord_notes(chord_notes, duration):
    import math
    scale_notes = []
    
    """my addition, may or may not be useful"""
    if chord_notes == [0,0,0]:
        wait(duration) 
    
    """Mark Evanstein code for establishing a scale based on a chord"""
    octaves_spanned = math.ceil((max(chord_notes) - min(chord_notes)) / 12)
    
    if chord_notes[0] + 12 * octaves_spanned not in chord_notes:
        chord_notes = chord_notes + [chord_notes[0] + 12 * octaves_spanned]
    
    for i in range(len(chord_notes)):
        scale_notes.append(chord_notes[i])
        if i + 1 < len(chord_notes) and chord_notes[i + 1] - chord_notes[i] > 2:
            scale_notes.append(math.ceil((chord_notes[i + 1] + chord_notes[i]) / 2))
    
    return Scale.from_pitches(scale_notes)
        
"""function that takes a chord and maximum duration
and produces a random melody based on that chord"""
def random_melody(chord, maximum_duration, duration):
    current_scale_degree = 0
    
    if chord == [0,0,0]:
        wait(duration)
        

    if maximum_duration == half_note_rhythms:

        for dur in random.choice(half_note_rhythms):
            scale = get_scale_from_chord_notes(chord, duration)
            saxophone.play_note(scale.degree_to_pitch(current_scale_degree), .5, dur)
            current_scale_degree += random.choice([-1, 1, 1, -2, 2])
            maintain_range(current_scale_degree)
            
    if maximum_duration == dotted_quarter_rhythms:

        for dur in random.choice(dotted_quarter_rhythms):
            scale = get_scale_from_chord_notes(chord, duration)
            saxophone.play_note(scale.degree_to_pitch(current_scale_degree), .5, dur)
            current_scale_degree += random.choice([-1, 1, 1, -2, 2])
            maintain_range(current_scale_degree)
            
    if maximum_duration == eighth_note_rhythms:

        for dur in random.choice(eighth_note_rhythms):
            scale = get_scale_from_chord_notes(chord, duration)
            saxophone.play_note(scale.degree_to_pitch(current_scale_degree), .5, dur)
            current_scale_degree += random.choice([-1, 1, 1, -2, 2])
            maintain_range(current_scale_degree)
            
    if maximum_duration == whole_tied_eighth_rhythms:

        for dur in random.choice(whole_tied_eighth_rhythms):
            scale = get_scale_from_chord_notes(chord, duration)
            saxophone.play_note(scale.degree_to_pitch(current_scale_degree), .5, dur)
            current_scale_degree += random.choice([-1, 1, 1, -2, 2])
            maintain_range(current_scale_degree)
   

"""print list of tuples of chords and durations"""
#print(lst_mkr_chord_duration(chords, durations))

"""converts variable into a int"""
def check_maximum_rhythm(chord_duration):
    
    if chord_duration == 2:
        return half_note_rhythms
    elif chord_duration == 1.5:
        return dotted_quarter_rhythms
    elif chord_duration == 4.5:
        return whole_tied_eighth_rhythms
    elif chord_duration == .5:
        return eighth_note_rhythms
    elif chord_duration == 1:
        return quarter_note_rhythms
    else:
        print("Error: rhythm duration outside of Giant Steps values")

def maintain_range(current_scale_degree):
    
    if current_scale_degree > MAX_DEGREE:
        current_scale_degree -= 6
    elif current_scale_degree < MIN_DEGREE:
        current_scale_degree += 6
        
"""program loop"""      
while True:

    for i in gcd.chord_duration_lst:
        fork(random_melody, args=(i[0], check_maximum_rhythm(i[1]), i[1]))
        piano.play_chord(i[0], .2, i[1])
        
    break

"""imported above with a different file name"""      
chord_duration_lst = [([47, 58, 66, 70, 75, 78], 2), ([50, 54, 60, 64, 66, 71, 74], 2), ([43, 50, 52, 62, 66, 71], 2), ([46, 56, 62, 67], 1.5), ([46, 55, 62, 63, 70], 4.5), ([45, 55, 60, 64, 67, 71], 1.5), ([50, 60, 63, 66, 69], 1.5), ([0, 0, 0], 1), ([43, 50, 52, 62, 66, 71, 74], 2), ([46, 56, 62, 67, 70], 2), ([39, 46, 55, 62, 67], 2), ([42, 52, 56, 58, 63], 1.5), ([47, 57, 61, 63, 66], 4.5), ([41, 56, 60, 63, 67], 2), ([46, 56, 68, 72, 74, 77], 1.5), ([46, 55, 62, 63, 70], 4.5), ([45, 55, 60, 64, 67, 71], 2), ([50, 60, 64, 66, 69], 1.5), ([43, 50, 59, 62, 66, 71, 74], 4.5), ([49, 59, 64, 68, 71, 75], 2), ([54, 64, 67, 70, 73], 1.5), ([47, 58, 68, 70, 73, 78], 4.5), ([41, 56, 68, 72, 75, 79], 2), ([46, 56, 68, 72, 74, 77], 1.5), ([39, 46, 74, 75, 79, 82], 4.5), ([49, 59, 68, 71, 75, 78], 1.5), ([42, 58, 68, 70, 75, 78], 0.5), ([0, 0, 0], 2), ([47, 58, 66, 70, 75, 78], 2), ([50, 54, 60, 64, 66, 71, 74], 2), ([43, 50, 52, 62, 66, 71], 2), ([46, 56, 62, 67], 1.5), ([46, 55, 62, 63, 70], 4.5), ([45, 55, 60, 64, 67, 71], 1.5), ([50, 60, 64, 66, 69], 1.5), ([43, 50, 59, 62, 66, 71, 74], 3), ([46, 56, 62, 67, 70], 2), ([39, 46, 55, 62, 67], 2), ([42, 52, 56, 58, 63], 1.5), ([47, 57, 61, 63, 66], 4.5), ([41, 56, 60, 63, 67], 2), ([46, 56, 68, 72, 74, 77], 1.5), ([46, 55, 62, 63, 70], 4.5), ([45, 55, 60, 64, 67, 71], 2), ([50, 60, 64, 66, 69], 1.5), ([62, 66, 71, 64], 4.5), ([49, 59, 64, 68, 71, 75], 2), ([54, 64, 68, 70, 73], 1.5), ([47, 58, 68, 70, 73, 78], 4.5), ([41, 56, 68, 72, 75, 79], 2), ([46, 56, 68, 72, 74, 77], 1.5), ([39, 46, 74, 75, 79, 82], 4.5), ([49, 59, 68, 71, 75, 78], 1.5), ([42, 58, 68, 70, 75, 78], 0.5), ([0, 0, 0], 2)]