WinCE系统声音定制
作者:ARM-WinCE
2010的第一篇Blog,介绍一下WinCE系统声音的定制。说白了,就是设置注册表。WinCE系统启动的开机音乐,点击触摸屏以及键盘输入的按键音,还有系统运行过程中的各种声音其实都是在注册表里面预先设置好的。这里做个简单介绍:
整个WinCE系统声音注册表设置如下:
[HKEY_CURRENT_USER/ControlPanel/Volume]
"Key"=dword:10002
"Screen"=dword:10002
"Mute"=dword:7
"Volume"=dword:99999999
[HKEY_LOCAL_MACHINE/Snd/Scheme]
".DefaultSounds"=mui_sz:"cplmain.cpl,#33123"
".AllSounds"=mui_sz:"cplmain.cpl,#33124"
".NoSounds"=mui_sz:"cplmain.cpl,#33127"
[HKEY_LOCAL_MACHINE/Snd/Event]
".Scheme"=".DefaultSounds"
"EventMask"=dword:FFFFFF
"EventCache"=dword:300
; Schemedescriptions
".NoSounds"=multi_sz:"","","","","","","","","","","","","","","","","","","","",""
".DefaultSounds"=multi_sz:"Asterisk","","critical","default","","exclam",
"infbeg","infend","infintr","","","","question",
"Infbeg","Infend","Infintr","startup","","","",""
".AllSounds"=multi_sz:"Asterisk","Close","critical","default","Empty","exclam",
"infbeg","infend","infintr","MenuPop","MenuSel","OpenProg","question",
"Infbeg","Infend","Infintr","startup","WindMax","WindMin","RecStart","RecEnd"
这些是默认设置,下面分别介绍一下:
1. 音量设置
[HKEY_CURRENT_USER/ControlPanel/Volume]
"Key"=dword:10002
"Screen"=dword:10002
"Mute"=dword:7
"Volume"=dword:99999999
Volume:是设置默认的系统音量的,0为最小,也就是没声音了;0xFFFFFFFF为最大音量
Mute:用来设置Mute类型,0位表示Notifications,1位表示Apps,2位表示Events。默认情况为0x7,也就是全部打开,如果为0,则表示完全Mute。
Screen:表示点击触摸屏的声音音量,从0x1到0x10002表示从最小到最大。
Key:表示按键输入的声音音量,从0x1到0x10002表示从最小到最大。
上面的这些设置在WinCE系统启动后,可以在”Control Panel”->”Volume&Sounds”中看到。
2. 系统声音的策略
[HKEY_LOCAL_MACHINE/Snd/Scheme]
".DefaultSounds"=mui_sz:"cplmain.cpl,#33123"
".AllSounds"=mui_sz:"cplmain.cpl,#33124"
".NoSounds"=mui_sz:"cplmain.cpl,#33127"
这里包含了所有的声音策略,有默认使用的声音策略,打开所有声音的策略和关闭所有声音的策略。如果用户想包含并使用自己声音策略,要先在这里声明。
每一种声音策略都对应到cplmain.cpl中的数字,这个定义可以在/WINCE600/PUBLIC/WCESHELLFE/OAK/CTLPNL/CPLMAIN/cplres.h中找到,如下:
#defineIDS_LOC_DEFAULTSOUNDS (REBASE+0x163) 对应#33123
#defineIDS_LOC_ALLSOUNDS (REBASE+0x164) 对应#33124
#defineIDS_LOC_NOSOUNDS (REBASE+0x167) 对应#33127
同样如果用户想定义自己的声音策略,也可以在这里面添加定义。具体的不说了,下面还会提到。
3. 声音策略的定义
[HKEY_LOCAL_MACHINE/Snd/Event]
".Scheme"=".DefaultSounds"
"EventMask"=dword:FFFFFF
"EventCache"=dword:300
; Schemedescriptions
".NoSounds"=multi_sz:"","","","","","","","","","","","","","","","","","","","",""
".DefaultSounds"=multi_sz:"Asterisk","","critical","default","","exclam",
"infbeg","infend","infintr","","","","question",
"Infbeg","Infend","Infintr","startup","","","",""
".AllSounds"=multi_sz:"Asterisk","Close","critical","default","Empty","exclam",
"infbeg","infend","infintr","MenuPop","MenuSel","OpenProg","question",
"Infbeg","Infend","Infintr","startup","WindMax","WindMin","RecStart","RecEnd"
这里定义了使用哪个声音策略,以及事件的屏蔽,还有声音策略的定义。
.Scheme:定义系统使用的声音策略。
EventMask:定义是否隐藏某些声音的事件,总共21个事件,可以选择性的隐藏某个事件,默认情况下,所有的事件都会在控制面板中的声音设置中看到。这里本来想传一张图片,结果发现csdn博客的图片上传功能暂时关闭了。多说两句,在控制面板中,找到声音设置,然后切换到Sounds窗口,在Event下面就可以看到所有的声音事件了。
实际上这些声音事件的定义在/WINCE600/public/wceshellfe/oak/ctlpnl/cplmain/sndschem.cpp中的一个数组idsSoundEvents[NUM_SOUND_EVENTS]中。
EventCache:设置Cache的大小,用于记录弹出窗口及窗口的切换动作。
.NoSounds:具体声音策略的定义
.DefaultSounds:具体声音策略的定义
.AllSounds:具体声音策略的定义
默认情况下,只是定义了这三种声音策略,每一种策略定义了针对21个声音事件分别采用什么样的声音。这里用户也可以添加自己的声音定制策略。所有的声音文件都是.wav文件,存放在/WINCE600/public/wceshellfe/oak/files目录下面。在创建WinCE工程病编译之后,这些.wav文件会被拷贝到编译工程的release目录下面,并被打包到WinCE的image中去。
4. 定制开机音乐
了解了上面的注册表,改变开机音乐就很简单了,对于WinCE系统中有21个声音事件,其中startup事件就是指开机音乐(可以从前面的.AllSounds声音策略定中看到),这个事件对应的是startup.wav文件。
所以最简单的方法就是把你的开机音乐文件命名为startup.wav,然后替换你WinCE工程编译后release目录下面的startup.wav文件,最后重新Makeimg一下,就可以了。