Question about Double / Float values in GRC

Hello All

I have a basic/beginner question.

I am using mkfifo to pipe output from a C++ application to a GRC script
using a named pipe.

I’m using C++ code that another student wrote and I am not too keen on
making difficult changes to it. In mode 1, it outputs a waveform in
double values in the range of +1 and -1 (just like a .WAV file but with
no header). In mode 2, an auxiliary function converts from doubles to
shorts in the range of -32768 to 32767.

I can get mode 2 to work with my GRC script by reading the file as
short, then converting to float so that I can apply resampling and the
feed it to the USRP (the resampling function won’t work with shorts).
This works great and I see the proper waveform output on the USRP, but
it seems awkward to convert from double to short in C++, then short to
float in GRC.

Next I tried with mode 1 with doubles. In my GRC script I read the file
in as float, and then I multiply by (2^15)-1 since the doubles range is
from +1 to -1. I get output from the USRP using this, but the waveform
doesn’t look right at all.

Is it even possible to read a file with double values using a GRC
generated script and the gr_file_source block? Or is there something
else I am doing wrong?

Thanks…Tom

Is it even possible to read a file with double values using a GRC
generated script and the gr_file_source block? Or is there something
else I am doing wrong?

Its a 2 part problem:

Unlike gnuradio blocks, in GRC, the data type is checked. So there is no
support for double streams. However you could configure the file source
to use a byte stream w/ a vlen of 8. That would match the itemsize,
but…

The other problem is that gnuradio has no blocks that use double
streams. Its wasted overhead since floats give all the necessary dynamic
range. So nobody invested any effort into it.

You may have to add a custom gnuradio block that converts a double
stream to a float stream. A set of double to<->from float blocks would
be a welcome addition.

-Josh