On Wed, 2009-08-12 at 10:00 -0700, Milo W. wrote:
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
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.