DTW Audio Comparison — User Guide
Dynamic Time Warping analysis comparing recordings of different lengths/tempos, measuring MFCC similarity, tempo-aligned loudness, and melodic interval accuracy with automatic quality assessment.
What this does
This script uses Dynamic Time Warping (DTW) to compare two audio recordings that may have different durations or tempos. Unlike basic comparison tools, DTW intelligently aligns sequences to handle timing variations, making it ideal for comparing performances with different speeds, rhythmic variations, or duration mismatches. Analyzes MFCC features (timbre), loudness, and melodic intervals with tempo-aware alignment.
Quick start
- In Praat, select exactly two Sound objects (Shift+click to select both).
- Run script… → Load this DTW comparison script.
- Click OK — processing completes in 10-30 seconds (depends on duration).
- Check Info window for detailed results.
- Check Objects window for "dtw_analysis_results" table.
- Optional: Save table as CSV (Select table → Save → Save as comma-separated values file).
Three-Dimensional Analysis
🎨 DTW MFCC Similarity (Timbre)
What it measures: Spectral/timbral similarity using Mel-Frequency Cepstral Coefficients
Interpretation:
- Normalized DTW distance <2: Excellent (very similar timbre)
- 2-5: Good (comparable tone quality)
- 5-10: Moderate (noticeable timbral differences)
- >10: Needs work (significantly different tone)
Use: Assesses tone quality, articulation, vowel shape (voice), instrument timbre matching
🔊 DTW Loudness Match (Dynamics)
What it measures: Tempo-aligned intensity comparison
Interpretation:
- Aligned dB difference <4: Excellent (similar dynamic control)
- 4-8 dB: Good (comparable loudness patterns)
- 8-15 dB: Moderate (noticeable dynamic differences)
- >15 dB: Needs work (different dynamic approach)
Use: Evaluates dynamic expression, loudness control matching
🎵 DTW Pitch Accuracy (Melody)
What it measures: Tempo-aligned melodic interval comparison
Interpretation:
- Aligned interval difference <0.3 semitones: Excellent
- 0.3-0.7 semitones: Very good
- 0.7-1.5 semitones: Good
- 1.5-3.0 semitones: Moderate
- >3.0 semitones: Needs work
Additional metrics:
- Contour accuracy: Percentage of matched melodic direction (up/down/stable)
- Transposition: Overall pitch difference (e.g., singing in wrong key)
DTW Advantages
Handles tempo variations:
- Student performs faster/slower than teacher → DTW aligns them
- Rubato or rhythmic variations → Flexible alignment
- Different durations (10s vs 15s) → Compares intelligently
Timing flexibility:
- No need for exact time alignment
- Accounts for accelerando/ritardando
- Finds best correspondence between sequences
vs. Standard comparison:
- Standard: Requires same duration, frame-by-frame comparison, fails with tempo changes
- DTW: Adaptive alignment, robust to timing differences, finds optimal matching
Output Files
Info window displays:
- Duration difference and tempo ratio
- DTW MFCC, Loudness, and Pitch assessments
- Contour accuracy percentage
- Overall transposition (key difference)
Results Table (dtw_analysis_results):
| Column | Description |
|---|---|
| parameter | Feature type (MFCC_DTW, LOUDNESS_DTW, PITCH_DTW) |
| metric | Specific measurement name |
| value | Numeric result |
| assessment | Quality rating (EXCELLENT/GOOD/MODERATE/NEEDS_WORK) |
| teacher_file | Reference recording name |
| student_file | Test recording name |
| duration_diff | Duration difference (seconds) |
| tempo_ratio | Speed ratio (student/teacher) |
To save results: Select "dtw_analysis_results" table → Save → Save as comma-separated values file → Choose location
Parameters
MFCC Parameters (timbre analysis):
| Parameter | Value | Description |
|---|---|---|
| number_of_filters | 24 | Mel filter bank size |
| fmin/fmax | 100-5000 Hz | Frequency range for analysis |
| number_of_coefficients | 13 | MFCC features (C0-C12, using C1-C12) |
DTW Parameters:
| Parameter | Value | Description |
|---|---|---|
| dtw_radius | 3 | Search radius for alignment |
| dtw_min_size | 5 | Minimum sequence length for FastDTW |
Pitch Parameters:
| Parameter | Value | Description |
|---|---|---|
| pitch_floor/ceiling | 75-600 Hz | Range for F0 detection |
Note: All parameters hardcoded in script, optimized for speech/singing analysis.
Applications
Music pedagogy:
- Compare student performance to teacher demonstration (different tempos OK)
- Assess timbre matching, dynamic expression, pitch accuracy simultaneously
- Track improvement across multiple recordings at different speeds
- Evaluate rubato/expressive timing variations
Language learning:
- Compare native speaker to learner (natural speech rate differences)
- Assess pronunciation (MFCC), intonation (pitch), and prosody (loudness)
- Handle hesitations and timing differences in speech
Performance analysis:
- Compare multiple takes at different tempos
- Analyze tempo consistency across performances
- Identify specific measures/phrases with issues (via frame analysis)
Limitations
- Processing time: 10-30 seconds for typical recordings (DTW computationally intensive)
- Similar content required: Recordings must be same piece/exercise (not random material)
- Approximate alignment: Uses FastDTW approximation for long sequences (sampling every 3rd frame)
- Start point matters: Recordings should begin at approximately same musical point
- Monophonic preferred: Pitch analysis works best with single melodic line
- Large tempo differences: Ratio >2.0× may reduce accuracy
Interpreting Results
Example 1: Excellent match
- MFCC: 1.5 (EXCELLENT) → Same tone quality
- Loudness: 3.2 dB (EXCELLENT) → Similar dynamics
- Pitch: 0.2 semitones (EXCELLENT) → Accurate intonation
- Contour: 95% → Correct melodic direction
- Tempo ratio: 1.15 → Student 15% slower (acceptable)
Example 2: Needs work
- MFCC: 12.0 (NEEDS_WORK) → Different timbre/articulation
- Loudness: 18 dB (NEEDS_WORK) → Poor dynamic control
- Pitch: 3.5 semitones (NEEDS_WORK) → Significant intonation errors
- Contour: 60% → Wrong melodic direction often
- Transposition: 7 semitones → Wrong key entirely
Example 3: Mixed results (common)
- MFCC: 4.0 (GOOD) → Decent tone quality
- Loudness: 11 dB (MODERATE) → Dynamics need attention
- Pitch: 0.8 semitones (GOOD) → Minor intonation issues
- Action: Focus practice on dynamic control