22 #define PAINTBUFFER_SIZE 2048
34 for (i = 0; i < count; i++, samp++, out += 2) {
35 val = samp->left >> 8;
36 out[0] = clamp(val, INT16_MIN, INT16_MAX);
38 val = samp->right >> 8;
39 out[1] = clamp(val, INT16_MIN, INT16_MAX);
52 lpos = ltime & ((
dma.samples >> 1) - 1);
54 out = (int16_t *)
dma.buffer + (lpos << 1);
56 count = (
dma.samples >> 1) - lpos;
57 if (ltime + count > endtime)
58 count = endtime - ltime;
70 int out_idx, out_mask;
77 out_mask =
dma.samples - 1;
79 step = 3 -
dma.channels;
81 if (
dma.samplebits == 16) {
82 int16_t *out = (int16_t *)
dma.buffer;
86 clamp(val, INT16_MIN, INT16_MAX);
88 out_idx = (out_idx + 1) & out_mask;
90 }
else if (
dma.samplebits == 8) {
91 uint8_t *out = (uint8_t *)
dma.buffer;
95 clamp(val, INT16_MIN, INT16_MAX);
96 out[out_idx] = (val >> 8) + 128;
97 out_idx = (out_idx + 1) & out_mask;
109 samp[i].
left = samp[i].
right = sin(i * 0.1) * 20000 * 256;
113 if (
dma.samplebits == 16 &&
dma.channels == 2) {
134 int *lscale, *rscale;
145 sfx = (uint8_t *)sc->
data + ch->
pos;
147 for (i = 0; i < count; i++, samp++) {
149 samp->
left += lscale[data];
150 samp->
right += rscale[data];
160 int leftvol, rightvol;
166 sfx = (int16_t *)sc->
data + ch->
pos;
168 for (i = 0; i < count; i++, samp++) {
170 left = (data * leftvol) >> 8;
171 right = (data * rightvol) >> 8;
218 while (ltime < end) {
226 if (ch->
end - ltime < count)
227 count = ch->
end - ltime;
233 if (count > 0 && ch->
sfx) {
236 Paint8(ch, sc, count, samp);
244 if (ltime >= ch->
end) {
287 for (i = 0; i < 32; i++) {
289 for (j = 0; j < 256; j++) {
304 int channels,
byte *data,
float volume)
321 float scale = (float)rate /
dma.speed;
322 int intVolume = (
int)(256 * volume);
326 for (
int i = 0; ; i++)
328 int src = (
int)(i * scale);
343 for (
int i = 0; ; i++)
345 int src = (
int)(i * scale);
362 for (
int i = 0; ; i++)
364 int src = (
int)(i * scale);
374 (((
byte *)data)[src * 2] - 128) * intVolume;
376 (((
byte *)data)[src * 2 + 1] - 128) * intVolume;
383 for (
int i = 0; ; i++)
385 int src = (
int)(i * scale);