ajout effets audio

This commit is contained in:
thomas committed 2026-09-05 08:49:49 +02:00
1 parent f8a79b08bf
commit 44a43828f1
14 files changed
+541 -6

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#ifndef AUDIO_EFFECTS_H
#define AUDIO_EFFECTS_H
#include "fx_equalizer.h"
#include "fx_overdrive.h"
#include "fx_saturation.h"
#include "fx_echo.h"
#include "fx_reverb.h"
/* Structure regroupant les parametres de tous les effets. Modifiable directement
* (ex: depuis l'IHM) via AudioEffects_GetParams(). L'ordre de traitement fixe est :
* egaliseur -> overdrive -> saturation -> echo -> reverberation. */
typedef struct
{
FxEqualizerParams equalizer;
FxOverdriveParams overdrive;
FxSaturationParams saturation;
FxEchoParams echo;
FxReverbParams reverb;
} AudioEffectsParams;
void AudioEffects_Init(void);
float AudioEffects_Process(float input);
AudioEffectsParams *AudioEffects_GetParams(void);
#endif /* AUDIO_EFFECTS_H */
+28
View File
@@ -0,0 +1,28 @@
#ifndef FX_ECHO_H
#define FX_ECHO_H
#include <stdbool.h>
#include <stdint.h>
#define FX_ECHO_SAMPLE_RATE 48000U
#define FX_ECHO_MAX_DELAY_MS 1000U
#define FX_ECHO_BUFFER_SIZE (FX_ECHO_SAMPLE_RATE * FX_ECHO_MAX_DELAY_MS / 1000U)
typedef struct
{
bool enabled;
float delay_ms; /* 0 a FX_ECHO_MAX_DELAY_MS */
float feedback; /* 0.0 a <1.0 */
float mix; /* 0.0 (sec) a 1.0 (100% repetitions) */
} FxEchoParams;
typedef struct
{
int16_t buffer[FX_ECHO_BUFFER_SIZE];
uint32_t write_idx;
} FxEchoState;
void FxEcho_Init(FxEchoState *state, FxEchoParams *params);
float FxEcho_Process(FxEchoState *state, const FxEchoParams *params, float input);
#endif /* FX_ECHO_H */
+44
View File
@@ -0,0 +1,44 @@
#ifndef FX_EQUALIZER_H
#define FX_EQUALIZER_H
#include <stdbool.h>
#define FX_EQ_NUM_BANDS 10U
typedef struct
{
float freq_hz; /* frequence centrale de la bande */
float gain_db; /* -24.0 a +24.0 dB */
float q; /* facteur de qualite, typiquement 0.5 a 5.0 */
} FxEqBand;
typedef struct
{
bool enabled;
FxEqBand bands[FX_EQ_NUM_BANDS];
} FxEqualizerParams;
typedef struct
{
/* coefficients biquad mis en cache, recalcules seulement si les parametres changent */
float b0, b1, b2, a1, a2;
/* dernieres valeurs de parametres utilisees pour calculer les coefficients ci-dessus */
float last_freq_hz;
float last_gain_db;
float last_q;
} FxEqBandState;
typedef struct
{
FxEqBandState band_state[FX_EQ_NUM_BANDS];
/* etat du filtre (direct form 1), par bande */
float x1[FX_EQ_NUM_BANDS];
float x2[FX_EQ_NUM_BANDS];
float y1[FX_EQ_NUM_BANDS];
float y2[FX_EQ_NUM_BANDS];
} FxEqualizerState;
void FxEqualizer_Init(FxEqualizerState *state, FxEqualizerParams *params);
float FxEqualizer_Process(FxEqualizerState *state, const FxEqualizerParams *params, float input);
#endif /* FX_EQUALIZER_H */
+22
View File
@@ -0,0 +1,22 @@
#ifndef FX_OVERDRIVE_H
#define FX_OVERDRIVE_H
#include <stdbool.h>
typedef struct
{
bool enabled;
float drive; /* 0.0 a 1.0 : quantite de distorsion */
float tone; /* 0.0 (sombre) a 1.0 (brillant) : filtre passe-bas post-distorsion */
float level; /* gain de compensation en sortie */
} FxOverdriveParams;
typedef struct
{
float tone_lp_state;
} FxOverdriveState;
void FxOverdrive_Init(FxOverdriveState *state, FxOverdriveParams *params);
float FxOverdrive_Process(FxOverdriveState *state, const FxOverdriveParams *params, float input);
#endif /* FX_OVERDRIVE_H */
+42
View File
@@ -0,0 +1,42 @@
#ifndef FX_REVERB_H
#define FX_REVERB_H
#include <stdbool.h>
#include <stdint.h>
#define FX_REVERB_NUM_COMBS 8U
#define FX_REVERB_NUM_ALLPASS 4U
typedef struct
{
bool enabled;
float room_size; /* 0.0 a 1.0 */
float damping; /* 0.0 (brillant) a 1.0 (etouffe) */
float mix; /* 0.0 (sec) a 1.0 (100% reverbere) */
} FxReverbParams;
typedef struct
{
float *buffer;
uint32_t size;
uint32_t idx;
float filter_store;
} FxCombState;
typedef struct
{
float *buffer;
uint32_t size;
uint32_t idx;
} FxAllpassState;
typedef struct
{
FxCombState combs[FX_REVERB_NUM_COMBS];
FxAllpassState allpass[FX_REVERB_NUM_ALLPASS];
} FxReverbState;
void FxReverb_Init(FxReverbState *state, FxReverbParams *params);
float FxReverb_Process(FxReverbState *state, const FxReverbParams *params, float input);
#endif /* FX_REVERB_H */
+22
View File
@@ -0,0 +1,22 @@
#ifndef FX_SATURATION_H
#define FX_SATURATION_H
#include <stdbool.h>
typedef struct
{
bool enabled;
float drive; /* 0.0 (aucun effet) a 1.0 (saturation maximale) */
float level; /* gain de compensation en sortie, typiquement 0.0 - 1.0 */
} FxSaturationParams;
typedef struct
{
float dc_block_x1;
float dc_block_y1;
} FxSaturationState;
void FxSaturation_Init(FxSaturationState *state, FxSaturationParams *params);
float FxSaturation_Process(FxSaturationState *state, const FxSaturationParams *params, float input);
#endif /* FX_SATURATION_H */