Closed ghost closed 6 years ago
Thanks for the explanation on retropie's forum. Besides the other 2 drivers, It seems only aztarac is suffering from this issue in fba. So basically, those games are running too fast because the samplerate is higher than the framerate.
This is pretty weird though, parallel n64 seems to achieve 30fps framerate with a samplerate of 44.1k . Is that because we are using retro_set_audio_sample_batch
and not retro_set_audio_sample
?
@twinaphex @fr500 any thoughts about this ?
Drop you set sample rate from 48k to 22 and try again restart the core after you do this
you dont need to read the conversation this is the code changes i done to get it to work https://github.com/libretro/mame2003-plus-libretro/pull/94 im not changing the sample rate just changing the timing. I think thats what it doing anyway im not tech savy on the retroarch end. I dont want to interfere with your core just giving some input that might or might not help you fix the issues.
I didn't manage to get the timing right so i downgraded the samplerate. If someone comes up with a better solution (without changing fba codebase, which i think is fine, the issue is in the "frontend" part of the core), i'm interested. I'll also tag @arcadez for this issue, he could be interested.
what i did is simple i set the retroarch timing
info->timing.sample_rate = Machine->drv->frames_per_second * 1000;
then on audio init instead if the the static sample rate set eg 48k to
Machine->sample_rate = Machine->drv->frames_per_second * 1000;
this way it only plays the audio time frame it needs to hope that explains it timing wise for you
here is our audio setup i will just post the two functions you need see for the timing
int osd_start_audio_stream(int stereo) {
Machine->sample_rate = Machine->drv->frames_per_second * 1000;
delta_samples = 0.0f;
usestereo = stereo ? 1 : 0;
/* determine the number of samples per frame */
samples_per_frame = Machine->sample_rate / Machine->drv->frames_per_second;
if (Machine->sample_rate == 0) return 0;
samples_buffer = (short *) calloc(samples_per_frame, 2 + usestereo * 2);
if (!usestereo) conversion_buffer = (short *) calloc(samples_per_frame, 4);
return samples_per_frame;
}
int osd_update_audio_stream(INT16 *buffer) { int i,j;
if ( Machine->sample_rate !=0 && buffer )
{
memcpy(samples_buffer, buffer, samples_per_frame * (usestereo ? 4 : 2));
if (usestereo)
audio_batch_cb(samples_buffer, samples_per_frame);
else
{
for (i = 0, j = 0; i < samples_per_frame; i++)
{
conversion_buffer[j++] = samples_buffer[i];
conversion_buffer[j++] = samples_buffer[i];
}
audio_batch_cb(conversion_buffer,samples_per_frame);
}
delta_samples += (Machine->sample_rate / Machine->drv->frames_per_second) - samples_per_frame;
if (delta_samples >= 1.0f)
{
int integer_delta = (int)delta_samples;
samples_per_frame += integer_delta;
delta_samples -= integer_delta;
}
}
return samples_per_frame;
}
@grant2258
im not changing the sample rate
Are you sure that's not what you are doing there : Machine->sample_rate = Machine->drv->frames_per_second * 1000;
?
Well, i think i found a nice solution to compute a correct nAudSegLen
(which is used to calculate the sample rate timing, mame2003 seems to use a static value of 1000) without actually changing nBurnSoundRate
(probably the equivalent of your Machine->sample_rate
).
Thanks for the help, i'm closing.
thats the numbers to work out the samples per frame to play. Glad you got it fixed
here is a list of that caused sound timing issues in mame2003 in the past until i fixed the issue. I seen the issues with sound raspeberry pi forums the issues here might be different im not sure how you guy hooked your sound timing up. What i will say is close this issue if all these games run fine. If you do have issues with some issues with them it will be sample rate timing issues changing the core speed. This is what cause the bad mame input and dipswitch and service lock bugs for mame and i see you guys are having some issues is just a pointer to what it could be
archriv2 Arch Rivals (rev 2.0) 30.000000 archrivl Arch Rivals (rev 4.0) 30.000000 armora Armor Attack 38.000000 armorap Armor Attack (prototype) 38.000000 armorar Armor Attack (Rock-ola) 38.000000 aztarac Aztarac 40.000000 barrier Barrier 38.000000 bigrun Big Run (11th Rallye version) 30.000000 blasted Blasted 30.000000 boxingb Boxing Bugs 38.000000 bradley Bradley Trainer 40.000000 bzone Battle Zone (set 1) 40.000000 bzone2 Battle Zone (set 2) 40.000000 bzonec Battle Zone (cocktail) 40.000000 cchasm Cosmic Chasm (set 1) 40.000000 cchasm1 Cosmic Chasm (set 2) 40.000000 cischeat Cisco Heat 30.000000 crater Crater Raider 30.000000 dairesya Dai Ressya Goutou (Japan) 30.000000 deltrace Delta Race 40.000000 demoderb Demolition Derby 30.000000 demoderm Demolition Derby (2-Player Mono Board Version) 30.000000 demon Demon 38.000000 domino Domino Man 30.000000 dotron Discs of Tron (Upright) 30.000000 dotrona Discs of Tron (Upright alternate) 30.000000 dotrone Discs of Tron (Environmental) 30.000000 elim2 Eliminator (2 Players, set 1) 40.000000 elim2a Eliminator (2 Players, set 2) 40.000000 elim4 Eliminator (4 Players) 40.000000 esb The Empire Strikes Back 30.000000 f1gpstar Grand Prix Star 30.000000 f1gpstr2 F-1 Grand Prix Star II 30.000000 farwest Far West 30.000000 gberet Green Beret 30.000000 ironhors Iron Horse 30.000000 journey Journey 30.000000 junofrst Juno First 30.000000 junofstg Juno First (Gottlieb) 30.000000 kick Kick (upright) 30.000000 kicka Kick (cocktail) 30.000000 kroozr Kozmik Kroozr 30.000000 llander Lunar Lander (rev 2) 40.000000 llander1 Lunar Lander (rev 1) 40.000000 lunarba1 Lunar Battle (prototype, earlier) 45.000000 maxrpm Max RPM 30.000000 omegrace Omega Race 40.000000 pigskin Pigskin 621AD 30.000000 powerdrv Power Drive 30.000000 rampage Rampage (revision 3) 30.000000 rampage2 Rampage (revision 2) 30.000000 rbtapper Tapper (Root Beer) 30.000000 redbaron Red Baron 45.000000 ripoff Rip Off 38.000000 rushatck Rush'n Attack 30.000000 sarge Sarge 30.000000 scudhamm Scud Hammer 30.000000 shangha2 Shanghai II (Japan) 30.000000 shanghai Shanghai (Japan) 30.000000 shollow Satan's Hollow (set 1) 30.000000 shollow2 Satan's Hollow (set 2) 30.000000 solarfox Solar Fox 30.000000 solarq Solar Quest 38.000000 spacduel Space Duel 45.000000 spacewar Space Wars 38.000000 spacfura Space Fury (revision A) 40.000000 spacfury Space Fury (revision C) 40.000000 speedfrk Speed Freak 38.000000 spyhnt2a Spy Hunter 2 (rev 1) 30.000000 spyhunt Spy Hunter 30.000000 spyhunt2 Spy Hunter 2 (rev 2) 30.000000 starcas Star Castle (version 3) 38.000000 starcas1 Star Castle (older) 38.000000 starcase Star Castle (Mottoeis) 38.000000 starcasp Star Castle (prototype) 38.000000 stargrds Star Guards 30.000000 starhawk Star Hawk 38.000000 startrek Star Trek 40.000000 starwar1 Star Wars (rev 1) 30.000000 starwars Star Wars (rev 2) 30.000000 stellcas Stellar Castle (Elettronolo) 38.000000 sundance Sundance 38.000000 sutapper Tapper (Suntory) 30.000000 tacscan Tac/Scan 40.000000 tailg Tailgunner 38.000000 tapper Tapper (Budweiser) 30.000000 tappera Tapper (alternate) 30.000000 timber Timber 30.000000 trisport Tri-Sports 30.000000 tron Tron (set 1) 30.000000 tron2 Tron (set 2) 30.000000 turbotag Turbo Tag (prototype) 30.000000 tutankhm Tutankham 30.000000 tutankst Tutankham (Stern) 30.000000 twotiger Two Tigers 30.000000 twotigra Two Tigers (dedicated) 30.000000 wacko Wacko 30.000000 warrior Warrior 38.000000 wotw War of the Worlds 38.000000 xenophob Xenophobe 30.000000 zektor Zektor (revision B) 40.000000 zwackery Zwackery 30.000000