VB.NET DirectX编程
最好用VS自带的在目录Windows下的"Microsoft.NET\DirectX\"COM组件或支持DirectDraw版本的...
最好用VS自带的在目录Windows下的 "Microsoft.NET\DirectX\" COM组件或支持DirectDraw版本的
展开
1个回答
2013-07-29
展开全部
蜂鸣器编程的话,有个API函数,VB中的声明为 Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long 调用方法是Beep 声音频率,持续时间(毫秒为单位) 比如 beep 2000,1000如果是声卡编程的话,也有相应的API函数,比如你可以用DirectSound(也就是DirectX的一部分),功能比较强大,也很专业。事实上,如果你使用的是专业级的声卡和音响设备,它可以在一定范围内回放出超出人耳听觉范围的声音。当然也可以用简单一点的API,以下是几个需要的函数:Private Declare Function midiOutGetDevCaps Lib "winmm.dll" Alias "midiOutGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As MIDIOUTCAPS, ByVal uSize As Long) As LongPrivate Declare Function midiOutGetNumDevs Lib "winmm" () As IntegerPrivate Declare Function MIDIOutOpen Lib "winmm.dll" Alias "midiOutOpen" (lphMidiOut As Long, ByVal uDeviceID As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As LongPrivate Declare Function midiOutClose Lib "winmm.dll" (ByVal hMidiOut As Long) As LongPrivate Declare Function midiOutShortMsg Lib "winmm.dll" (ByVal hMidiOut As Long, ByVal dwMsg As Long) As LongPrivate Declare Function midiOutGetErrorText Lib "winmm.dll" Alias "midiOutGetErrorTextA" (ByVal err As Long, ByVal lpText As String, ByVal uSize As Long) As LongPrivate Const MAXERRORLENGTH = 128 ' max error text length (including NULL)Private Const MIDIMAPPER = (-1)Private Const MIDI_MAPPER = (-1)'MIDIOUTCAPS结构描述了Musical Instrument Digital Interface(MIDI)输入设备的性能Type MIDIOUTCAPS wMid As Integer wPid As Integer ' 产品 ID vDriverVersion As Long ' 设备版本 szPname As String * 32 ' 设备 name wTechnology As Integer ' 设备类型 wVoices As Integer wNotes As Integer wChannelMask As Integer dwSupport As LongEnd TypePublic Sub note_on(ch As Integer, ByVal kk As Integer, v As Integer)' 发音主函数。参数分别为通道编号,音调,速度 Call midi_outshort(&H90 + ch, kk, v)End SubSub midi_outshort(b1 As Integer, b2 A
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询