找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 5259|回复: 6

【VB】VB借助midiOutShortMsg写的电子琴(只支持一种音色)

[复制链接]

1111

主题

1651

回帖

7万

积分

用户组: 管理员

一只技术宅

UID
1
精华
244
威望
743 点
宅币
24235 个
贡献
46222 次
宅之契约
0 份
在线时间
2296 小时
注册时间
2014-1-26
发表于 2014-7-20 18:24:07 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
原帖位置:http://www.0xaa55.com/thread-721-1-1.html
转载请注明出处。
按住Shift升一个八度,按住Ctrl降一个八度,按ASDFGHJKL;'等按键发音。
代码很简单。才几行。
20140720180352.png
BIN: 电子琴.exe (28 KB, 下载次数: 4, 售价: 1 个宅币)
SRC: 电子琴.7z (7.57 KB, 下载次数: 17, 售价: 5 个宅币)

本帖被以下淘专辑推荐:

回复

使用道具 举报

1111

主题

1651

回帖

7万

积分

用户组: 管理员

一只技术宅

UID
1
精华
244
威望
743 点
宅币
24235 个
贡献
46222 次
宅之契约
0 份
在线时间
2296 小时
注册时间
2014-1-26
 楼主| 发表于 2014-7-20 18:27:45 | 显示全部楼层
VERSION 5.00
Begin VB.Form frmMain
   BorderStyle     =   1  'Fixed Single
   Caption         =   "电子琴"
   ClientHeight    =   2055
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   10095
   KeyPreview      =   -1  'True
   LinkTopic       =   "frmMIDI"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   137
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   673
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer tmrDrawKey
      Interval        =   1
      Left            =   0
      Top             =   0
   End
   Begin VB.PictureBox picKeys
      Align           =   2  'Align Bottom
      BorderStyle     =   0  'None
      Height          =   2055
      Left            =   0
      ScaleHeight     =   2055
      ScaleWidth      =   10095
      TabIndex        =   0
      Top             =   0
      Width           =   10095
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   70
         Left            =   9720
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   71
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   68
         Left            =   9480
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   69
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   66
         Left            =   9240
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   67
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   63
         Left            =   8760
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   64
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   61
         Left            =   8520
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   62
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   58
         Left            =   8040
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   59
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   56
         Left            =   7800
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   57
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   54
         Left            =   7560
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   55
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   51
         Left            =   7080
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   52
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   49
         Left            =   6840
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   50
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   46
         Left            =   6360
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   47
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   44
         Left            =   6120
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   45
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   42
         Left            =   5880
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   43
         Tag             =   "0"
         Top             =   0
         Width           =   225
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "]"
            ForeColor       =   &H8000000E&
            Height          =   180
            Index           =   18
            Left            =   75
            TabIndex        =   91
            Top             =   960
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   39
         Left            =   5400
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   40
         Tag             =   "0"
         Top             =   0
         Width           =   225
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "P"
            ForeColor       =   &H8000000E&
            Height          =   180
            Index           =   15
            Left            =   75
            TabIndex        =   88
            Top             =   960
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   37
         Left            =   5160
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   38
         Tag             =   "0"
         Top             =   0
         Width           =   225
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "O"
            ForeColor       =   &H8000000E&
            Height          =   180
            Index           =   13
            Left            =   75
            TabIndex        =   86
            Top             =   960
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   34
         Left            =   4680
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   35
         Tag             =   "0"
         Top             =   0
         Width           =   225
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "U"
            ForeColor       =   &H8000000E&
            Height          =   180
            Index           =   10
            Left            =   75
            TabIndex        =   83
            Top             =   960
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   32
         Left            =   4440
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   33
         Tag             =   "0"
         Top             =   0
         Width           =   225
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Y"
            ForeColor       =   &H8000000E&
            Height          =   180
            Index           =   8
            Left            =   75
            TabIndex        =   81
            Top             =   960
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   30
         Left            =   4200
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   31
         Tag             =   "0"
         Top             =   0
         Width           =   225
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "T"
            ForeColor       =   &H8000000E&
            Height          =   180
            Index           =   6
            Left            =   75
            TabIndex        =   79
            Top             =   960
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   27
         Left            =   3720
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   28
         Tag             =   "0"
         Top             =   0
         Width           =   225
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "E"
            ForeColor       =   &H8000000E&
            Height          =   180
            Index           =   3
            Left            =   75
            TabIndex        =   76
            Top             =   960
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   25
         Left            =   3480
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   26
         Tag             =   "0"
         Top             =   0
         Width           =   225
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "W"
            ForeColor       =   &H8000000E&
            Height          =   180
            Index           =   1
            Left            =   75
            TabIndex        =   74
            Top             =   960
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   22
         Left            =   3000
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   23
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   20
         Left            =   2760
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   21
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   18
         Left            =   2520
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   19
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   15
         Left            =   2040
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   16
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   13
         Left            =   1800
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   14
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   10
         Left            =   1320
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   11
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   8
         Left            =   1080
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   9
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   6
         Left            =   840
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   7
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   3
         Left            =   360
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   4
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00000000&
         ForeColor       =   &H80000008&
         Height          =   1215
         Index           =   1
         Left            =   120
         ScaleHeight     =   79
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   13
         TabIndex        =   2
         Tag             =   "0"
         Top             =   0
         Width           =   225
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   53
         Left            =   7440
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   54
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   55
         Left            =   7680
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   56
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   57
         Left            =   7920
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   58
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   59
         Left            =   8160
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   60
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   60
         Left            =   8400
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   61
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   62
         Left            =   8640
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   63
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   64
         Left            =   8880
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   65
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   65
         Left            =   9120
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   66
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   67
         Left            =   9360
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   68
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   69
         Left            =   9600
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   70
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   71
         Left            =   9840
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   72
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   36
         Left            =   5040
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   37
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "K"
            Height          =   180
            Index           =   12
            Left            =   75
            TabIndex        =   85
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   38
         Left            =   5280
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   39
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "L"
            Height          =   180
            Index           =   14
            Left            =   75
            TabIndex        =   87
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   40
         Left            =   5520
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   41
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   ";"
            Height          =   180
            Index           =   16
            Left            =   75
            TabIndex        =   89
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   41
         Left            =   5760
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   42
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "'"
            Height          =   180
            Index           =   17
            Left            =   75
            TabIndex        =   90
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   43
         Left            =   6000
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   44
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   45
         Left            =   6240
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   46
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   47
         Left            =   6480
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   48
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   48
         Left            =   6720
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   49
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   50
         Left            =   6960
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   51
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   52
         Left            =   7200
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   53
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   24
         Left            =   3360
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   25
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "A"
            Height          =   180
            Index           =   0
            Left            =   120
            TabIndex        =   73
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   26
         Left            =   3600
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   27
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "S"
            Height          =   180
            Index           =   2
            Left            =   75
            TabIndex        =   75
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   28
         Left            =   3840
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   29
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "D"
            Height          =   180
            Index           =   4
            Left            =   75
            TabIndex        =   77
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   31
         Left            =   4320
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   32
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "G"
            Height          =   180
            Index           =   7
            Left            =   75
            TabIndex        =   80
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   33
         Left            =   4560
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   34
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "H"
            Height          =   180
            Index           =   9
            Left            =   75
            TabIndex        =   82
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   35
         Left            =   4800
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   36
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "J"
            Height          =   180
            Index           =   11
            Left            =   75
            TabIndex        =   84
            Top             =   1320
            Width           =   90
         End
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   23
         Left            =   3120
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   24
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   21
         Left            =   2880
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   22
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   19
         Left            =   2640
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   20
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   17
         Left            =   2400
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   18
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   16
         Left            =   2160
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   17
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   14
         Left            =   1920
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   15
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   12
         Left            =   1680
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   13
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   0
         Left            =   0
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   1
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   2
         Left            =   240
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   3
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   4
         Left            =   480
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   5
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   5
         Left            =   720
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   6
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   7
         Left            =   960
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   8
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   9
         Left            =   1200
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   10
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   11
         Left            =   1440
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   12
         Tag             =   "1"
         Top             =   0
         Width           =   255
      End
      Begin VB.PictureBox picKey
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H80000008&
         Height          =   2055
         Index           =   29
         Left            =   4080
         ScaleHeight     =   135
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   15
         TabIndex        =   30
         Tag             =   "1"
         Top             =   0
         Width           =   255
         Begin VB.Label lblPrompt
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "F"
            Height          =   180
            Index           =   5
            Left            =   75
            TabIndex        =   78
            Top             =   1320
            Width           =   90
         End
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Declare Function midiOutOpen Lib "winmm.dll" (lphMidiOut As Long, ByVal uDeviceID As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Private Declare Function midiOutShortMsg Lib "winmm.dll" (ByVal hMidiOut As Long, ByVal dwMsg As Long) As Long
Private Declare Function midiOutClose Lib "winmm.dll" (ByVal hMidiOut As Long) As Long

Private Declare Function ReleaseCapture Lib "user32" () As Long

Dim LastIndex As Long
Dim hMidiOut As Long

Dim PressTimes() As Single
Dim KeyStates(255) As Boolean

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim TuneCode As Long
TuneCode = -1
If Not KeyStates(KeyCode) Then
    Select Case KeyCode
        Case vbKeyA
            TuneCode = 24
        Case vbKeyW
            TuneCode = 25
        Case vbKeyS
            TuneCode = 26
        Case vbKeyE
            TuneCode = 27
        Case vbKeyD
            TuneCode = 28
        Case vbKeyF
            TuneCode = 29
        Case vbKeyT
            TuneCode = 30
        Case vbKeyG
            TuneCode = 31
        Case vbKeyY
            TuneCode = 32
        Case vbKeyH
            TuneCode = 33
        Case vbKeyU
            TuneCode = 34
        Case vbKeyJ
            TuneCode = 35
        Case vbKeyK
            TuneCode = 36
        Case vbKeyO
            TuneCode = 37
        Case vbKeyL
            TuneCode = 38
        Case vbKeyP
            TuneCode = 39
        Case 186 ';
            TuneCode = 40
        Case 222 ''
            TuneCode = 41
        Case 221 ']
            TuneCode = 42
    End Select
    If (Shift And 1) And (TuneCode <> -1) Then TuneCode = TuneCode + 12
    If (Shift And 2) And (TuneCode <> -1) Then TuneCode = TuneCode - 12
    If TuneCode <> -1 Then PlaySound TuneCode
    KeyStates(KeyCode) = True
End If
If KeyCode = vbKeyEscape Then
    Dim I&
    For I = 0 To 127 'ESC键按下全部音符
        midiOutShortMsg hMidiOut, &H90& Or (I * &H100&) Or (127 * &H10000)
    Next
End If
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
KeyStates(KeyCode) = False
End Sub

Private Sub Form_Load()
LastIndex = -1
midiOutOpen hMidiOut, -1, 0, 0, 0
If hMidiOut = 0 Then End

ReDim PressTimes(picKey.UBound)

midiOutShortMsg hMidiOut, &HC0& '乐器:0
End Sub

Private Sub Form_Unload(Cancel As Integer)
midiOutClose hMidiOut
End Sub

Sub PlaySound(ByVal Tune As Long)
midiOutShortMsg hMidiOut, &H90& Or ((Tune + 36) * &H100&) Or (127 * &H10000) '按下音符
PressTimes(Tune) = Timer
picKey(Tune).Cls
End Sub

Private Sub picKey_DblClick(Index As Integer)
PlaySound Index
End Sub

Private Sub picKey_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
PlaySound Index
LastIndex = Index
ReleaseCapture
End Sub

Private Sub picKey_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And 1 Then
    If LastIndex <> Index Then
        PlaySound Index
        LastIndex = Index
    End If
End If
End Sub

Private Sub picKey_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
LastIndex = -1
End Sub

Private Sub tmrDrawKey_Timer()
Dim I&, N!, TDiff!, Clr As Long
N = Timer
For I = 0 To UBound(PressTimes)
    If picKey(I).BackColor Then '如果是白色键
        TDiff = (N - PressTimes(I)) * 5
        If TDiff > 1 Then TDiff = 1
        If TDiff < 0 Then TDiff = 0
        Clr = TDiff * 255
        picKey(I).Line (0, 0)-(picKey(I).ScaleWidth, picKey(I).ScaleHeight), RGB(Clr, Clr, Clr), BF
    Else '否则是黑色键
        TDiff = (N - PressTimes(I)) * 5
        If TDiff > 1 Then TDiff = 1
        If TDiff < 0 Then TDiff = 0
        Clr = 255 - TDiff * 255
        picKey(I).Line (0, 0)-(picKey(I).ScaleWidth, picKey(I).ScaleHeight), RGB(Clr, Clr, Clr), BF
    End If
Next
End Sub
回复 赞! 靠!

使用道具 举报

0

主题

13

回帖

18

积分

用户组: 初·技术宅

UID
606
精华
0
威望
2 点
宅币
1 个
贡献
0 次
宅之契约
0 份
在线时间
0 小时
注册时间
2014-12-21
发表于 2014-12-21 07:13:00 | 显示全部楼层
vb学习中,非常有收获
回复 赞! 靠!

使用道具 举报

2

主题

22

回帖

117

积分

用户组: 小·技术宅

UID
3003
精华
0
威望
2 点
宅币
89 个
贡献
0 次
宅之契约
0 份
在线时间
20 小时
注册时间
2017-10-24
发表于 2017-10-25 01:58:40 | 显示全部楼层
改变音色很简单呀,只需一句代码
回复 赞! 靠!

使用道具 举报

9

主题

176

回帖

1万

积分

用户组: 真·技术宅

UID
4293
精华
6
威望
441 点
宅币
8670 个
贡献
850 次
宅之契约
0 份
在线时间
338 小时
注册时间
2018-9-19
发表于 2019-11-1 16:17:58 | 显示全部楼层
可以考虑加入midiIn的API实现对midi键盘的支持,另外⌨按键可以考虑设计成双排键模式(一排低音键,一排高音键):
ZXCVBNM 为低音白键(对应的黑键是SD GHJ)
,./QWER 为中音白键(对应的黑键是L; 234)
TYUIOP[ 为高音白键(对应的黑键是67 90-)
] 超高音C键
这样就可以满足大多数情况了
回复 赞! 靠!

使用道具 举报

1111

主题

1651

回帖

7万

积分

用户组: 管理员

一只技术宅

UID
1
精华
244
威望
743 点
宅币
24235 个
贡献
46222 次
宅之契约
0 份
在线时间
2296 小时
注册时间
2014-1-26
 楼主| 发表于 2019-11-6 15:23:30 | 显示全部楼层
系统消息 发表于 2019-11-1 16:17
可以考虑加入midiIn的API实现对midi键盘的支持,另外⌨按键可以考虑设计成双排键模式(一排低音键,一排高 ...

音乐人:卧槽我学这个干嘛?

ThinkPad用户:卧槽我的笔记本键盘布局不是这样的!

程序员:卧槽机械键盘贼响,盖过了它发的音!



回复 赞! 靠!

使用道具 举报

1

主题

159

回帖

624

积分

用户组: 大·技术宅

UID
7535
精华
0
威望
0 点
宅币
464 个
贡献
0 次
宅之契约
0 份
在线时间
71 小时
注册时间
2021-10-16
发表于 2022-5-13 17:18:55 | 显示全部楼层

非常感谢~~支持~~~
回复 赞! 靠!

使用道具 举报

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-4-19 22:16 , Processed in 0.052657 second(s), 37 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表