trunk/src/emu/sound.c
| r31259 | r31260 | |
| 642 | 642 | // grab data from the output |
| 643 | 643 | stream_output &output = *input.m_source; |
| 644 | 644 | 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; |
| 646 | 646 | |
| 647 | 647 | // determine the time at which the current sample begins, accounting for the |
| 648 | 648 | // latency we calculated between the input and output streams |
| r31259 | r31260 | |
| 673 | 673 | while (numsamples--) |
| 674 | 674 | { |
| 675 | 675 | // compute the sample |
| 676 | | stream_sample_t sample = *source++; |
| 676 | INT64 sample = *source++; |
| 677 | 677 | *dest++ = (sample * gain) >> 8; |
| 678 | 678 | } |
| 679 | 679 | } |
| r31259 | r31260 | |
| 700 | 700 | int endfrac = nextfrac >> (FRAC_BITS - 12); |
| 701 | 701 | |
| 702 | 702 | // 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); |
| 704 | 704 | *dest++ = (sample * gain) >> 8; |
| 705 | 705 | |
| 706 | 706 | // advance |
| r31259 | r31260 | |
| 716 | 716 | int smallstep = step >> (FRAC_BITS - 8); |
| 717 | 717 | while (numsamples--) |
| 718 | 718 | { |
| 719 | | int remainder = smallstep; |
| 719 | INT64 remainder = smallstep; |
| 720 | 720 | int tpos = 0; |
| 721 | 721 | |
| 722 | 722 | // 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; |
| 725 | 725 | remainder -= scale; |
| 726 | 726 | while (remainder > 0x100) |
| 727 | 727 | { |
| 728 | | sample += source[tpos++] * 0x100; |
| 728 | sample += (INT64) source[tpos++] * (INT64) 0x100; |
| 729 | 729 | remainder -= 0x100; |
| 730 | 730 | } |
| 731 | | sample += source[tpos] * remainder; |
| 731 | sample += (INT64) source[tpos] * remainder; |
| 732 | 732 | sample /= smallstep; |
| 733 | 733 | |
| 734 | 734 | *dest++ = (sample * gain) >> 8; |