mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-09-10 16:53:15 +02:00
. adjusted synchronization between PSG & FM cores (better avoid generating additional samples)
This commit is contained in:
parent
39dc73d406
commit
868f14dc44
@ -325,7 +325,7 @@ int SN76489_Update(INT16 *buffer, int clock_length)
|
||||
return blip_read_samples(blip, buffer);
|
||||
}
|
||||
|
||||
int SN76489_Sync(unsigned int samples)
|
||||
int SN76489_Clocks(int length)
|
||||
{
|
||||
return blip_clocks_needed(blip, samples);
|
||||
}
|
||||
return blip_clocks_needed(blip, length);
|
||||
}
|
@ -17,6 +17,7 @@ extern uint8 *SN76489_GetContextPtr(void);
|
||||
extern int SN76489_GetContextSize(void);
|
||||
extern void SN76489_Write(int data);
|
||||
extern int SN76489_Update(INT16 *buffer, int clock_length);
|
||||
extern int SN76489_Sync(unsigned int samples);
|
||||
extern int SN76489_Clocks(int length);
|
||||
extern void SN76489_BoostNoise(int boost);
|
||||
|
||||
#endif /* _SN76489_H_ */
|
@ -271,14 +271,14 @@ int sound_context_load(uint8 *state)
|
||||
/* End of frame update, return the number of samples run so far. */
|
||||
int sound_update(unsigned int cycles)
|
||||
{
|
||||
int size, delta;
|
||||
int size, avail;
|
||||
|
||||
/* run PSG & FM chips until end of frame */
|
||||
cycles <<= 11;
|
||||
psg_update(cycles);
|
||||
fm_update(cycles);
|
||||
|
||||
/* return available FM samples */
|
||||
/* check number of available FM samples */
|
||||
if (config.hq_fm)
|
||||
{
|
||||
size = Fir_Resampler_avail();
|
||||
@ -291,22 +291,25 @@ int sound_update(unsigned int cycles)
|
||||
error("%d FM samples available\n",size);
|
||||
#endif
|
||||
|
||||
/* compare with number of PSG samples available */
|
||||
delta = size - (snd.psg.pos - snd.psg.buffer);
|
||||
/* check number of available PSG samples */
|
||||
avail = snd.psg.pos - snd.psg.buffer;
|
||||
#ifdef LOGSOUND
|
||||
error("%d PSG samples available\n", snd.psg.pos - snd.psg.buffer);
|
||||
error("%d PSG samples available\n", avail);
|
||||
#endif
|
||||
|
||||
/* resynchronize FM & PSG chips */
|
||||
if (delta > 0)
|
||||
if (size > avail)
|
||||
{
|
||||
/* PSG chip is late, get needed samples */
|
||||
snd.psg.pos += SN76489_Update(snd.psg.pos, SN76489_Sync(delta));
|
||||
/* FM chip is ahead */
|
||||
fm_cycles_count += SN76489_Clocks(size - avail) * psg_cycles_ratio;
|
||||
|
||||
/* return number of available samples */
|
||||
size = avail;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* PSG chip is ahead, adjust clocks count */
|
||||
psg_cycles_count += (SN76489_Sync(-delta) * psg_cycles_ratio);
|
||||
/* PSG chip is ahead */
|
||||
psg_cycles_count += SN76489_Clocks(avail - size) * psg_cycles_ratio;
|
||||
}
|
||||
|
||||
#ifdef LOGSOUND
|
||||
|
Loading…
Reference in New Issue
Block a user