use new dparams api. run demo_dparams to hear how smooth it is now

Original commit message from CVS:
use new dparams api. run demo_dparams to hear how smooth it is now
This commit is contained in:
Steve Baker 2002-05-29 18:54:19 +00:00
parent 85a358dbe3
commit 6ad042fada
2 changed files with 14 additions and 11 deletions

View file

@ -62,8 +62,9 @@ int main(int argc,char *argv[]) {
gst_element_connect_many(sinesrc, volfilter, osssink, NULL); gst_element_connect_many(sinesrc, volfilter, osssink, NULL);
/* this breaks with current alsa oss compat lib */ /* this breaks with current alsa oss compat lib */
g_object_set(G_OBJECT(osssink),"fragment",0x00180008,NULL); g_object_set(G_OBJECT(osssink),"fragment",0x00180008,NULL);
g_object_set(G_OBJECT(osssink),"sync",FALSE,NULL);
g_object_set(G_OBJECT(sinesrc),"samplesperbuffer",64,NULL); g_object_set(G_OBJECT(sinesrc),"samplesperbuffer",1024,NULL);
/***** set up the GUI *****/ /***** set up the GUI *****/
window = gtk_window_new(GTK_WINDOW_TOPLEVEL); window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@ -87,7 +88,7 @@ int main(int argc,char *argv[]) {
dpman = gst_dpman_get_manager (sinesrc); dpman = gst_dpman_get_manager (sinesrc);
g_assert(gst_dpman_attach_dparam (dpman, "freq", freq)); g_assert(gst_dpman_attach_dparam (dpman, "freq", freq));
gst_dpman_set_mode(dpman, "synchronous"); gst_dpman_set_mode(dpman, "asynchronous");
spec = (GParamSpecFloat*)gst_dpman_get_param_spec (dpman, "freq"); spec = (GParamSpecFloat*)gst_dpman_get_param_spec (dpman, "freq");
freq_adj = (GtkAdjustment*)gtk_adjustment_new((gfloat)log(spec->default_value), freq_adj = (GtkAdjustment*)gtk_adjustment_new((gfloat)log(spec->default_value),
@ -106,12 +107,12 @@ int main(int argc,char *argv[]) {
/* this defines the maximum slope that this * /* this defines the maximum slope that this *
* param can change. This says that in 50ms * * param can change. This says that in 50ms *
* the value can change from 0.0 to 1.0 */ * the value can change from 0.0 to 1.0 */
g_object_set(G_OBJECT(volume), "slope_delta_float", 1.0F, NULL); g_object_set(G_OBJECT(volume), "slope_delta_float", 0.1F, NULL);
g_object_set(G_OBJECT(volume), "slope_time", 50000000LL, NULL); g_object_set(G_OBJECT(volume), "slope_time", 50000000LL, NULL);
dpman = gst_dpman_get_manager (volfilter); dpman = gst_dpman_get_manager (volfilter);
g_assert(gst_dpman_attach_dparam (dpman, "volume", volume)); g_assert(gst_dpman_attach_dparam (dpman, "volume", volume));
gst_dpman_set_mode(dpman, "synchronous"); gst_dpman_set_mode(dpman, "asynchronous");
g_object_set(G_OBJECT(volfilter), "mute", FALSE, NULL); g_object_set(G_OBJECT(volfilter), "mute", FALSE, NULL);

View file

@ -196,7 +196,7 @@ gst_sinesrc_init (GstSineSrc *src)
&(src->volume) &(src->volume)
); );
gst_dpman_set_rate_change_pad(src->dpman, src->srcpad); gst_dpman_set_rate(src->dpman, src->samplerate);
gst_sinesrc_populate_sinetable(src); gst_sinesrc_populate_sinetable(src);
gst_sinesrc_update_table_inc(src); gst_sinesrc_update_table_inc(src);
@ -210,7 +210,7 @@ gst_sinesrc_get(GstPad *pad)
GstBuffer *buf; GstBuffer *buf;
gint16 *samples; gint16 *samples;
gint i=0, frame_countdown; gint i=0;
g_return_val_if_fail (pad != NULL, NULL); g_return_val_if_fail (pad != NULL, NULL);
src = GST_SINESRC(gst_pad_get_parent (pad)); src = GST_SINESRC(gst_pad_get_parent (pad));
@ -225,11 +225,11 @@ gst_sinesrc_get(GstPad *pad)
samples = (gint16*)GST_BUFFER_DATA(buf); samples = (gint16*)GST_BUFFER_DATA(buf);
GST_BUFFER_DATA(buf) = (gpointer) samples; GST_BUFFER_DATA(buf) = (gpointer) samples;
frame_countdown = GST_DPMAN_PREPROCESS(src->dpman, src->samples_per_buffer, src->timestamp); GST_DPMAN_PREPROCESS(src->dpman, src->samples_per_buffer, src->timestamp);
src->timestamp += (gint64)src->samples_per_buffer * 1000000000LL / (gint64)src->samplerate; src->timestamp += (gint64)src->samples_per_buffer * 1000000000LL / (gint64)src->samplerate;
while(GST_DPMAN_PROCESS_COUNTDOWN(src->dpman, frame_countdown, i)) { while(GST_DPMAN_PROCESS(src->dpman, i)) {
src->table_lookup = (gint)(src->table_pos); src->table_lookup = (gint)(src->table_pos);
src->table_lookup_next = src->table_lookup + 1; src->table_lookup_next = src->table_lookup + 1;
@ -251,12 +251,13 @@ gst_sinesrc_get(GstPad *pad)
/* * src->volume * 32767.0; */ /* * src->volume * 32767.0; */
/*linear interpolation */ /*linear interpolation */
samples[i++] = ((src->table_interp samples[i] = ((src->table_interp
*(src->table_data[src->table_lookup_next] *(src->table_data[src->table_lookup_next]
-src->table_data[src->table_lookup] -src->table_data[src->table_lookup]
) )
)+src->table_data[src->table_lookup] )+src->table_data[src->table_lookup]
)* src->volume * 32767.0; )* src->volume * 32767.0;
i++;
} }
@ -282,6 +283,7 @@ gst_sinesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
break; break;
case ARG_SAMPLERATE: case ARG_SAMPLERATE:
src->samplerate = g_value_get_int (value); src->samplerate = g_value_get_int (value);
gst_dpman_set_rate(src->dpman, src->samplerate);
src->newcaps=TRUE; src->newcaps=TRUE;
gst_sinesrc_update_table_inc(src); gst_sinesrc_update_table_inc(src);
break; break;