我正在尝试在gstreamer管道中使用元素audiofirfilter。现在没有运气。
我搜索了docs和mailinglist作为示例,但不幸的是,由于缺少一些片段(我在嵌入式系统上),所以无法编译。
我的管道是
if (data.pipeline == NULL) {
data.pipeline = gst_pipeline_new ("pipeline");
data.fakesrc = gst_element_factory_make("fakesrc", NULL);
data.capsfilter = gst_element_factory_make("capsfilter", NULL);
data.audioconvert = gst_element_factory_make("audioconvert", NULL);
data.audiofirfilter = gst_element_factory_make("audiofirfilter", NULL);
data.alsasink = gst_element_factory_make("alsasink", NULL);
gst_bin_add_many (GST_BIN (data.pipeline), data.fakesrc, data.capsfilter, data.audioconvert, data.audiofirfilter, data.alsasink, NULL);
if (!gst_element_link_many (data.fakesrc, data.capsfilter, data.audioconvert, data.audiofirfilter, data.alsasink, NULL) ) {
qDebug() << "Error: not all elements could be linked!";
return;
}
GstCaps* caps = gst_caps_new_simple("audio/x-raw",
"format", G_TYPE_STRING, "S16LE",
"rate", G_TYPE_INT, SAMPLING_FREQUENCY,
"channels", G_TYPE_INT,2,
"layout", G_TYPE_STRING, "interleaved",
NULL);
g_object_set(G_OBJECT(data.capsfilter), "caps", caps, NULL);
g_object_set (G_OBJECT (data.fakesrc),
"sync", TRUE,
"signal-handoffs", TRUE,
"sizemax",BUFFER_SIZE,
"sizetype",2,NULL);
gdouble filter_kernel[16] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
GValueArray *va;
va = g_value_array_new (1);
GValue v = { 0, };
g_value_init (&v, G_TYPE_DOUBLE);
for (int i = 0; i < 16; i++) {
g_value_set_double (&v, filter_kernel[i]);
g_value_array_append (va, &v);
g_value_reset (&v);
}
g_object_set (G_OBJECT (data.audiofirfilter), "kernel", va, NULL);
g_object_set (G_OBJECT (data.audiofirfilter), "latency", (gint64) (16 / 2), NULL);
g_value_array_free (va);
g_signal_connect (data.fakesrc, "handoff", G_CALLBACK (SourceHandoffCallback), /*&data*/ this);
GstBus *bus;
bus = gst_pipeline_get_bus (GST_PIPELINE(data.pipeline));
gst_object_unref (bus);
}
我现在只想实现单一的脉冲响应。
管道根本无法播放。这是立体声管道。
有没有人有不涉及fft的audiofirfilter应用程序的有效示例?反FFT?
谢谢
最佳答案
我尝试了一个更简单的管道,并且可行:
gst_init (NULL,NULL);
cFusionDrumsPlayerData data;
data.pipeline = gst_pipeline_new ("pipeline");
data.src = gst_element_factory_make("audiotestsrc", NULL);
data.audiofirfilter = gst_element_factory_make("audiofirfilter", NULL);
data.sink = gst_element_factory_make("autoaudiosink", NULL);
gst_bin_add_many (GST_BIN (data.pipeline), data.src, data.audiofirfilter, data.sink, NULL);
if (!gst_element_link_many (data.src, data.audiofirfilter, data.sink, NULL) ) {
return;
}
gdouble filter_kernel[16] = {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
GValueArray *va;
va = g_value_array_new (1);
GValue v = { 0, };
g_value_init (&v, G_TYPE_DOUBLE);
for (int i = 0; i < 16; i++) {
g_value_set_double (&v, filter_kernel[i]);
g_value_array_append (va, &v);
g_value_reset (&v);
}
g_object_set (G_OBJECT (data.audiofirfilter), "kernel", va, NULL);
g_object_set (G_OBJECT (data.audiofirfilter), "latency", (gint64) (16 / 2), NULL);
g_value_array_free (va);
gst_element_set_state (data.pipeline, GST_STATE_PLAYING);
我认为可能是问题的根源(fakesrc)