Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > eb6f01499a5d4428f90019094419e1c5 > files > 753

liblirc-devel-0.10.1-7.mga7.armv7hl.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>LIRC - Linux Infrared Remote Control</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="lirc.css">
<LINK REL="shortcut icon" HREF="../images/favicon.ico">
<META NAME="description" CONTENT="LIRC - Linux Infrared Remote Control">
<META NAME="keywords" CONTENT="linux remote control, multimedia">
<META charset="UTF-8">
</HEAD>
<body>
<TABLE CLASS="menu"><TR>
<TD CLASS="menu"><IMG class="menuimg" SRC="../images/diode.gif" ALT="LIRC icon" ALIGN="LEFT"></TD>
<TD><IMG class="menuimg" SRC="../images/lirc.gif" ALT="LIRC logo" ALIGN="RIGHT"></TD>
</TR></TABLE>
<p></p>

    <a name="audio_alsa_hw"></a><hr>
    <h1>Using the ALSA audio IR receiver driver</h1>

    <h2>Hardware</h2>

    <p>
      This driver supports the <a href="../ir-audio.html">IR-audio</a>
      IR receiver module. A more detailed description of how to build
      and set up the hardware can be found by following the link.
    </p>

    <h2>How to use ALSA</h2>

    <p>
      Because I haven't seen yet any noticeable ALSA documentation for
      users, I should explain a little here about how to use ALSA
      itself. Still I will presume you already have installed ALSA and
      it is running.
    </p>

    <p>
      ALSA provides a lot of mixer controls, and it is not always
      obvious how to enable recording from a specific input, although
      as soon as you get the idea it turns to be relatively
      simple. Launch the alsamixer application (you can use the -c
      switch to select the desired sound card by number). Now scroll to
      see that you have a lot of controls :-) and many of them have
      unknown functions. Suppose your IR-audio module is connected to
      the CD-IN input; let's first test if your hardware works at
      all. Find the "CD" control, move the volume up and unmute it
      (with the 'M' key). Then take some remote control and activate
      it in front of your IR receiver. You should hear some kind of a
      bubbling, squeaking or beeping sound (depending on you remote
      control type). If you do, then your IR receiver works (I'll be
      surprised if it doesn't :).
    </p>

    <p>
      Now mute the channel again and select this channel for capturing
      by pressing "SPACE" on it: on the top you should see the text
      "CAPTUR" which means that this channel is connected to the
      analog-to-digital converter input (the level of CD control
      doesn't matter - it can be set to zero). Then look for a control
      called "Capture". Press SPACE on it (if it is applicable to your
      sound card) and move the "volume" up. On most sound cards this is
      enough, but on my Yamaha YMF754 I also had to move up the level
      of the "ADC Capture" and "Digital" controls (there are also ADC
      Capture 1 and Digital 1 but those are for SPDIF as far as I
      understand).
    </p>

    <p>
      Finally, let's test if recording from selected input works. In a
      separate window (I did it in X11) launch the arecord tool with
      the following parameters:
    </p>

    <pre>
    arecord -D hw:# -c1 -r8000 -f U8
    </pre>

    <p>
      where # is the number of your sound card (0, 1, ...) (if your
      sound card has more than one ADC and your device is connected to
      the 2nd, 3rd, ...  ADC you will have to use the extended form
      "-D hw:#,#" where second # selects the ADC device number on the
      sound card). The <b>-c1</b> parameter tells arecord to sample
      monophonic signal (left channel), the <b>-r8000</b> sets the
      sampling frequency to 8kHz and <b>-f U8</b> selects "unsigned
      byte" sampling format.
    </p>

    <p>
      You should see a lot of garbage symbols. If you move the
      "Capture" lever down to zero, arecord should type just one or
      two symbols (that is "silence").  Now try to raise "Capture" and
      to disconnect from ADC all unneeded signals (e.g. turn "CAPTUR"
      off, if possible, from all inputs except CD).  It still should
      show silence (because you don't press any buttons on IR control,
      aren't you?). Finally, press some buttons on IR control and you
      should clearly see how signal changes. If it doesn't (and you
      heard the signal in the previous experiment) you connected to
      the wrong (right) channel. If you used a BLS-04 connector (like
      me :-) you have to re-plug it after rotating by 180 degrees
      (since the center two pins are ground and L/R pins are on
      sides). Otherwise you will have to redo the connector (well, see
      yourself...).
    </p>

    <p>
      Okay, now if arecord shows correct results like described above,
      you're ready to use lirc (ugh... finally!).
    </p>

    <h2>Using the driver</h2>

    <p>
      The input device is by default "hw" (to see a list of available
      devices try "arecord -L"); this can be overridden with the
      --device command-line switch. For example, my IR module is
      connected to the second sound card, thus I run (for example)
      irrecord this way:
    </p>

    <pre>
    irrecord -d hw:1,0 file
    </pre>

    <p>
      You also can use ALSA library internal environment variables
      such as ALSA_PCM_CARD and ALSA_PCM_DEVICE to specify the values
      for card number and card device number.
    </p>

    <p>
      Also you can specify the sampling rate (in Hertz) by placing a
      '@' after device name and then the numeric sample rate. The
      default value is 8000, however, you can play with it:
    </p>

    <pre>
    irrecord -d hw@11025 file
    </pre>

    <p>
      The basic sampling frequencies (supported by most sound cards)
      are: 8000, 11050, 16000, 22050, 32000, 44100, 48000 Hertz. The
      higher the sampling frequency, the more accurate results
      (e.g. space/pulse lengths in microseconds) you will get, but
      with all remote controls I've tried 8000Hz is quite enough.
    </p>

    <p>
      However, when you create configuration files (e.g. with
      irrecord) I'd recommend you to set sampling rate as high as
      possible:
    </p>

    <pre>
    irrecord -d hw@48000 file
    </pre>

    <p>
      This could help create more accurate timings in the config file
      and then you can use this config with lower sampling rates.
    </p>

    <p>
      Some sound cards do not support capturing in mono which is the
      default for audio_alsa.  If you come across this you will receive
      a message stating an invalid argument when setting the capture format.
      You can get around this problem by telling audio_alsa to capture in
      stereo:

    </p>
<pre>
    irrecord -d hw@44100,l file
    </pre>

      or:

    <pre>
    irrecord -d hw@44100,r file
    </pre>

    <p>
     The l (left) or r (right) character instructs audio_alsa on which
     channel it should inspect when reading the samples from the IR receiver.

    </p>
<h2>Quirks</h2>

    <p>
      I have found that on my motherboard the built-in audio card has
      a bug that could influence other sound cards too. When xmms was
      playing something very loud and master volume was close to 100%
      I observed that lirc become "deaf" for some time. Investigations
      shown that there is a bug in audio card schematics that causes
      CD-IN pre-amplifier to shutdown because of not enough power when
      too much power goes to the master amplifier (well, this is just
      my suspicion). When I lowered master volume to 90%, everything
      started to work fine. In any case, playing at 100% volume was
      causing sound distortion (because master amplifier is also out
      of power and clips output signal, although it does not shutdown
      like pre-amplifier does) thus lowering master volume does only
      good.
    </p>

    <p>
      Another bug I've come across and you should be aware of is that
      some ALSA drivers (notably my driver for Yamaha YMF7[2,4,5]4)
      are buggy and sampled data sometimes contains noise (clicks)
      which influence badly recognition of proper command
      sequences. This happens for me, however, only at 11025 and
      22050Hz rates, so you may wish to test if you're not affected by
      recording a wav file with <b>arecord</b> and the listening to it
      - the clicks are <b>very</b> noticeable by ear. A sign of this
      situation may be that while you're keeping the button on remote
      control pressed, the <b>irw</b> tool will repeatedly drop the
      repeat count (2nd column) to 0 after 2-6 repeats.
    </p>
<p class="footer">
        [<A HREF="http://www.lirc.org/">LIRC homepage</A>]
      </p>
</body>
</html>