Skip to content
Snippets Groups Projects
Commit f040d3f3 authored by Alexander Pace's avatar Alexander Pace
Browse files

Interpolator changes

parent 9796c278
No related branches found
No related tags found
No related merge requests found
......@@ -156,6 +156,8 @@ void convolve(float *output, gsl_vector_float *thiskernel, float *input, guint k
gsl_vector_float_view output_vector = gsl_vector_float_view_array(output, channels);
gsl_matrix_float_view input_matrix = gsl_matrix_float_view_array(input, kernel_length, channels);
gsl_blas_sgemv (CblasTrans, 1.0, &(input_matrix.matrix), thiskernel, 0, &(output_vector.vector));
return;
}
......@@ -196,15 +198,8 @@ void resample(float *output, gsl_vector_float **thiskernel, float *input, guint
kernel_offset = samp % factor;
output_offset = samp * channels;
input_offset = samp / factor * channels;
/*
* The first kernel is a delta function by definition, so just
* copy the input
*/
// AEP- disable the copy conditional, always perform the convolution.
/*if (kernel_offset == 0)
copy_input(output + output_offset, thiskernel[kernel_offset], input + input_offset, kernel_length, channels);
else*/
convolve(output + output_offset, thiskernel[kernel_offset], input + input_offset, kernel_length, channels);
convolve(output + output_offset, thiskernel[kernel_offset], input + input_offset, kernel_length, channels);
}
return;
}
......@@ -626,12 +621,9 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf
guint processed = 0;
//float *output = (float *) GST_BUFFER_DATA(outbuf);
//memset(GST_BUFFER_DATA(outbuf), 0, GST_BUFFER_SIZE(outbuf)); // FIXME necesary?
gst_buffer_map(outbuf, &mapinfo, GST_MAP_WRITE);
float *output = (float *) outbuf;
float *output = (float *) mapinfo.data;
memset(mapinfo.data, 0, mapinfo.size);
gst_buffer_unmap(outbuf, &mapinfo);
// FIXME- clean up this print statement (format)
//GST_INFO_OBJECT(element, "Processing a %d sample output buffer from %d input", output_length);
......@@ -659,6 +651,7 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf
}
GST_INFO_OBJECT(element, "Processed a %d samples", processed);
set_metadata(element, outbuf, output_length, !copied_nongap);
gst_buffer_unmap(outbuf, &mapinfo);
}
return result;
......
......@@ -14,8 +14,8 @@ import test_common
import numpy
in_rate = 512
out_rate = 2048
num_chan = 200
out_rate = 1024
num_chan = 100
opt = sys.argv[1]
......@@ -30,6 +30,7 @@ head = pipeparts.mkfirbank(pipeline, head, fir_matrix = numpy.ones((num_chan,1))
if opt == "resample":
head = pipeparts.mkcapsfilter(pipeline, pipeparts.mkresample(pipeline, head), "audio/x-raw, format=F32LE, rate=%d" % out_rate)
if opt == "interp":
print "Notice-- running interpolator"
head = pipeparts.mkcapsfilter(pipeline, pipeparts.mkinterpolator(pipeline, head), "audio/x-raw, format=F32LE, rate=%d" % out_rate)
pipeparts.mkfakesink(pipeline, head)
......
......@@ -39,18 +39,18 @@ def interp_test_01(pipeline, name):
gap_threshold = .75 # of 1
buffer_length = 5.0 # seconds
test_duration = 20.0 # seconds
frequency = 11.0
wave = 0
#
# build pipeline
#
head = test_common.gapped_test_src(pipeline, buffer_length = buffer_length, rate = rate, width = 32, test_duration = test_duration, gap_frequency = gap_frequency, gap_threshold = gap_threshold, control_dump_filename = "%s_control.dump" % name)§
#head = test_common.gapped_test_src(pipeline, channels = 1, wave = 0, freq = 10, buffer_length = buffer_length, rate = in_rate, test_duration = test_duration, gap_frequency = gap_frequency, gap_threshold = gap_threshold, control_dump_filename = "%s_control.dump" % name)
head = test_common.gapped_test_src(pipeline, freq=frequency, wave=wave, buffer_length = buffer_length, rate = in_rate, width = 32, test_duration = test_duration, gap_frequency = gap_frequency, gap_threshold = gap_threshold, control_dump_filename = "%s_control.dump" % name)
head = pipeparts.mkcapsfilter(pipeline, pipeparts.mkaudioconvert(pipeline, head), "audio/x-raw, format=F32LE, rate=%d" % in_rate)
head = tee = pipeparts.mktee(pipeline, head)
head = pipeparts.mkcapsfilter(pipeline, pipeparts.mkinterpolator(pipeline, head), "audio/x-raw, format=F32LE, rate=%d" % out_rate)
#head = pipeparts.mkcapsfilter(pipeline, pipeparts.mkresample(pipeline, head), "audio/x-raw, rate=%d" % out_rate)
pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head), "%s_out.dump" % name)
pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, tee), "%s_in.dump" % name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment