Sound card sampling rate question

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

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

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
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 32 av. observatoire, 25044
Besancon, France

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs