程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> 如何從SOUND.DRV中提取聲音

如何從SOUND.DRV中提取聲音

編輯:VB綜合教程
'-------------------------------------------------------------------
  'Author:GordonF.MacLeod
  'HowtoextractsoundsfromtheSOUND.DRVlibrary..
  'Hereare4differentsoundeffectsthatcancalled
  'viaAPI'stothe"SOUND.DRV"library.Youcanmodify
  'thevaluestocreateyourownuniquesounds.
  'DeclaretheseAPI's:
  
  DeclareFunctionOpenSoundLib"sound.drv"()
  DeclareFunctionVoiceQueueSizeLib"sound.drv"(ByValnVoice,ByValnByteS)
  DeclareFunctionSetVoiceSoundLib"sound.drv"(ByValnSource,ByValFreq&,
  ByValnDuration)
  DeclareFunctionStartSoundLib"sound.drv"()
  DeclareFunctionCloseSoundLib"sound.drv"()
  DeclareFunctionWaitSoundStateLib"sound.drv"(ByValState)
  
  'Addthisroutine,tobeusedwithSirenSound1routine
  
  SubSound(ByValFreqAsLong,ByValDurationAsInteger)
  DimSAsInteger
  'Shiftfrequencytohighbyte.
  Freq=Freq*2^16
  S=SetVoiceSound(1,Freq,Duration)
  S=StartSound()
  While(WaitSoundState(1)<>0):Wend
  EndSub
  
  
  'Herearethe4soundroutines:
  
  '*AttentionSound#1*
  SubAttenSound1()
  DimSucc,SAsInteger
  Succ=OpenSound()
  S=SetVoiceSound(1,1500*2^16,50)
  S=SetVoiceSound(1,1000*2^16,50)
  S=SetVoiceSound(1,1500*2^16,100)
  S=SetVoiceSound(1,1000*2^16,100)
  S=SetVoiceSound(1,800*2^16,40)
  
  S=StartSound()
  While(WaitSoundState(1)<>0):Wend
  Succ=CloseSound()
  
  EndSub
  
  '*ClickSound#1*
  SubClickSound1()
  DimSucc,SAsInteger
  Succ=OpenSound()
  S=SetVoiceSound(1,200*2^16,2)
  S=StartSound()
  While(WaitSoundState(1)<>0):Wend
  Succ=CloseSound()
  
  EndSub
  
  '*ErrorSound#1*
  SubErrorSound1()
  DimSucc,SAsInteger
  Succ=OpenSound()
  S=SetVoiceSound(1,200*2^16,150)
  S=SetVoiceSound(1,100*2^16,100)
  S=SetVoiceSound(1,80*2^16,90)
  S=StartSound()
  While(WaitSoundState(1)<>0):Wend
  Succ=CloseSound()
  EndSub
  
  '*SirenSound#1*
  SubSirenSound1()
  DimSuccAsInteger
  DimJAsLong
  Succ=OpenSound()
  ForJ=440To1000Step5
  CallSound(J,J/100)
  NextJ
  ForJ=1000To440Step-5
  CallSound(J,J/100)
  NextJ
  Succ=CloseSound()
  
  EndSub->

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved