mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 15:48:05 -04:00
sound, fix mcd cdda (mono, resampling), type cleanup, remove minimp3
This commit is contained in:
parent
9f1d5acdb4
commit
f7741cac91
14 changed files with 193 additions and 89 deletions
|
@ -386,16 +386,14 @@ void mp3_start_play(void *f, int pos)
|
|||
}
|
||||
|
||||
|
||||
void mp3_update(int *buffer, int length, int stereo)
|
||||
void mp3_update(s32 *buffer, int length, int stereo)
|
||||
{
|
||||
int length_mp3;
|
||||
|
||||
// playback was started, track not ended
|
||||
if (mp3_handle < 0 || mp3_src_pos >= mp3_src_size) return;
|
||||
|
||||
length_mp3 = length;
|
||||
if (PicoIn.sndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo
|
||||
else if (PicoIn.sndRate == 11025) length_mp3 <<= 2; // so make length 44100ish
|
||||
length_mp3 = length * Pico.snd.cdda_mult >> 16;
|
||||
|
||||
/* do we have to wait? */
|
||||
if (mp3_job_started && mp3_samples_ready < length_mp3)
|
||||
|
@ -409,30 +407,30 @@ void mp3_update(int *buffer, int length, int stereo)
|
|||
/* mix mp3 data, only stereo */
|
||||
if (mp3_samples_ready >= length_mp3)
|
||||
{
|
||||
int shr = 0;
|
||||
void (*mix_samples)(int *dest_buf, short *mp3_buf, int count) = mix_16h_to_32;
|
||||
if (PicoIn.sndRate == 22050) { mix_samples = mix_16h_to_32_s1; shr = 1; }
|
||||
else if (PicoIn.sndRate == 11025) { mix_samples = mix_16h_to_32_s2; shr = 2; }
|
||||
void (*mix_samples)(s32 *dest_buf, s16 *mp3_buf, int count, int fac16) = mix_16h_to_32_resample_stereo;
|
||||
if (!stereo)
|
||||
mix_samples = mix_16h_to_32_resample_mono;
|
||||
|
||||
if (1152 - mp3_buffer_offs >= length_mp3) {
|
||||
mix_samples(buffer, mp3_mix_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length<<1);
|
||||
mix_samples(buffer, mp3_mix_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length, Pico.snd.cdda_mult);
|
||||
|
||||
mp3_buffer_offs += length_mp3;
|
||||
} else {
|
||||
// collect samples from both buffers..
|
||||
int left = 1152 - mp3_buffer_offs;
|
||||
int left = (1152 - mp3_buffer_offs) * Pico.snd.cdda_div >> 16;
|
||||
int sm = stereo ? 2 : 1;
|
||||
|
||||
if (mp3_play_bufsel == 0)
|
||||
{
|
||||
mix_samples(buffer, mp3_mix_buffer[0] + mp3_buffer_offs*2, length<<1);
|
||||
mp3_buffer_offs = length_mp3 - left;
|
||||
mix_samples(buffer, mp3_mix_buffer[0] + mp3_buffer_offs*2, length, Pico.snd.cdda_mult);
|
||||
mp3_play_bufsel = 1;
|
||||
} else {
|
||||
mix_samples(buffer, mp3_mix_buffer[1] + mp3_buffer_offs*2, (left>>shr)<<1);
|
||||
mp3_buffer_offs = length_mp3 - left;
|
||||
mix_samples(buffer + ((left>>shr)<<1),
|
||||
mp3_mix_buffer[0], (mp3_buffer_offs>>shr)<<1);
|
||||
mix_samples(buffer, mp3_mix_buffer[1] + mp3_buffer_offs*2, left, Pico.snd.cdda_mult);
|
||||
mix_samples(buffer + left * sm,
|
||||
mp3_mix_buffer[0], (length-left), Pico.snd.cdda_mult);
|
||||
mp3_play_bufsel = 0;
|
||||
}
|
||||
mp3_buffer_offs = (length-left) * Pico.snd.cdda_mult >> 16;
|
||||
}
|
||||
mp3_samples_ready -= length_mp3;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue