# Wav sink problem

**URL:** <https://www.ruby-forum.com/t/wav-sink-problem/223256>\
**Category:** GNU Radio\
**Created:** [September 26, 2012, 10:52pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256 "2012-09-26T22:52:29Z")\
**Posts on this page:** 15\
**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:** [September 26, 2012, 10:52pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/1 "2012-09-26T22:52:29Z")

</div>

Hi,

i construct very simple scheme Audio Source --\> Wav Sink  
gr generates non-null wav file  
-rw-rw-r-- 1 anton anton 24M . 27 00:46 freq2.wav

but when i try to play it or fetch info about file with soxi (sox  
plugin)  
i got nothing

aplay freq2.wav  
WAVE ‘freq2.wav’ : Signed 16 bit Little Endian,  
44100 ,

and soxi freq2.wav shows

$ soxi freq2.wav

Input File : ‘freq2.wav’  
Channels : 1  
Sample Rate : 44100  
Precision : 16-bit  
Sample Encoding: 16-bit Signed Integer PCM

so it seems to me wav sink produces corrupted wav files or … what am  
i doing wrong?

e.g.  
soxi info on good wav file

$ soxi arecord.wav

Input File : ‘arecord.wav’  
Channels : 1  
Sample Rate : 8000  
Precision : 8-bit  
Duration : 00:00:02.38 = 19000 samples ~ 178.125 CDDA sectors  
File Size : 19.0k  
Bit Rate : 64.1k  
Sample Encoding: 8-bit Unsigned Integer PCM

look at Sample Encoding - it is Signed for gnuradio and Unsigned for all  
others.

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 4:43pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/2 "2012-09-27T16:43:27Z")

</div>

Hi Anton,

I’d rather look if your audio source is producing the correct samples.

On Thu, Sep 27, 2012 at 12:51:20AM +0400, Anton K. wrote:

> i construct very simple scheme Audio Source → Wav Sink  
> gr generates non-null wav file  
> -rw-rw-r-- 1 anton anton 24M сент. 27 00:46 freq2.wav

Looks good.

> $ soxi freq2.wav
> 
> Input File : ‘freq2.wav’  
> Channels : 1  
> Sample Rate : 44100  
> Precision : 16-bit  
> Sample Encoding: 16-bit Signed Integer PCM

Looks good, too.

> File Size : 19.0k  
> Bit Rate : 64.1k  
> Sample Encoding: 8-bit Unsigned Integer PCM
> 
> look at Sample Encoding - it is Signed for gnuradio and Unsigned for all others.

You’re comparing 16- with 8-Bit. They’re different.

Check the WAV file with Audacity. You can also connect the WAV sink to a  
signal source for further tests.

M

–  
Karlsruhe Institute of Technology (KIT)  
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.  
Research Associate

Kaiserstraße 12  
Building 05.01  
76131 Karlsruhe

Phone: +49 721 608-43790  
Fax: +49 721 608-46071  
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and  
National Laboratory of the Helmholtz Association

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 4:56pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/3 "2012-09-27T16:56:54Z")

</div>

Hi, Martin, thanks for reply.

In Audacity i see only gray background and no signal.

Actually i have started with nbfm reciever and tried to save audio in  
wav file. That i tried to redirect it to audio sink and audio was ok.  
Than i tried to use very simple scheme with audio source to wav sink  
and realize that wav file is broken.

I do not think it is good when soxi not shoing time length for the  
file - that means file is broken.

On Thu, Sep 27, 2012 at 6:42 PM, Martin B. (CEL)

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 5:09pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/4 "2012-09-27T17:09:10Z")

</div>

On Thu, Sep 27, 2012 at 06:55:08PM +0400, Anton K. wrote:

> file - that means file is broken.  
> Are you making sure the flow graph is terminated correctly? If you  
> simply kill the flow graph, the WAV block has no chance to write a  
> correct file header. This happens in the block destructor, or when you  
> call close().  
> If you can’t do that, you must use gr\_file\_sink.

MB

> > > -rw-rw-r-- 1 anton anton 24M сент. 27 00:46 freq2.wav
> > 
> > > Precision : 8-bit  
> > > signal source for further tests.  
> > > Kaiserstraße 12
> > 
> > * * *
> > 
> > Discuss-gnuradio mailing list  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)
> 
> * * *
> 
> Discuss-gnuradio mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

–  
Karlsruhe Institute of Technology (KIT)  
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.  
Research Associate

Kaiserstraße 12  
Building 05.01  
76131 Karlsruhe

Phone: +49 721 608-43790  
Fax: +49 721 608-46071  
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and  
National Laboratory of the Helmholtz Association

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 5:14pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/5 "2012-09-27T17:14:26Z")

</div>

Martin,  
actually no, i am not sure.  
i am just pushing stop button in gnuradio companion.

from grc perspective view, what method is supposed to be used for  
graceful script termination?

On Thu, Sep 27, 2012 at 7:07 PM, Martin B. (CEL)

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 5:18pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/6 "2012-09-27T17:18:31Z")

</div>

I recall running into this issue myself now, with multimode and  
simple\_fm\_rcv.

What I do in those two apps is that when I turn “off”  
recording, I change the wavfile filename to /dev/null, which causes a  
formal cleanup-and-close of the previous file.

On 27 Sep 2012 11:13,  
Anton K. wrote:

> Martin,  
> actually no, i am not sure.  
> i am  
> just pushing stop button in gnuradio companion.
> 
> from grc  
> perspective view, what method is supposed to be used for  
> graceful  
> script termination?

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 5:29pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/7 "2012-09-27T17:29:37Z")

</div>

So it can programmed with GRC, or i supposed to make some stuff in  
python script?

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 5:59pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/8 "2012-09-27T17:59:27Z")

</div>

Ok i see.

And, if i want to run script from shell to record audio files and  
rotate them every hour, how to make start/stop recording procedure in  
this case?

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 5:32pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/9 "2012-09-27T17:32:33Z")

</div>

On 27 Sep 2012 11:28, Anton K. wrote:

> So it can programmed  
> with GRC, or i supposed to make some stuff in  
> python script?
> 
> On  
> Thu, Sep 27, 2012 at 7:17 PM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I recall  
> > running into this issue myself now, with multimode and simple\_fm\_rcv.  
> > What I do in those two apps is that when I turn “off” recording, I  
> > change the wavfile filename to /dev/null, which causes a formal  
> > cleanup-and-close of the previous file. On 27 Sep 2012 11:13, Anton  
> > Komarov wrote: Martin, actually no, i am not sure. i am just pushing  
> > stop button in gnuradio companion. from grc perspective view, what  
> > method is supposed to be used for graceful script termination? O  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio mailing  
> > list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [1]  
> > [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio) [2]

Use a  
conditional expression in the “filename” field of the wavefile sink, and  
then have a “checkbox” control to control recording. Make the expression  
conditional on the state of the checkbox, and if “recording” isn’t  
checked, make the file /dev/null, otherwise make it the file you want.

Links:

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 9:12pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/10 "2012-09-27T21:12:18Z")

</div>

Ok, tried with selector and check box.  
I started script, check box appeared, i cheched it and recording to  
wav file started.  
Wait a bit and unchecked it, got file 2.7 Mbytes, not growing more,  
then stopped the script.  
FIle is corrupted.

Here is links on my grc scheme - [http://db.tt/ACl4nLNy](http://db.tt/ACl4nLNy) and wav file i  
got - [http://db.tt/87PIVwCy](http://db.tt/87PIVwCy)

Any help will be appreciated, i dont believe wav sink is so buggy…

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 6:05pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/11 "2012-09-27T18:05:53Z")

</div>

On 27 Sep 2012 11:58, Anton K. wrote:

> Ok i see.
> 
> And,  
> if i want to run script from shell to record audio files and  
> rotate  
> them every hour, how to make start/stop recording procedure in  
> this  
> case?
> 
> On Thu, Sep 27, 2012 at 7:31 PM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > On 27 Sep 2012 11:28, Anton K. wrote: So it can programmed with  
> > GRC, or i supposed to make some stuff in python script? On Thu, Sep 27,  
> > 2012 at 7:17 PM, \<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [1]\> wrote: I recall running into  
> > this issue myself now, with multimode and simple\_fm\_rcv. What I do in  
> > those two apps is that when I turn “off” recording, I change the wavfile  
> > filename to /dev/null, which causes a formal cleanup-and-close of the  
> > previous file. On 27 Sep 2012 11:13, Anton K. wrote: Martin,  
> > actually no, i am not sure. i am just pushing stop button in gnuradio  
> > companion. from grc perspective view, what method is supposed to be used  
> > for graceful script termination? O  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio mailing  
> > list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [2]  
> > [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio) [3] Use a  
> > conditional expression in the “filename” field of the wavefile sink, and  
> > then have a “checkbox” control to control recording. Make the expression  
> > conditional on the state of the checkbox, and if “recording” isn’t  
> > checked, make the file /dev/null, otherwise make it the file you want.  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio mailing  
> > list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [4]  
> > [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio) [5]

You can use  
the XMLRPC server that GRC provides to change any flow-graph variables  
you want from outside.

## Links:

[1]  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[2] [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[3]  
[Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)  
[4]  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[5]  
[Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 27, 2012, 11:48pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/12 "2012-09-27T23:48:17Z")

</div>

> Ok, tried with selector and check box.  
> I started script, check box appeared, i cheched it and recording to  
> wav file started.  
> Wait a bit and unchecked it, got file 2.7 Mbytes, not growing more,  
> then stopped the script.  
> FIle is corrupted.

Looked at your flow-graph.

You have to make the _filename_ on the WAV sink change depending on  
recording/not-recording.

Just use a conditional expression as the filename parameter in the  
filename sink

“myfile” if recording\_on else “/dev/null”

–  
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.

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [September 28, 2012, 6:55am UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/13 "2012-09-28T06:55:17Z")

</div>

ok! with conditional filename works like a charm!  
thank you very much!  
sorry that i did get for the first time 😉

---

<div class="post-metadata">

**Author:** ![jteez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@jteez](https://www.ruby-forum.com/u/jteez)\
**Post date:** [December 23, 2020, 5:30pm UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/14 "2020-12-23T17:30:59Z")

</div>

Hi, I know its an old thread but supper grateful for finding this and just wanted to add comments from my windows environment not sure why, but had a bit of a mare getting to it work especially around string vs. quotes vs nul value, etc.

I created a ‘QT GUI Checkbox’ called recording\_on. I set the type to string. I set the default and false values to “C:\xxxx\rubbish.wav” (without the quotes and with a proper folder structure and the true value to “C:\xxxx\rf\_file.wav” (without the quotes and with a proper folder". Then just set the filename property in the “Wav File Sync” to “recording\_on” (without the quotes)…

Thanks All!

---

<div class="post-metadata">

**Author:** ![rubybaz](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/rubybaz/32/2747_2.png) [@rubybaz](https://www.ruby-forum.com/u/rubybaz)\
**Post date:** [May 16, 2021, 5:48am UTC](https://www.ruby-forum.com/t/wav-sink-problem/223256/15 "2021-05-16T05:48:07Z")

</div>

I recall running into this subject myself, with multimode and simple\_fm\_rcv. What I do in those two apps is that when I turn “off” recording, I changed the wav-file filename to /dev/null, which causes a formal cleanup-and-close of the previous file.
