"""Populate the chime_index list with the initial note then add the
additional adjacent notes."""
chime_index = []
chime_index.append(random.randrange(len(chime.scale)))

direction = random.choice((-1, 1))
for count in range(1, len(chime.scale) // 2):
    chime_index.append((chime_index[count - 1] + direction) % len(chime.scale))

"""Randomly select the number of notes to play in the sequence."""
notes_to_play = random.randrange(len(chime_index) + 1)

"""Play the note sequence with a random delay between each."""
note_amplitude = map_range(corr_wifi.wind_speed, 0, 50, 0.4, 1.0)
for count in range(notes_to_play):
    chime.strike(chime.scale[chime_index[count]], note_amplitude)
    time.sleep(
        random.randrange(10, 60) * 0.01
    )  # random delay of 0.10 to 0.50 seconds

"""Delay the next note sequence inversely based on wind speed plus a
random interval."""
if corr_wifi.wind_speed < 1:
    time.sleep(30)
else:
    time.sleep(
        map_range(corr_wifi.wind_speed, 0, 50, 2.0, 0.01) + (random.random() / 2)
    )