mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
lfocontrolsource: cleanups and fix triangle calculations
This commit is contained in:
parent
35b817ad48
commit
e87d563cac
1 changed files with 22 additions and 29 deletions
|
@ -78,12 +78,11 @@ _sine_get (GstLFOControlSource * self, gdouble amp, gdouble off,
|
||||||
GstClockTime timeshift, GstClockTime period, gdouble frequency,
|
GstClockTime timeshift, GstClockTime period, gdouble frequency,
|
||||||
GstClockTime timestamp)
|
GstClockTime timestamp)
|
||||||
{
|
{
|
||||||
GstClockTime pos = _calculate_pos (timestamp, timeshift, period);
|
gdouble pos =
|
||||||
|
gst_guint64_to_gdouble (_calculate_pos (timestamp, timeshift, period));
|
||||||
gdouble ret;
|
gdouble ret;
|
||||||
|
|
||||||
ret =
|
ret = sin (2.0 * M_PI * (frequency / GST_SECOND) * pos);
|
||||||
sin (2.0 * M_PI * (frequency / GST_SECOND) *
|
|
||||||
gst_guint64_to_gdouble (pos));
|
|
||||||
ret *= amp;
|
ret *= amp;
|
||||||
ret += off;
|
ret += off;
|
||||||
|
|
||||||
|
@ -183,13 +182,12 @@ _saw_get (GstLFOControlSource * self, gdouble amp, gdouble off,
|
||||||
GstClockTime timeshift, GstClockTime period, gdouble frequency,
|
GstClockTime timeshift, GstClockTime period, gdouble frequency,
|
||||||
GstClockTime timestamp)
|
GstClockTime timestamp)
|
||||||
{
|
{
|
||||||
GstClockTime pos = _calculate_pos (timestamp, timeshift, period);
|
gdouble pos =
|
||||||
|
gst_guint64_to_gdouble (_calculate_pos (timestamp, timeshift, period));
|
||||||
|
gdouble per = gst_guint64_to_gdouble (period);
|
||||||
gdouble ret;
|
gdouble ret;
|
||||||
|
|
||||||
ret =
|
ret = -((pos - per / 2.0) * ((2.0 * amp) / per));
|
||||||
-((gst_guint64_to_gdouble (pos) -
|
|
||||||
gst_guint64_to_gdouble (period) / 2.0) * ((2.0 * amp) /
|
|
||||||
gst_guint64_to_gdouble (period)));
|
|
||||||
ret += off;
|
ret += off;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -235,13 +233,12 @@ _rsaw_get (GstLFOControlSource * self, gdouble amp, gdouble off,
|
||||||
GstClockTime timeshift, GstClockTime period, gdouble frequency,
|
GstClockTime timeshift, GstClockTime period, gdouble frequency,
|
||||||
GstClockTime timestamp)
|
GstClockTime timestamp)
|
||||||
{
|
{
|
||||||
GstClockTime pos = _calculate_pos (timestamp, timeshift, period);
|
gdouble pos =
|
||||||
|
gst_guint64_to_gdouble (_calculate_pos (timestamp, timeshift, period));
|
||||||
|
gdouble per = gst_guint64_to_gdouble (period);
|
||||||
gdouble ret;
|
gdouble ret;
|
||||||
|
|
||||||
ret =
|
ret = (pos - per / 2.0) * ((2.0 * amp) / per);
|
||||||
((gst_guint64_to_gdouble (pos) -
|
|
||||||
gst_guint64_to_gdouble (period) / 2.0) * ((2.0 * amp) /
|
|
||||||
gst_guint64_to_gdouble (period)));
|
|
||||||
ret += off;
|
ret += off;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -288,24 +285,20 @@ _triangle_get (GstLFOControlSource * self, gdouble amp, gdouble off,
|
||||||
GstClockTime timeshift, GstClockTime period, gdouble frequency,
|
GstClockTime timeshift, GstClockTime period, gdouble frequency,
|
||||||
GstClockTime timestamp)
|
GstClockTime timestamp)
|
||||||
{
|
{
|
||||||
GstClockTime pos = _calculate_pos (timestamp, timeshift, period);
|
gdouble pos =
|
||||||
|
gst_guint64_to_gdouble (_calculate_pos (timestamp, timeshift, period));
|
||||||
|
gdouble per = gst_guint64_to_gdouble (period);
|
||||||
gdouble ret;
|
gdouble ret;
|
||||||
|
|
||||||
if (gst_guint64_to_gdouble (pos) <= gst_guint64_to_gdouble (period) / 4.0)
|
if (pos <= 0.25 * per)
|
||||||
ret =
|
/* 1st quarter */
|
||||||
gst_guint64_to_gdouble (pos) * ((4.0 * amp) /
|
ret = pos * ((4.0 * amp) / per);
|
||||||
gst_guint64_to_gdouble (period));
|
else if (pos <= 0.75 * per)
|
||||||
else if (gst_guint64_to_gdouble (pos) <=
|
/* 2nd & 3rd quarter */
|
||||||
(3.0 * gst_guint64_to_gdouble (period)) / 4.0)
|
ret = -(pos - per / 2.0) * ((4.0 * amp) / per);
|
||||||
ret =
|
|
||||||
-(gst_guint64_to_gdouble (pos) -
|
|
||||||
gst_guint64_to_gdouble (period) / 2.0) * ((4.0 * amp) /
|
|
||||||
gst_guint64_to_gdouble (period));
|
|
||||||
else
|
else
|
||||||
ret =
|
/* 4th quarter */
|
||||||
gst_guint64_to_gdouble (period) -
|
ret = -(per - pos) * ((4.0 * amp) / per);
|
||||||
gst_guint64_to_gdouble (pos) * ((4.0 * amp) /
|
|
||||||
gst_guint64_to_gdouble (period));
|
|
||||||
|
|
||||||
ret += off;
|
ret += off;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue