Increasing ALSA Sampling Rate

Is it possible to increase the maximum sampling rate for audio_alsa?

I am experimenting with using a modified TV tuner card as an ADC. The
card uses a Bt878a chipset. arecord can record from the card at 1972000
rate and GRC shows the maximum rate as 1972000, but GNUradio can only
sample at 896000.

Running GNUradio at 1972000 rate gives the following error-

audio_alsa_source[hw:2,1]: get_period_size failed: Invalid argument
Traceback (most recent call last):
File “/root/top_block.py”, line 81, in
tb = top_block()
File “/root/top_block.py”, line 49, in init
self.audio_source_0 = audio.source(samp_rate, “hw:2,1”, True)
File “/usr/local/lib/python2.6/site-packages/gnuradio/audio_alsa.py”,
line 241, in source
return _audio_alsa.source(*args, **kwargs)
RuntimeError: audio_alsa_source

Is there some setting change that can enable the 1792000 rate?

Thanks,
George

On Thu, Jan 27, 2011 at 11:38 AM, George S. Williams
[email protected] wrote:

audio_alsa_source[hw:2,1]: get_period_size failed: Invalid argument

Is there some setting change that can enable the 1792000 rate?

Thanks,
George

George,
It appears that this error is occurring in the ALSA asound library
itself (see line 205 of gr-audio-alsa/src/audio_alsa_source.cc). I
haven’t spent much time looking around the alsa implementation, so I
can’t say for certain, but this appears to be a problem with ALSA, not
GNU Radio.

Hopefully, someone else with much more knowledge about ALSA and it’s
capabilities can tell you better.

Tom

Hey, Tom,

Thanks for the reply. I’m not sure that it’s entirely an ALSA problem.

Both my aplay and snd-bt88x are patched to allow 1792000. If I do-
arecord -D hw:1,1 -r 1792000 -f S16_LE -t wav -d 5 test0.wav

I get-
Recording WAVE ‘test0.wav’ : Signed 16 bit Little Endian, Rate 1792000
Hz, Mono

And- soxi reports-
Input File : ‘test0.wav’
Channels : 1
Sample Rate : 1.792e+06
Precision : 16-bit
Duration : 00:00:05.00 = 8960000 samples ~ 375 CDDA sectors
Sample Encoding: 16-bit Signed Integer PCM

So it looks to me like ALSA recorded at 1792000.

Wish I knew more about ALSA and gnuradio- probably will before it’s
over.

George

On Mon, Jan 31, 2011 at 1:10 PM, George S. Williams [email protected]
wrote:

Wish I knew more about ALSA and gnuradio- probably will before it’s over.

George

Ok, gotcha. Then I’ll reword what I said; it must be a problem with
how we are using ALSA :slight_smile:

Like I said, though, this is not my area of expertise, so I’m hoping
someone else with more knowledge of the ALSA API can help out.

Tom

On 01/31/2011 01:10 PM, George S. Williams wrote:

Hey, Tom,

Thanks for the reply. I’m not sure that it’s entirely an ALSA problem.

Both my aplay and snd-bt88x are patched to allow 1792000. If I do-
arecord -D hw:1,1 -r 1792000 -f S16_LE -t wav -d 5 test0.wav

audio_alsa_source[hw:2,1]: get_period_size failed: Invalid argument

I think the clue is in the above.

It looks like the device-specific driver for this hardware doesn’t
contain the “PERIOD_SIZE” parameter
in the configuration description for the hardware, and Gnu Radio uses
that information for buffer
planning purposes (using it for set_output_multiple() ). Not clear
whether there’s a fix or not, and
whether the fix belongs in Alsa or Gnu Radio.


Principal Investigator
Shirleys Bay Radio Astronomy Consortium

On 1/31/2011 4:22 PM, Marcus D. Leech wrote:

audio_alsa_source[hw:2,1]: get_period_size failed: Invalid argument

I think the clue is in the above.

It looks like the device-specific driver for this hardware doesn’t contain the
“PERIOD_SIZE” parameter
in the configuration description for the hardware, and Gnu Radio uses that
information for buffer
planning purposes (using it for set_output_multiple() ). Not clear whether
there’s a fix or not, and
whether the fix belongs in Alsa or Gnu Radio.

Would this keep Gnu Radio from using the card at 1792000 but still allow
896000?

Using this in config.conf
[audio_alsa]
verbose = true

And setting samp_rate to 896000

GRC returns this-
PCM name: hw:1,1
Access types:
MMAP_INTERLEAVED YES
MMAP_NONINTERLEAVED NO
MMAP_COMPLEX NO
RW_INTERLEAVED YES
RW_NONINTERLEAVED NO
Formats:
S8 YES
S16_LE YES
Number of channels
min channels: 1
max channels: 1
1 channels YES
Sample Rates:
min rate: 119466 (dir = 1)
max rate: 1792000 (dir = 0)
8000 NO
16000 NO
22050 NO
32000 NO
44100 NO
48000 NO
96000 NO
192000 NO

So I would think that Gnu Radio should know about the higher rate?? The
flowgraph does execute at 896000.

But, if I set samp_rate to 1792000, I get the get_period_size failed:
Invalid argument error.

Just trying to understand this stuff- still in the steep part of the
learning curve.

George

schrieb George S. Williams am 2011-01-27 17:38:

Is it possible to increase the maximum sampling rate for audio_alsa?

I am experimenting with using a modified TV tuner card as an ADC. The
card uses a Bt878a chipset. arecord can record from the card at 1972000
rate and GRC shows the maximum rate as 1972000, but GNUradio can only
sample at 896000.

896kSPS is quite something. Can you tell more about the hardware? I at
least (and probably many others) am very interested in something like
this.

Regards

Patrick

Engineers motto: cheap, good, fast: choose any two
Patrick S.
Student of Telemati_cs_, Techn. University Graz, Austria

planning purposes (using it for set_output_multiple() ). Not

Formats:
16000 NO
But, if I set samp_rate to 1792000, I get the get_period_size failed:
Invalid argument error.

Just trying to understand this stuff- still in the steep part of the
learning curve.

George

I suspect the answer lies in the bt87x kernel driver for Alsa and not in
Gnu Radio per se. Could be wrong, I haven’t looked
that deeply into the audio-alsa code.


Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium

Hey, Patrick,

I found the idea in this post to the list-
http://www.mail-archive.com/[email protected]/msg28487.html

which led to this-

which led to this-

The cards are old PV-BT878P+ analog video cards. I found 2 on ebay for
about $10US each- a Rev-9D, which is the one described in the article,
and a Rev-10A. The card for the Rev-10A is a bit different, but the same
connection from the tuner module is used in the modification. I have
both cards working with GNU Radio at 896000. (And apparently working
with ALSA at 1792000)

The article is a bit dated- the current ALSA interface is the snd-bt87x
module instead of the old btaudio module. But the modification to
aplay.c is the same. The Bt87x Audio Capture kernel module will need to
be recompiled with the Bt87x Audio overclocking option set (if it isn’t
already) in order to go from 448000 to 896000 or 1792000.

This should be enough to give you the basic idea.

Later,
George