109 |
} |
} |
110 |
|
|
111 |
|
|
112 |
// zero out the sum buffer |
// zero out the output sum buffer |
113 |
for (uint u = 0; u < pAudioIO->FragmentSize * pAudioIO->Channels; u++) { |
memset(pAudioSumBuffer, 0, pAudioIO->FragmentSize * pAudioIO->Channels * sizeof(float)); |
|
pAudioSumBuffer[u] = 0.0; |
|
|
} |
|
114 |
|
|
115 |
|
|
116 |
// render audio from all active voices |
// render audio from all active voices |
134 |
// (from 32bit to 16bit sample) and copy to output buffer |
// (from 32bit to 16bit sample) and copy to output buffer |
135 |
float sample_point; |
float sample_point; |
136 |
for (uint u = 0; u < pAudioIO->FragmentSize * pAudioIO->Channels; u++) { |
for (uint u = 0; u < pAudioIO->FragmentSize * pAudioIO->Channels; u++) { |
137 |
sample_point = this->pAudioSumBuffer[u] / 4; // FIXME division by 4 just for testing purposes (to give a bit of head room when mixing multiple voices together) |
sample_point = this->pAudioSumBuffer[u] * this->Volume; |
138 |
if (sample_point < -32768.0) sample_point = -32768.0; |
if (sample_point < -32768.0) sample_point = -32768.0; |
139 |
if (sample_point > 32767.0) sample_point = 32767.0; |
if (sample_point > 32767.0) sample_point = 32767.0; |
140 |
this->pAudioIO->pOutputBuffer[u] = (sample_t) sample_point; |
this->pAudioIO->pOutputBuffer[u] = (sample_t) sample_point; |