Skip to content

Commit f94b89c

Browse files
authored
Merge pull request #203 from Libvisual/lv-scope-solid-line
libvisual-plugins: Make actor "lv_scope" show silence as a solid line
2 parents c41616b + 8528039 commit f94b89c

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

libvisual-plugins/plugins/actor/lv_scope/actor_lv_scope.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static void lv_scope_render (VisPluginData *plugin, VisVideo *video, VisAudio *a
214214
ScopePrivate *priv = visual_plugin_get_private (plugin);
215215
VisColor col;
216216
float *pcmbuf;
217-
int i, y, y_old, x;
217+
int y, x;
218218
int video_width, video_height, video_pitch;
219219
uint8_t *buf;
220220
int isBeat = 0;
@@ -287,18 +287,20 @@ static void lv_scope_render (VisPluginData *plugin, VisVideo *video, VisAudio *a
287287
}
288288

289289
// Scope
290+
const int max_displacement = video_height / 4;
291+
const int y_origin = video_height / 2;
292+
int i;
290293

291-
y_old = video_height / 2;
292294
for (i = 0; i < video_width; i++) {
293295
int j;
294296

295-
y = (video_height / 2) + (pcmbuf[(i >> 1) % PCM_SIZE] * (video_height / 4));
297+
const int y_tip = y_origin + (pcmbuf[(i >> 1) % PCM_SIZE] * (max_displacement));
296298

297-
if (y > y_old) {
298-
for (j = y_old; j < y; j++)
299+
if (y_tip > y_origin) {
300+
for (j = y_origin; j < y_tip; j++)
299301
buf[(j * video_pitch) + i] = 255;
300302
} else {
301-
for (j = y; j < y_old; j++)
303+
for (j = y_tip; j <= y_origin; j++)
302304
buf[(j * video_pitch) + i] = 255;
303305
}
304306
}

0 commit comments

Comments
 (0)