Previous 199869 Revisions Next

r31260 Friday 11th July, 2014 at 19:52:43 UTC by Couriersud
USE 64bit intermediary results in sound_stream::generate_resampled_data. This will allow sound drivers to make use of the full width of stream_sample_t. [Couriersud]
[src/emu]sound.c

trunk/src/emu/sound.c
r31259r31260
642642   // grab data from the output
643643   stream_output &output = *input.m_source;
644644   sound_stream &input_stream = *output.m_stream;
645   int gain = (input.m_gain * input.m_user_gain * output.m_gain) >> 16;
645   INT64 gain = (input.m_gain * input.m_user_gain * output.m_gain) >> 16;
646646
647647   // determine the time at which the current sample begins, accounting for the
648648   // latency we calculated between the input and output streams
r31259r31260
673673      while (numsamples--)
674674      {
675675         // compute the sample
676         stream_sample_t sample = *source++;
676         INT64 sample = *source++;
677677         *dest++ = (sample * gain) >> 8;
678678      }
679679   }
r31259r31260
700700         int endfrac = nextfrac >> (FRAC_BITS - 12);
701701
702702         // blend between the two samples accordingly
703         stream_sample_t sample = (source[0] * (0x1000 - startfrac) + source[1] * (endfrac - 0x1000)) / (endfrac - startfrac);
703         INT64 sample = ((INT64) source[0] * (0x1000 - startfrac) + (INT64) source[1] * (endfrac - 0x1000)) / (endfrac - startfrac);
704704         *dest++ = (sample * gain) >> 8;
705705
706706         // advance
r31259r31260
716716      int smallstep = step >> (FRAC_BITS - 8);
717717      while (numsamples--)
718718      {
719         int remainder = smallstep;
719         INT64 remainder = smallstep;
720720         int tpos = 0;
721721
722722         // compute the sample
723         int scale = (FRAC_ONE - basefrac) >> (FRAC_BITS - 8);
724         stream_sample_t sample = source[tpos++] * scale;
723         INT64 scale = (FRAC_ONE - basefrac) >> (FRAC_BITS - 8);
724         INT64 sample = (INT64) source[tpos++] * scale;
725725         remainder -= scale;
726726         while (remainder > 0x100)
727727         {
728            sample += source[tpos++] * 0x100;
728            sample += (INT64) source[tpos++] * (INT64) 0x100;
729729            remainder -= 0x100;
730730         }
731         sample += source[tpos] * remainder;
731         sample += (INT64) source[tpos] * remainder;
732732         sample /= smallstep;
733733
734734         *dest++ = (sample * gain) >> 8;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team