2024-07-24 00:00:27 +02:00
|
|
|
#ifndef _MIXER_PRIV_H_
|
|
|
|
#define _MIXER_PRIV_H_
|
2024-07-23 22:31:30 +02:00
|
|
|
#include "../streamtypes.h"
|
2023-07-30 23:47:50 +02:00
|
|
|
|
|
|
|
#define VGMSTREAM_MAX_MIXING 512
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
MIX_SWAP,
|
|
|
|
MIX_ADD,
|
|
|
|
MIX_VOLUME,
|
|
|
|
MIX_LIMIT,
|
|
|
|
MIX_UPMIX,
|
|
|
|
MIX_DOWNMIX,
|
|
|
|
MIX_KILLMIX,
|
|
|
|
MIX_FADE
|
2024-07-23 22:50:36 +02:00
|
|
|
} mix_type_t;
|
2023-07-30 23:47:50 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2024-07-23 22:50:36 +02:00
|
|
|
mix_type_t type;
|
2023-07-30 23:47:50 +02:00
|
|
|
/* common */
|
|
|
|
int ch_dst;
|
|
|
|
int ch_src;
|
|
|
|
float vol;
|
|
|
|
|
|
|
|
/* fade envelope */
|
|
|
|
float vol_start; /* volume from pre to start */
|
|
|
|
float vol_end; /* volume from end to post */
|
|
|
|
char shape; /* curve type */
|
|
|
|
int32_t time_pre; /* position before time_start where vol_start applies (-1 = beginning) */
|
|
|
|
int32_t time_start; /* fade start position where vol changes from vol_start to vol_end */
|
|
|
|
int32_t time_end; /* fade end position where vol changes from vol_start to vol_end */
|
|
|
|
int32_t time_post; /* position after time_end where vol_end applies (-1 = end) */
|
2024-07-23 22:50:36 +02:00
|
|
|
} mix_op_t;
|
2023-07-30 23:47:50 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2024-07-23 23:51:44 +02:00
|
|
|
int input_channels; /* starting channels before mixing */
|
2023-07-30 23:47:50 +02:00
|
|
|
int output_channels; /* resulting channels after mixing */
|
2024-07-23 23:51:44 +02:00
|
|
|
int mixing_channels; /* max channels needed to mix */
|
|
|
|
|
|
|
|
bool active; /* mixing working */
|
2024-07-23 22:31:30 +02:00
|
|
|
|
2024-07-23 23:51:44 +02:00
|
|
|
int chain_count; /* op number */
|
|
|
|
size_t chain_size; /* max ops */
|
|
|
|
mix_op_t chain[VGMSTREAM_MAX_MIXING]; /* effects to apply (could be alloc'ed but to simplify...) */
|
2024-07-23 22:31:30 +02:00
|
|
|
|
2024-07-23 23:51:44 +02:00
|
|
|
/* fades only apply at some points, other mixes are active */
|
|
|
|
bool has_non_fade;
|
|
|
|
bool has_fade;
|
2024-07-23 22:31:30 +02:00
|
|
|
|
2023-07-30 23:47:50 +02:00
|
|
|
float* mixbuf; /* internal mixing buffer */
|
2024-07-23 22:31:30 +02:00
|
|
|
int current_channels; /* state: channels may increase/decrease during ops */
|
|
|
|
int32_t current_subpos; /* state: current sample pos in the stream */
|
2023-07-30 23:47:50 +02:00
|
|
|
|
2024-07-23 23:51:44 +02:00
|
|
|
} mixer_t;
|
|
|
|
|
|
|
|
void mixer_op_swap(mixer_t* data, int32_t sample_count, mix_op_t* op);
|
|
|
|
void mixer_op_add(mixer_t* data, int32_t sample_count, mix_op_t* op);
|
|
|
|
void mixer_op_volume(mixer_t* data, int32_t sample_count, mix_op_t* op);
|
|
|
|
void mixer_op_limit(mixer_t* data, int32_t sample_count, mix_op_t* op);
|
|
|
|
void mixer_op_upmix(mixer_t* data, int32_t sample_count, mix_op_t* op);
|
|
|
|
void mixer_op_downmix(mixer_t* data, int32_t sample_count, mix_op_t* op);
|
|
|
|
void mixer_op_killmix(mixer_t* data, int32_t sample_count, mix_op_t* op);
|
|
|
|
void mixer_op_fade(mixer_t* data, int32_t sample_count, mix_op_t* op);
|
|
|
|
bool mixer_op_fade_is_active(mixer_t* data, int32_t current_start, int32_t current_end);
|
2023-07-30 23:47:50 +02:00
|
|
|
#endif
|