https://github.com/platers/songpong
Synchronizing pong to music
https://github.com/platers/songpong
constrained-optimization convex-optimization cvxpy music-visualizer pong
Last synced: about 2 months ago
JSON representation
Synchronizing pong to music
- Host: GitHub
- URL: https://github.com/platers/songpong
- Owner: platers
- License: mit
- Created: 2024-08-27T00:53:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-02T23:13:47.000Z (about 1 year ago)
- Last Synced: 2024-12-12T18:23:48.118Z (10 months ago)
- Topics: constrained-optimization, convex-optimization, cvxpy, music-visualizer, pong
- Language: Python
- Homepage:
- Size: 55.7 KB
- Stars: 59
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Song Pong
[https://www.youtube.com/watch?v=V0AXprDRsUU](https://www.youtube.com/watch?v=lxjElOAgkPg)
[Blog Post](https://victortao.substack.com/p/song-pong)

This is a version of Pong that synchronizes the bounces with a song. You are free to use this code for any purpose, I only ask that you link back to this repo.
## Basic Usage
1. Install the required dependencies:
```
pip install pygame numpy cvxpy mido
```Alternatively, you can use `uv` to install the dependencies:
```
pip install uv
```2. Run the game with a MIDI file:
```
curl -o example_midi.mid https://bitmidi.com/uploads/72257.mid # download a MIDI file
python pong.py example_midi.mid
```Or using `uv run`:
```
uv run pong.py example_midi.mid
```3. For non-MIDI audio files, you need to provide a JSON file with note timings:
```
python pong.py path/to/your/audio_file.mp3 --times_file path/to/your/times.json
```Or using `uv run`:
```
uv run pong.py path/to/your/audio_file.mp3 --times_file path/to/your/times.json
```The JSON file should contain a list of times (in seconds) when the ball should hit a paddle.