def analyze_f0_file(file_path, context_frames=10):
    """
    Analyze F0 file to find max/min values and their surrounding context
    
    Args:
        file_path: Path to the F0 text file
        context_frames: Number of frames to show before and after max/min points
    """
    # Read F0 values
    with open(file_path, 'r') as f:
        f0_values = np.array([float(line.strip()) for line in f if line.strip()])
    
    # Find indices of max and min values
    max_idx = np.argmax(f0_values)
    min_idx = np.argmin(f0_values)
    
    # Convert to MIDI notes for reference
    max_midi = freq_to_midi(f0_values[max_idx])
    min_midi = freq_to_midi(f0_values[min_idx])
    
    # Get context windows
    def get_context(idx):
        start = max(0, idx - context_frames)
        end = min(len(f0_values), idx + context_frames + 1)
        return f0_values[start:end], start
    
    max_context, max_start = get_context(max_idx)
    min_context, min_start = get_context(min_idx)
    
    print(f"\nAnalysis for {file_path}:")
    print("-" * 50)
    print(f"Maximum F0: {f0_values[max_idx]:.2f} Hz ({get_note_name(int(round(max_midi)))}) at frame {max_idx}")
    print(f"Minimum F0: {f0_values[min_idx]:.2f} Hz ({get_note_name(int(round(min_midi)))}) at frame {min_idx}")
    
    print("\nContext around maximum:")
    for i, val in enumerate(max_context):
        frame_idx = max_start + i
        marker = " >> " if frame_idx == max_idx else "    "
        print(f"{marker}Frame {frame_idx}: {val:.2f} Hz")
    
    print("\nContext around minimum:")
    for i, val in enumerate(min_context):
        frame_idx = min_start + i
        marker = " >> " if frame_idx == min_idx else "    "
        print(f"{marker}Frame {frame_idx}: {val:.2f} Hz")

    Analyze F0 file to find max/min values and their surrounding context
    
    Args:
        file_path: Path to the F0 text file
        context_frames: Number of frames to show before and after max/min points
    
evals/pitch_range/raw_pitch_extracted_combined/analyze_f0.py