Make also the pan-property float (saves scaling and yields better resolution)

Original commit message from CVS:
* gst/audiofxgood/audiopanorama.c: (gst_audio_panorama_class_init),
(gst_audio_panorama_set_property),
(gst_audio_panorama_get_property),
(gst_audio_panorama_transform_m2s_int),
(gst_audio_panorama_transform_s2s_int),
(gst_audio_panorama_transform_m2s_float),
(gst_audio_panorama_transform_s2s_float):
* gst/audiofxgood/audiopanorama.h:
* tests/check/elements/audiopanorama.c: (GST_START_TEST):
Make also the pan-property float (saves scaling and yields better
resolution)
This commit is contained in:
Stefan Kost 2006-08-24 19:00:22 +00:00
parent 6bc998156f
commit 2019f527f7
6 changed files with 54 additions and 44 deletions

View file

@ -1,3 +1,17 @@
2006-08-24 Stefan Kost <ensonic@users.sf.net>
* gst/audiofxgood/audiopanorama.c: (gst_audio_panorama_class_init),
(gst_audio_panorama_set_property),
(gst_audio_panorama_get_property),
(gst_audio_panorama_transform_m2s_int),
(gst_audio_panorama_transform_s2s_int),
(gst_audio_panorama_transform_m2s_float),
(gst_audio_panorama_transform_s2s_float):
* gst/audiofxgood/audiopanorama.h:
* tests/check/elements/audiopanorama.c: (GST_START_TEST):
Make also the pan-property float (saves scaling and yields better
resolution)
2006-08-24 Stefan Kost <ensonic@users.sf.net>
* gst/audiofxgood/audiopanorama.c: (gst_audio_panorama_set_caps),

View file

@ -73,8 +73,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-raw-float, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 2 ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) 32, " "signed = (boolean) true; "
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
"audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 2 ], "
@ -88,8 +87,7 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-raw-float, "
"rate = (int) [ 1, MAX ], "
"channels = (int) 2, "
"endianness = (int) BYTE_ORDER, "
"width = (int) 32, " "signed = (boolean) true; "
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
"audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) 2, "
@ -151,9 +149,9 @@ gst_audio_panorama_class_init (GstAudioPanoramaClass * klass)
gobject_class->get_property = gst_audio_panorama_get_property;
g_object_class_install_property (gobject_class, PROP_PANORAMA,
g_param_spec_int ("panorama", "Panorama",
"Position in stereo panorama (-100 left -> 100 right)", -100, 100, 0,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_param_spec_float ("panorama", "Panorama",
"Position in stereo panorama (-1.0 left -> 1.0 right)", -1.0, 1.0,
0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size =
GST_DEBUG_FUNCPTR (gst_audio_panorama_get_unit_size);
@ -180,7 +178,7 @@ gst_audio_panorama_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_PANORAMA:
filter->panorama = g_value_get_int (value);
filter->panorama = g_value_get_float (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -196,7 +194,7 @@ gst_audio_panorama_get_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_PANORAMA:
g_value_set_int (value, filter->panorama);
g_value_set_float (value, filter->panorama);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -310,13 +308,13 @@ gst_audio_panorama_transform_m2s_int (GstAudioPanorama * filter, gint16 * idata,
glong lval, rval;
gdouble rpan, lpan;
/* pan: -100 0 100
/* pan: -1.0 0.0 1.0
* lpan: 1.0 0.5 0.0
* rpan: 0.0 0.5 1.0
*
* FIXME: we should use -3db (1/sqtr(2)) for 50:50
*/
rpan = (gdouble) (filter->panorama + 100) / 200.0;
rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
lpan = 1.0 - rpan;
for (i = 0; i < num_samples; i++) {
@ -339,19 +337,19 @@ gst_audio_panorama_transform_s2s_int (GstAudioPanorama * filter, gint16 * idata,
gdouble lival, rival;
gdouble lrpan, llpan, rrpan, rlpan;
/* pan: -100 0 100
/* pan: -1.0 0.0 1.0
* llpan: 1.0 1.0 0.0
* lrpan: 1.0 0.0 0.0
* rrpan: 0.0 1.0 1.0
* rlpan: 0.0 0.0 1.0
*/
if (filter->panorama > 0) {
rlpan = (gdouble) filter->panorama / 100.0;
rlpan = (gdouble) filter->panorama;
llpan = 1.0 - rlpan;
lrpan = 0.0;
rrpan = 1.0;
} else {
rrpan = (gdouble) (100 + filter->panorama) / 100.0;
rrpan = (gdouble) (1.0 + filter->panorama);
lrpan = 1.0 - rrpan;
rlpan = 0.0;
llpan = 1.0;
@ -377,13 +375,13 @@ gst_audio_panorama_transform_m2s_float (GstAudioPanorama * filter,
gfloat val;
gdouble rpan, lpan;
/* pan: -100 0 100
/* pan: -1.0 0.0 1.0
* lpan: 1.0 0.5 0.0
* rpan: 0.0 0.5 1.0
*
* FIXME: we should use -3db (1/sqtr(2)) for 50:50
*/
rpan = (gdouble) (filter->panorama + 100) / 200.0;
rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
lpan = 1.0 - rpan;
for (i = 0; i < num_samples; i++) {
@ -402,19 +400,19 @@ gst_audio_panorama_transform_s2s_float (GstAudioPanorama * filter,
gfloat lival, rival;
gdouble lrpan, llpan, rrpan, rlpan;
/* pan: -100 0 100
/* pan: -1.0 0.0 1.0
* llpan: 1.0 1.0 0.0
* lrpan: 1.0 0.0 0.0
* rrpan: 0.0 1.0 1.0
* rlpan: 0.0 0.0 1.0
*/
if (filter->panorama > 0) {
rlpan = (gdouble) filter->panorama / 100.0;
rlpan = (gdouble) filter->panorama;
llpan = 1.0 - rlpan;
lrpan = 0.0;
rrpan = 1.0;
} else {
rrpan = (gdouble) (100 + filter->panorama) / 100.0;
rrpan = (gdouble) (1.0 + filter->panorama);
lrpan = 1.0 - rrpan;
rlpan = 0.0;
llpan = 1.0;

View file

@ -41,7 +41,7 @@ typedef void (*GstAudioPanoramaProcessFunc)(GstAudioPanorama*, guint8*, guint8*,
struct _GstAudioPanorama {
GstBaseTransform element;
gint panorama;
gfloat panorama;
/* < private > */
GstAudioPanoramaProcessFunc process;

View file

@ -73,8 +73,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-raw-float, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 2 ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) 32, " "signed = (boolean) true; "
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
"audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 2 ], "
@ -88,8 +87,7 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-raw-float, "
"rate = (int) [ 1, MAX ], "
"channels = (int) 2, "
"endianness = (int) BYTE_ORDER, "
"width = (int) 32, " "signed = (boolean) true; "
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
"audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) 2, "
@ -151,9 +149,9 @@ gst_audio_panorama_class_init (GstAudioPanoramaClass * klass)
gobject_class->get_property = gst_audio_panorama_get_property;
g_object_class_install_property (gobject_class, PROP_PANORAMA,
g_param_spec_int ("panorama", "Panorama",
"Position in stereo panorama (-100 left -> 100 right)", -100, 100, 0,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_param_spec_float ("panorama", "Panorama",
"Position in stereo panorama (-1.0 left -> 1.0 right)", -1.0, 1.0,
0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size =
GST_DEBUG_FUNCPTR (gst_audio_panorama_get_unit_size);
@ -180,7 +178,7 @@ gst_audio_panorama_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_PANORAMA:
filter->panorama = g_value_get_int (value);
filter->panorama = g_value_get_float (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -196,7 +194,7 @@ gst_audio_panorama_get_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_PANORAMA:
g_value_set_int (value, filter->panorama);
g_value_set_float (value, filter->panorama);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -310,13 +308,13 @@ gst_audio_panorama_transform_m2s_int (GstAudioPanorama * filter, gint16 * idata,
glong lval, rval;
gdouble rpan, lpan;
/* pan: -100 0 100
/* pan: -1.0 0.0 1.0
* lpan: 1.0 0.5 0.0
* rpan: 0.0 0.5 1.0
*
* FIXME: we should use -3db (1/sqtr(2)) for 50:50
*/
rpan = (gdouble) (filter->panorama + 100) / 200.0;
rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
lpan = 1.0 - rpan;
for (i = 0; i < num_samples; i++) {
@ -339,19 +337,19 @@ gst_audio_panorama_transform_s2s_int (GstAudioPanorama * filter, gint16 * idata,
gdouble lival, rival;
gdouble lrpan, llpan, rrpan, rlpan;
/* pan: -100 0 100
/* pan: -1.0 0.0 1.0
* llpan: 1.0 1.0 0.0
* lrpan: 1.0 0.0 0.0
* rrpan: 0.0 1.0 1.0
* rlpan: 0.0 0.0 1.0
*/
if (filter->panorama > 0) {
rlpan = (gdouble) filter->panorama / 100.0;
rlpan = (gdouble) filter->panorama;
llpan = 1.0 - rlpan;
lrpan = 0.0;
rrpan = 1.0;
} else {
rrpan = (gdouble) (100 + filter->panorama) / 100.0;
rrpan = (gdouble) (1.0 + filter->panorama);
lrpan = 1.0 - rrpan;
rlpan = 0.0;
llpan = 1.0;
@ -377,13 +375,13 @@ gst_audio_panorama_transform_m2s_float (GstAudioPanorama * filter,
gfloat val;
gdouble rpan, lpan;
/* pan: -100 0 100
/* pan: -1.0 0.0 1.0
* lpan: 1.0 0.5 0.0
* rpan: 0.0 0.5 1.0
*
* FIXME: we should use -3db (1/sqtr(2)) for 50:50
*/
rpan = (gdouble) (filter->panorama + 100) / 200.0;
rpan = (gdouble) (filter->panorama + 1.0) / 2.0;
lpan = 1.0 - rpan;
for (i = 0; i < num_samples; i++) {
@ -402,19 +400,19 @@ gst_audio_panorama_transform_s2s_float (GstAudioPanorama * filter,
gfloat lival, rival;
gdouble lrpan, llpan, rrpan, rlpan;
/* pan: -100 0 100
/* pan: -1.0 0.0 1.0
* llpan: 1.0 1.0 0.0
* lrpan: 1.0 0.0 0.0
* rrpan: 0.0 1.0 1.0
* rlpan: 0.0 0.0 1.0
*/
if (filter->panorama > 0) {
rlpan = (gdouble) filter->panorama / 100.0;
rlpan = (gdouble) filter->panorama;
llpan = 1.0 - rlpan;
lrpan = 0.0;
rrpan = 1.0;
} else {
rrpan = (gdouble) (100 + filter->panorama) / 100.0;
rrpan = (gdouble) (1.0 + filter->panorama);
lrpan = 1.0 - rrpan;
rlpan = 0.0;
llpan = 1.0;

View file

@ -41,7 +41,7 @@ typedef void (*GstAudioPanoramaProcessFunc)(GstAudioPanorama*, guint8*, guint8*,
struct _GstAudioPanorama {
GstBaseTransform element;
gint panorama;
gfloat panorama;
/* < private > */
GstAudioPanoramaProcessFunc process;

View file

@ -181,7 +181,7 @@ GST_START_TEST (test_mono_left)
gint16 *res;
panorama = setup_panorama_m ();
g_object_set (G_OBJECT (panorama), "panorama", -100, NULL);
g_object_set (G_OBJECT (panorama), "panorama", -1.0, NULL);
fail_unless (gst_element_set_state (panorama,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
@ -221,7 +221,7 @@ GST_START_TEST (test_mono_right)
gint16 *res;
panorama = setup_panorama_m ();
g_object_set (G_OBJECT (panorama), "panorama", 100, NULL);
g_object_set (G_OBJECT (panorama), "panorama", 1.0, NULL);
fail_unless (gst_element_set_state (panorama,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
@ -301,7 +301,7 @@ GST_START_TEST (test_stereo_left)
gint16 *res;
panorama = setup_panorama_s ();
g_object_set (G_OBJECT (panorama), "panorama", -100, NULL);
g_object_set (G_OBJECT (panorama), "panorama", -1.0, NULL);
fail_unless (gst_element_set_state (panorama,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
@ -341,7 +341,7 @@ GST_START_TEST (test_stereo_right)
gint16 *res;
panorama = setup_panorama_s ();
g_object_set (G_OBJECT (panorama), "panorama", 100, NULL);
g_object_set (G_OBJECT (panorama), "panorama", 1.0, NULL);
fail_unless (gst_element_set_state (panorama,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");