[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Is there any way to obtain the binary output from

From: Johnathan Corgan
Subject: Re: [Discuss-gnuradio] Is there any way to obtain the binary output from audio source
Date: Wed, 12 Aug 2009 11:27:40 -0700

On Wed, 2009-08-12 at 10:00 -0700, Milo Wong wrote:

> I was wondering if there is anyway to obtain the binary output from
> audio source in GRC. I need this bits information as modulating signal
> for ASK. Since sound card digitized our analog voice signal to binary
> information in 16bits (suppose the sound card is 16bits), so I think
> it should be a way to directly obtain the 16bits binary output of each
> float symbol from audio source. I used to digitize them through "float
> to byte" type conversion, however, it would lost a lot of dynamic
> range since byte is only 8bits which is too imprecision.
> I've been confused by this question for a long time. Is there anybody
> who can help me? Thank you in advance!

The audio sources in GNU Radio provide a single-precision floating point
output stream with a dynamic range from -1.0 to 1.0.

Digital modulators in GNU Radio typically require a stream of "unpacked
bytes", where each byte in the stream contains one or more LSBs
representing the symbol you wish to modulate.  BPSK modulation has two
symbols, so these are represented by a '0' or '1' as the LSB.  QPSK has
four symbols, and these are represented by '00', '01', '10', and '11' in
the the two LSBs.  Other modulators are similar.

So your goal is to figure out how to convert a series of floating point
samples representing an analog data source (audio) into a series of
unpacked bytes appropriate to feed your modulator of choice.  In digital
comms, this is the job of a vocoder.  Different vocoders result in
differing properties of your communication system, such as data rate
required, fidelity of the audio demodulation, effect of noise, and what
happens when there are gaps in the packet stream.

The simplest route you can go is to use the sample stream unmodified,
which would give you a "signed-linear PCM" codec.  First, you would pass
your sample stream into a multiplier to get the dynamic range from
[-1.0,1.0] to [-32767.0:32767:0].  Then you use the type conversion
block gr.float_to_short() to turn this from floating point into signed
short integers of [-32767,32767].  Finally, you pass them through a
gr.packed_to_unpacked_ss block with the right number of LSBs to turn
them into symbols appropriate to your digital modulation.

Signed-linear PCM is generally not used in RF comms as it requires a
very wide bandwidth compared to other codecs.  If you are sampling voice
at 8000 sps, then it takes 96000 bps (16 bits per sample) to encode the
voice stream.  It also degrades very poorly in the presence of noise or
missing frames.

GNU Radio has an implementation of the GSM full-rate codec.  This takes
audio at 8000 sps and generates a 13 Kbps stream of compressed audio.
The GNU Radio GSM codec takes signed-linear shorts in and outputs
33-byte GSM frames, which you then need to modulate accordingly.

For an example of how this is done in practice, look at the tx_voice.py
script in the digital examples.  There is additional work involved in
taking the GSM frames and encoding them for packet-based transmission,
but the part about getting from voice to digital is there.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]