【VB开源代码栏目提醒】:本文主要为网学会员提供电子合成乐器.frm,希望对需要电子合成乐器.frm网友有所帮助,学习一下!
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "我的电子琴1.0"
ClientHeight = 3210
ClientLeft = 45
ClientTop = 330
ClientWidth = 7545
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3210
ScaleWidth = 7545
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton mix5
Caption = "5"
Height = 375
Left = 3960
TabIndex = 16
Top = 1800
Width = 375
End
Begin VB.CommandButton mix4
Caption = "4"
Height = 375
Left = 3960
TabIndex = 15
Top = 1200
Width = 375
End
Begin VB.CommandButton mix3
Caption = "3"
Height = 375
Left = 3960
TabIndex = 14
Top = 600
Width = 375
End
Begin VB.CommandButton mix2
Caption = "2"
Height = 375
Left = 3360
TabIndex = 13
Top = 1800
Width = 375
End
Begin VB.CommandButton mix1
Caption = "1"
Height = 375
Left = 3360
TabIndex = 12
Top = 1200
Width = 375
End
Begin VB.Frame Frame4
Caption = "Mix"
Height = 2175
Left = 3120
TabIndex = 10
Top = 240
Width = 1455
Begin VB.CommandButton mix0
Caption = "0"
Height = 375
Left = 240
TabIndex = 11
Top = 360
Width = 375
End
End
Begin VB.Frame Frame3
Caption = "Tempo"
Height = 615
Left = 240
TabIndex = 8
Top = 1800
Width = 2415
Begin VB.HScrollBar Tempo
Height = 255
Left = 120
Max = 350
Min = 10
SmallChange = 10
TabIndex = 9
Top = 240
Value = 120
Width = 2175
End
End
Begin VB.Frame Frame2
Caption = "Volume"
Height = 615
Left = 240
TabIndex = 6
Top = 1080
Width = 2415
Begin
VB.HScrollBar Volume
Height = 255
Left = 120
Max = 1200
Min = -3000
SmallChange = 50
TabIndex = 7
Top = 240
Width = 2175
End
End
Begin VB.CommandButton play
Caption = "开始"
Height = 375
Left = 1200
Style = 1 'Graphical
TabIndex = 5
Top = 480
Width = 495
End
Begin VB.CommandButton stop
Caption = "停止"
Height = 375
Left = 480
Style = 1 'Graphical
TabIndex = 4
Top = 480
Width = 495
End
Begin VB.CommandButton pause
Caption = "暂停"
Height = 375
Left = 1920
Style = 1 'Graphical
TabIndex = 3
Top = 480
Width = 495
End
Begin VB.Frame Frame1
Caption = "播放控制"
Height = 735
Left = 240
TabIndex = 2
Top = 240
Width = 2415
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 120
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton openmidi
Caption = "打开"
Height = 375
Left = 240
Style = 1 'Graphical
TabIndex = 0
Top = 2640
Width = 495
End
Begin VB.Label Label1
Caption = "Midi文件"
Height = 255
Left = 960
TabIndex = 1
Top = 2760
Width = 6495
End
Begin VB.Image Image1
Height = 1980
Left = 4800
Top = 480
Width = 2280
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim objDX As New DirectX7
Dim DMPerf As DirectMusicPerformance
Dim DMLoader As DirectMusicLoader
Dim DMSegment As DirectMusicSegment
Dim DMSegState As DirectMusicSegmentState
Dim DMixPerf(5) As DirectMusicPerformance
Dim DMixSegment(5) As DirectMusicSegment
Dim startmidi As Long
Dim startmusic As Long
Dim pausetime As Long
Dim midifile As String
Dim onoff(5) As Boolean
Dim j As Integer
Private Sub Form_Load()
Me.Show
Set DMLoader = objDX.DirectMusicLoaderCreate()
Set DMPerf = objDX.DirectMusicPerformanceCreate()
DMPerf.Init Nothing, 0
DMPerf.SetPort -1, 4
DMPerf.SetMasterVolume 1000
DMPerf.SetMasterAutoDownload True
For j = 0 To 5
Set DMixPerf(j) = objDX.DirectMusicPerformanceCreate()
DMixPerf(j).Init Nothing, 0
DMixPerf(j).SetPort -1, 4
DMixPerf(j).SetMasterVolume 100
DMixPerf(j).SetMasterAutoDownload True
Next j
For j = 0 To 5
Set DMixSegment(j) = DMLoader.LoadSegment("mix" & Str(j) & ".mid")
DMixSegment(j).SetStandardMidiFile
DMixSegment(j).SetRepeats -1
onoff(j) = False
Next j
pausetime = 0
startmidi = 0
startmusic = 0
midifile = ""
End Sub
Private Sub mix0_Click()
If onoff(0) = False Then
Set DMSegState = DMixPerf(0).PlaySegment(DMixSegment(0), 0, 0)
onoff(0) = True
mix0.Caption = "V"
Else
DMixPerf(0).stop DMixSegment(0), DMSegState, 0, 0
onoff(0) = False
mix0.Caption = "0"
End If
End Sub
Private Sub mix1_Click()
If onoff(1) = False Then
Set DMSegState = DMixPerf(1).PlaySegment(DMixSegment(1), 0, 0)
onoff(1) = True
mix1.Caption = "V"
Else
DMixPerf(1).stop DMixSegment(1), DMSegState, 0, 0
onoff(1) = False
mix1.Caption = "1"
End If
End Sub
Private Sub mix2_Click()
If onoff(2) = False Then
Set DMSegState = DMixPerf(2).PlaySegment(DMixSegment(2), 0, 0)
onoff(2) = True
mix2.Caption = "V"
Else
DMixPerf(2).stop DMixSegment(2), DMSegState, 0, 0
onoff(2) = False
mix2.Caption = "2"
End If
End Sub
Private Sub mix3_Click()
If onoff(3) = False Then
Set DMSegState = DMixPerf(3)