title: Alsa Lib Hardware Parameters setting
body: <p>I'm trying to record sound on my linux (debian) embedded device with alsa library. My embedded hardware is this [1], and according to its datasheet page 33 [2], </p>
  
  <blockquote>
    <p>Analog audio signals are featured by the on-SOM TLV320AIC3106 audio codec. </p>
  </blockquote>
  
  <p>and the datasheet of this Texas Instruments audio codec [3], </p>
  
  <blockquote>
    <p>Supports Rates From 8 kHz to 96 kHz</p>
  </blockquote>
  
  <p>I use the example application code for alsa lib, for initial work I didn't change the code. In the example code, the sampling rate was set to 44100Hz. I successfully recorded sound and played after. For now, I think, I can record sound with alsa-lib with the sampling rate of 8000Hz based on the datasheets. I set the sampling rate to 8000Hz but while the alsa configuration, it changes to 16000Hz. 
  I set sampling rate to 8000Hz;</p>
  
  <pre><code>snd_pcm_hw_params_set_rate_near(handle, params, &amp;(record_params-&gt;rate), &amp;dir);
  snd_pcm_hw_params_set_channels(handle, params, record_params-&gt;channel);
  rc = snd_pcm_hw_params(handle, params);
  </code></pre>
  
  <p>But after invoking this method;</p>
  
  <pre><code>snd_pcm_hw_params_get_period_time(params, &amp;(record_params-&gt;rate), &amp;dir);
  </code></pre>
  
  <p>it changes to 16000. There is no other method call between above. Are my settings wrong or may be the codec doesn't support for 8kHz? </p>
  
  <p><strong>UPDATE:</strong> When I set rate to 16000, it changes to 8000. I'm really confused more. </p>
  
  <p>[1] = <a href="http://www.variscite.com/products/system-on-module-som/cortex-a9/dart-mx6-cpu-freescale-imx6" rel="nofollow noreferrer">http://www.variscite.com/products/system-on-module-som/cortex-a9/dart-mx6-cpu-freescale-imx6</a></p>
  
  <p>[2] = <a href="http://www.variscite.com/images/stories/DataSheets/DART-MX6/DART-MX6_v1_2_datasheet_v2_1.pdf" rel="nofollow noreferrer">http://www.variscite.com/images/stories/DataSheets/DART-MX6/DART-MX6_v1_2_datasheet_v2_1.pdf</a></p>
  
  <p>[3] = <a href="http://www.ti.com/lit/ds/symlink/tlv320aic3106.pdf" rel="nofollow noreferrer">http://www.ti.com/lit/ds/symlink/tlv320aic3106.pdf</a></p>