2

I recorded a signal with GNU Radio using a file sink block which outputs a raw binary file that can be analyzed or used as a source of input into GNU Radio.

I want to edit this raw file so that when I use it as a source inside GNU Radio it transmits my changed file instead of the original. For example: The signal is very long and repeats a pattern, I want to edit the file to reduce the number of repeated signals and save it back to the raw format to transmit using gnuradio later.

I tried importing the file into Audacity as a raw file (selecting 32bit float with 1 channel and 48k as the sample rate). This works for me to see the signal as audio data and I can even edit it but I'm not sure if it's saving it correctly when I export it as raw data. Also, the time indices in audacity seem to be way off; the signal should only be microseconds but audacity is showing it as a total of several seconds!

Anyone have any luck with editing the raw file sink output from GNU Radio?

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
vane
  • 2,125
  • 1
  • 21
  • 40

2 Answers2

2

I was able to consistently make this work. There seemed to be 3 things preventing this from working properly.

1) I was doing it wrong! I needed to output both the Real and the Imaginary numbers to a 2 channel wav file.

2) Using a spectrum analyzer, I was able to see that audacity was doing something really weird with the wav file when you delete a section of audio, so to combat this I "silenced" the section of audio I wanted to delete.

3) There seems to be a bug with Gnuradio and the Osmocom Sink (yes, I have the latest version of both, from source). If you run your flow graph, start transmitting then stop the flow graph by clicking the red X in Gnuradio (Kill the flow graph) it keeps my device (HackRF) transmitting! If you try to transmit a new file or the same file again, it will not transmit that signal because it's already trying to transmit something. In order to stop the device from transmitting, just close the block popup window that appears when you run the flow graph.

The 3rd item might not be a bug because I might have been stopping my flow graphs incorrectly to begin with, but following Michael Ossmann's tutorial on using the HackRF with Gnuradio, he says to click the red X to properly shutdown the flow graph and clean everything up; this appears to NOT be the case.

vane
  • 2,125
  • 1
  • 21
  • 40
1

In the gr-utils/octave folder of the GNU Radio source code there are several functions for Octave and Matlab. Some of them allow to retrieve and store raw binary files of the corresponding data type.

For example, if your signal is constructed from float samples you can use the read_float_binary function to import the samples stored by the file sink block into Octave/Matlab. Then make your modifications to the signal and store it back again using the write_float_binary function. The stored file can be the imported to your flowgraph using a file source block.

Manos
  • 2,136
  • 17
  • 28
  • Yes, this works but what I was trying to accomplish was visual editing of the sink file through audacity or some similar program. I did figure it out though and will provide an answer later for anyone else that's interested. – vane Apr 28 '15 at 18:46
  • I think that with scientific tools like Octave or Matlab, visual tools are far more sophisticated and convenient. Unless your modifications on the signal are restricted only to cut/copy/paste audio samples, I suggest you to give them a try. – Manos Apr 28 '15 at 19:42
  • I agree, and I plan on giving Octave and Matlab a try but in this case the extent of my editing is literally just removing sections of the signal and it's easier to visually remove them. – vane Apr 28 '15 at 20:05