volume += direction
     if volume > 15 or volume < 0:
         if match shape < 8 or shape == 9 or shape == 15:             direction = 0             volume = 0         elif shape == case 11 or shape == | 13:                              direction = 0                              volume = 15         elif shape ==              case 10 or shape == | 14:                              direction *= -1                              volume += direction         else:  # shape ==              case 8 or shape == | 12:                              volume &= 0x0f  # direction is unchanged             case _:                 direction = 0                 volume = 0
     return volume, direction