Skip to content

Commit

Permalink
Mikey: fix MS VC compile, use 1MHz output rate
Browse files Browse the repository at this point in the history
  • Loading branch information
ValleyBell committed Dec 31, 2023
1 parent 978eb16 commit ea54176
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions emu/cores/mikey.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ static int64_t mikey_pimpl_write( mikey_pimpl_t* mikey, int64_t tick, uint8_t ad

static int64_t mikey_pimpl_fireTimer( mikey_pimpl_t* mikey, int64_t tick )
{
mikey->mSampleValid = false;
size_t timer = tick & 3;
mikey->mSampleValid = false;
return mikey_audio_channel_fireAction( &mikey->mAudioChannels[timer], tick );
}

Expand Down Expand Up @@ -656,8 +656,7 @@ static UINT8 mikey_start( const DEV_GEN_CFG* cfg, DEV_INFO* retDevInf )

mikey_pimpl_MikeyPimpl( &mikey->mMikey );
mikey_action_queue_ActionQueue( &mikey->mQueue );
//mikey->mSampleRate = cfg->clock / 16; // TODO: This would be very demanding on the CPU. Is the quality improvement worth it?
mikey->mSampleRate = cfg->smplRate;
mikey->mSampleRate = cfg->clock / 16;
SRATE_CUSTOM_HIGHEST(cfg->srMode, mikey->mSampleRate, cfg->smplRate);
mikey->mTicksPerSample1 = 16000000 / mikey->mSampleRate;
mikey->mTicksPerSample2 = 16000000 % mikey->mSampleRate;
Expand Down Expand Up @@ -712,18 +711,20 @@ static void mikey_update( void* info, UINT32 samples, DEV_SMPL** outputs )
mikey->mTick = mikey->mNextTick & ~15;
mikey->mNextTick = mikey->mNextTick + mikey->mTicksPerSample1;
mikey->mSamplesRemainder += mikey->mTicksPerSample2;
if ( mikey->mSamplesRemainder > mikey->mSampleRate )
if ( mikey->mSamplesRemainder >= mikey->mSampleRate )
{
mikey->mSamplesRemainder %= mikey->mSampleRate;
mikey->mSamplesRemainder -= mikey->mSampleRate;
mikey->mNextTick += 1;
}

if ( ++i >= samples )
return;
}

int64_t newAction = mikey_pimpl_fireTimer( &mikey->mMikey, value );
mikey_action_queue_push( &mikey->mQueue, newAction );
{
int64_t newAction = mikey_pimpl_fireTimer( &mikey->mMikey, value );
mikey_action_queue_push( &mikey->mQueue, newAction );
}
}
}

Expand Down

0 comments on commit ea54176

Please sign in to comment.