AI-powered mixtape creator that turns a directory of music files into a flowing track sequence, suitable for a personal mixtape. Using advanced audio analysis and machine learning, it arranges tracks based on musical characteristics like tempo, key, energy, and rhythm to create flowing mixtapes.
- π΅ Audio Analysis: Extracts tempo, key, energy, brightness, and rhythm complexity from MP3, FLAC, WAV, M4A, and OGG files
- π― Smart Ordering: Uses weighted transition scoring to create optimal track sequences
- π¨ AI Artwork: Generate album artwork using OpenAI DALL-E based on musical analysis
- π Multi-CD Support: Automatically splits large collections across multiple CDs with natural break points
- π·οΈ Metadata Management: Updates ID3v2/FLAC tags with album info, track numbers and ReplayGain
- π Genre Detection: Looks up accurate genres using MusicBrainz database
- β‘ Multithreaded: Fast analysis using parallel processing
- π₯οΈ Rich UI: Beautiful command-line interface with progress indicators
This project was created using Claude Code. I wanted to quickly whip up something that will formalize and automate how I created "mixtapes" for myself. I prefer creating my own compilation albums versus creating playlist files (e.g. m3u). I do so by creating a new subdirectory under my Music directory, dumping a dozen or so pre-selected music files into it, ordering them, generating cover art with an AI image generator, updating their ID3 tags and renaming them in the chosen order. I mostly create mixtapes based on certain moods, so that I can quickly choose a playlist based on what I want to hear. I find that music collection managers that have "mood" as a filter work terribly.
The only problem is choosing a good order for the songs. It always takes too
long and I don't want every mixtape to turn into some ridiculous project. So I
created mixtaper to make this process quicker. I can now just dump the files
into a directory and let the program do everything for me:
- Analyze the songs for things like tempo, key, energy, etc.
- Choose an ordering for the songs that will "flow well" based on the analysis.
- Generate cover art via OpenAI DALL-E (or select an existing
^(cover|front)\.(png|jpg)$image in the directory). - Calculate ReplayGain values for the tracks individually and the album as a whole.
- Set relevant ID3 tags for the files.
- Rename the files with the format "[TRACK_NUMBER]. [ARTIST] - [TITLE]".
I also added support for multi-CD mixtapes. mixtaper will recommend a number of
CDs if it finds that the directory contains "more songs than common in albums",
and prefix the files with the disc number, so, "[DISC_NUMBER][TRACK_NUMBER]. [ARTIST] - [TITLE]".
This is an early release. I decided to let Claude Code implement this and see
how it goes. For now, it seems to work quite nicely. My biggest issue right now
is how to craft a good prompt for the cover art generation. The current prompt
generator isn't good, but prompts can be edited. The ordering mixtaper creates
could be better, but I'm fine with it for now. I can always tinker with the
parameters and re-run.
By default, mixtaper works interactively, asking you questions and also for
confirmation. You can pre-answer questions via command line flags, or opt for
completely automatic, non-interactive execution. Information later on.
mixtaper is a command line utility written in Python and distributed via PyPI.
It is recommended to install it via a utility such as pipx:
pipx install mixtaperYou can also install it directly through pip:
python3 -m pip install mixtaper# Interactive mode - prompts for configuration
mixtaper /path/to/music
# Automatic mode with smart defaults
mixtaper /path/to/music --auto
# Preview without making changes
mixtaper /path/to/music --dry-run# Generate AI artwork (requires OpenAI API key)
export OPENAI_API_KEY="your-api-key"
mixtaper /path/to/music --ai-art
# Preset album information
mixtaper /path/to/music --title "My Mixtape" --artist "DJ Name" --year 2024
# Preselect number of CDs
mixtaper /path/to/music --num-cds 2
# Predefine AI artwork prompt
mixtaper /path/to/music --ai-art --ai-prompt "Abstract digital art with neon colors"
# Performance tuning
mixtaper /path/to/music --threads 8| Option | Description |
|---|---|
--title |
Album title (default: directory name) |
--artist |
Album artist (default: Various Artists) |
--year |
Release year (default: current year) |
--num-cds |
Number of CDs to create (default: auto-suggest) |
--ai-art |
Generate AI artwork using DALL-E |
--ai-prompt |
Custom prompt for AI artwork generation |
--auto |
Automatic mode - no interactive prompts |
--dry-run |
Preview operations without making changes |
-y, --yes |
Automatically confirm all prompts |
--threads |
Number of analysis threads (default: 4) |
The tool analyzes each audio file to extract:
- Tempo: BPM detection for rhythmic continuity
- Key: Chromatic feature analysis for harmonic compatibility
- Energy: RMS levels for dynamic flow management
- Brightness: Spectral centroid for tonal continuity
- Rhythm Complexity: Onset density analysis
Uses a weighted scoring algorithm for track transitions:
- Tempo similarity: 30%
- Key compatibility: 20%
- Energy flow: 25%
- Brightness continuity: 15%
- Rhythm complexity: 10%
- Reads existing Artist/Title from file metadata
- Looks up accurate genres via MusicBrainz API
- Updates all files with consistent album information
- Adds ReplayGain tags for volume normalization
- Embeds album artwork in file metadata
- Renames files to format: "01. Artist - Title.ext"
- For multi-CD sets: "201. Artist - Title.ext" (CD 2, Track 1)
- Safe renaming with conflict resolution
- Preserves original files if errors occur
The project uses a modular architecture for maintainability:
mixtaper/
βββ __init__.py # Package exports
βββ config.py # Configuration and data classes
βββ audio_analyzer.py # Audio analysis using librosa
βββ metadata_manager.py # ID3v2/FLAC metadata handling
βββ musicbrainz_client.py # MusicBrainz API integration
βββ artwork_generator.py # AI artwork generation
βββ mixtape_optimizer.py # Track ordering algorithms
βββ tui.py # Rich-based user interface
βββ cli.py # Command-line interface
# Install development dependencies
uv sync --dev
# Run all tests
uv run python run_tests.py
# Or use pytest directly
uv run pytest tests/ -v# Format code
uv run ruff format .
# Lint code
uv run ruff check .# Test with audio files
uv run mixtaper.py /path/to/test/audio/files
# Test AI artwork (requires OpenAI API key)
export OPENAI_API_KEY="your-api-key"
uv run mixtaper.py /path/to/music --ai-art --dry-run- Python 3.8+
- FFmpeg (for audio format support)
- librosa: Audio analysis and feature extraction
- mutagen: Audio metadata reading/writing
- rich: Beautiful command-line interface
- numpy/scipy: Numerical computations
- openai: AI artwork generation (optional)
- requests: HTTP client for API calls
- OpenAI API Key: For AI artwork generation
- MusicBrainz: Free genre lookup (no API key required)
βββ Mixtaper βββ
Processing: /music/Various Artists - 2024 - New Wave Mix
βββ Audio Analysis βββ
[1/13] Analyzing: 04. The Cure - Boys Don't Cry.flac
[2/13] Analyzing: 03. Don Henley - The Boys Of Summer.flac
...
βββ Genre Lookup βββ
[1/13] The Cure - Boys Don't Cry
Genre: alternative rock
[2/13] Don Henley - The Boys Of Summer
Genre: classic rock
...
βββ Suggested Track Order βββ
01. Crowded House - Don't Dream It's Over [alternative rock] (82 BPM, Energy: 0.17)
02. A-Ha - Take on Me [dance-pop] (85 BPM, Energy: 0.18)
03. Don Henley - The Boys Of Summer [classic rock] (89 BPM, Energy: 0.16)
...
β Mixtape organization complete!
β’ 13 tracks processed
β’ 1 CD created
β’ Metadata and ReplayGain tags updated
β’ Album artwork preserved
Various Artists - 2024 - New Wave Mix/
βββ cover.jpg # Album artwork
βββ 01. Crowded House - Don't Dream It's Over.flac
βββ 02. A-Ha - Take on Me.flac
βββ 03. Don Henley - The Boys Of Summer.flac
βββ ...
Apache License 2.0 - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
uv run python run_tests.py - Submit a pull request
- Report issues: GitHub Issues
- Documentation: See
CLAUDE.mdfor development details - Examples: Check the
tests/directory for usage examples