mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 20:46:22 +00:00
audiovisualizers: add aa-line code and user for wave/space-scope
This commit is contained in:
parent
78337fc198
commit
c61f85da82
4 changed files with 85 additions and 9 deletions
|
@ -3,6 +3,10 @@ video-rate. It receives audio-data at the sampling-rate. It needs to render
|
||||||
video-frames at frame-rate. The rendering needs n audio samples (depends on
|
video-frames at frame-rate. The rendering needs n audio samples (depends on
|
||||||
subclass). The baseclass takes care of that.
|
subclass). The baseclass takes care of that.
|
||||||
|
|
||||||
|
Some effects could be enhanced by running geometrictransform elements
|
||||||
|
afterwards. A blur and/or videozoom element would be great (vertigotv looks
|
||||||
|
great but has some negotiation issues).
|
||||||
|
|
||||||
= Feedback =
|
= Feedback =
|
||||||
* put 'Audio' to klass as well ?
|
* put 'Audio' to klass as well ?
|
||||||
|
|
||||||
|
@ -32,6 +36,12 @@ spectrascope - done
|
||||||
spacescope - stereo wavescope
|
spacescope - stereo wavescope
|
||||||
- left->x, right->y - done
|
- left->x, right->y - done
|
||||||
- polar mapping
|
- polar mapping
|
||||||
|
multiscope :
|
||||||
|
- like wave/space scope, but run the signal through two filters to split it into
|
||||||
|
bass, mid and high (200 Hz, 2000 Hz)
|
||||||
|
- draw 3 wave-scopes into red/gree/blue
|
||||||
|
- when drawing only draw that component to mix colors
|
||||||
|
- eventually use the spacescope-position to rotate/shift the wave
|
||||||
|
|
||||||
= TODO =
|
= TODO =
|
||||||
- element maker template
|
- element maker template
|
||||||
|
@ -47,6 +57,7 @@ GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch audiotestsrc ! audioconvert ! w
|
||||||
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! wavescope ! colorspace ! ximagesink
|
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! wavescope ! colorspace ! ximagesink
|
||||||
|
|
||||||
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! spacescope style=lines shade-amount=0x00080402 ! ximagesink
|
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! spacescope style=lines shade-amount=0x00080402 ! ximagesink
|
||||||
|
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! spacescope style=lines shade-amount=0x00080402 ! vertigotv ! ximagesink
|
||||||
|
|
||||||
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! spectrascope ! colorspace ! ximagesink
|
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! spectrascope ! colorspace ! ximagesink
|
||||||
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! spectrascope shader=fade-and-move-up shade-amount=0x00040302 ! colorspace ! ximagesink
|
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-launch filesrc location=$HOME/Music/1.mp3 ! decodebin2 ! audioconvert ! spectrascope shader=fade-and-move-up shade-amount=0x00040302 ! colorspace ! ximagesink
|
||||||
|
|
|
@ -37,3 +37,66 @@
|
||||||
draw_dot (_vd, _x, _y, _st, _c); \
|
draw_dot (_vd, _x, _y, _st, _c); \
|
||||||
} \
|
} \
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
|
#define draw_line_aa(_vd, _x1, _x2, _y1, _y2, _st, _c) G_STMT_START { \
|
||||||
|
guint _i, _j, _x, _y; \
|
||||||
|
gint _dx = _x2 - _x1, _dy = _y2 - _y1; \
|
||||||
|
gfloat _f, _rx, _ry, _fx, _fy; \
|
||||||
|
guint32 _oc, _nc, _c1, _c2, _c3; \
|
||||||
|
\
|
||||||
|
_j = abs (_dx) > abs (_dy) ? abs (_dx) : abs (_dy); \
|
||||||
|
for (_i = 0; _i < _j; _i++) { \
|
||||||
|
_f = (gfloat) _i / (gfloat) _j; \
|
||||||
|
_rx = _x1 + _dx * _f; \
|
||||||
|
_ry = _y1 + _dy * _f; \
|
||||||
|
_x = (guint)_rx; \
|
||||||
|
_y = (guint)_ry; \
|
||||||
|
_fx = _rx - (gfloat)_x; \
|
||||||
|
_fy = _ry - (gfloat)_y; \
|
||||||
|
\
|
||||||
|
_f = ((1.0 - _fx) + (1.0 - _fy)) / 2.0; \
|
||||||
|
_oc = _vd[(_y * _st) + _x]; \
|
||||||
|
_c3 = (_oc & 0xff) + ((_c & 0xff) * _f); \
|
||||||
|
_c3 = MIN(_c3, 255); \
|
||||||
|
_c2 = ((_oc & 0xff00) >> 8) + (((_c & 0xff00) >> 8) * _f); \
|
||||||
|
_c2 = MIN(_c2, 255); \
|
||||||
|
_c1 = ((_oc & 0xff0000) >> 16) + (((_c & 0xff0000) >> 16) * _f); \
|
||||||
|
_c1 = MIN(_c1, 255); \
|
||||||
|
_nc = 0x00 | (_c1 << 16) | (_c2 << 8) | _c3; \
|
||||||
|
_vd[(_y * _st) + _x] = _nc; \
|
||||||
|
\
|
||||||
|
_f = (_fx + (1.0 - _fy)) / 2.0; \
|
||||||
|
_oc = _vd[(_y * _st) + _x + 1]; \
|
||||||
|
_c3 = (_oc & 0xff) + ((_c & 0xff) * _f); \
|
||||||
|
_c3 = MIN(_c3, 255); \
|
||||||
|
_c2 = ((_oc & 0xff00) >> 8) + (((_c & 0xff00) >> 8) * _f); \
|
||||||
|
_c2 = MIN(_c2, 255); \
|
||||||
|
_c1 = ((_oc & 0xff0000) >> 16) + (((_c & 0xff0000) >> 16) * _f); \
|
||||||
|
_c1 = MIN(_c1, 255); \
|
||||||
|
_nc = 0x00 | (_c1 << 16) | (_c2 << 8) | _c3; \
|
||||||
|
_vd[(_y * _st) + _x + 1] = _nc; \
|
||||||
|
\
|
||||||
|
_f = ((1.0 - _fx) + _fy) / 2.0; \
|
||||||
|
_oc = _vd[((_y + 1) * _st) + _x]; \
|
||||||
|
_c3 = (_oc & 0xff) + ((_c & 0xff) * _f); \
|
||||||
|
_c3 = MIN(_c3, 255); \
|
||||||
|
_c2 = ((_oc & 0xff00) >> 8) + (((_c & 0xff00) >> 8) * _f); \
|
||||||
|
_c2 = MIN(_c2, 255); \
|
||||||
|
_c1 = ((_oc & 0xff0000) >> 16) + (((_c & 0xff0000) >> 16) * _f); \
|
||||||
|
_c1 = MIN(_c1, 255); \
|
||||||
|
_nc = 0x00 | (_c1 << 16) | (_c2 << 8) | _c3; \
|
||||||
|
_vd[((_y + 1) * _st) + _x] = _nc; \
|
||||||
|
\
|
||||||
|
_f = (_fx + _fy) / 2.0; \
|
||||||
|
_oc = _vd[((_y + 1) * _st) + _x + 1]; \
|
||||||
|
_c3 = (_oc & 0xff) + ((_c & 0xff) * _f); \
|
||||||
|
_c3 = MIN(_c3, 255); \
|
||||||
|
_c2 = ((_oc & 0xff00) >> 8) + (((_c & 0xff00) >> 8) * _f); \
|
||||||
|
_c2 = MIN(_c2, 255); \
|
||||||
|
_c1 = ((_oc & 0xff0000) >> 16) + (((_c & 0xff0000) >> 16) * _f); \
|
||||||
|
_c1 = MIN(_c1, 255); \
|
||||||
|
_nc = 0x00 | (_c1 << 16) | (_c2 << 8) | _c3; \
|
||||||
|
_vd[((_y + 1) * _st) + _x + 1] = _nc; \
|
||||||
|
} \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
|
|
@ -214,20 +214,21 @@ render_lines (GstBaseAudioVisualizer * scope, guint32 * vdata, gint16 * adata,
|
||||||
guint i, s, x, y, ox, oy;
|
guint i, s, x, y, ox, oy;
|
||||||
gfloat dx, dy;
|
gfloat dx, dy;
|
||||||
guint w = scope->width;
|
guint w = scope->width;
|
||||||
|
guint h = scope->height;
|
||||||
gint x2, y2;
|
gint x2, y2;
|
||||||
|
|
||||||
/* draw lines 1st channel x, 2nd channel y */
|
/* draw lines 1st channel x, 2nd channel y */
|
||||||
dx = scope->width / 65536.0;
|
dx = (w - 1) / 65536.0;
|
||||||
ox = scope->width / 2;
|
ox = (w - 1) / 2;
|
||||||
dy = scope->height / 65536.0;
|
dy = (h - 1) / 65536.0;
|
||||||
oy = scope->height / 2;
|
oy = (h - 1) / 2;
|
||||||
s = 0;
|
s = 0;
|
||||||
x2 = (guint) (ox + (gfloat) adata[s++] * dx);
|
x2 = (guint) (ox + (gfloat) adata[s++] * dx);
|
||||||
y2 = (guint) (oy + (gfloat) adata[s++] * dy);
|
y2 = (guint) (oy + (gfloat) adata[s++] * dy);
|
||||||
for (i = 1; i < num_samples; i++) {
|
for (i = 1; i < num_samples; i++) {
|
||||||
x = (guint) (ox + (gfloat) adata[s++] * dx);
|
x = (guint) (ox + (gfloat) adata[s++] * dx);
|
||||||
y = (guint) (oy + (gfloat) adata[s++] * dy);
|
y = (guint) (oy + (gfloat) adata[s++] * dy);
|
||||||
draw_line (vdata, x2, x, y2, y, w, 0x00FFFFFF);
|
draw_line_aa (vdata, x2, x, y2, y, w, 0x00FFFFFF);
|
||||||
x2 = x;
|
x2 = x;
|
||||||
y2 = y;
|
y2 = y;
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,12 +218,13 @@ render_lines (GstBaseAudioVisualizer * scope, guint32 * vdata, gint16 * adata,
|
||||||
guint i, c, s, x, y, oy;
|
guint i, c, s, x, y, oy;
|
||||||
gfloat dx, dy;
|
gfloat dx, dy;
|
||||||
guint w = scope->width;
|
guint w = scope->width;
|
||||||
|
guint h = scope->height;
|
||||||
gint x2, y2;
|
gint x2, y2;
|
||||||
|
|
||||||
/* draw lines */
|
/* draw lines */
|
||||||
dx = (gfloat) w / (gfloat) num_samples;
|
dx = (gfloat) (w - 1) / (gfloat) num_samples;
|
||||||
dy = scope->height / 65536.0;
|
dy = (h - 1) / 65536.0;
|
||||||
oy = scope->height / 2;
|
oy = (h - 1) / 2;
|
||||||
for (c = 0; c < channels; c++) {
|
for (c = 0; c < channels; c++) {
|
||||||
s = c;
|
s = c;
|
||||||
x2 = 0;
|
x2 = 0;
|
||||||
|
@ -232,7 +233,7 @@ render_lines (GstBaseAudioVisualizer * scope, guint32 * vdata, gint16 * adata,
|
||||||
x = (guint) ((gfloat) i * dx);
|
x = (guint) ((gfloat) i * dx);
|
||||||
y = (guint) (oy + (gfloat) adata[s] * dy);
|
y = (guint) (oy + (gfloat) adata[s] * dy);
|
||||||
s += channels;
|
s += channels;
|
||||||
draw_line (vdata, x2, x, y2, y, w, 0x00FFFFFF);
|
draw_line_aa (vdata, x2, x, y2, y, w, 0x00FFFFFF);
|
||||||
x2 = x;
|
x2 = x;
|
||||||
y2 = y;
|
y2 = y;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue