A Python application that helps pianists practice and visualize their dynamic expression in real-time using MIDI input from digital pianos.
- Real-time Dynamics Visualization: See your playing dynamics as colored bars above each piano key
- Musical Notation Display: Shows current dynamics level (pp, p, mp, mf, f, ff, etc.)
- MIDI Input Support: Works with any MIDI-compatible digital piano or keyboard
- Visual Feedback: Color-coded bars that respond to your playing intensity
- Cross-platform: Works on Windows, macOS, and Linux
While there are many programs that help learn to play piano or improve sight-reading, few focus specifically on practicing and fine-tuning dynamic expression. This software fills that gap by providing immediate visual feedback on your dynamic control.
The application shows colored bars above each piano key indicating the velocity/dynamics of your playing.
- Python 3.8 or higher
- A MIDI-compatible digital piano or keyboard (optional - you can use mock mode)
- MIDI drivers installed on your system (for real MIDI devices)
-
Clone the repository:
git clone https://github.com/scottroot/Piano-Dynamics-Midi-Trainer.git cd Piano-Dynamics-Midi-Trainer
-
Install the package:
pip install -e .
- Connect your MIDI device and ensure it's recognized by your system
- List available MIDI ports (optional):
musical-dynamics-trainer --list-ports
- Run the application:
# Use default MIDI port (usually port 0) musical-dynamics-trainer # Or specify a specific port musical-dynamics-trainer --port 1
Perfect for testing or when you don't have a MIDI device handy:
musical-dynamics-trainer --mock-midi
This will simulate MIDI input automatically, playing random notes every second so you can see how the visualization works.
Want to see the core functionality without the GUI? Run the basic usage example:
python examples/basic_usage.py
This demonstrates the dynamics mapping, MIDI key conversion, and color coding without needing any MIDI hardware.
# Basic usage
musical-dynamics-trainer # Use default MIDI port
musical-dynamics-trainer --port 1 # Use specific MIDI port
musical-dynamics-trainer --mock-midi # Use mock MIDI (no device needed)
# Information and debugging
musical-dynamics-trainer --list-ports # Show available MIDI ports
musical-dynamics-trainer --verbose # Enable detailed logging
musical-dynamics-trainer --help # Show all options
musical-dynamics-trainer --version # Show version info
- Launch the application using one of the methods above
- If using a real MIDI device: Play your piano - you'll see colored bars appear above the keys you press
- If using mock mode: The app will automatically simulate playing, showing you how the visualization works
- Observe the dynamics - the top of the window shows your current dynamics level
- Practice control - try to maintain consistent dynamics or practice crescendos/diminuendos
- Press Escape to exit the application
Velocity Range | Dynamics | Description | Color |
---|---|---|---|
1-8 | pppp | Extremely soft | Dark blue |
9-31 | pp | Very soft | Blue |
32-53 | p/mp | Soft/Moderately soft | Light blue |
54-79 | mf | Moderately loud | Purple |
80-95 | f | Loud | Orange |
96-127 | ff/fff | Very loud/Extremely loud | Red |
-
Clone and install development dependencies:
git clone https://github.com/scottroot/Piano-Dynamics-Midi-Trainer.git cd Piano-Dynamics-Midi-Trainer make dev-setup
-
Run tests:
make test
-
Check code quality:
make check
Musical-Dynamics-Training-Software/
โโโ src/musical_dynamics/ # Main package
โ โโโ __init__.py # Package initialization
โ โโโ __main__.py # Command-line entry point
โ โโโ config.py # Configuration settings
โ โโโ constants.py # MIDI mappings and constants
โ โโโ gui.py # Tkinter GUI implementation
โ โโโ midi_handler.py # MIDI input processing
โโโ tests/ # Test suite
โโโ docs/ # Documentation
โโโ examples/ # Usage examples
โโโ img/ # Images and assets
โโโ pyproject.toml # Package configuration
โโโ requirements.txt # Runtime dependencies
โโโ requirements-dev.txt # Development dependencies
โโโ README.md # This file
make help # Show all available commands
make install # Install package in development mode
make install-dev # Install development dependencies
make test # Run tests
make test-cov # Run tests with coverage
make lint # Run linting checks
make format # Format code with black
make clean # Clean build artifacts
make build # Build package
make check # Run all quality checks
The project includes comprehensive tests for all core functionality:
# Run all tests
pytest
# Run with coverage report
pytest --cov=musical_dynamics --cov-report=html
# Run specific test file
pytest tests/test_constants.py
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes and add tests
- Run quality checks:
make check
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
numpy>=1.18.1,<2.0.0
rtmidi>=1.4.0,<2.0.0
pytest>=7.0.0,<8.0.0
pytest-cov>=4.0.0,<5.0.0
black>=23.0.0,<24.0.0
flake8>=6.0.0,<7.0.0
mypy>=1.0.0,<2.0.0
pre-commit>=3.0.0,<4.0.0
"No MIDI ports found"
- Ensure your MIDI device is connected and drivers are installed
- Try running
musical-dynamics-trainer --list-ports
to see available ports - On Windows, you may need to install ASIO drivers
- No MIDI device? Use
musical-dynamics-trainer --mock-midi
to test without hardware
"Failed to open MIDI input"
- Check that your MIDI device is not being used by another application
- Try a different MIDI port number
- Restart your MIDI device
- Still having issues? Try mock mode to verify the application works:
musical-dynamics-trainer --mock-midi
"Piano image not found"
- The application will run without the background image
- Ensure the
img/piano_3.png
file is in the correct location
"Application won't start"
- Make sure you've installed the package:
pip install -e .
- Check your Python version:
python --version
(needs 3.8+) - Try running with verbose logging:
musical-dynamics-trainer --verbose
Want to test the app without MIDI hardware?
musical-dynamics-trainer --mock-midi
Want to see what the app does without the GUI?
python examples/basic_usage.py
Having MIDI connection issues?
- First try:
musical-dynamics-trainer --list-ports
- If no ports show up, check your MIDI device drivers
- If ports show up but connection fails, try different port numbers
- As a last resort, use mock mode to test the application
- Check the Issues page
- Create a new issue with detailed information about your problem
- Include your operating system, Python version, and MIDI device information
- Try mock mode first to confirm the application works on your system
This project is licensed under the MIT License - see the LICENSE file for details.
- python-rtmidi: For MIDI input handling capabilities
- Tkinter: For the GUI framework
- NumPy: For numerical operations
- The open source community: For inspiration and tools
- Support for different piano layouts
- Recording and playback functionality
- Statistical analysis of dynamics patterns
- Customizable color schemes
- Export functionality for practice sessions
- Integration with music notation software
- Author: Scott Hendrix
- Repository: https://github.com/scottroot/Piano-Dynamics-Midi-Trainer
- Issues: https://github.com/scottroot/Piano-Dynamics-Midi-Trainer/issues
Happy practicing! ๐นโจ