VbMIDI钢琴程序2音轨功能代码QZQ

Private Sub Command3_Click()
Dim s1 As String
Dim s2 As String
Dim i As Integer
Dim midiNote1 As Integer
Dim midiNote2 As Integer

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

For i = 1 To Len(s1) Or Len(s2) '取两个字符串长度中的较大值作为循环次数
    Dim note1 As String
    Dim note2 As String
    
    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 "1"
            midiNote1 = 23
        Case "2"
            midiNote1 = 34
        Case "3"
            midiNote1 = 36
        Case "4"
            midiNote1 = 38
        Case "5"
            midiNote1 = 40
        Case "6"
            midiNote1 = 42
        Case "7"
            midiNote1 = 44
        Case Else
            midiNote1 = 0
    End Select
    
    Select Case note2
        Case "1"
            midiNote2 = 23
        Case "2"
            midiNote2 = 34
        Case "3"
            midiNote2 = 36
        Case "4"
            midiNote2 = 38
        Case "5"
            midiNote2 = 40
        Case "6"
            midiNote2 = 42
        Case "7"
            midiNote2 = 44
        Case Else
            midiNote2 = 0
    End Select
    
    If midiNote1 > 0 Then
        Call note_on(0, midiNote1 + Sta, sudu) '使用 note_on 过程播放音符
    Else
        Call note_off(0, 0) '如果没有音符,停止播放
    End If
    
    If midiNote2 > 0 Then
        Call note_on(0, midiNote2 + Sta, sudu) '使用 note_on 过程播放音符
    Else
        Call note_off(0, 0) '如果没有音符,停止播放
    End If
    
    Sleep 300
Next

End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

EYYLTV

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值