Sound improvements, especially CD Audio and the Sound Blasters.

This commit is contained in:
OBattler
2020-10-21 02:46:50 +02:00
parent baee7c1530
commit 6e013acf95
9 changed files with 1457 additions and 1471 deletions

View File

@@ -1,186 +1,5 @@
#define NCoef 2 #define NCoef 2
/* fc=350Hz */
static inline float low_iir(int i, float NewSample) {
float ACoef[NCoef+1] = {
0.00049713569693400649,
0.00099427139386801299,
0.00049713569693400649
};
float BCoef[NCoef+1] = {
1.00000000000000000000,
-1.93522955470669530000,
0.93726236021404663000
};
static float y[2][NCoef+1]; /* output samples */
static float x[2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[i][n] = x[i][n-1];
y[i][n] = y[i][n-1];
}
/* Calculate the new output */
x[i][0] = NewSample;
y[i][0] = ACoef[0] * x[i][0];
for(n=1; n<=NCoef; n++)
y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n];
return y[i][0];
}
/* fc=350Hz */
static inline float low_cut_iir(int i, float NewSample) {
float ACoef[NCoef+1] = {
0.96839970114733542000,
-1.93679940229467080000,
0.96839970114733542000
};
float BCoef[NCoef+1] = {
1.00000000000000000000,
-1.93522955471202770000,
0.93726236021916731000
};
static float y[2][NCoef+1]; /* output samples */
static float x[2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[i][n] = x[i][n-1];
y[i][n] = y[i][n-1];
}
/* Calculate the new output */
x[i][0] = NewSample;
y[i][0] = ACoef[0] * x[i][0];
for(n=1; n<=NCoef; n++)
y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n];
return y[i][0];
}
/* fc=3.5kHz */
static inline float high_iir(int i, float NewSample) {
float ACoef[NCoef+1] = {
0.72248704753064896000,
-1.44497409506129790000,
0.72248704753064896000
};
float BCoef[NCoef+1] = {
1.00000000000000000000,
-1.36640781670578510000,
0.52352474706139873000
};
static float y[2][NCoef+1]; /* output samples */
static float x[2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[i][n] = x[i][n-1];
y[i][n] = y[i][n-1];
}
/* Calculate the new output */
x[i][0] = NewSample;
y[i][0] = ACoef[0] * x[i][0];
for(n=1; n<=NCoef; n++)
y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n];
return y[i][0];
}
/* fc=3.5kHz */
static inline float high_cut_iir(int i, float NewSample) {
float ACoef[NCoef+1] = {
0.03927726802250377400,
0.07855453604500754700,
0.03927726802250377400
};
float BCoef[NCoef+1] = {
1.00000000000000000000,
-1.36640781666419950000,
0.52352474703279628000
};
static float y[2][NCoef+1]; /* output samples */
static float x[2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[i][n] = x[i][n-1];
y[i][n] = y[i][n-1];
}
/* Calculate the new output */
x[i][0] = NewSample;
y[i][0] = ACoef[0] * x[i][0];
for(n=1; n<=NCoef; n++)
y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n];
return y[i][0];
}
#undef NCoef
#define NCoef 2
/* fc=3.2kHz */
static inline float sb_iir(int i, float NewSample) {
float ACoef[NCoef+1] = {
0.03356837051492005100,
0.06713674102984010200,
0.03356837051492005100
};
float BCoef[NCoef+1] = {
1.00000000000000000000,
-1.41898265221812010000,
0.55326988968868285000
};
/* float ACoef[NCoef+1] = {
0.17529642630084405000,
0.17529642630084405000
};
float BCoef[NCoef+1] = {
1.00000000000000000000,
-0.64940759319751051000
};*/
static float y[2][NCoef+1]; /* output samples */
static float x[2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[i][n] = x[i][n-1];
y[i][n] = y[i][n-1];
}
/* Calculate the new output */
x[i][0] = NewSample;
y[i][0] = ACoef[0] * x[i][0];
for(n=1; n<=NCoef; n++)
y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n];
return y[i][0];
}
#undef NCoef
#define NCoef 2
/* fc=150Hz */ /* fc=150Hz */
static inline float adgold_highpass_iir(int i, float NewSample) { static inline float adgold_highpass_iir(int i, float NewSample) {
float ACoef[NCoef+1] = { float ACoef[NCoef+1] = {
@@ -347,30 +166,204 @@ static inline float dac_iir(int i, float NewSample) {
} }
#undef NCoef
#define NCoef 2
/* fc=350Hz */
static inline double low_iir(int c, int i, double NewSample) {
double ACoef[NCoef+1] = {
0.00049713569693400649,
0.00099427139386801299,
0.00049713569693400649
};
double BCoef[NCoef+1] = {
1.00000000000000000000,
-1.93522955470669530000,
0.93726236021404663000
};
static double y[2][2][NCoef+1]; /* output samples */
static double x[2][2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[c][i][n] = x[c][i][n-1];
y[c][i][n] = y[c][i][n-1];
}
/* Calculate the new output */
x[c][i][0] = NewSample;
y[c][i][0] = ACoef[0] * x[c][i][0];
for(n=1; n<=NCoef; n++)
y[c][i][0] += ACoef[n] * x[c][i][n] - BCoef[n] * y[c][i][n];
return y[c][i][0];
}
/* fc=350Hz */
static inline double low_cut_iir(int c, int i, double NewSample) {
double ACoef[NCoef+1] = {
0.96839970114733542000,
-1.93679940229467080000,
0.96839970114733542000
};
double BCoef[NCoef+1] = {
1.00000000000000000000,
-1.93522955471202770000,
0.93726236021916731000
};
static double y[2][2][NCoef+1]; /* output samples */
static double x[2][2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[c][i][n] = x[c][i][n-1];
y[c][i][n] = y[c][i][n-1];
}
/* Calculate the new output */
x[c][i][0] = NewSample;
y[c][i][0] = ACoef[0] * x[c][i][0];
for(n=1; n<=NCoef; n++)
y[c][i][0] += ACoef[n] * x[c][i][n] - BCoef[n] * y[c][i][n];
return y[c][i][0];
}
/* fc=3.5kHz */
static inline double high_iir(int c, int i, double NewSample) {
double ACoef[NCoef+1] = {
0.72248704753064896000,
-1.44497409506129790000,
0.72248704753064896000
};
double BCoef[NCoef+1] = {
1.00000000000000000000,
-1.36640781670578510000,
0.52352474706139873000
};
static double y[2][2][NCoef+1]; /* output samples */
static double x[2][2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[c][i][n] = x[c][i][n-1];
y[c][i][n] = y[c][i][n-1];
}
/* Calculate the new output */
x[c][i][0] = NewSample;
y[c][i][0] = ACoef[0] * x[c][i][0];
for(n=1; n<=NCoef; n++)
y[c][i][0] += ACoef[n] * x[c][i][n] - BCoef[n] * y[c][i][n];
return y[c][i][0];
}
/* fc=3.5kHz */
static inline double high_cut_iir(int c, int i, double NewSample) {
double ACoef[NCoef+1] = {
0.03927726802250377400,
0.07855453604500754700,
0.03927726802250377400
};
double BCoef[NCoef+1] = {
1.00000000000000000000,
-1.36640781666419950000,
0.52352474703279628000
};
static double y[2][2][NCoef+1]; /* output samples */
static double x[2][2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[c][i][n] = x[c][i][n-1];
y[c][i][n] = y[c][i][n-1];
}
/* Calculate the new output */
x[c][i][0] = NewSample;
y[c][i][0] = ACoef[0] * x[c][i][0];
for(n=1; n<=NCoef; n++)
y[c][i][0] += ACoef[n] * x[c][i][n] - BCoef[n] * y[c][i][n];
return y[c][i][0];
}
#undef NCoef
#define NCoef 2
/* fc=3.2kHz */
static inline double sb_iir(int c, int i, double NewSample) {
double ACoef[NCoef+1] = {
0.03356837051492005100,
0.06713674102984010200,
0.03356837051492005100
};
double BCoef[NCoef+1] = {
1.00000000000000000000,
-1.41898265221812010000,
0.55326988968868285000
};
static double y[2][2][NCoef+1]; /* output samples */
static double x[2][2][NCoef+1]; /* input samples */
int n;
/* shift the old samples */
for(n=NCoef; n>0; n--) {
x[c][i][n] = x[c][i][n-1];
y[c][i][n] = y[c][i][n-1];
}
/* Calculate the new output */
x[c][i][0] = NewSample;
y[c][i][0] = ACoef[0] * x[c][i][0];
for(n=1; n<=NCoef; n++)
y[c][i][0] += ACoef[n] * x[c][i][n] - BCoef[n] * y[c][i][n];
return y[c][i][0];
}
#undef NCoef
#define NCoef 1
#define SB16_NCoef 51 #define SB16_NCoef 51
extern float low_fir_sb16_coef[SB16_NCoef]; extern double low_fir_sb16_coef[2][SB16_NCoef];
static inline float low_fir_sb16(int i, float NewSample) static inline double low_fir_sb16(int c, int i, double NewSample)
{ {
static float x[2][SB16_NCoef+1]; //input samples static double x[2][2][SB16_NCoef+1]; //input samples
static int pos = 0; static int pos[2] = { 0, 0 };
float out = 0.0; double out = 0.0;
int n; int n;
/* Calculate the new output */ /* Calculate the new output */
x[i][pos] = NewSample; x[c][i][pos[c]] = NewSample;
for (n = 0; n < ((SB16_NCoef+1)-pos) && n < SB16_NCoef; n++) for (n = 0; n < ((SB16_NCoef+1)-pos[c]) && n < SB16_NCoef; n++)
out += low_fir_sb16_coef[n] * x[i][n+pos]; out += low_fir_sb16_coef[c][n] * x[c][i][n+pos[c]];
for (; n < SB16_NCoef; n++) for (; n < SB16_NCoef; n++)
out += low_fir_sb16_coef[n] * x[i][(n+pos) - (SB16_NCoef+1)]; out += low_fir_sb16_coef[c][n] * x[c][i][(n+pos[c]) - (SB16_NCoef+1)];
if (i == 1) if (i == 1)
{ {
pos++; pos[c]++;
if (pos > SB16_NCoef) if (pos[c] > SB16_NCoef)
pos = 0; pos[c] = 0;
} }
return out; return out;

View File

@@ -37,10 +37,10 @@
/* SB 2.0 CD version */ /* SB 2.0 CD version */
typedef struct sb_ct1335_mixer_t typedef struct sb_ct1335_mixer_t
{ {
int32_t master; double master;
int32_t voice; double voice;
int32_t fm; double fm;
int32_t cd; double cd;
uint8_t index; uint8_t index;
uint8_t regs[256]; uint8_t regs[256];
@@ -48,12 +48,12 @@ typedef struct sb_ct1335_mixer_t
/* SB PRO */ /* SB PRO */
typedef struct sb_ct1345_mixer_t typedef struct sb_ct1345_mixer_t
{ {
int32_t master_l, master_r; double master_l, master_r;
int32_t voice_l, voice_r; double voice_l, voice_r;
int32_t fm_l, fm_r; double fm_l, fm_r;
int32_t cd_l, cd_r; double cd_l, cd_r;
int32_t line_l, line_r; double line_l, line_r;
int32_t mic; double mic;
/*see sb_ct1745_mixer for values for input selector*/ /*see sb_ct1745_mixer for values for input selector*/
int32_t input_selector; int32_t input_selector;
@@ -71,13 +71,13 @@ typedef struct sb_ct1345_mixer_t
/* SB16 and AWE32 */ /* SB16 and AWE32 */
typedef struct sb_ct1745_mixer_t typedef struct sb_ct1745_mixer_t
{ {
int32_t master_l, master_r; double master_l, master_r;
int32_t voice_l, voice_r; double voice_l, voice_r;
int32_t fm_l, fm_r; double fm_l, fm_r;
int32_t cd_l, cd_r; double cd_l, cd_r;
int32_t line_l, line_r; double line_l, line_r;
int32_t mic; double mic;
int32_t speaker; double speaker;
int bass_l, bass_r; int bass_l, bass_r;
int treble_l, treble_r; int treble_l, treble_r;
@@ -103,8 +103,8 @@ typedef struct sb_ct1745_mixer_t
int32_t input_gain_L; int32_t input_gain_L;
int32_t input_gain_R; int32_t input_gain_R;
int32_t output_gain_L; double output_gain_L;
int32_t output_gain_R; double output_gain_R;
uint8_t index; uint8_t index;
uint8_t regs[256]; uint8_t regs[256];
@@ -112,7 +112,7 @@ typedef struct sb_ct1745_mixer_t
typedef struct sb_t typedef struct sb_t
{ {
uint8_t opl_enabled; uint8_t opl_enabled, mixer_enabled;
opl_t opl, opl2; opl_t opl, opl2;
sb_dsp_t dsp; sb_dsp_t dsp;
union { union {
@@ -133,6 +133,7 @@ extern uint8_t sb_ct1345_mixer_read(uint16_t addr, void *p);
extern void sb_ct1345_mixer_reset(sb_t* sb); extern void sb_ct1345_mixer_reset(sb_t* sb);
extern void sb_get_buffer_sbpro(int32_t *buffer, int len, void *p); extern void sb_get_buffer_sbpro(int32_t *buffer, int len, void *p);
extern void sbpro_filter_cd_audio(int channel, double *buffer, void *p);
extern void sb_close(void *p); extern void sb_close(void *p);
extern void sb_speed_changed(void *p); extern void sb_speed_changed(void *p);

View File

@@ -46,7 +46,7 @@ extern int sound_card_current;
extern void sound_add_handler(void (*get_buffer)(int32_t *buffer, \ extern void sound_add_handler(void (*get_buffer)(int32_t *buffer, \
int len, void *p), void *p); int len, void *p), void *p);
extern void sound_set_cd_audio_filter(void (*filter)(int channel, \ extern void sound_set_cd_audio_filter(void (*filter)(int channel, \
float *buffer, void *p), void *p); double *buffer, void *p), void *p);
extern int sound_card_available(int card); extern int sound_card_available(int card);
extern char *sound_card_getname(int card); extern char *sound_card_getname(int card);

View File

@@ -221,14 +221,14 @@ static void ad1848_poll(void *p)
} }
} }
static void ad1848_filter_cd_audio(int channel, float *buffer, void *p) static void ad1848_filter_cd_audio(int channel, double *buffer, void *p)
{ {
ad1848_t *ad1848 = (ad1848_t *)p; ad1848_t *ad1848 = (ad1848_t *)p;
int32_t c; int32_t c;
uint32_t volume = channel ? ad1848->cd_vol_r : ad1848->cd_vol_l; uint32_t volume = channel ? ad1848->cd_vol_r : ad1848->cd_vol_l;
c = (((int32_t) *buffer) * volume) >> 16; c = (((int32_t) *buffer) * volume) >> 16;
*buffer = (float) c; *buffer = (double) c;
} }
void ad1848_init(ad1848_t *ad1848, int type) void ad1848_init(ad1848_t *ad1848, int type)

View File

@@ -1274,7 +1274,7 @@ static void es1371_get_buffer(int32_t *buffer, int len, void *p)
es1371->pos = 0; es1371->pos = 0;
} }
static void es1371_filter_cd_audio(int channel, float *buffer, void *p) static void es1371_filter_cd_audio(int channel, double *buffer, void *p)
{ {
es1371_t *es1371 = (es1371_t *)p; es1371_t *es1371 = (es1371_t *)p;
int32_t c; int32_t c;
@@ -1284,7 +1284,7 @@ static void es1371_filter_cd_audio(int channel, float *buffer, void *p)
c = (((int32_t) *buffer) * cd) >> 15; c = (((int32_t) *buffer) * cd) >> 15;
c = (c * master) >> 15; c = (c * master) >> 15;
*buffer = (float) c; *buffer = (double) c;
} }
static inline double sinc(double x) static inline double sinc(double x)

View File

@@ -1172,6 +1172,7 @@ azt_init(const device_t *info)
azt2316a_create_config_word(azt2316a); azt2316a_create_config_word(azt2316a);
sound_add_handler(azt2316a_get_buffer, azt2316a); sound_add_handler(azt2316a_get_buffer, azt2316a);
sound_set_cd_audio_filter(sbpro_filter_cd_audio, azt2316a->sb);
if (azt2316a->cur_mpu401_enabled) { if (azt2316a->cur_mpu401_enabled) {
azt2316a->mpu = (mpu_t *) malloc(sizeof(mpu_t)); azt2316a->mpu = (mpu_t *) malloc(sizeof(mpu_t));

File diff suppressed because it is too large Load Diff

View File

@@ -117,7 +117,7 @@ uint8_t adjustMap2[24] = {
252, 0, 252, 0 252, 0, 252, 0
}; };
float low_fir_sb16_coef[SB16_NCoef]; double low_fir_sb16_coef[2][SB16_NCoef];
#ifdef ENABLE_SB_DSP_LOG #ifdef ENABLE_SB_DSP_LOG
@@ -147,13 +147,15 @@ sinc(double x)
} }
static void static void
recalc_sb16_filter(int playback_freq) recalc_sb16_filter(int c, int playback_freq)
{ {
/* Cutoff frequency = playback / 2 */ /* Cutoff frequency = playback / 2 */
float fC = ((float)playback_freq / 2.0) / 48000.0;
float gain;
int n; int n;
double w, h; double w, h;
double fC = ((double) playback_freq) / 96000.0;
double gain;
pclog("recalc_sb16_filter(%i, %i)\n", c, playback_freq);
for (n = 0; n < SB16_NCoef; n++) { for (n = 0; n < SB16_NCoef; n++) {
/* Blackman window */ /* Blackman window */
@@ -162,18 +164,18 @@ recalc_sb16_filter(int playback_freq)
h = sinc(2.0 * fC * ((double)n - ((double)(SB16_NCoef-1) / 2.0))); h = sinc(2.0 * fC * ((double)n - ((double)(SB16_NCoef-1) / 2.0)));
/* Create windowed-sinc filter */ /* Create windowed-sinc filter */
low_fir_sb16_coef[n] = w * h; low_fir_sb16_coef[c][n] = w * h;
} }
low_fir_sb16_coef[(SB16_NCoef - 1) / 2] = 1.0; low_fir_sb16_coef[c][(SB16_NCoef - 1) / 2] = 1.0;
gain = 0.0; gain = 0.0;
for (n = 0; n < SB16_NCoef; n++) for (n = 0; n < SB16_NCoef; n++)
gain += low_fir_sb16_coef[n]; gain += low_fir_sb16_coef[c][n];
/* Normalise filter, to produce unity gain */ /* Normalise filter, to produce unity gain */
for (n = 0; n < SB16_NCoef; n++) for (n = 0; n < SB16_NCoef; n++)
low_fir_sb16_coef[n] /= gain; low_fir_sb16_coef[c][n] /= gain;
} }
@@ -555,7 +557,7 @@ sb_exec_command(sb_dsp_t *dsp)
temp = 1000000 / temp; temp = 1000000 / temp;
sb_dsp_log("Sample rate - %ihz (%i)\n",temp, dsp->sblatcho); sb_dsp_log("Sample rate - %ihz (%i)\n",temp, dsp->sblatcho);
if ((dsp->sb_freq != temp) && (dsp->sb_type >= SB16)) if ((dsp->sb_freq != temp) && (dsp->sb_type >= SB16))
recalc_sb16_filter(temp); recalc_sb16_filter(0, temp);
dsp->sb_freq = temp; dsp->sb_freq = temp;
break; break;
case 0x41: /* Set output sampling rate */ case 0x41: /* Set output sampling rate */
@@ -569,7 +571,7 @@ sb_exec_command(sb_dsp_t *dsp)
dsp->sblatchi = dsp->sblatcho; dsp->sblatchi = dsp->sblatcho;
dsp->sb_timei = dsp->sb_timeo; dsp->sb_timei = dsp->sb_timeo;
if (dsp->sb_freq != temp && dsp->sb_type >= SB16) if (dsp->sb_freq != temp && dsp->sb_type >= SB16)
recalc_sb16_filter(dsp->sb_freq); recalc_sb16_filter(0, dsp->sb_freq);
} }
break; break;
case 0x48: /* Set DSP block transfer size */ case 0x48: /* Set DSP block transfer size */
@@ -1046,7 +1048,8 @@ sb_dsp_init(sb_dsp_t *dsp, int type, int subtype, void *parent)
/* Initialise SB16 filter to same cutoff as 8-bit SBs (3.2 kHz). This will be recalculated when /* Initialise SB16 filter to same cutoff as 8-bit SBs (3.2 kHz). This will be recalculated when
a set frequency command is sent. */ a set frequency command is sent. */
recalc_sb16_filter(3200*2); recalc_sb16_filter(0, 3200*2);
recalc_sb16_filter(1, 44100);
} }

View File

@@ -77,7 +77,7 @@ static int cd_buf_update = CD_BUFLEN / SOUNDBUFLEN;
static volatile int cdaudioon = 0; static volatile int cdaudioon = 0;
static int cd_thread_enable = 0; static int cd_thread_enable = 0;
static void (*filter_cd_audio)(int channel, float *buffer, void *p) = NULL; static void (*filter_cd_audio)(int channel, double *buffer, void *p) = NULL;
static void *filter_cd_audio_p = NULL; static void *filter_cd_audio_p = NULL;
@@ -215,8 +215,8 @@ static void
sound_cd_thread(void *param) sound_cd_thread(void *param)
{ {
int c, r, i, channel_select[2]; int c, r, i, channel_select[2];
float audio_vol_l, audio_vol_r; double audio_vol_l, audio_vol_r;
float cd_buffer_temp[2] = {0.0, 0.0}; double cd_buffer_temp[2] = {0.0, 0.0};
thread_set_event(sound_cd_start_event); thread_set_event(sound_cd_start_event);
@@ -274,18 +274,18 @@ sound_cd_thread(void *param)
if ((audio_vol_l != 0.0) && (channel_select[0] != 0)) { if ((audio_vol_l != 0.0) && (channel_select[0] != 0)) {
if (channel_select[0] & 1) if (channel_select[0] & 1)
cd_buffer_temp[0] += ((float) cd_buffer[i][c]); /* Channel 0 => Port 0 */ cd_buffer_temp[0] += ((double) cd_buffer[i][c]); /* Channel 0 => Port 0 */
if (channel_select[0] & 2) if (channel_select[0] & 2)
cd_buffer_temp[0] += ((float) cd_buffer[i][c + 1]); /* Channel 1 => Port 0 */ cd_buffer_temp[0] += ((double) cd_buffer[i][c + 1]); /* Channel 1 => Port 0 */
cd_buffer_temp[0] *= audio_vol_l; /* Multiply Port 0 by Port 0 volume */ cd_buffer_temp[0] *= audio_vol_l; /* Multiply Port 0 by Port 0 volume */
} }
if ((audio_vol_r != 0.0) && (channel_select[1] != 0)) { if ((audio_vol_r != 0.0) && (channel_select[1] != 0)) {
if (channel_select[1] & 1) if (channel_select[1] & 1)
cd_buffer_temp[1] += ((float) cd_buffer[i][c]); /* Channel 0 => Port 1 */ cd_buffer_temp[1] += ((double) cd_buffer[i][c]); /* Channel 0 => Port 1 */
if (channel_select[1] & 2) if (channel_select[1] & 2)
cd_buffer_temp[1] += ((float) cd_buffer[i][c + 1]); /* Channel 1 => Port 1 */ cd_buffer_temp[1] += ((double) cd_buffer[i][c + 1]); /* Channel 1 => Port 1 */
cd_buffer_temp[1] *= audio_vol_r; /* Multiply Port 1 by Port 1 volume */ cd_buffer_temp[1] *= audio_vol_r; /* Multiply Port 1 by Port 1 volume */
} }
@@ -297,8 +297,8 @@ sound_cd_thread(void *param)
} }
if (sound_is_float) { if (sound_is_float) {
cd_out_buffer[c] += (cd_buffer_temp[0] / 32768.0); cd_out_buffer[c] += (float) (cd_buffer_temp[0] / 32768.0);
cd_out_buffer[c+1] += (cd_buffer_temp[1] / 32768.0); cd_out_buffer[c+1] += (float) (cd_buffer_temp[1] / 32768.0);
} else { } else {
if (cd_buffer_temp[0] > 32767) if (cd_buffer_temp[0] > 32767)
cd_buffer_temp[0] = 32767; cd_buffer_temp[0] = 32767;
@@ -309,8 +309,8 @@ sound_cd_thread(void *param)
if (cd_buffer_temp[1] < -32768) if (cd_buffer_temp[1] < -32768)
cd_buffer_temp[1] = -32768; cd_buffer_temp[1] = -32768;
cd_out_buffer_int16[c] += cd_buffer_temp[0]; cd_out_buffer_int16[c] += (int16_t) cd_buffer_temp[0];
cd_out_buffer_int16[c+1] += cd_buffer_temp[1]; cd_out_buffer_int16[c+1] += (int16_t) cd_buffer_temp[1];
} }
} }
} }
@@ -384,7 +384,7 @@ sound_add_handler(void (*get_buffer)(int32_t *buffer, int len, void *p), void *p
void void
sound_set_cd_audio_filter(void (*filter)(int channel, float *buffer, void *p), void *p) sound_set_cd_audio_filter(void (*filter)(int channel, double *buffer, void *p), void *p)
{ {
if ((filter_cd_audio == NULL) || (filter == NULL)) { if ((filter_cd_audio == NULL) || (filter == NULL)) {
filter_cd_audio = filter; filter_cd_audio = filter;