人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

VB.NET中運用Directsound9之容易播放

VB.NET中運用Directsound9之容易播放

更新時間:2022-09-10 文章作者:未知 信息來源:網絡 閱讀次數:

關于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音效跟混音以及聲音抓取等。

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 阿巴嘎旗| 嘉黎县| 蒙自县| 玉溪市| 铜鼓县| 札达县| 秦皇岛市| 贡觉县| 衡阳市| 平南县| 高唐县| 高要市| 馆陶县| 乌恰县| 永胜县| 育儿| 十堰市| 鞍山市| 普兰县| 肇州县| 大荔县| 苗栗市| 绥芬河市| 黄平县| 台东县| 张北县| 鹤峰县| 苍溪县| 清新县| 江陵县| 句容市| 长汀县| 沅江市| 米易县| 宁明县| 忻州市| 八宿县| 汕头市| 东乡族自治县| 西丰县| 高唐县|