| 171 | |
| 172 | template<bool stereo> |
| 173 | inline int mixBuffer(int16 *&buf, const int8 *data, Paula::Offset &offset, frac_t rate, int neededSamples, unsigned int bufSize, uint8 volume, uint8 panning, Paula::FilterState &filterState, int voice) { |
| 174 | int samples; |
| 175 | for (samples = 0; samples < neededSamples && offset.int_off < bufSize; ++samples) { |
| 176 | const int32 tmp = filter(((int32) data[offset.int_off]) * volume, filterState, voice); |
| 177 | if (stereo) { |
| 178 | *buf++ += (tmp * (255 - panning)) >> 7; |
| 179 | *buf++ += (tmp * (panning)) >> 7; |
| 180 | } else |
| 181 | *buf++ += tmp; |
| 182 | |
| 183 | // Step to next source sample |
| 184 | offset.rem_off += rate; |
| 185 | if (offset.rem_off >= (frac_t)FRAC_ONE) { |
| 186 | offset.int_off += fracToInt(offset.rem_off); |
| 187 | offset.rem_off &= FRAC_LO_MASK; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return samples; |
| 192 | } |
| 193 | |
| 194 | template<bool stereo> |
| 195 | int Paula::readBufferIntern(int16 *buffer, const int numSamples) { |