选择显示字体大小

vb.net中使用directsound9之简单播放

     关于vb6的爱好者.大家还是尽快放弃vb6吧,我从97年开始用,现在终于也到了.net了,中间的痛苦可想而知。尤其是服务器编程,.net会方便很多。客户端随着xp的推广跟windows update的升级,也快了,别到时候别没有准备。
  
    我的学习方法:
  
    看sdk的文档,了解诸多概念,然后看sdk c#的教程(已经习惯了)
  
    准备工作:
  
    vs2003(有2002的,但是不用那个版本)
  
    dxsdk 9.0c 2004 dec(记住,是for vs2k3的,曾经有过vs2k2的,而且很多地方不通用)
  
    win2k(这个久不用说了吧)
  
    主要步骤:
  
    1、首先要添加引用.否则直接imports没办法找到 microsoft.directx....
  
    2、引用完了,为了方便再imports microsoft.directx.directsound
  
    为了播放一个简单的声音文件进行如下操作:
  
    ·创建一个设备,关联到这个窗体
  
    ·创建一个缓冲,指定来源(这里用文件)
  
    ·播放...
  
  dim ad as device '创建设备
  dim buf as secondarybuffer '创建缓冲
  private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
   ad = new device '实力化设备对象
   ad.setcooperativelevel(me.handle, cooperativelevel.normal) '关联
   buf = new secondarybuffer("g:\media\wav\ff9start.wav", ad) '实力化缓冲区
   buf.play(0, bufferplayflags.looping) '播放,同时指定开始位置跟方式
  end sub
  
    这是一个最基本最简单的例子,目的是了解步骤。
  
    有趣的现象,由于ds关联的是窗体,当窗体失去焦点的时候,他会停止播放 一旦重新获得焦点会继续播放。
  
    很方便吧
  
    但是ds用的是缓冲区的,在切换的时候,会丢失声音,少了那么一点,sdk也提到过,但是我没有认真看(1 感觉问题不大(除非录音) 2 英文的,懒~)
  
    实际上没有必要解决丢失问题,因为对buf描述的时候就有这个选项。
  
    普通的(就是默认的,我用的这种)
  
    sticky 看原文吧:buffers with \"sticky\" focus will continue to play if the user switches to another application not using directsound. however, if the user switches to another directsound application, all normal-focus and sticky-focus buffers in the previous application are muted.";
  
    全局的:buffers with global focus will continue to play if the user switches focus to another application, even if the new application uses directsound. the one exception is if you switch focus to a directsound application that uses the dsscl_writeprimary cooperative level. in this case, the global-focus buffers from other applications will not be audible.";
  
    再就是 默认 硬件加速 软件加速 (用默认就好,有硬件就用硬件,否则模拟)
  
    以下是原文:
  
  if (mixhardware)
  {
   stext = stext + "\n\nwith the hardware mixing flag, the new buffer will be forced to use hardware mixing. if the device does not support hardware mixing or if the required hardware resources are not available, the call to the directsound.createsoundbuffer method will fail.";
  }
  else if (mixsoftware)
  {
   stext = stext + "\n\nwith the software mixing flag, the new buffer will use software mixing, even if hardware resources are available.";
  }
  else
  {
   // default mixing
   stext = stext + "\n\nwith default mixing, the new buffer will use hardware mixing if available, otherwise software mixing will be used.";
  }
   
    由于内容很简单,没有翻译的必要(主要是因为懒,自己能看懂稍微记录一下就算了)
  
    实际上directsound能作的工作很多,包括特效,3d音效跟混音以及声音抓取等。  


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons