1119
1191
half_height = waveview->half_height;
1121
1193
/* this makes it slightly easier to comprehend whats going on */
1123
1194
#define origin half_height
1126
for (x = begin; x < end; x++) {
1129
int clip_max, clip_min;
1134
max = waveview->cache->data[cache_index].max;
1135
min = waveview->cache->data[cache_index].min;
1147
/* don't rectify at single-sample zoom */
1149
if (waveview->rectified && waveview->samples_per_unit > 1) {
1151
if (fabs (min) > fabs (max)) {
1155
max = max * waveview->height;
1157
pymax = (int) rint ((item->y1 + waveview->height - max) * item->canvas->pixels_per_unit);
1158
pymin = (int) rint ((item->y1 + waveview->height) * item->canvas->pixels_per_unit);
1162
max = max * half_height;
1163
min = min * half_height;
1165
pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
1166
pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
1169
/* OK, now fill the RGB buffer at x=i with a line between pymin and pymax,
1170
or, if samples_per_unit == 1, then a dot at each location.
1173
if (pymax == pymin) {
1174
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
1176
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, pymin);
1179
/* show clipped waveforms with small red lines */
1181
if (clip_max || clip_min) {
1182
clip_length = MIN(5,(waveview->height/4));
1186
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
1190
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
1193
/* presto, we're done */
1198
if (!waveview->rectified) {
1196
if(waveview->filled && !rectify) {
1201
int next_pymin, next_pymax;
1203
int next_clip_max = 0;
1204
int next_clip_min = 0;
1206
if(s1 < waveview->samples_per_unit) {
1207
/* we haven't got a prev vars to compare with, so outline the whole line here */
1208
prev_pymax = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
1209
prev_pymin = prev_pymax;
1212
s1 -= waveview->samples_per_unit;
1215
if(end == waveview->bbox_lrx) {
1216
/* we don't have the NEXT vars for the last sample */
1217
last_pymax = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
1218
last_pymin = last_pymax;
1221
s2 += waveview->samples_per_unit;
1224
cache_index = gnome_canvas_waveview_ensure_cache (waveview, s1, s2);
1227
* Compute the variables outside the rendering rect
1229
if(prev_pymax != prev_pymin) {
1230
prev_pymax = (int) rint ((item->y1 + origin - MIN(waveview->cache->data[cache_index].max, 1.0) * half_height) * item->canvas->pixels_per_unit);
1231
prev_pymin = (int) rint ((item->y1 + origin - MAX(waveview->cache->data[cache_index].min, -1.0) * half_height) * item->canvas->pixels_per_unit);
1234
if(last_pymax != last_pymin) {
1235
/* take the index of one sample right of what we render */
1236
int index = cache_index + (end - begin);
1238
last_pymax = (int) rint ((item->y1 + origin - MIN(waveview->cache->data[index].max, 1.0) * half_height) * item->canvas->pixels_per_unit);
1239
last_pymin = (int) rint ((item->y1 + origin - MAX(waveview->cache->data[index].min, -1.0) * half_height) * item->canvas->pixels_per_unit);
1243
* initialize NEXT* variables for the first run, duplicated in the loop for speed
1245
max = waveview->cache->data[cache_index].max;
1246
min = waveview->cache->data[cache_index].min;
1261
next_pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
1262
next_pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
1267
for(x = begin; x < end; ++x) {
1268
int clip_max = next_clip_max;
1269
int clip_min = next_clip_min;
1270
int fill_max, fill_min;
1277
/*next is now the last column, which is outside the rendering rect, and possibly outside the region*/
1278
next_pymax = last_pymax;
1279
next_pymin = last_pymin;
1284
max = waveview->cache->data[cache_index].max;
1285
min = waveview->cache->data[cache_index].min;
1303
next_pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
1304
next_pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
1308
if (pymax == pymin) {
1309
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
1311
if((prev_pymax < pymax && next_pymax < pymax) ||
1312
(prev_pymax == pymax && next_pymax == pymax)) {
1313
fill_max = pymax + 1;
1314
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
1317
fill_max = MAX(prev_pymax, next_pymax);
1318
if(pymax == fill_max) {
1319
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
1323
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max);
1327
if((prev_pymin > pymin && next_pymin > pymin) ||
1328
(prev_pymin == pymin && next_pymin == pymin)) {
1329
fill_min = pymin - 1;
1330
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin-1);
1333
fill_min = MIN(prev_pymin, next_pymin);
1334
if(pymin == fill_min) {
1335
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
1338
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, fill_min, pymin);
1342
if(fill_max < fill_min) {
1343
PAINT_VERTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max, fill_min);
1345
else if(fill_max == fill_min) {
1346
PAINT_DOTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max);
1351
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
1355
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
1362
else if(waveview->filled && rectify) {
1363
int prev_pymax = -1;
1364
int last_pymax = -1;
1367
int next_clip_max = 0;
1368
int next_clip_min = 0;
1370
// for rectified, this stays constant throughout the loop
1371
pymin = (int) rint ((item->y1 + waveview->height) * item->canvas->pixels_per_unit);
1373
if(s1 < waveview->samples_per_unit) {
1374
/* we haven't got a prev vars to compare with, so outline the whole line here */
1378
s1 -= waveview->samples_per_unit;
1381
if(end == waveview->bbox_lrx) {
1382
/* we don't have the NEXT vars for the last sample */
1386
s2 += waveview->samples_per_unit;
1389
cache_index = gnome_canvas_waveview_ensure_cache (waveview, s1, s2);
1392
* Compute the variables outside the rendering rect
1394
if(prev_pymax < 0) {
1395
max = MIN(waveview->cache->data[cache_index].max, 1.0);
1396
min = MAX(waveview->cache->data[cache_index].min, -1.0);
1398
if (fabs (min) > fabs (max)) {
1402
prev_pymax = (int) rint ((item->y1 + waveview->height - max * waveview->height) * item->canvas->pixels_per_unit);
1405
if(last_pymax < 0) {
1406
/* take the index of one sample right of what we render */
1407
int index = cache_index + (end - begin);
1409
max = MIN(waveview->cache->data[index].max, 1.0);
1410
min = MAX(waveview->cache->data[index].min, -1.0);
1412
if (fabs (min) > fabs (max)) {
1416
last_pymax = (int) rint ((item->y1 + waveview->height - max * waveview->height) * item->canvas->pixels_per_unit);
1420
* initialize NEXT* variables for the first run, duplicated in the loop for speed
1422
max = waveview->cache->data[cache_index].max;
1423
min = waveview->cache->data[cache_index].min;
1435
if (fabs (min) > fabs (max)) {
1439
next_pymax = (int) rint ((item->y1 + waveview->height - max * waveview->height) * item->canvas->pixels_per_unit);
1444
for(x = begin; x < end; ++x) {
1445
int clip_max = next_clip_max;
1446
int clip_min = next_clip_min;
1453
/*next is now the last column, which is outside the rendering rect, and possibly outside the region*/
1454
next_pymax = last_pymax;
1459
max = waveview->cache->data[cache_index].max;
1460
min = waveview->cache->data[cache_index].min;
1472
if (fabs (min) > fabs (max)) {
1476
next_pymax = (int) rint ((item->y1 + waveview->height - max * waveview->height) * item->canvas->pixels_per_unit);
1480
if (pymax == pymin) {
1481
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
1483
if((prev_pymax < pymax && next_pymax < pymax) ||
1484
(prev_pymax == pymax && next_pymax == pymax)) {
1485
fill_max = pymax + 1;
1486
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
1489
fill_max = MAX(prev_pymax, next_pymax);
1490
if(pymax == fill_max) {
1491
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
1495
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max);
1499
if(fill_max < pymin) {
1500
PAINT_VERTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max, pymin);
1502
else if(fill_max == pymin) {
1503
PAINT_DOTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, pymin);
1508
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
1512
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
1519
cache_index = gnome_canvas_waveview_ensure_cache (waveview, s1, s2);
1521
for (x = begin; x < end; x++) {
1524
int clip_max, clip_min;
1529
max = waveview->cache->data[cache_index].max;
1530
min = waveview->cache->data[cache_index].min;
1544
if (fabs (min) > fabs (max)) {
1548
max = max * waveview->height;
1550
pymax = (int) rint ((item->y1 + waveview->height - max) * item->canvas->pixels_per_unit);
1551
pymin = (int) rint ((item->y1 + waveview->height) * item->canvas->pixels_per_unit);
1555
max = max * half_height;
1556
min = min * half_height;
1558
pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
1559
pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
1562
/* OK, now fill the RGB buffer at x=i with a line between pymin and pymax,
1563
or, if samples_per_unit == 1, then a dot at each location.
1566
if (pymax == pymin) {
1567
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
1569
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, pymin);
1572
/* show clipped waveforms with small red lines */
1575
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
1579
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
1582
/* presto, we're done */
1588
if (!waveview->rectified && waveview->zero_line) {
1199
1589
// Paint zeroline.
1200
1590
//PAINT_HORIZA(buf, waveview->zero_r, waveview->zero_g, waveview->zero_b, waveview->zero_a, begin, endi-1, origin );