首页 > 其他分享 >VB版本MIDI钢琴简谱播放器全代码QZQ-2024-8-30

VB版本MIDI钢琴简谱播放器全代码QZQ-2024-8-30

时间:2024-08-30 09:50:15浏览次数:12  
标签:Case note VB off Sta MIDI AddItem 2024 Call

Private Declare Function GetKeyState% Lib “user32” (ByVal nVirtKey As Long)
Private Declare Sub Sleep Lib “kernel32” (ByVal dwMilliseconds As Long)
Private sudu As Integer
Private Const VK_LBUTTON& = &H1
Private isOgain As Boolean '是否重复按键
Private Sta As Integer

Private Declare Function midiOutGetDevCaps Lib “winmm.dll” Alias “midiOutGetDevCapsA” (ByVal uDeviceID As Long, lpCaps As MIDIOUTCAPS, ByVal uSize As Long) As Long
Private Declare Function midiOutGetNumDevs Lib “winmm” () As Integer
Private 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 Long
Private Declare Function midiOutClose Lib “winmm.dll” (ByVal hMidiOut As Long) As Long
Private Declare Function midiOutShortMsg Lib “winmm.dll” (ByVal hMidiOut As Long, ByVal dwMsg As Long) As Long
Private Declare Function midiOutGetErrorText Lib “winmm.dll” Alias “midiOutGetErrorTextA” (ByVal err As Long, ByVal lpText As String, ByVal uSize As Long) As Long

Private Const MAXERRORLENGTH = 128 ’ max error text length (including NULL)

Private Const MIDIMAPPER = (-1)
Private Const MIDI_MAPPER = (-1)
'MIDIOUTCAPS结构描述了Musical Instrument Digital Interface(MIDI)输入设备的性能
Private 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 Long
End Type

Dim hMidi As Long
Dim s As String

Private Function Midi_OutDevsToList(Obj As Control) As Boolean
Dim i As Integer
Dim midicaps As MIDIOUTCAPS
Dim isAdd As Boolean

Obj.Clear
isAdd = False
If midiOutGetDevCaps(MIDIMAPPER, midicaps, Len(midicaps)) = 0 Then    '若获取设备信息成功
      Obj.AddItem midicaps.szPname       '添加设备名称
      Obj.ItemData(Obj.NewIndex) = MIDIMAPPER   '这是默认设备ID  = -1
      isAdd = True
End If
    '添加其他设备
For i = 0 To midiOutGetNumDevs() - 1
    If midiOutGetDevCaps(i, midicaps, Len(midicaps)) = 0 Then
      Obj.AddItem midicaps.szPname
      Obj.ItemData(Obj.NewIndex) = i
      isAdd = True
    End If
Next
Midi_OutDevsToList = isAdd

End Function
Private Function midi_OutOpen(ByVal dev_id As Integer) As Integer
Dim midi_error As Integer

midi_error = MIDIOutOpen(hMidi, dev_id, 0, 0, 0)

midi_OutOpen = (hMidi <> 0)

End Function

Private Sub note_on(ch As Integer, ByVal kk As Integer, v As Integer)
Call midi_outshort(&H90 + ch, kk, v)
End Sub

Private Sub note_off(ch As Integer, ByVal kk As Integer)
Call midi_outshort(&H80 + ch, kk, 0)
End Sub

Private Sub midi_OutClose()
Dim midi_error As Integer

    midi_error = midiOutClose(hMidi)
    
    hMidi = 0

End Sub

Sub program_change(ch As Integer, cc0nr As Integer, ByVal pnr As Integer)
Call midi_outshort(&HC0 + ch, pnr, 0)
End Sub

Sub midi_outshort(b1 As Integer, b2 As Integer, b3 As Integer)
Dim midi_error As Integer

midi_error = midiOutShortMsg(hMidi, b3 * &H10000 + b2 * &H100 + b1)

End Sub

Private Sub Combo1_Click()
Dim dl As Integer
dl = midi_OutOpen(Combo1.ItemData(Combo1.ListIndex))
Combo1.ListIndex = 0
End Sub

Private Sub Combo2_Click()
Call program_change(0, 0, Combo2.ListIndex)
End Sub

Private Sub Combo3_Click()
Call program_change(0, 0, Combo3.ListIndex)
End Sub

Private Sub Command1_Click()

 Dim selectedDeviceID As Integer
'假设你从某个地方获取了设备 ID,这里只是示例,实际情况可能需要根据你的程序逻辑进行修改。
selectedDeviceID = Combo1.ItemData(Combo1.ListIndex)
Call midi_OutOpen(selectedDeviceID)

End Sub

Private Sub Command2_Click()
Call midi_OutClose
End Sub

Private Sub Command3_Click()

   Dim s1 As String
   Dim s2 As String
   Dim i As Integer
   Dim midiNote1 As Integer
   Dim midiNote2 As Integer


   Dim note1 As String
   Dim note2 As String

Dim k As Integer

 k = Int(Text3.Text)





s1 = Text1.Text
s2 = Text2.Text '假设第二个文本框的名称为 Text2

For i = 1 To Len(s1) Or Len(s2) '取两个字符串长度中的较大值作为循环次数
If i <= Len(s1) Then
note1 = Mid(s1, i, 1)
Else
note1 = “” '如果第一个字符串结束了,设置为空字符串
End If

       If i <= Len(s2) Then
           note2 = Mid(s2, i, 1)
       Else
           note2 = "" '如果第二个字符串结束了,设置为空字符串
       End If
       
       Select Case note1
          Case "-"
        midiNote1 = 0
 
     Case "1...."
        midiNote1 = 1
     Case "2...."
        midiNote1 = 2
     Case "3...."
        midiNote1 = 3
     Case "4...."
        midiNote1 = 4
     Case "5...."
        midiNote1 = 5
     Case "6...."
        midiNote1 = 6
     Case "7...."
        midiNote1 = 7
     Case "1..."
        midiNote1 = 8
     Case "2..."
        midiNote1 = 9
     Case "3..."
        midiNote1 = 10
     Case "4..."
        midiNote1 = 11

     Case "5..."
        midiNote1 = 12


     Case "6..."
        midiNote1 = 13

     Case "7..."
        midiNote1 = 14

    Case "1.."
        midiNote1 = 15


     Case "2.."
        midiNote1 = 16

     Case "3.."
        midiNote1 = 17

    Case "4.."
        midiNote1 = 18


     Case "5.."
        midiNote1 = 19

     Case "6.."
        midiNote1 = 20

 Case "7.."
        midiNote1 = 21


    Case "1."
        midiNote1 = 22


     Case "2."
        midiNote1 = 23

     Case "3."
        midiNote1 = 24

    Case "4."
        midiNote1 = 25


     Case "5."
        midiNote1 = 26

     Case "6."
        midiNote1 = 27

 Case "7."
        midiNote1 = 28




    Case "1"
        midiNote1 = 29


     Case "2"
        midiNote1 = 30

     Case "3"
        midiNote1 = 31

    Case "4"
        midiNote1 = 32


     Case "5"
        midiNote1 = 33

     Case "6"
        midiNote1 = 34

 Case "7"
        midiNote1 = 35




    Case "1'"
        midiNote1 = 36


     Case "2'"
        midiNote1 = 37

     Case "3'"
        midiNote1 = 38

    Case "4'"
        midiNote1 = 39


     Case "5'"
        midiNote1 = 40

     Case "6'"
        midiNote1 = 41

 Case "7'"
        midiNote1 = 42




    Case "1''"
        midiNote1 = 43


     Case "2''"
        midiNote1 = 44

     Case "3''"
        midiNote1 = 45

    Case "4''"
        midiNote1 = 46


     Case "5''"
        midiNote1 = 47

     Case "6''"
        midiNote1 = 48

 Case "7''"
        midiNote1 = 49


    Case "1'''"
        midiNote1 = 50


     Case "2'''"
        midiNote1 = 51

     Case "3'''"
        midiNote1 = 52

    Case "4'''"
        midiNote1 = 53


     Case "5'''"
        midiNote1 = 54

     Case "6'''"
        midiNote1 = 55

 Case "7'''"
        midiNote1 = 56


    Case "1''''"
        midiNote1 = 57


     Case "2''''"
        midiNote1 = 58

     Case "3''''"
        midiNote1 = 59

    Case "4''''"
        midiNote1 = 60


     Case "5''''"
        midiNote1 = 61

     Case "6''''"
        midiNote1 = 62

 Case "7''''"
        midiNote1 = 63
           Case Else
               midiNote1 = 0
       End Select
       
       Select Case note2
            Case "-"
        midiNote2 = 0
     Case "1...."
        midiNote2 = 1
     Case "2...."
        midiNote2 = 2
     Case "3...."
        midiNote2 = 3
     Case "4...."
        midiNote2 = 4
     Case "5...."
        midiNote2 = 5
     Case "6...."
        midiNote2 = 6
     Case "7...."
        midiNote2 = 7
     Case "1..."
        midiNote2 = 8
     Case "2..."
        midiNote2 = 9
     Case "3..."
        midiNote2 = 10
     Case "4..."
        midiNote2 = 11

     Case "5..."
        midiNote2 = 12


     Case "6..."
        midiNote2 = 13

     Case "7..."
        midiNote2 = 14

    Case "1.."
        midiNote2 = 15


     Case "2.."
        midiNote2 = 16

     Case "3.."
        midiNote2 = 17

    Case "4.."
        midiNote2 = 18


     Case "5.."
        midiNote2 = 19

     Case "6.."
        midiNote2 = 20

 Case "7.."
        midiNote2 = 21


    Case "1."
        midiNote2 = 22


     Case "2."
        midiNote2 = 23

     Case "3."
        midiNote2 = 24

    Case "4."
        midiNote2 = 25


     Case "5."
        midiNote2 = 26

     Case "6."
        midiNote2 = 27

 Case "7."
        midiNote2 = 28




    Case "1"
        midiNote2 = 29


     Case "2"
        midiNote2 = 30

     Case "3"
        midiNote2 = 31

    Case "4"
        midiNote2 = 32


     Case "5"
        midiNote2 = 33

     Case "6"
        midiNote2 = 34

 Case "7"
        midiNote2 = 35




    Case "1'"
        midiNote2 = 36


     Case "2'"
        midiNote2 = 37

     Case "3'"
        midiNote2 = 38

    Case "4'"
        midiNote2 = 39


     Case "5'"
        midiNote2 = 40

     Case "6'"
        midiNote2 = 41

 Case "7'"
        midiNote2 = 42




    Case "1''"
        midiNote2 = 43


     Case "2''"
        midiNote2 = 44

     Case "3''"
        midiNote2 = 45

    Case "4''"
        midiNote2 = 46


     Case "5''"
        midiNote2 = 47

     Case "6''"
        midiNote2 = 48

 Case "7''"
        midiNote2 = 49


    Case "1'''"
        midiNote2 = 50


     Case "2'''"
        midiNote2 = 51

     Case "3'''"
        midiNote2 = 52

    Case "4'''"
        midiNote2 = 53


     Case "5'''"
        midiNote2 = 54

     Case "6'''"
        midiNote2 = 55

 Case "7'''"
        midiNote2 = 56


    Case "1''''"
        midiNote2 = 57


     Case "2''''"
        midiNote2 = 58

     Case "3''''"
        midiNote2 = 59

    Case "4''''"
        midiNote2 = 60


     Case "5''''"
        midiNote2 = 61

     Case "6''''"
        midiNote2 = 62

 Case "7''''"
        midiNote2 = 63



        Case Else
               midiNote2 = 0
       End Select
       
      
      
      
   If midiNote1 > 0 Then
           Call note_on(0, midiNote1 + Sta, sudu) '使用 note_on 过程播放音符
           '设置第一个音符的音色
          
            Call program_change(0, 0, Combo2.ListIndex)
           
           
       Else
           Call note_off(0, 0) '如果没有音符,停止播放
       End If
       
       If midiNote2 > 0 Then
           Call note_on(0, midiNote2 + Sta, sudu) '使用 note_on 过程播放音符
           '设置第二个音符的音色
         
            Call program_change(0, 0, Combo3.ListIndex)
           
       Else
           Call note_off(0, 0) '如果没有音符,停止播放
       End If
       
      Sleep 200
   Next

End Sub

Private Sub Form_Load()
Dim Retu As Boolean
Dim i As Integer

Retu = Midi_OutDevsToList(Combo1)
Combo1.ListIndex = 0
Call fill_sound_list

Call fill_sound_list1

For i = 0 To 64
   Picture1(i).DragMode = 1
Next
HScroll1.Value = 36
HScroll2.Value = 100

End Sub

Private Sub fill_sound_list()

    Combo2.AddItem "大钢琴(声学钢琴)0"
    Combo2.AddItem "明亮的钢琴1"
    Combo2.AddItem "电钢琴2"
    Combo2.AddItem "酒吧钢琴3"
    Combo2.AddItem "柔和的电钢琴4"
    Combo2.AddItem "加合唱效果的电钢琴5"
    Combo2.AddItem "羽管键琴(拨弦古钢琴)6"
    Combo2.AddItem "科拉维科特琴(击弦古钢琴)7"
    Combo2.AddItem "钢片琴8"
    Combo2.AddItem "钟琴9"
    Combo2.AddItem "八音盒10"
    Combo2.AddItem "颤音琴11"
    Combo2.AddItem "马林巴12"
    Combo2.AddItem "木琴13"
    Combo2.AddItem "管钟14"
    Combo2.AddItem "大扬琴15"
    Combo2.AddItem "击杆风琴16"
    Combo2.AddItem "打击式风琴17"
    Combo2.AddItem "摇滚风琴18"
    Combo2.AddItem "教堂风琴19"
    Combo2.AddItem "簧管风琴20"
    Combo2.AddItem "手风琴21"
    Combo2.AddItem "口琴22"
    Combo2.AddItem "探戈手风琴23"
    Combo2.AddItem "尼龙弦吉他24"
    Combo2.AddItem "钢弦吉他25"
    Combo2.AddItem "爵士电吉他26"
    Combo2.AddItem "清音电吉他27"
    Combo2.AddItem "闷音电吉他28"
    Combo2.AddItem "加驱动效果的电吉他29"
    Combo2.AddItem "加失真效果的电吉他30"
    Combo2.AddItem "吉他和音31"
    Combo2.AddItem "大贝司(声学贝司)32"
    Combo2.AddItem "电贝司(指弹)33"
    Combo2.AddItem "电贝司(拨片)34"
    Combo2.AddItem "无品贝司35"
    Combo2.AddItem "掌击贝司136"
    Combo2.AddItem "掌击贝司237"
    Combo2.AddItem "电子合成贝司138"
    Combo2.AddItem "电子合成贝司239"
    Combo2.AddItem "小提琴40"
    Combo2.AddItem "中提琴41"
    Combo2.AddItem "大提琴42"
    Combo2.AddItem "低音大提琴43"
    Combo2.AddItem "弦乐群颤音音色44"
    Combo2.AddItem "弦乐群拨弦音色45"
    Combo2.AddItem "竖琴46"
    Combo2.AddItem "定音鼓47"
    Combo2.AddItem "弦乐合奏音色148"
    Combo2.AddItem "弦乐合奏音色249"
    Combo2.AddItem "合成弦乐合奏音色150"
    Combo2.AddItem "合成弦乐合奏音色251"
    Combo2.AddItem "人声合唱啊52"
    Combo2.AddItem "人声嘟53"
    Combo2.AddItem "合成人声54"
    Combo2.AddItem "管弦乐敲击齐奏55"
    Combo2.AddItem "小号56"
    Combo2.AddItem "长号57"
    Combo2.AddItem "大号58"
    Combo2.AddItem "加弱音器小号59"
    Combo2.AddItem "法国号(圆号)60"
    Combo2.AddItem "铜管组(铜管乐器合奏音色)61"
    Combo2.AddItem "合成铜管音色162"
    Combo2.AddItem "合成铜管音色263"
    Combo2.AddItem "高音萨克斯风64"
    Combo2.AddItem "次中音萨克斯风65"
    Combo2.AddItem "中音萨克斯风66"
    Combo2.AddItem "低音萨克斯风67"
    Combo2.AddItem "双簧管68"
    Combo2.AddItem "英国管69"
    Combo2.AddItem "巴松(大管)70"
    Combo2.AddItem "单簧管(黑管)71"
    Combo2.AddItem "短笛72"
    Combo2.AddItem "长笛73"
    Combo2.AddItem "竖笛74"
    Combo2.AddItem "排箫75"
    Combo2.AddItem "吹瓶声76"
    Combo2.AddItem "日本尺八77"
    Combo2.AddItem "口哨声78"
    Combo2.AddItem "奥卡雷那79"
    Combo2.AddItem "合成主音1(方波)80"
    Combo2.AddItem "合成主音2(锯齿波)81"
    Combo2.AddItem "合成主音382"
    Combo2.AddItem "合成主音483"
    Combo2.AddItem "合成主音584"
    Combo2.AddItem "合成主音6(人声)85"
    Combo2.AddItem "合成主音7(平行五度)86"
    Combo2.AddItem "合成主音8(贝司加主音)87"
    Combo2.AddItem "合成音色1(新世纪)88"
    Combo2.AddItem "合成音色2(温暖)89"
    Combo2.AddItem "合成音色390"
    Combo2.AddItem "合成音色4(合唱)91"
    Combo2.AddItem "合成音色592"
    Combo2.AddItem "合成音色6(金属声)93"
    Combo2.AddItem "合成音色7(光环)94"
    Combo2.AddItem "合成音色895"
    Combo2.AddItem "合成效果1雨声96"
    Combo2.AddItem "合成效果2音轨97"
    Combo2.AddItem "合成效果3水晶98"
    Combo2.AddItem "合成效果4大气99"
    Combo2.AddItem "合成效果5明亮100"
    Combo2.AddItem "合成效果6鬼怪101"
    Combo2.AddItem "合成效果7回声102"
    Combo2.AddItem "合成效果8科幻103"
    Combo2.AddItem "西塔尔(印度)104"
    Combo2.AddItem "班卓琴(美洲)105"
    Combo2.AddItem "三昧线(日本)106"
    Combo2.AddItem "十三弦筝(日本)107"
    Combo2.AddItem "卡林巴108"
    Combo2.AddItem "风笛109"
    Combo2.AddItem "民族提琴110"
    Combo2.AddItem "唢呐111"
    Combo2.AddItem "叮当铃112"
    Combo2.AddItem "阿哥哥鼓113"
    Combo2.AddItem "钢鼓114"
    Combo2.AddItem "木鱼115"
    Combo2.AddItem "太鼓116"
    Combo2.AddItem "古高音鼓117"
    Combo2.AddItem "合成鼓118"
    Combo2.AddItem "铜钹119"
    Combo2.AddItem "磨弦120"
    Combo2.AddItem "呼吸声121"
    Combo2.AddItem "海浪声122"
    Combo2.AddItem "鸟鸣123"
    Combo2.AddItem "电话铃124"
    Combo2.AddItem "直升机125"
    Combo2.AddItem "鼓掌声126"
    Combo2.AddItem "枪声127"

Combo2.ListIndex = 0

End Sub

Private Sub fill_sound_list1()
Combo3.AddItem “大钢琴(声学钢琴)0”
Combo3.AddItem “明亮的钢琴1”
Combo3.AddItem “电钢琴2”
Combo3.AddItem “酒吧钢琴3”
Combo3.AddItem “柔和的电钢琴4”
Combo3.AddItem “加合唱效果的电钢琴5”
Combo3.AddItem “羽管键琴(拨弦古钢琴)6”
Combo3.AddItem “科拉维科特琴(击弦古钢琴)7”
Combo3.AddItem “钢片琴8”
Combo3.AddItem “钟琴9”
Combo3.AddItem “八音盒10”
Combo3.AddItem “颤音琴11”
Combo3.AddItem “马林巴12”
Combo3.AddItem “木琴13”
Combo3.AddItem “管钟14”
Combo3.AddItem “大扬琴15”
Combo3.AddItem “击杆风琴16”
Combo3.AddItem “打击式风琴17”
Combo3.AddItem “摇滚风琴18”
Combo3.AddItem “教堂风琴19”
Combo3.AddItem “簧管风琴20”
Combo3.AddItem “手风琴21”
Combo3.AddItem “口琴22”
Combo3.AddItem “探戈手风琴23”
Combo3.AddItem “尼龙弦吉他24”
Combo3.AddItem “钢弦吉他25”
Combo3.AddItem “爵士电吉他26”
Combo3.AddItem “清音电吉他27”
Combo3.AddItem “闷音电吉他28”
Combo3.AddItem “加驱动效果的电吉他29”
Combo3.AddItem “加失真效果的电吉他30”
Combo3.AddItem “吉他和音31”
Combo3.AddItem “大贝司(声学贝司)32”
Combo3.AddItem “电贝司(指弹)33”
Combo3.AddItem “电贝司(拨片)34”
Combo3.AddItem “无品贝司35”
Combo3.AddItem “掌击贝司136”
Combo3.AddItem “掌击贝司237”
Combo3.AddItem “电子合成贝司138”
Combo3.AddItem “电子合成贝司239”
Combo3.AddItem “小提琴40”
Combo3.AddItem “中提琴41”
Combo3.AddItem “大提琴42”
Combo3.AddItem “低音大提琴43”
Combo3.AddItem “弦乐群颤音音色44”
Combo3.AddItem “弦乐群拨弦音色45”
Combo3.AddItem “竖琴46”
Combo3.AddItem “定音鼓47”
Combo3.AddItem “弦乐合奏音色148”
Combo3.AddItem “弦乐合奏音色249”
Combo3.AddItem “合成弦乐合奏音色150”
Combo3.AddItem “合成弦乐合奏音色251”
Combo3.AddItem “人声合唱啊52”
Combo3.AddItem “人声嘟53”
Combo3.AddItem “合成人声54”
Combo3.AddItem “管弦乐敲击齐奏55”
Combo3.AddItem “小号56”
Combo3.AddItem “长号57”
Combo3.AddItem “大号58”
Combo3.AddItem “加弱音器小号59”
Combo3.AddItem “法国号(圆号)60”
Combo3.AddItem “铜管组(铜管乐器合奏音色)61”
Combo3.AddItem “合成铜管音色162”
Combo3.AddItem “合成铜管音色263”
Combo3.AddItem “高音萨克斯风64”
Combo3.AddItem “次中音萨克斯风65”
Combo3.AddItem “中音萨克斯风66”
Combo3.AddItem “低音萨克斯风67”
Combo3.AddItem “双簧管68”
Combo3.AddItem “英国管69”
Combo3.AddItem “巴松(大管)70”
Combo3.AddItem “单簧管(黑管)71”
Combo3.AddItem “短笛72”
Combo3.AddItem “长笛73”
Combo3.AddItem “竖笛74”
Combo3.AddItem “排箫75”
Combo3.AddItem “吹瓶声76”
Combo3.AddItem “日本尺八77”
Combo3.AddItem “口哨声78”
Combo3.AddItem “奥卡雷那79”
Combo3.AddItem “合成主音1(方波)80”
Combo3.AddItem “合成主音2(锯齿波)81”
Combo3.AddItem “合成主音382”
Combo3.AddItem “合成主音483”
Combo3.AddItem “合成主音584”
Combo3.AddItem “合成主音6(人声)85”
Combo3.AddItem “合成主音7(平行五度)86”
Combo3.AddItem “合成主音8(贝司加主音)87”
Combo3.AddItem “合成音色1(新世纪)88”
Combo3.AddItem “合成音色2(温暖)89”
Combo3.AddItem “合成音色390”
Combo3.AddItem “合成音色4(合唱)91”
Combo3.AddItem “合成音色592”
Combo3.AddItem “合成音色6(金属声)93”
Combo3.AddItem “合成音色7(光环)94”
Combo3.AddItem “合成音色895”
Combo3.AddItem “合成效果1雨声96”
Combo3.AddItem “合成效果2音轨97”
Combo3.AddItem “合成效果3水晶98”
Combo3.AddItem “合成效果4大气99”
Combo3.AddItem “合成效果5明亮100”
Combo3.AddItem “合成效果6鬼怪101”
Combo3.AddItem “合成效果7回声102”
Combo3.AddItem “合成效果8科幻103”
Combo3.AddItem “西塔尔(印度)104”
Combo3.AddItem “班卓琴(美洲)105”
Combo3.AddItem “三昧线(日本)106”
Combo3.AddItem “十三弦筝(日本)107”
Combo3.AddItem “卡林巴108”
Combo3.AddItem “风笛109”
Combo3.AddItem “民族提琴110”
Combo3.AddItem “唢呐111”
Combo3.AddItem “叮当铃112”
Combo3.AddItem “阿哥哥鼓113”
Combo3.AddItem “钢鼓114”
Combo3.AddItem “木鱼115”
Combo3.AddItem “太鼓116”
Combo3.AddItem “古高音鼓117”
Combo3.AddItem “合成鼓118”
Combo3.AddItem “铜钹119”
Combo3.AddItem “磨弦120”
Combo3.AddItem “呼吸声121”
Combo3.AddItem “海浪声122”
Combo3.AddItem “鸟鸣123”
Combo3.AddItem “电话铃124”
Combo3.AddItem “直升机125”
Combo3.AddItem “鼓掌声126”
Combo3.AddItem “枪声127”

Combo3.ListIndex = 10

End Sub

Private Sub HScroll1_Change()
Sta = HScroll1.Value
Label4.Caption = Diao(Sta Mod 12)
End Sub

Private Sub HScroll2_Change()
sudu = HScroll2.Value
End Sub

Private Sub Picture1_DragOver(Index As Integer, Source As Control, x As Single, Y As Single, State As Integer)
'完成发音
Static OldNote As Integer
If (OldNote <> Index) Then
Call note_off(0, OldNote + Sta)
Call note_on(0, Index + Sta, sudu) '参数分别为通道编号,音调,速度
OldNote = Index
isOgain = False
End If
End Sub

Private Function Diao(i As Integer) As String
Select Case i
Case 0
Diao = “C”
Case 1
Diao = “C#”
Case 2
Diao = “D”
Case 3
Diao = “D#”
Case 4
Diao = “E”
Case 5
Diao = “F”
Case 6
Diao = “F#”
Case 7
Diao = “G”
Case 8
Diao = “G#”
Case 9
Diao = “A”
Case 10
Diao = “A#”
Case 11
Diao = “B”
End Select
End Function

Private Sub Command4_Click()

Dim s As String
Dim i As Integer

Dim k As Integer

 k = Int(Text3.Text)

s = Text1.Text
For i = 1 To Len(s)

Select Case Mid(s, i, 1)

Case “1…”
Call note_on(0, 1 + Sta, sudu)
Sleep k
Call note_off(0, 1 + Sta)

Case “2…”
Call note_on(0, 2 + Sta, sudu)
Sleep k
Call note_off(0, 2 + Sta)

Case “3…”
Call note_on(0, 3 + Sta, sudu)
Sleep k
Call note_off(0, 3 + Sta)

Case “4…”
Call note_on(0, 4 + Sta, sudu)
Sleep k
Call note_off(0, 4 + Sta)

Case “5…”
Call note_on(0, 5 + Sta, sudu)
Sleep k
Call note_off(0, 5 + Sta)

Case “6…”
Call note_on(0, 6 + Sta, sudu)
Sleep k
Call note_off(0, 6 + Sta)

Case “7…”
Call note_on(0, 7 + Sta, sudu)
Sleep k
Call note_off(0, 7 + Sta)

Case “1…”
Call note_on(0, 8 + Sta, sudu)
Sleep k
Call note_off(0, 8 + Sta)

Case “2…”
Call note_on(0, 9 + Sta, sudu)
Sleep k
Call note_off(0, 9 + Sta)

Case “3…”
Call note_on(0, 10 + Sta, sudu)
Sleep k
Call note_off(0, 10 + Sta)

Case “4…”
Call note_on(0, 11 + Sta, sudu)
Sleep k
Call note_off(0, 11 + Sta)

Case “5…”
Call note_on(0, 12 + Sta, sudu)
Sleep k
Call note_off(0, 12 + Sta)

Case “6…”
Call note_on(0, 13 + Sta, sudu)
Sleep k
Call note_off(0, 13 + Sta)

Case “7…”
Call note_on(0, 14 + Sta, sudu)
Sleep k
Call note_off(0, 14 + Sta)

Case “1…”
Call note_on(0, 15 + Sta, sudu)
Sleep k
Call note_off(0, 15 + Sta)

Case “2…”
Call note_on(0, 16 + Sta, sudu)
Sleep k
Call note_off(0, 16 + Sta)

Case “3…”
Call note_on(0, 17 + Sta, sudu)
Sleep k
Call note_off(0, 17 + Sta)

Case “4…”
Call note_on(0, 18 + Sta, sudu)
Sleep k
Call note_off(0, 18 + Sta)

Case “5…”
Call note_on(0, 19 + Sta, sudu)
Sleep k
Call note_off(0, 19 + Sta)

Case “6…”
Call note_on(0, 20 + Sta, sudu)
Sleep k
Call note_off(0, 20 + Sta)

Case “7…”
Call note_on(0, 21 + Sta, sudu)
Sleep k
Call note_off(0, 21 + Sta)

Case “1.”
Call note_on(0, 22 + Sta, sudu)
Sleep k
Call note_off(0, 22 + Sta)

Case “2.”
Call note_on(0, 23 + Sta, sudu)
Sleep k
Call note_off(0, 23 + Sta)

Case “3.”
Call note_on(0, 24 + Sta, sudu)
Sleep k
Call note_off(0, 24 + Sta)

Case “4.”
Call note_on(0, 25 + Sta, sudu)
Sleep k
Call note_off(0, 25 + Sta)

Case “5.”
Call note_on(0, 26 + Sta, sudu)
Sleep k
Call note_off(0, 26 + Sta)

Case “6.”
Call note_on(0, 27 + Sta, sudu)
Sleep k
Call note_off(0, 27 + Sta)

Case “7.”
Call note_on(0, 28 + Sta, sudu)
Sleep k
Call note_off(0, 28 + Sta)

Case “1”
Call note_on(0, 29 + Sta, sudu)
Sleep k
Call note_off(0, 29 + Sta)

Case “2”
Call note_on(0, 30 + Sta, sudu)
Sleep k
Call note_off(0, 30 + Sta)

Case “3”
Call note_on(0, 31 + Sta, sudu)
Sleep k
Call note_off(0, 31 + Sta)

Case “4”
Call note_on(0, 32 + Sta, sudu)
Sleep k
Call note_off(0, 32 + Sta)

Case “5”
Call note_on(0, 33 + Sta, sudu)
Sleep k
Call note_off(0, 33 + Sta)

Case “6”
Call note_on(0, 34 + Sta, sudu)
Sleep k
Call note_off(0, 34 + Sta)

Case “7”
Call note_on(0, 35 + Sta, sudu)
Sleep k
Call note_off(0, 35 + Sta)

Case “1’”
Call note_on(0, 36 + Sta, sudu)
Sleep k
Call note_off(0, 36 + Sta)

Case “2’”
Call note_on(0, 37 + Sta, sudu)
Sleep k
Call note_off(0, 37 + Sta)

Case “3’”
Call note_on(0, 38 + Sta, sudu)
Sleep k
Call note_off(0, 38 + Sta)

Case “4’”
Call note_on(0, 39 + Sta, sudu)
Sleep k
Call note_off(0, 39 + Sta)

Case “5’”
Call note_on(0, 40 + Sta, sudu)
Sleep k
Call note_off(0, 40 + Sta)

Case “6’”
Call note_on(0, 41 + Sta, sudu)
Sleep k
Call note_off(0, 41 + Sta)

Case “7’”
Call note_on(0, 42 + Sta, sudu)
Sleep k
Call note_off(0, 42 + Sta)

Case “1’'”
Call note_on(0, 43 + Sta, sudu)
Sleep k
Call note_off(0, 43 + Sta)

Case “2’'”
Call note_on(0, 44 + Sta, sudu)
Sleep k
Call note_off(0, 44 + Sta)

Case “3’'”
Call note_on(0, 45 + Sta, sudu)
Sleep k
Call note_off(0, 45 + Sta)

Case “4’'”
Call note_on(0, 46 + Sta, sudu)
Sleep k
Call note_off(0, 46 + Sta)

Case “5’'”
Call note_on(0, 47 + Sta, sudu)
Sleep k
Call note_off(0, 47 + Sta)

Case “6’'”
Call note_on(0, 48 + Sta, sudu)
Sleep k
Call note_off(0, 48 + Sta)

Case “7’'”
Call note_on(0, 49 + Sta, sudu)
Sleep k
Call note_off(0, 49 + Sta)

Case “1’‘’”
Call note_on(0, 50 + Sta, sudu)
Sleep k
Call note_off(0, 50 + Sta)

Case “2’‘’”
Call note_on(0, 51 + Sta, sudu)
Sleep k
Call note_off(0, 51 + Sta)

Case “3’‘’”
Call note_on(0, 52 + Sta, sudu)
Sleep k
Call note_off(0, 52 + Sta)

Case “4’‘’”
Call note_on(0, 53 + Sta, sudu)
Sleep k
Call note_off(0, 53 + Sta)

Case “5’‘’”
Call note_on(0, 54 + Sta, sudu)
Sleep k
Call note_off(0, 54 + Sta)

Case “6’‘’”
Call note_on(0, 55 + Sta, sudu)
Sleep k
Call note_off(0, 55 + Sta)

Case “7’‘’”
Call note_on(0, 56 + Sta, sudu)
Sleep k
Call note_off(0, 56 + Sta)

Case “1’‘’'”
Call note_on(0, 57 + Sta, sudu)
Sleep k
Call note_off(0, 57 + Sta)

Case “2’‘’'”
Call note_on(0, 58 + Sta, sudu)
Sleep k
Call note_off(0, 58 + Sta)

Case “3’‘’'”
Call note_on(0, 59 + Sta, sudu)
Sleep k
Call note_off(0, 59 + Sta)

Case “4’‘’'”
Call note_on(0, 60 + Sta, sudu)
Sleep k
Call note_off(0, 60 + Sta)

Case “5’‘’'”
Call note_on(0, 61 + Sta, sudu)
Sleep k
Call note_off(0, 61 + Sta)

Case “6’‘’'”
Call note_on(0, 62 + Sta, sudu)
Sleep k
Call note_off(0, 62 + Sta)

Case “7’‘’'”
Call note_on(0, 63 + Sta, sudu)
Sleep k
Call note_off(0, 63 + Sta)

Case “-”
Call note_off(0, 34 + Sta)
Sleep k
Call note_off(0, 34 + Sta)

End Select
Next
End Sub

Private Sub Command5_Click()
Dim s As String
Dim i As Integer

Dim k As Integer

 k = Int(Text3.Text)

s = Text2.Text
For i = 1 To Len(s)

Select Case Mid(s, i, 1)

Case “1…”
Call note_on(0, 1 + Sta, sudu)
Sleep k
Call note_off(0, 1 + Sta)

Case “2…”
Call note_on(0, 2 + Sta, sudu)
Sleep k
Call note_off(0, 2 + Sta)

Case “3…”
Call note_on(0, 3 + Sta, sudu)
Sleep k
Call note_off(0, 3 + Sta)

Case “4…”
Call note_on(0, 4 + Sta, sudu)
Sleep k
Call note_off(0, 4 + Sta)

Case “5…”
Call note_on(0, 5 + Sta, sudu)
Sleep k
Call note_off(0, 5 + Sta)

Case “6…”
Call note_on(0, 6 + Sta, sudu)
Sleep k
Call note_off(0, 6 + Sta)

Case “7…”
Call note_on(0, 7 + Sta, sudu)
Sleep k
Call note_off(0, 7 + Sta)

Case “1…”
Call note_on(0, 8 + Sta, sudu)
Sleep k
Call note_off(0, 8 + Sta)

Case “2…”
Call note_on(0, 9 + Sta, sudu)
Sleep k
Call note_off(0, 9 + Sta)

Case “3…”
Call note_on(0, 10 + Sta, sudu)
Sleep k
Call note_off(0, 10 + Sta)

Case “4…”
Call note_on(0, 11 + Sta, sudu)
Sleep k
Call note_off(0, 11 + Sta)

Case “5…”
Call note_on(0, 12 + Sta, sudu)
Sleep k
Call note_off(0, 12 + Sta)

Case “6…”
Call note_on(0, 13 + Sta, sudu)
Sleep k
Call note_off(0, 13 + Sta)

Case “7…”
Call note_on(0, 14 + Sta, sudu)
Sleep k
Call note_off(0, 14 + Sta)

Case “1…”
Call note_on(0, 15 + Sta, sudu)
Sleep k
Call note_off(0, 15 + Sta)

Case “2…”
Call note_on(0, 16 + Sta, sudu)
Sleep k
Call note_off(0, 16 + Sta)

Case “3…”
Call note_on(0, 17 + Sta, sudu)
Sleep k
Call note_off(0, 17 + Sta)

Case “4…”
Call note_on(0, 18 + Sta, sudu)
Sleep k
Call note_off(0, 18 + Sta)

Case “5…”
Call note_on(0, 19 + Sta, sudu)
Sleep k
Call note_off(0, 19 + Sta)

Case “6…”
Call note_on(0, 20 + Sta, sudu)
Sleep k
Call note_off(0, 20 + Sta)

Case “7…”
Call note_on(0, 21 + Sta, sudu)
Sleep k
Call note_off(0, 21 + Sta)

Case “1.”
Call note_on(0, 22 + Sta, sudu)
Sleep k
Call note_off(0, 22 + Sta)

Case “2.”
Call note_on(0, 23 + Sta, sudu)
Sleep k
Call note_off(0, 23 + Sta)

Case “3.”
Call note_on(0, 24 + Sta, sudu)
Sleep k
Call note_off(0, 24 + Sta)

Case “4.”
Call note_on(0, 25 + Sta, sudu)
Sleep k
Call note_off(0, 25 + Sta)

Case “5.”
Call note_on(0, 26 + Sta, sudu)
Sleep k
Call note_off(0, 26 + Sta)

Case “6.”
Call note_on(0, 27 + Sta, sudu)
Sleep k
Call note_off(0, 27 + Sta)

Case “7.”
Call note_on(0, 28 + Sta, sudu)
Sleep k
Call note_off(0, 28 + Sta)

Case “1”
Call note_on(0, 29 + Sta, sudu)
Sleep k
Call note_off(0, 29 + Sta)

Case “2”
Call note_on(0, 30 + Sta, sudu)
Sleep k
Call note_off(0, 30 + Sta)

Case “3”
Call note_on(0, 31 + Sta, sudu)
Sleep k
Call note_off(0, 31 + Sta)

Case “4”
Call note_on(0, 32 + Sta, sudu)
Sleep k
Call note_off(0, 32 + Sta)

Case “5”
Call note_on(0, 33 + Sta, sudu)
Sleep k
Call note_off(0, 33 + Sta)

Case “6”
Call note_on(0, 34 + Sta, sudu)
Sleep k
Call note_off(0, 34 + Sta)

Case “7”
Call note_on(0, 35 + Sta, sudu)
Sleep k
Call note_off(0, 35 + Sta)

Case “1’”
Call note_on(0, 36 + Sta, sudu)
Sleep k
Call note_off(0, 36 + Sta)

Case “2’”
Call note_on(0, 37 + Sta, sudu)
Sleep k
Call note_off(0, 37 + Sta)

Case “3’”
Call note_on(0, 38 + Sta, sudu)
Sleep k
Call note_off(0, 38 + Sta)

Case “4’”
Call note_on(0, 39 + Sta, sudu)
Sleep k
Call note_off(0, 39 + Sta)

Case “5’”
Call note_on(0, 40 + Sta, sudu)
Sleep k
Call note_off(0, 40 + Sta)

Case “6’”
Call note_on(0, 41 + Sta, sudu)
Sleep k
Call note_off(0, 41 + Sta)

Case “7’”
Call note_on(0, 42 + Sta, sudu)
Sleep k
Call note_off(0, 42 + Sta)

Case “1’'”
Call note_on(0, 43 + Sta, sudu)
Sleep k
Call note_off(0, 43 + Sta)

Case “2’'”
Call note_on(0, 44 + Sta, sudu)
Sleep k
Call note_off(0, 44 + Sta)

Case “3’'”
Call note_on(0, 45 + Sta, sudu)
Sleep k
Call note_off(0, 45 + Sta)

Case “4’'”
Call note_on(0, 46 + Sta, sudu)
Sleep k
Call note_off(0, 46 + Sta)

Case “5’'”
Call note_on(0, 47 + Sta, sudu)
Sleep k
Call note_off(0, 47 + Sta)

Case “6’'”
Call note_on(0, 48 + Sta, sudu)
Sleep k
Call note_off(0, 48 + Sta)

Case “7’'”
Call note_on(0, 49 + Sta, sudu)
Sleep k
Call note_off(0, 49 + Sta)

Case “1’‘’”
Call note_on(0, 50 + Sta, sudu)
Sleep k
Call note_off(0, 50 + Sta)

Case “2’‘’”
Call note_on(0, 51 + Sta, sudu)
Sleep k
Call note_off(0, 51 + Sta)

Case “3’‘’”
Call note_on(0, 52 + Sta, sudu)
Sleep k
Call note_off(0, 52 + Sta)

Case “4’‘’”
Call note_on(0, 53 + Sta, sudu)
Sleep k
Call note_off(0, 53 + Sta)

Case “5’‘’”
Call note_on(0, 54 + Sta, sudu)
Sleep k
Call note_off(0, 54 + Sta)

Case “6’‘’”
Call note_on(0, 55 + Sta, sudu)
Sleep k
Call note_off(0, 55 + Sta)

Case “7’‘’”
Call note_on(0, 56 + Sta, sudu)
Sleep k
Call note_off(0, 56 + Sta)

Case “1’‘’'”
Call note_on(0, 57 + Sta, sudu)
Sleep k
Call note_off(0, 57 + Sta)

Case “2’‘’'”
Call note_on(0, 58 + Sta, sudu)
Sleep k
Call note_off(0, 58 + Sta)

Case “3’‘’'”
Call note_on(0, 59 + Sta, sudu)
Sleep k
Call note_off(0, 59 + Sta)

Case “4’‘’'”
Call note_on(0, 60 + Sta, sudu)
Sleep k
Call note_off(0, 60 + Sta)

Case “5’‘’'”
Call note_on(0, 61 + Sta, sudu)
Sleep k
Call note_off(0, 61 + Sta)

Case “6’‘’'”
Call note_on(0, 62 + Sta, sudu)
Sleep k
Call note_off(0, 62 + Sta)

Case “7’‘’'”
Call note_on(0, 63 + Sta, sudu)
Sleep k
Call note_off(0, 63 + Sta)

Case “-”
Call note_off(0, 34 + Sta)
Sleep k
Call note_off(0, 34 + Sta)

End Select
Next
End Sub

标签:Case,note,VB,off,Sta,MIDI,AddItem,2024,Call
From: https://blog.csdn.net/qq_32257509/article/details/141709224

相关文章

  • sxOI-2024初中组游记
    Day024/8/28颓废中。和mac玩了一会儿蛋仔,不管我用惊吓箱还是突击还是勾爪还是泡泡,都随便秒杀mac,甚至我在跳舞他都打不死我:)然后玩了迷你,好基友白宵上线,好家伙他在做跑酷!直接帮忙(他不会用区域方块复制器)。然后就没有然后了。Day124/8/29WhatcanIsay?直接切到考试吧。......
  • 【Datawhale AI 夏令营2024--CV】Task2 阅读小结与尝试
    一、阅读小结        yolo不仅要识别物体的种类还要识别物体的位置1.1、物体检测介绍:1.输入:照片可以利用opencv来提取照片的每一帧,在循环下对视频中每一帧的照片进行处理cap=cv2.VideoCapture(video_path)whileTrue:ret,frame=cap.read()......
  • 2024.8.29 总结
    上午&中午按计划学了李超线段树,照着题解写过了模板题。然后本来打算去做题单里的一道Ynoi紫来练dsuontree,于是边写题解边想,结果写着写着就不会了,发现好像dsuontree不太好做,好像是两只log的。还可能大概会一个单log大常数线段树合并。看题解区发现有跑出dfs序后......
  • 广电数安 未来已展 | 天空卫士亮相BIRTV2024
    8月21日至24日,第三十一届北京国际广播电影电视展览会(BIRTV2024)在北京隆重举行。开幕当天,中宣部及广电总局领导莅临我司展位,对安全科技引领以及护航新质生产力等方面提出期望和要求。天空卫士作为唯一一家数据安全厂商受邀参展,借此机遇,向与会嘉宾展示了为广电行业量身打造的全新数据......
  • VBA技术资料MF195:屏蔽工作表中的粘贴输入
    我给VBA的定义:VBA是个人小型自动化处理的有效工具。利用好了,可以大大提高自己的工作效率,而且可以提高数据的准确度。“VBA语言攻”提供的教程一共九套,分为初级、中级、高级三大部分,教程是对VBA的系统讲解,从简单的入门、到入门后的提高、到数据库、到字典、到WordVBA的应用、到高级......
  • 2024 牛客多校 6
    https://ac.nowcoder.com/acm/contest/81601#questionB-Cake2考虑平面图欧拉定理:\(V-E+F=2\)每条线段相交的数量可以由小的那一侧顶点数推出,\(k\ne\frac{n}{2}\)时有\(V=2\min(k-1,n-k-1)\timesn\times\frac{1}{2},E=2\min(k-1,n-k-1)\timesn\)也可以打表C-Cake3......
  • 第三届电力工程与电气技术国际学术会议(ICPEET 2024) 2024 3rd International Conferenc
    文章目录一、会议详情二、重要信息三、大会介绍四、出席嘉宾五、征稿主题六、咨询一、会议详情二、重要信息大会官网:https://ais.cn/u/vEbMBz提交检索:EICompendex、IEEEXplore、Scopus大会时间:2024年9月13-15日大会地点:马来西亚·吉隆坡最终截稿:2024年9月9日(23:......
  • 2024年图像处理、机器学习与模式识别国际学术会议(IPMLP 2024)2024 International Conf
    文章目录一、会议详情二、重要信息三、大会介绍四、出席嘉宾五、征稿主题六、咨询一、会议详情二、重要信息大会官网:https://ais.cn/u/vEbMBz提交检索:EICompendex、IEEEXplore、Scopus会议时间:2024.9.13-15日会议地点:中国广州最终截稿时间:2024年9月9日23时59分......
  • 2024全新快递平台系统独立版小程序源码|带cps推广营销流量主+前端
    2024全新快递平台系统独立版小程序源码|带cps推广营销流量主+前端2024全新快递平台系统**版小程序源码:开启CPS推广营销新时代在这个快节奏的时代,快递服务已经成为我们生活中不可或缺的一部分。随着科技的不断进步,2024年迎来了一个全新的快递平台系统**版小程序源码,它不仅......
  • 2024年高频Java面试题
    1、java反射的作用与原理1、定义:反射机制是在运行时,对于任意一个类,都能够知道这个类的所有属性和方法;对于任意个对象,都能够调用它的任意一个方法。在java中,只要给定类的名字,就可以通过反射机制来获得类的所有信息。这种动态获取的信息以及动态调用对象的方法的功能称为Ja......