Forum: GNU Radio sound card sampling rate question

D500384e425fd1e51583f596fffb5d13?d=identicon&s=25 jmfriedt (Guest)
on 2014-06-25 10:43
(Received via mailing list)
I am facing a funny issue: I want to use the sound card for analyzing
the spectral response
of a quartz tuning fork at 32768 Hz. I just happened to discover that my
laptop (Panasonic CF-19)
has a sound card able to sample a signal at 192 kHz. I checked with
audacity (Generate -> Tone at
32768 Hz and a frequency counter gives the right output frequency while
an oscilloscope displays
a clean sine wave).
Now I want to do the same with gnuradio-companion: Signal Source sampled
at 192 kHz, output frequency
at 32768 Hz, directly connected to the audio sink manually set to 192
kHz. To make a long story short:
at low frequency (<20 kHz output) the output is at the right frequency,
so the sampling rate is
properly understood. Above 24 kHz I get a clean sine wave output at f-24
kHz, so it looks like an
aliasing effect with a sampling frequency of 48 kHz, which is not
consistent with my first observation.
And setting an output frequency of 24.xx kHz (xx=300 or 400 Hz)
generates on the oscilloscope a funny
low frequency beat signal which must be related to the antialiasing
filters of the card.

What I cannot understand is where gnuradio fails to initialize the sound
card the way audacity does.
Reading the source code, I find in gr-audio/lib/alsa/alsa_sink.cc the
following intialization

      // sampling rate
      unsigned int orig_sampling_rate = d_sampling_rate;
      if((error = snd_pcm_hw_params_set_rate_near(d_pcm_handle,
d_hw_params,
                                                  &d_sampling_rate, 0))
< 0)
        bail("failed to set rate near", error);

      if(orig_sampling_rate != d_sampling_rate) {
        fprintf(stderr, "audio_alsa_sink[%s]: unable to support sampling
rate %d\n",
                snd_pcm_name(d_pcm_handle), orig_sampling_rate);
        fprintf(stderr, "  card requested %d instead.\n",
d_sampling_rate);
      }

which does not seem to test whether the sampling rate is above or below
48 kHz (as found in the
pull down menu of the Audio Sink block of gnuradio-companion), and I get
no error message when
running my application.
Any idea what could be going wrong ?

Thanks, JM

--
JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 32 av. observatoire, 25044
Besancon, France
D17685d174fee4ca258c75cce7bc2202?d=identicon&s=25 Marcus Müller (Guest)
on 2014-06-25 10:49
(Received via mailing list)
Hi JM,

guessing in the dark: You are likely running a modern linux
distribution. Many of these tend to emulate an Alsa device, which in
fact is but an Pulseaudio server, which in turn speaks to the real
device. They set that as the default audio device in the system.
Have you tried using the explicit device name (aplay -L) of your
physical device in the audio sink?

Greetings,
Marcus
D500384e425fd1e51583f596fffb5d13?d=identicon&s=25 jmfriedt (Guest)
on 2014-06-25 20:04
(Received via mailing list)
that was it indeed: selecting out of the aplay -L options the default
setup
yields the behaviour I described in my email, while selecting hw as
shown in
the output of aplay -L

hw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    Direct hardware device without any conversions

allows me to generate a clean 32768 Hz sine wave.

Thanks, JM

> On 25.06.2014 10:40, jmfriedt wrote:
> > And setting an output frequency of 24.xx kHz (xx=300 or 400 Hz) generates on
the oscilloscope a funny
> >
> >
> > Thanks, JM
> >
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


--
JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 32 av. observatoire, 25044
Besancon, France
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.