当前时区为 UTC + 8 小时



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

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 272
Using the ALSA audio IR receiver driver
使用ALSA音频接收红外控制
Hardware

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.
ALSA提供了很多的混音控制,可能你会觉得不很清楚如何让它从指定的输入进行录音,其实,这是相当简单的事情。
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 :).
运行alsamixer软件(你可以使用-c参数和数字来选择想要的声卡)。现在,滚动界面,看到很多控制条,其中很多并不知道是什么功能。
假设你的红外音频模块是连接到CD-IN的接口,先来看下硬件是否正常工作。找到“CD”控制条,音量开大,按M键可以取消静音。把遥控器对着红外接收器试试,应该可以听到本本声,或者比比声,这依照你的遥控器类型,有不同的声音。如果你可以听到,说明你的红外接收器可以工作。(其实,想没声都难)。

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工具软件,带上如下参数:
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...).
你会看到很多的乱码。如果你向下调节"Capture"到零,arecord应该只输出一两个符号了(表示“无声”)。现在,调大"Capure",并且关断所有连接到ADC的无用的信号(比如,关闭除开CD的其他所有的"CAPTUR",如果可以的话)。仍然应该是无声的状态(因为你并没有按遥控器的按钮,不是吗)。最后,随便按些遥控器按钮,应该可以清晰的看到信号的改变。如果不是这样(你还是看到原来的信号),你那是接错了通道。如果你是像我一样,使用BLS-04这样的连接器,拔出来,转个180度(因为这2边的中间的2个脚是地信号和左右声道)。或者,你重做一个接头(随便你了)。
Okay, now if arecord shows correct results like described above, you're ready to use lirc (ugh... finally!).
Using the driver
好了,现在arecord显示正常,你可以使用lirc了。

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.
大多数声卡的基本采样频率是:。。。。。。。。。。。。。频率越高,结果越精确。只是我使用的所有遥控器,8000的都足够了。

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
当然,在你使用irrecord生成配置文件的时候,我建议你设置到最高的采样速率。

This could help create more accurate timings in the config file and then you can use this config with lower sampling rates.
Quirks
这样能生成更精确的配置文件。然后,使用在这配置文件下,跑低速率的采样。
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.
我已经发现,在我的主板的内建声卡有bug。并且还会影响到其他的声卡。当xmms大音量播放时,主声道音量几乎到了100%,我发现lirc会有时失灵。
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
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 272
没事作的家伙,都可以测试。那二极管不需要的。


附件:
ir-audio.png
ir-audio.png [ 2.4 KiB | 被浏览 765 次 ]


_________________
● 鸣学
页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 2 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

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


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

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

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