当前时区为 UTC + 8 小时

发表新帖 回复这个主题  [ 2 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 翻译的lirc-audio,给cc
帖子发表于 : 2007-09-21 20:08 

注册: 2005-08-14 21:55
帖子: 58436
地址: 长沙
送出感谢: 4
接收感谢: 272
Using the ALSA audio IR receiver driver

This driver supports the IR-audio IR receiver module. A more detailed description of how to build and set up the hardware can be found by following the link.
How to use ALSA

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.

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 :).

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).
现在,把通道静音,使用空格键,选择成捕捉模式。在顶部,应该看到"CAPTUR"字样,表示当前通道连接到了模数转换器。(CD控制条的电压没关系,可以设置成零)。然后,找“capture”控制条。按空格键(假设你的声卡可以这样),加大音量。对于大多数声卡,这样就可以了。除开我的雅马哈声卡,我不得不调大"ADC Capture"和"Digital"控制条的电压。

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:
arecord -D hw:# -c1 -r8000 -f U8

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 -c1 parameter tells arecord to sample monophonic signal (left channel), the -r8000 sets the sampling frequency to 8kHz and -f U8 selects "unsigned byte" sampling format.
这里,#号表示你的声卡(0开始)(如果你的声卡有多个AD转换器,而你的接收器连接到了第二个,第三个AD转换器上,你还必须使用扩展参数,"-D hw:#,#"这样的写法,第二个#号表示这个声卡上的对应的ADC)。参数-cl告诉arecord只采样单声道(左边通道)。而-r8000是设置采样速率为8KHz。参数-f U8表示使用无符号8位字节的采样格式。
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...).
Okay, now if arecord shows correct results like described above, you're ready to use lirc (ugh... finally!).
Using the driver

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:
irrecord -d hw:1,0 file
输入设备缺省是"hw"(用"arecord -L"可以看可用设备列表);可以使用--device参数修改。比如,我的接收器是连接到第二个声卡,所以我这样作的:

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.
你也可以使用ALSA库的内部环境变量,比如 ALSA_PCM_CARD 和 ALSA_PCM_DEVICE 来指定声卡设备。
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:
irrecord -d hw@11025 file
同时,你可以指定采样速率,就是在设备名后面带上一个 @ 号,接着是采样速率。缺省值是8000。

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.

However, when you create configuration files (e.g. with irrecord) I'd recommend you to set sampling rate as high as possible:
irrecord -d hw@48000 file

This could help create more accurate timings in the config file and then you can use this config with lower sampling rates.
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.
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 arecord and the listening to it - the clicks are very noticeable by ear. A sign of this situation may be that while you're keeping the button on remote control pressed, the irw tool will repeatedly drop the repeat count (2nd column) to 0 after 2-6 repeats.

[LIRC homepage]
The LIRC Manual, last update: 17-Jan-2007

● 鸣学

2 楼 
 文章标题 :
帖子发表于 : 2007-09-21 20:12 

注册: 2005-08-14 21:55
帖子: 58436
地址: 长沙
送出感谢: 4
接收感谢: 272

ir-audio.png [ 2.4 KiB | 被浏览 763 次 ]

● 鸣学
显示帖子 :  排序  
发表新帖 回复这个主题  [ 2 篇帖子 ] 

当前时区为 UTC + 8 小时


正在浏览此版面的用户:没有注册用户 和 3 位游客

不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译