织梦CMS - 轻松建站从此开始!

罗索

CWaveBox - WAI wrapper for playing PCM multiwaves, useful in

罗索客 发布于 2006-11-09 22:12 点击:次 
PBy zenith__. /P P 点击浏览该文件 点击浏览该文件 BRBRMultiwave player (Waveform Audio Interface PCM wave wrapper)./P PIntroductionBRHave you ever desired to play Waves in your Windows application or game without being lost with SDK / MFC anomalies wh
TAG:

<P>By zenith__. </P>
<P> 点击浏览该文件 点击浏览该文件<BR><BR>Multiwave player ('Waveform Audio Interface' PCM wave wrapper).</P>
<P>Introduction<BR>Have you ever desired to play Waves in your Windows application or game without being lost with SDK / MFC anomalies which give you only a part of something, which is in fact useless if you're going to do some serious work? Here, I'll collect all needed parts and upgrade it to the higher level so you can think about more serious work with sound.</P>
<P>The CWaveBox class relies on the SDK 'Waveform Audio Interface' API to play / produce (PCM uncompressed) multiwaves at once. Mixing and timing of multiple waves is required in games for adding interactive special/dimensional sound effects into. This class enables you possibility for that through the Windows WAI driver, by wrapping it with only one worker thread for multiwave support. I've seen a lots of examples about this topic concentrated about queuing / streaming WAI with two or more Wave data blocks continuously to avoid gap when switching, but few or just one of them only has properly freed / closed WAI interface which prevents unstoppable waste of memory if not anything else. Memory waste / leak of that (or any other) type is unknown with CWaveBox. Playing performance is enhanced by caching Wave and playing from RAM, so, this class isn't for 'classic players' from file, which costs additional time for 'on the play' caching when CPU time is not critical. If you want to, feel free and recode it for such a thing, I won't be mad ;-). This class if fully portable to Windows CE, so you can play within at Pocket PC also.</P>
<P>Background<BR>Whole idea for coding this class came from 'need for a sound' better than that from 'PlaySound', 'sndPlaySound' or any other partial solution. This class is already implemented in one board game, with great AI, for Pocket PC (which my friend Vrx and I have coded). Special thanks to people who have been translating the game tutorial into eight world languages, and some of them have 'stuck into translation' ;-). Here is a great tutorial at this topic: Using the Windows waveOut Interface.</P>
<P>Special thanks to the guy who wrote and coded the tutorial and WinAmp waveOut plug-in. I hope he wouldn't criticize me, because I have borrowed a few functions (allocateBlocks, freeBlocks and waveOutProc) from his tutorial / code and some of the variables notation. I'm a lazy ass. ;-).</P>
<P>All Waves mixed in the demo are downloaded from here.</P>
<P>Code, brief overview:<BR>The CWaveBox class is structured with the WAVE model which is used for storing wave data, size, wfx (format info) loaded by the Load method and Wave message WMSG set by Play method, to provide INTERFACE model with all required information and serves PlayThread as sub interface to the WAI driver in order to successfully establish the WAI instance and play for every Wave.</P>
<P>Points of Interest<BR>This class can be extended by UnLoad method, so any Wave can be Loaded and UnLoaded any time. Also, playing from file 'on the fly' which has lower memory usage, but has bigger CPU usage, wouldn't be a bad extension. Then, events can replace the current pooling model and extend Play for compressed Waves too. I will like to see this class attached to the MPEG3 'licence free' and 'commercially usable without fee' decoder on this zone so we can freely implement it in our games and applications.</P>
<P>zenith__<BR><a href="http://www.codeproject.com/audio/CWaveBox.asp"; target="_blank" >http://www.codeproject.com/audio/CWaveBox.asp<;/A></P> (iwgh)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/200611/6328.html]
本文出处: 作者:iwgh
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容