Skip to content

Commit

Permalink
sound: fix ym2612 forgetting lfo state when dac is on
Browse files Browse the repository at this point in the history
for less bad audio in OD2
  • Loading branch information
notaz committed Jun 15, 2023
1 parent 8013663 commit 8ec805d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pico/sound/ym2612.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,15 +1228,14 @@ static void chan_render_prep(void)
crct.lfo_inc = ym2612.OPN.lfo_inc;
}

static void chan_render_finish(s32 *buffer, unsigned short length, int active_chans)
static void chan_render_finish(s32 *buffer, int length, int active_chans)
{
ym2612.OPN.eg_cnt = crct.eg_cnt;
ym2612.OPN.eg_timer = crct.eg_timer;
g_lfo_ampm = crct.pack >> 16; // need_save
ym2612.OPN.lfo_cnt = crct.lfo_cnt;
ym2612.OPN.lfo_cnt += ym2612.OPN.lfo_inc * length;
}

static UINT32 update_lfo_phase(FM_SLOT *SLOT, UINT32 block_fnum)
static UINT32 update_lfo_phase(const FM_SLOT *SLOT, UINT32 block_fnum)
{
UINT32 fnum_lfo;
INT32 lfo_fn_table_index_offset;
Expand Down Expand Up @@ -1809,6 +1808,7 @@ int YM2612UpdateOne_(s32 *buffer, int length, int stereo, int is_buf_empty)
if (ym2612.slot_mask & 0x00f000) active_chs |= chan_render(buffer, length, 3, flags|((pan&0x0c0)>>2)) << 3;
BIT_IF(flags, 1, (ym2612.ssg_mask & 0x0f0000) && (ym2612.OPN.ST.flags & 1));
if (ym2612.slot_mask & 0x0f0000) active_chs |= chan_render(buffer, length, 4, flags|((pan&0x300)>>4)) << 4;
g_lfo_ampm = crct.pack >> 16; // need_save; now because ch5 might skip updating it
BIT_IF(flags, 1, (ym2612.ssg_mask & 0xf00000) && (ym2612.OPN.ST.flags & 1));
if (ym2612.slot_mask & 0xf00000) active_chs |= chan_render(buffer, length, 5, flags|((pan&0xc00)>>6)|(!!ym2612.dacen<<2)) << 5;
#undef BIT_IF
Expand Down

0 comments on commit 8ec805d

Please sign in to comment.