关于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音效跟混音以及声音抓取等。
-
vb.net教程之VB.NET中使用Directsound9之简单播放
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。
栏目列表
最新更新
求1000阶乘的结果末尾有多少个0
详解MyBatis延迟加载是如何实现的
IDEA 控制台中文乱码4种解决方案
SpringBoot中版本兼容性处理的实现示例
Spring的IOC解决程序耦合的实现
详解Spring多数据源如何切换
Java报错:UnsupportedOperationException in Col
使用Spring Batch实现批处理任务的详细教程
java中怎么将多个音频文件拼接合成一个
SpringBoot整合ES多个精确值查询 terms功能实
数据库审计与智能监控:从日志分析到异
SQL Server 中的数据类型隐式转换问题
SQL Server中T-SQL 数据类型转换详解
sqlserver 数据类型转换小实验
SQL Server数据类型转换方法
SQL Server 2017无法连接到服务器的问题解决
SQLServer地址搜索性能优化
Sql Server查询性能优化之不可小觑的书签查
SQL Server数据库的高性能优化经验总结
SQL SERVER性能优化综述(很好的总结,不要错
uniapp/H5 获取手机桌面壁纸 (静态壁纸)
[前端] DNS解析与优化
为什么在js中需要添加addEventListener()?
JS模块化系统
js通过Object.defineProperty() 定义和控制对象
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比