Generated summary and code by Deepseek-R1
Quartz_MIDI_MapHematite_MIDI_Map
\U0001F4CA Data Transformation Principles
1. Data Input and Processing Flow
X-ray Diffraction Data → Feature Extraction → Musical Event Mapping → MIDI Generation
↓ ↓ ↓ ↓
Angle/Intensity Peak Detection Pitch/Volume/Duration Multi-track Synthesis
2. Feature Extraction Algorithms
2.1 Data Preprocessing
# Savitzky-Golay filter for data smoothing
smoothed = savgol_filter(intensities, window_length=11, polyorder=3)
- Purpose: Eliminate experimental noise while preserving characteristic peaks
- Parameters: Window length 11, polynomial order 3
2.2 Feature Point Detection
# Peak detection
peaks, _ = find_peaks(smoothed, prominence=np.std(smoothed)*0.5)
# Valley detection
valleys, _ = find_peaks(-smoothed, prominence=np.std(smoothed)*0.5)
- Algorithm: Local prominence-based extremum detection
- Sensitivity: Threshold set at 0.5 times standard deviation
2.3 Feature Scoring System
# Scoring formula: score = intensity × (1 + deviation/10)
dev = abs(angles[idx] - 90)
score = smoothed[idx] * (1 + dev/10)
- Physical Interpretation:
- Intensity: Diffraction peak intensity → Musical event loudness
- Angle Deviation: Distance from 90° → Pitch variation
- Composite Score: Determines note duration and importance
3. Music Parameter Mapping Relationships
3.1 Pitch Mapping
# Non-linear pitch function
pitch_curve = lambda x: int(30 + 5*(x**0.5))
- Mapping: Angle deviation → MIDI pitch (0-127)
- Characteristics:
- Square root function avoids monotonic linear mapping
- Base pitch 30 ensures low-frequency ambiance
- Higher deviation = higher pitch (non-linear progression)
3.2 Volume Mapping
# Linear interpolation from intensity to volume
volume = np.interp(intensity, [min_int, max_int], [60, 100])
- Range: 60-100 (medium to strong volume)
- Principle: Intensity peaks correspond to prominent notes
3.3 Time Distribution
# Uniform time point distribution
time_points = np.linspace(0.1, max_duration, num_features)
- Strategy: Feature points sorted by score, evenly distributed throughout the piece
- Start time: 0.1 seconds (avoids conflicts at time 0)
3.4 Duration Calculation
duration = base_duration * (0.5 + score/max_score)
- Base duration: 2 seconds
- Scaling factor: Dynamically adjusted based on score (0.5-1.5 times)
4. Multi-track Music Synthesis
4.1 Track Configuration (GM Standard Sounds)
| Track | Program # | Instrument | Function |
|---|---|---|---|
| 0 | 87 | Sci-Fi Sound (FX1) | Main Melody |
| 1 | 103 | Space Atmosphere (FX3) | Ambient Layer |
| 2 | 24 | Nylon Guitar | Low-frequency Layer |
| 3 | 101 | High-frequency Pulse (FX4) | Special Effects |
4.2 Ambient Effect Design
- Reverb Effect: Controller 91, value 60
- Particle Sounds: High-frequency short notes at random time points
- Low-frequency Vibration: Sustained bass notes every 4 seconds
5. Visualization Analysis
5.1 Dual-plot Report
- Upper Plot: Original data curve + feature point markers
- Color mapping: Angle deviation (viridis colormap)
- Reference line: 90° position (red dashed line)
- Lower Plot: Pitch distribution histogram
- Shows MIDI pitch distribution of all feature points
6. Scientific Basis and Artistic Expression
6.1 Scientific Correspondences
Diffraction Pattern Feature ↔ Musical Parameter
─────────────────────────────────────────────────
Peak Intensity ↔ Note Volume
Peak Position (Angle) ↔ Note Pitch
Peak Count and Distribution ↔ Rhythmic Density
Feature Complexity ↔ Musical Richness
6.2 Artistic Design Philosophy
- Theme: Space/sci-fi style, reflecting minerals' cosmic origins
- Emotion: Creates mysterious, exploratory atmosphere through ambient effects
- Structure: Ordered rather than random, reflecting crystalline regularity
7. Technical Features Summary
- Data-Driven: Music parameters entirely determined by diffraction data
- Non-linear Mapping: Avoids mechanical linear conversion, enhances artistic quality
- Multi-dimensional Expression: Simultaneously conveys intensity, angle, distribution
- Reproducibility: Same data produces identical music, scientifically rigorous
- Visualization Support: Generates analytical reports linking science and art
8. Application Scenarios
- Science Education: Making abstract diffraction data audible
- Artistic Creation: Giving artistic expression to scientific data
- Data Analysis: Perceiving data characteristics through auditory means
- Interdisciplinary Research: Connecting materials science and music technology
Core Concept: Transforming the microscopic crystal structure of minerals (revealed by X-ray diffraction) into perceptible musical structures, allowing scientific data to gain new expressive dimensions through artistic forms.


