sound, fix mcd cdda (mono, resampling), type cleanup, remove minimp3

This commit is contained in:
kub 2022-02-08 20:49:43 +00:00
parent 9f1d5acdb4
commit f7741cac91
14 changed files with 193 additions and 89 deletions

View file

@ -128,10 +128,10 @@ void mp3_start_play(void *f_, int pos1024)
mp3dec_decode(mp3_current_file, &mp3_file_pos, mp3_file_len);
}
void mp3_update(int *buffer, int length, int stereo)
void mp3_update(s32 *buffer, int length, int stereo)
{
int length_mp3, shr = 0;
void (*mix_samples)(int *dest_buf, short *mp3_buf, int count) = mix_16h_to_32;
int length_mp3;
void (*mix_samples)(int *dest_buf, short *mp3_buf, int count, int fac16) = mix_16h_to_32_resample_stereo;
if (mp3_current_file == NULL || mp3_file_pos >= mp3_file_len)
return; /* no file / EOF */
@ -139,35 +139,29 @@ void mp3_update(int *buffer, int length, int stereo)
if (!decoder_active)
return;
length_mp3 = length;
if (PicoIn.sndRate <= 11025 + 100) {
mix_samples = mix_16h_to_32_s2;
length_mp3 <<= 2; shr = 2;
}
else if (PicoIn.sndRate <= 22050 + 100) {
mix_samples = mix_16h_to_32_s1;
length_mp3 <<= 1; shr = 1;
}
length_mp3 = length * Pico.snd.cdda_mult >> 16;
if (!stereo)
mix_samples = mix_16h_to_32_resample_mono;
if (1152 - cdda_out_pos >= length_mp3) {
mix_samples(buffer, cdda_out_buffer + cdda_out_pos * 2,
length * 2);
length, Pico.snd.cdda_mult);
cdda_out_pos += length_mp3;
} else {
int ret, left = 1152 - cdda_out_pos;
int left = (1152 - cdda_out_pos) * Pico.snd.cdda_div >> 16;
int ret, sm = stereo ? 2 : 1;
if (left > 0)
mix_samples(buffer, cdda_out_buffer + cdda_out_pos * 2,
(left >> shr) * 2);
left, Pico.snd.cdda_mult);
ret = mp3dec_decode(mp3_current_file, &mp3_file_pos,
mp3_file_len);
if (ret == 0) {
cdda_out_pos = length_mp3 - left;
mix_samples(buffer + (left >> shr) * 2,
cdda_out_buffer,
(cdda_out_pos >> shr) * 2);
mix_samples(buffer + left * sm, cdda_out_buffer,
length-left, Pico.snd.cdda_mult);
cdda_out_pos = (length-left) * Pico.snd.cdda_mult >> 16;
} else
cdda_out_pos = 0;
}