8000 GitHub - pengx17/latency-test: generated by Sonnet 4 + Gemini 2.5 Pro
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pengx17/latency-test

Repository files navigation

Headphone Rhythmic Latency Test App

A Godot-based application for testing audio latency by synchronizing key presses with a rhythmic beat.

image

Overview

This application helps you measure your ability to synchronize with a consistent audio beat, providing an indication of the overall latency you experience with your audio setup (headphones, sound card, system processing) and your own reaction time.

It plays a click sound at a user-configurable Beats Per Minute (BPM) and measures the time difference between your key presses (spacebar) and the nearest click sound.

Features

  • Rhythmic Testing: Plays continuous clicks at a specified BPM (default 120).
  • User Synchronization: You press any letter key (A-Z) in time with the beeps.
  • Rolling Average Latency: Calculates and displays the average latency of your last 15 clicks.
  • Real-time Feedback: Shows the latency of your most recent click relative to the beat.
  • Adjustable BPM: The BPM can be changed in the Godot editor inspector for the Main node.
  • Results Export: Save the series of recorded latencies to a text file.

How to Use

  1. Open in Godot: Open this project in the Godot Engine (version 4.x recommended).
  2. Run the Main Scene: Run the Main.tscn scene.
  3. (Optional) Adjust BPM:
    • Select the Main node in the scene tree.
    • In the Inspector panel, you can change the Bpm property.
    • Restart the scene if you change the BPM while it's running for it to take full effect (or stop and start the metronome).
  4. Start the Metronome: Click the "Start Metronome" button.
  5. Synchronize: Listen to the clicks and press any letter key (A-Z) in time with the rhythm.
  6. Observe Latency:
    • The "Avg. Latency" display shows the average difference between your presses and the beeps over the last 15 clicks.
    • The "Last click" display shows the latency of your most recent press. A positive value means you pressed after the beep, a negative value means you pressed before.
  7. Stop the Metronome: Click "Stop Metronome" to pause the test.
  8. Clear History: Click "Clear History" to reset the recorded latencies.
  9. Save Results:
    • After stopping the metronome (or while it's stopped), if you have recorded some latencies, you can click "Save Results".
    • This saves the list of individual latencies from the current session to a file named rhythmic_latency_results.txt in your Godot project's user:// directory (e.g., C:/Users/YourUser/AppData/Roaming/Godot/app_userdata/YourProjectName).

Interpreting Results

  • Average Latency: This gives you a general idea of how consistently early or late you are pressing the key relative to the beat. A value close to 0 ms is ideal, indicating good synchronization.
  • Individual Click Latency ("Last click"):
    • Positive values: You pressed after the beep.
    • Negative values: You pressed before the beep.
    • This can help you understand if you have a tendency to lead or follow the beat.
  • Consistency: Look at the spread of your individual latencies (which you can see in the saved file). Small variations mean you are more consistent.

Low and consistent latency values generally indicate a good audio setup and/or good rhythmic accuracy. High or inconsistent values might point to issues with audio drivers, Bluetooth latency, system load, or simply needing more practice with the rhythm.

Files

  • Main.tscn: The main scene for the application.
  • Main.gd: The core script handling the test logic, audio playback, and UI.
  • project.godot: The Godot project file.
  • README.md: This file.
  • generate_click.gd: A utility script (not run directly by the app) that was used to conceptualize click generation. It's not essential for the app's runtime but shows how the click sound is structured. (Consider removing or clarifying its role if it's confusing).

Troubleshooting / Notes

  • Ensure your system audio is working correctly.
  • For best results, use wired headphones to minimize Bluetooth latency.
  • Other applications running in the background might affect system performance and audio latency.
  • The MAX_BEEP_HISTORY constant in Main.gd determines how many past beeps are stored to find the "closest" beep to your key press. This helps account for slightly early or late presses.

Project Structure

latency-test/
├── Main.tscn          # Main scene with UI layout
├── Main.gd            # Core application logic
├── generate_click.gd  # Tool script for audio generation (optional)
├── project.godot      # Godot project configuration
└── README.md          # This file

Requirements

  • Godot 4.4 or later
  • Audio output device (headphones recommended)
  • Keyboard for letter key input (A-Z)

Building and Running

  1. Open the project in Godot Engine
  2. Press F5 or click "Play" to run the application
  3. The main scene should load automatically

Customization

You can modify the following parameters in Main.gd:

  • total_tests: Number of tests to run (default: 10)
  • frequency: Click sound frequency in Hz (default: 2000)
  • duration: Click sound duration in seconds (default: 0.05)
  • Timer ranges for random intervals between tests

Contributing

Feel free to submit issues, feature requests, or improvements to this latency testing application.

License

This project is open source and available under the MIT License.

About

generated by Sonnet 4 + Gemini 2.5 Pro

Resources

Stars

Watchers

Forks

Packages

No packages published
0