208 lines
5.7 KiB
Markdown
208 lines
5.7 KiB
Markdown
# Modulation CV Avancée - Portamento & FM pour STM32F3
|
|
|
|
## Vue d'ensemble 🌊
|
|
|
|
Le système de modulation CV avancée ajoute des fonctionnalités de synthétiseur professionnel à votre Apple-ADB-Ressurector :
|
|
|
|
- **Portamento sinusoïdal** : Transitions douces entre les notes
|
|
- **Vibrato LFO** : Modulation automatique de hauteur
|
|
- **Modulation FM** : Contrôle expressif par mouvements souris
|
|
- **Génération temps réel** : Calculs sinusoïdaux optimisés
|
|
|
|
## Fonctionnalités 🎛️
|
|
|
|
### 1. **Portamento Sinusoïdal**
|
|
Transitions musicales douces entre les notes avec courbe en S :
|
|
```
|
|
Note A → Portamento → Note B
|
|
[Courbe sinusoïdale lisse au lieu de saut brutal]
|
|
```
|
|
|
|
**Paramètres :**
|
|
- **Vitesse** : `PORTAMENTO_SPEED = 0.05f` (0.01 lent → 0.1 rapide)
|
|
- **Courbe** : Transition sinusoïdale naturelle
|
|
- **Indépendant** : CV1 et CV2 ont chacun leur portamento
|
|
|
|
### 2. **Vibrato LFO**
|
|
Oscillateur basse fréquence pour effet vibrato :
|
|
```
|
|
Note de base + sin(LFO_phase) * profondeur
|
|
```
|
|
|
|
**Paramètres :**
|
|
- **Fréquence** : `VIBRATO_FREQUENCY = 4.5Hz` (0.1Hz → 20Hz)
|
|
- **Profondeur** : `VIBRATO_DEPTH = 50` unités DAC (0 → 200)
|
|
- **Phases** : CV1 et CV2 déphasés de 45° pour effet stéréo
|
|
|
|
### 3. **Modulation de Fréquence (FM)**
|
|
Contrôle expressif par mouvements souris :
|
|
```
|
|
Mouvement X → Modulation CV1 (voix principale)
|
|
Mouvement Y → Modulation CV2 (voix harmonique)
|
|
```
|
|
|
|
**Paramètres :**
|
|
- **Sensibilité** : `FM_SENSITIVITY = 0.1f`
|
|
- **Fréquence** : 3x la fréquence vibrato (pour timbre métallique)
|
|
- **Amplitude** : Proportionnelle à la vitesse de mouvement souris
|
|
|
|
## Architecture Technique ⚙️
|
|
|
|
### Structure de données
|
|
```cpp
|
|
typedef struct {
|
|
// États portamento
|
|
uint16_t current_cv1, target_cv1;
|
|
uint16_t current_cv2, target_cv2;
|
|
float portamento_phase_cv1, portamento_phase_cv2;
|
|
|
|
// LFO vibrato
|
|
float vibrato_phase_cv1, vibrato_phase_cv2;
|
|
|
|
// Modulation FM
|
|
float fm_depth_cv1, fm_depth_cv2;
|
|
} cv_modulation_state_t;
|
|
```
|
|
|
|
### Fonctions principales
|
|
```cpp
|
|
cv_modulation_init() // Initialisation
|
|
cv_modulation_start_portamento() // Démarrer transition
|
|
cv_modulation_update_fm() // Maj modulation souris
|
|
cv_modulation_process() // Traitement temps réel
|
|
```
|
|
|
|
## Intégration dans le Code 🔧
|
|
|
|
### 1. **Clavier → Portamento**
|
|
```cpp
|
|
// Au lieu d'écrire directement dans le DAC :
|
|
HAL_DAC_SetValue(&hdac1, channel, value);
|
|
|
|
// Maintenant : démarrer portamento
|
|
cv_modulation_start_portamento(channel, target_value);
|
|
```
|
|
|
|
### 2. **Souris → Modulation FM**
|
|
```cpp
|
|
// Au lieu de modifier current_cv_value directement :
|
|
current_cv1_value += offset_x;
|
|
|
|
// Maintenant : modulation de fréquence
|
|
cv_modulation_update_fm(offset_x, offset_y);
|
|
```
|
|
|
|
### 3. **Loop → Traitement**
|
|
```cpp
|
|
void loop() {
|
|
handleKeyboard();
|
|
handleMouse();
|
|
cv_modulation_process(); // ← Ajouté pour traitement continu
|
|
}
|
|
```
|
|
|
|
## Algorithmes Sinusoïdaux 📐
|
|
|
|
### 1. **Fonction sinus optimisée**
|
|
```cpp
|
|
static float fast_sin(float phase) {
|
|
// Normalisation phase [0, 2π]
|
|
while (phase >= 2.0f * M_PI) phase -= 2.0f * M_PI;
|
|
return sinf(phase); // Fonction ARM optimisée
|
|
}
|
|
```
|
|
|
|
### 2. **Transition douce (courbe S)**
|
|
```cpp
|
|
static float smooth_transition(float t) {
|
|
if (t <= 0.0f) return 0.0f;
|
|
if (t >= 1.0f) return 1.0f;
|
|
return (1.0f - sinf(t * M_PI + M_PI * 0.5f)) * 0.5f;
|
|
}
|
|
```
|
|
|
|
### 3. **Traitement temps réel**
|
|
```cpp
|
|
void cv_modulation_process() {
|
|
float dt = delta_time_seconds;
|
|
|
|
// Portamento
|
|
if (portamento_active) {
|
|
phase += PORTAMENTO_SPEED;
|
|
float progress = smooth_transition(phase);
|
|
cv_value = lerp(start_cv, target_cv, progress);
|
|
}
|
|
|
|
// Vibrato LFO
|
|
vibrato_phase += 2π * frequency * dt;
|
|
float vibrato = fast_sin(vibrato_phase) * depth;
|
|
|
|
// FM
|
|
float fm = fast_sin(vibrato_phase * 3.0f) * fm_depth * 20.0f;
|
|
|
|
// Valeur finale
|
|
final_cv = cv_value + vibrato + fm;
|
|
HAL_DAC_SetValue(&hdac1, channel, final_cv);
|
|
}
|
|
```
|
|
|
|
## Configuration & Réglages 🎚️
|
|
|
|
### Paramètres modifiables (cv_modulation.h) :
|
|
```cpp
|
|
#define PORTAMENTO_SPEED 0.05f // Vitesse glissement
|
|
#define VIBRATO_FREQUENCY 4.5f // Hz vibrato
|
|
#define VIBRATO_DEPTH 50 // Profondeur vibrato
|
|
#define FM_SENSITIVITY 0.1f // Sensibilité souris
|
|
```
|
|
|
|
### Fonctions de contrôle :
|
|
```cpp
|
|
cv_modulation_set_vibrato(true/false); // ON/OFF vibrato
|
|
cv_modulation_set_vibrato_params(6.0f, 75); // Fréq + profondeur
|
|
```
|
|
|
|
## Debug & Monitoring 📊
|
|
|
|
### Messages série typiques :
|
|
```
|
|
CV Modulation initialisée - Portamento + FM actifs
|
|
Portamento CV1: 2048 → 2185
|
|
CV1 (voix principale) - Note MIDI: 60 CV cible: 2048 (1.65V) [Portamento actif]
|
|
FM Modulation - X: 2.50 Y: -1.20
|
|
Vibrato: ON
|
|
Vibrato params - Freq: 4.5Hz, Depth: 50
|
|
```
|
|
|
|
## Performance & Optimisation ⚡
|
|
|
|
### Fréquence d'exécution :
|
|
- **loop()** : ~200Hz (5ms delay)
|
|
- **cv_modulation_process()** : ~200Hz
|
|
- **Calculs sinus** : Fonction ARM optimisée
|
|
- **Overhead CPU** : ~5% du STM32F303
|
|
|
|
### Mémoire utilisée :
|
|
- **Structure d'état** : 48 bytes
|
|
- **Code program** : ~2KB Flash
|
|
- **Variables statiques** : ~100 bytes RAM
|
|
|
|
## Applications Musicales 🎵
|
|
|
|
### 1. **Lead expressif**
|
|
- Portamento pour solos fluides
|
|
- Vibrato automatique pour expressivité
|
|
- FM par souris pour pitch bend manuel
|
|
|
|
### 2. **Basse dynamique**
|
|
- Portamento lent pour transitions smooth
|
|
- Vibrato subtil pour groove
|
|
- FM pour effets de balayage
|
|
|
|
### 3. **Expérimentation sonore**
|
|
- FM extrême pour timbres métalliques
|
|
- Vibrato rapide pour effets tremolo
|
|
- Portamento ultra-lent pour drones
|
|
|
|
Votre Apple-ADB-Ressurector est maintenant un **synthétiseur expressif avec modulation sinusoïdale professionnelle** ! 🎹🌊⚡
|