BPM Correction
Genre-specific BPM ranges and correction logic.
This module provides genre-aware BPM validation and correction, helping detect half-time issues common in electronic music.
- class mixref.detective.bpm_correction.Genre[source]
-
Supported music genres for BPM validation.
- DNB = 'dnb'
- TECHNO = 'techno'
- HOUSE = 'house'
- DUBSTEP = 'dubstep'
- TRANCE = 'trance'
- __new__(value)
- class mixref.detective.bpm_correction.BPMRange[source]
Bases:
objectBPM range definition for a genre.
- __init__(min_bpm, max_bpm, typical)
- class mixref.detective.bpm_correction.CorrectedBPM[source]
Bases:
objectResult of BPM correction.
- genre
The genre used for validation (if any).
- Type:
- __init__(original_bpm, corrected_bpm, was_corrected, correction_reason=None, in_genre_range=None, genre=None)
- mixref.detective.bpm_correction.correct_bpm(bpm, genre=None, half_time_threshold=100.0)[source]
Apply genre-aware BPM corrections.
Common in electronic music production, BPM detection can sometimes detect “half-time” (half the actual tempo). This function corrects such issues and validates against genre expectations.
- Parameters:
- Returns:
CorrectedBPM with original BPM, corrected value, and validation info.
- Return type:
Example
>>> from mixref.detective.bpm_correction import correct_bpm, Genre >>> >>> # Half-time detection (87 BPM -> 174 BPM for DnB) >>> result = correct_bpm(87.0, genre=Genre.DNB) >>> print(result.corrected_bpm) 174.0 >>> print(result.was_corrected) True >>> >>> # Already in range >>> result = correct_bpm(174.0, genre=Genre.DNB) >>> print(result.was_corrected) False
- mixref.detective.bpm_correction.is_in_genre_range(bpm, genre)[source]
Check if BPM is within typical range for a genre.
- Parameters:
- Returns:
True if BPM is within the genre’s typical range.
- Return type:
Example
>>> from mixref.detective.bpm_correction import is_in_genre_range, Genre >>> >>> is_in_genre_range(174.0, Genre.DNB) True >>> is_in_genre_range(120.0, Genre.DNB) False
- mixref.detective.bpm_correction.get_genre_range(genre)[source]
Get the BPM range for a specific genre.
- Parameters:
genre (Genre) – The genre to query.
- Returns:
BPMRange with min, max, and typical BPM values.
- Return type:
Example
>>> from mixref.detective.bpm_correction import get_genre_range, Genre >>> >>> range_info = get_genre_range(Genre.TECHNO) >>> print(f"{range_info.min_bpm}-{range_info.max_bpm} BPM") 120.0-140.0 BPM