# Wav file source question

**URL:** <https://www.ruby-forum.com/t/wav-file-source-question/235852>\
**Category:** GNU Radio\
**Created:** [July 19, 2013, 5:19pm UTC](https://www.ruby-forum.com/t/wav-file-source-question/235852 "2013-07-19T17:19:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [July 19, 2013, 5:19pm UTC](https://www.ruby-forum.com/t/wav-file-source-question/235852/1 "2013-07-19T17:19:49Z")

</div>

Hi guys,

I am playing with gnuradio companion. I have a question on wav file.

I play like this first (the samp\_rate set to 32k)

_Audio Source —\> Wav File Sink;_

I save the file as test.wav. It sound well.

Then, I play the file back (samp\_rate is 32k).

\*Wave File Source —\> Audio Sink; \*

The error comes as: WAV file does not contain any samples.

Could anyone point out the problem? How could I use the ‘wav file  
source’  
block?

Thanks,

Baokun

---

<div class="post-metadata">

**Author:** ![Baokun\_Liu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ebca7d/32.png) [@Baokun\_Liu](https://www.ruby-forum.com/u/Baokun_Liu)\
**Post date:** [June 9, 2015, 9:08pm UTC](https://www.ruby-forum.com/t/wav-file-source-question/235852/2 "2015-06-09T21:08:48Z")

</div>

Did you find the solution?

regards

Baokun Liu wrote

> Then, I play the file back (samp\_rate is 32k).  
> Baokun
> 
> * * *
> 
> Discuss-gnuradio mailing list

> Discuss-gnuradio@

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

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/wav-file-source-question-tp42578p54103.html](http://gnuradio.4.n7.nabble.com/wav-file-source-question-tp42578p54103.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Baokun\_Liu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ebca7d/32.png) [@Baokun\_Liu](https://www.ruby-forum.com/u/Baokun_Liu)\
**Post date:** [June 9, 2015, 9:19pm UTC](https://www.ruby-forum.com/t/wav-file-source-question/235852/3 "2015-06-09T21:19:54Z")

</div>

Hi fffdddooo,

Baokum Liu asked that two years ago. Some things have changed since  
then; do you have a question that we might help you answer?

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![Baokun\_Liu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ebca7d/32.png) [@Baokun\_Liu](https://www.ruby-forum.com/u/Baokun_Liu)\
**Post date:** [June 9, 2015, 9:57pm UTC](https://www.ruby-forum.com/t/wav-file-source-question/235852/4 "2015-06-09T21:57:17Z")

</div>

Well. I read the workaround. The problem is if you use file source and  
file  
sink instead of wav file source and wav file sink, you are not  
generating a  
wav file. You can name it \*.wav, but it isn’t a wav file at all.  
What I want to do is generating a wav file wich can be playd with any  
wav  
player (that I can do with wav file sink) and been able to use it again  
in  
gnu radio (wich does not work with file wav file source).  
I’ve tried 8 and 16 bits and different data rate

Marcus Müller-3 wrote

> > > block?
> > 
> > –  
> > View this message in context:  
> > [http://gnuradio.4.n7.nabble.com/wav-file-source-question-tp42578p54103.html](http://gnuradio.4.n7.nabble.com/wav-file-source-question-tp42578p54103.html)  
> > Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).
> > 
> > * * *
> > 
> > Discuss-gnuradio mailing list

> Discuss-gnuradio@

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

> Discuss-gnuradio@

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

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/wav-file-source-question-tp42578p54105.html](http://gnuradio.4.n7.nabble.com/wav-file-source-question-tp42578p54105.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Baokun\_Liu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ebca7d/32.png) [@Baokun\_Liu](https://www.ruby-forum.com/u/Baokun_Liu)\
**Post date:** [June 9, 2015, 10:05pm UTC](https://www.ruby-forum.com/t/wav-file-source-question/235852/5 "2015-06-09T22:05:28Z")

</div>

Hi fffdddoo (is that really the name by which we should address you?),

I’m guessing you try to save audio directly from the audio source to a  
wav file, right?

So, my blind guess is that Baokum wrongly configured the audio source  
and simply nothing came out of it.  
For example, no soundcard normally uses a sampling rate of 32kHz. A  
typical rate is 44.1kHz.

You might want to check your console output for errors. Most of the  
time, the audio sink complains about things like the device name not  
working or something else going wrong; this all depends very much on  
which operating system you use GNU Radio.  
Do you get any errors?

Of course, when using a file\_sink you don’t generate a wav file, that’s  
why we have the WAV sink 🙂

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![Baokun\_Liu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ebca7d/32.png) [@Baokun\_Liu](https://www.ruby-forum.com/u/Baokun_Liu)\
**Post date:** [June 10, 2015, 1:25am UTC](https://www.ruby-forum.com/t/wav-file-source-question/235852/6 "2015-06-10T01:25:16Z")

</div>

Here’s an example that generates a wave file that is playable by both  
gnuradio and mplayer

---

<div class="post-metadata">

**Author:** ![Baokun\_Liu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ebca7d/32.png) [@Baokun\_Liu](https://www.ruby-forum.com/u/Baokun_Liu)\
**Post date:** [June 10, 2015, 12:12am UTC](https://www.ruby-forum.com/t/wav-file-source-question/235852/7 "2015-06-10T00:12:15Z")

</div>

You can address me by Fernando, it’s easier to pronounce 😉  
I’m trying to save audio from the audio source to a file or from a  
signal  
source 1Khz for instance.  
I’ve tryed different things, and different data rate (I’ve tried 44100  
also)  
and is always the same eror

Generating: “/home/ubuntu/top\_block.py”

Executing: “/home/ubuntu/top\_block.py”

Traceback (most recent call last):  
File “/home/ubuntu/top\_block.py”, line 51, in   
tb = top\_block()  
File “/home/ubuntu/top\_block.py”, line 33, in **init**  
self.blocks\_wavfile\_source\_0 =  
blocks.wavfile\_source(“/home/ubuntu/prueba.wav”, True)  
File  
“/usr/local/lib/python2.7/dist-packages/gnuradio/blocks/blocks\_swig0.py”,  
line 1418, in make  
return \_blocks\_swig0.wavfile\_source\_make(\*args, \*\*kwargs)  
RuntimeError: WAV file does not contain any samples

> > > Done

But i have converted a mp3 file to wav with mpg123 and the file plays  
well  
using wav file source.  
Moreover: i’ve converted a file with mpg123 to a wav file at 22Ksps and  
it  
works too.  
And The file wav generated in gnuradio with wav file source is a valid  
wav  
file which I can play with amarok.  
So the problem is that wav file source does not recognice the files  
created  
by wav file sink altough they seem to be fully valid files.

regards

Marcus Müller-3 wrote

> You might want to check your console output for errors. Most of the
> 
> > I’ve tried 8 and 16 bits and different data rate
> > 
> > > > > \*Wave File Source —\> Audio Sink; \*
> > > > 
> > > > Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).  
> > > > [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)  
> > > > Discuss-gnuradio mailing list

> Discuss-gnuradio@

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

> Discuss-gnuradio@

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

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/wav-file-source-question-tp42578p54111.html](http://gnuradio.4.n7.nabble.com/wav-file-source-question-tp42578p54111.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).
