Mercurial > repos > blastem
comparison psg.c @ 1356:4d16c09210fd
Fix resampling code to deal with case in which output frequency is greater than the input frequency. Probably could stand to be improved, but at least it doesn't cause the emulator to deadlock
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 11 May 2017 07:51:28 -0700 |
parents | c15896605bf2 |
children | 4e5797b3935a |
comparison
equal
deleted
inserted
replaced
1355:03cb4dd2499f | 1356:4d16c09210fd |
---|---|
133 } | 133 } |
134 int32_t tmp = context->accum * context->lowpass_alpha + context->last_sample * (0x10000 - context->lowpass_alpha); | 134 int32_t tmp = context->accum * context->lowpass_alpha + context->last_sample * (0x10000 - context->lowpass_alpha); |
135 context->accum = tmp >> 16; | 135 context->accum = tmp >> 16; |
136 | 136 |
137 context->buffer_fraction += context->buffer_inc; | 137 context->buffer_fraction += context->buffer_inc; |
138 if (context->buffer_fraction >= BUFFER_INC_RES) { | 138 while (context->buffer_fraction >= BUFFER_INC_RES) { |
139 context->buffer_fraction -= BUFFER_INC_RES; | 139 context->buffer_fraction -= BUFFER_INC_RES; |
140 int32_t tmp = context->last_sample * ((context->buffer_fraction << 16) / context->buffer_inc); | 140 int32_t tmp = context->last_sample * ((context->buffer_fraction << 16) / context->buffer_inc); |
141 tmp += context->accum * (0x10000 - ((context->buffer_fraction << 16) / context->buffer_inc)); | 141 tmp += context->accum * (0x10000 - ((context->buffer_fraction << 16) / context->buffer_inc)); |
142 context->audio_buffer[context->buffer_pos++] = tmp >> 16; | 142 context->audio_buffer[context->buffer_pos++] = tmp >> 16; |
143 | 143 |