Forum: GNU Radio Wav sink problem

Posted by Anton Komarov (Guest)
on 2012-09-26 22:52
(Received via mailing list)
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 ,
<imidiate stop>

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.
Posted by Martin Braun (CEL) (Guest)
on 2012-09-27 16:43
(Received via mailing list)
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 Komarov 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 Braun
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
Posted by Anton Komarov (Guest)
on 2012-09-27 16:56
(Received via mailing list)
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 Braun (CEL)
Posted by Martin Braun (CEL) (Guest)
on 2012-09-27 17:09
(Received via mailing list)
On Thu, Sep 27, 2012 at 06:55:08PM +0400, Anton Komarov 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
> > Discuss-gnuradio@gnu.org
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

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

Dipl.-Ing. Martin Braun
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
Posted by Anton Komarov (Guest)
on 2012-09-27 17:14
(Received via mailing list)
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 Braun (CEL)
Posted by unknown (Guest)
on 2012-09-27 17:18
(Received via mailing list)
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?
Posted by Anton Komarov (Guest)
on 2012-09-27 17:29
(Received via mailing list)
So it can programmed with GRC, or i supposed to make some stuff in
python script?
Posted by unknown (Guest)
on 2012-09-27 17:32
(Received via mailing list)
On 27 Sep 2012 11:28, Anton Komarov 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, <mleech@ripnet.com> 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 Discuss-gnuradio@gnu.org [1]
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:
Posted by Anton Komarov (Guest)
on 2012-09-27 17:59
(Received via mailing list)
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?
Posted by unknown (Guest)
on 2012-09-27 18:05
(Received via mailing list)
On 27 Sep 2012 11:58, Anton Komarov 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, <mleech@ripnet.com> wrote:
>

>> On 27 Sep 2012 11:28, Anton Komarov 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, <mleech@ripnet.com [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 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 Discuss-gnuradio@gnu.org [2]
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 Discuss-gnuradio@gnu.org [4]
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:mleech@ripnet.com
[2] mailto:Discuss-gnuradio@gnu.org
[3]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
[4]
mailto:Discuss-gnuradio@gnu.org
[5]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Posted by Anton Komarov (Guest)
on 2012-09-27 21:12
(Received via mailing list)
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 and wav file i
got - http://db.tt/87PIVwCy

Any help will be appreciated, i dont believe wav sink is so buggy....
Posted by Marcus D. Leech (Guest)
on 2012-09-27 23:48
(Received via mailing list)
> 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 Leech
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org
Posted by Anton Komarov (Guest)
on 2012-09-28 06:55
(Received via mailing list)
ok! with conditional filename works like a charm!
thank you very much!
sorry that i did get for the first time ;-)
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.