Metadata-Version: 2.1
Name: leadsheetanalyser
Version: 0.2.0
Summary: A package for music analysis, chord processing, and harmonic analysis via modal systems and optimal transport
Author-Email: Nicolas Klutchnikoff <nicolas.klutchnikoff@univ-rennes2.fr>
License: MIT License
         
         Copyright (c) 2025 Nicolas Klutchnikoff (nicolas.klutchnikoff@univ-rennes2.fr)
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: pandas>=1.3.0
Requires-Dist: jams>=0.3.4
Requires-Dist: music21>=6.0.0
Requires-Dist: numpy>=1.20.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: matplotlib>=3.3.0
Requires-Dist: seaborn>=0.11.0
Requires-Dist: harte-library>=0.2.0
Requires-Dist: POT>=0.9.7
Description-Content-Type: text/markdown

# LeadSheet Analyser 🎵

A specialized Python package for leadsheet analysis using chord dissimilarity metrics.

## Features

- **🎼 Chord Processing**: Parse both Harte notation (`A:min`) and shorthand (`Am`)
- **📐 Modal Embeddings**: Map chords into continuous geometric spaces using musical systems (e.g. Diatonic, Messiaen)
- **🧮 Optimal Transport**: Compute alignment and distance between entire chord progressions
- **💾 Data Processing**: Tools for musical datasets (JAMS format support)
- **📚 Rich Constants**: Comprehensive musical constants and predefined systems

## Quick Start

```python
import leadsheetanalyser

# Parse chords (supports multiple formats)
chord = leadsheetanalyser.map_chord("Am")  # Shorthand
chord = leadsheetanalyser.map_chord("A:min")  # Harte notation

# Analyze chord relationships in a musical system
from leadsheetanalyser.chord_dissimilarities import modal_dissimilarity, create_identity_system
c_maj = leadsheetanalyser.chord_name_to_tuple("C:maj")
f_maj = leadsheetanalyser.chord_name_to_tuple("F:maj")
system = create_identity_system()
dissimilarity = modal_dissimilarity(c_maj, f_maj, system, p=1.0)

# Compute Optimal Transport distance between two songs
from leadsheetanalyser.song_distance import song_distance
song1 = [c_maj, f_maj, c_maj]
song2 = [c_maj, leadsheetanalyser.chord_name_to_tuple("G:7"), c_maj]
dist = song_distance(song1, song2, W=system, p=1.0)
```

## Package Structure

```
leadsheetanalyser/
├── chords.py                # Chord processing and parsing
├── chord_dissimilarities.py # Modal embeddings and chord distances
├── song_distance.py         # Optimal transport between progressions
├── musical_systems.py       # Musical system definitions (W matrix)
├── system_analysis.py       # Comparative analysis and clustering
├── scales.py                # Scale analysis and properties
├── constants.py             # Predefined systems and mappings
└── data_processing.py       # Dataset tools (JAMS)
```

## Installation & Setup

```bash
# Install from PyPI
pip install leadsheetanalyser

# Or install from source for development
git clone https://github.com/USERNAME/leadsheetanalyser.git
cd leadsheetanalyser
pip install -e .

# Set up datasets (downloads from GitHub releases - fast & efficient)
python scripts/download_data.py
```

For complete data setup instructions, see **[DATA.md](DATA.md)**.

## Testing

```bash
# Run all tests
python -m pytest tests/

# Or use the provided script
python tests/run_tests.py
```

## Dependencies

Core dependencies (automatically installed with `pip install -e .`):
- `numpy`, `scipy` - Scientific computing and clustering
- `pandas` - Data manipulation
- `pot` - Python Optimal Transport
- `jams` - Musical annotation format
- `music21`, `harte-library` - Music and chord processing
- `matplotlib`, `seaborn` - Visualization

## Documentation

- **[DATA.md](DATA.md)** - Complete data setup and management guide
- **[ORGANIZATION.md](ORGANIZATION.md)** - Package architecture and API reference

## License

MIT License - see [LICENSE](LICENSE) for details.
