# Loading file into memory

**URL:** <https://www.ruby-forum.com/t/loading-file-into-memory/224141>\
**Category:** GNU Radio\
**Created:** [October 31, 2012, 3:33pm UTC](https://www.ruby-forum.com/t/loading-file-into-memory/224141 "2012-10-31T15:33:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [October 31, 2012, 3:33pm UTC](https://www.ruby-forum.com/t/loading-file-into-memory/224141/1 "2012-10-31T15:33:57Z")

</div>

Dear Gnuradio List,

I’m doing some benchmarking involving read a WAV file into my gnuradio  
program, executing a APT Decoder, and writing out the result to a file.  
I’m finding that my results are all I/O bound. I want to be able to load  
the entire file into memory (load the WAV file into a vector or other  
datatype) and then execute it, but still preserve the sampling rate. Is  
there a way of doing that?

Sincerely,  
Tommy T. II  
UVA Grad Student

---

<div class="post-metadata">

**Author:** ![Tommy\_TSII](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e56c9b/32.png) [@Tommy\_TSII](https://www.ruby-forum.com/u/Tommy_TSII)\
**Post date:** [October 31, 2012, 10:35pm UTC](https://www.ruby-forum.com/t/loading-file-into-memory/224141/2 "2012-10-31T22:35:55Z")

</div>

On Wed, Oct 31, 2012 at 10:32 AM, Tommy T. II [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Dear Gnuradio List,
> 
> ```
> I'm doing some benchmarking involving read a WAV file into my gnuradio 
> 
> ```

program, executing a APT Decoder, and writing out the result to a file. I’m  
finding that my results are all I/O bound. I want to be able to load the entire  
file into memory (load the WAV file into a vector or other datatype) and then  
execute it, but still preserve the sampling rate. Is there a way of doing that?

> Sincerely,  
> Tommy T. II  
> UVA Grad Student

Tommy,

You could probably just use Python (possibly using Scipy’s fromfile  
function) to read in the samples into an array and send that to a  
vector\_source\_f. That’s not really ideal since we don’t condone the  
use of vector\_source/sink blocks for real applications, but if you  
have the memory, this might be ok. You’ll find a large latency at the  
start as you are reading the file and then inserting it into the  
vector source.

Another approach would be to make a RAM disk and put the WAV file  
there, then just read it in like normal.

Tom

---

<div class="post-metadata">

**Author:** ![Tommy\_TSII](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e56c9b/32.png) [@Tommy\_TSII](https://www.ruby-forum.com/u/Tommy_TSII)\
**Post date:** [October 31, 2012, 10:40pm UTC](https://www.ruby-forum.com/t/loading-file-into-memory/224141/3 "2012-10-31T22:40:01Z")

</div>

> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

What sample rate are you using that is causing issues processing a WAV  
file for APT? APT is relatively-speaking narrowband, so there’s  
no way on gods little green earth that you’ll be exceeding the read  
rate of your local disk for APT. If things are stalling, you’re doing  
something wrong inside the flow-graph.

–  
Marcus L.  
Principal Investigator  
Shirleys Bay Radio Astronomy Consortium

> **[Live Draw HK Tercepat | Result HK | HK Pools | Live HK | HK Prize Hari Ini](https://www.sbrac.org/)**
>
> Temukan live draw hk tercepat melalui halaman hk pools yang resmi dan dapatkan result hk prize melalui live hk secara langsung di situs kami.
