midi发声的程序怎么写??

boyok 2005-03-20 04:40:13
midi发声的程序怎么写???

最好给出代码。
...全文
84 点赞 收藏 3
写回复
3 条回复
boyok 2005年03月25日
我的意思是怎么用程序 发出 1 2 3 等声音,不是播放mid文件
回复 点赞
wgy081 2005年03月22日
楼上的 都 说的很清楚了,主要是用mcisendstring这个api函数来实现,不过这个函数来控制音量我还没搞定。
回复 点赞
Gujianda 2005年03月20日
将下面的内容存为play.frm 文件就行

VERSION 5.00
Begin VB.Form Form1
Caption = "播放多媒体文件"
ClientHeight = 3285
ClientLeft = 60
ClientTop = 345
ClientWidth = 4890
LinkTopic = "Form1"
ScaleHeight = 3285
ScaleWidth = 4890
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "播放"
Height = 495
Left = 240
TabIndex = 5
Top = 2640
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "停止播放"
Height = 495
Left = 2160
TabIndex = 4
Top = 2640
Width = 1455
End
Begin VB.FileListBox File1
Height = 1890
Left = 2160
Pattern = "*.wav;*.mid;*.avi"
TabIndex = 2
Top = 480
Width = 2535
End
Begin VB.DirListBox Dir1
Height = 1560
Left = 240
TabIndex = 1
Top = 960
Width = 1815
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 240
TabIndex = 0
Top = 480
Width = 1815
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "请选择.wav.mid.avi文件"
Height = 180
Left = 120
TabIndex = 3
Top = 120
Width = 2412
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long


Private Sub Command1_Click()
Dim PathName As String, S As String, ShortPathName As String

PathName = File1.Path
If Right(PathName, 1) <> "\" Then PathName = PathName & "\"
PathName = PathName & File1.FileName

S = String(LenB(PathName), Chr(0))
GetShortPathName PathName, S, Len(S)
ShortPathName = Left(S, InStr(S, Chr(0)) - 1)

mciSendString "close MyWav", vbNullString, 0, 0
mciSendString "open " & ShortPathName & " alias MyWav", vbNullString, 0, 0
mciSendString "play MyWav", vbNullString, 0, 0
End Sub

Private Sub Command2_Click()
mciSendString "close MyWav", vbNullString, 0, 0
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub Form_Unload(Cancel As Integer)
mciSendString "close MyWav", vbNullString, 0, 0
End Sub
回复 点赞
发动态
发帖子
VB基础类
创建于2007-09-28

2749

社区成员

19.7w+

社区内容

VB 基础类
社区公告
暂无公告