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
|
@ -24,7 +24,7 @@ static char *mystrip(char *str);
|
|||
|
||||
#include "menu_pico.h"
|
||||
#include "emu.h"
|
||||
#include <pico/pico.h>
|
||||
#include <pico/pico_int.h>
|
||||
|
||||
// always output DOS endlines
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 95864e8e0d3b34402a49ae9af6c66f7e98c13c35
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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